Skip to content

[PR] feat: plugin lanes accept host declaration of exposed bili tools (#3906) - #3907

Closed
ranxianglei wants to merge 4 commits into
masterfrom
2026-10-20_exposed-tools-declaration
Closed

ranxianglei wants to merge 4 commits into
masterfrom
2026-10-20_exposed-tools-declaration

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #3906

Step 1 of the #3884 Step3+ structural direction — owner-approved in the #3884 thread (2026-10-20). Branch is stacked on top of #3885 (the code_run fix it refactors); merging this PR pulls in #3885's two commits as ancestors — either merge order works, but #3885-first is the natural sequence.

What

Plugin lanes accept an optional inbound header x-bili-plugin-exposed-tools — the host's per-request declaration of which bili tools it actually exposed for this request/preset (comma-separated names; present-but-empty = "exposes none"). When present it is ground truth for the reachability decision: it outranks wire-shape inference entirely, profile default included. When absent, the legacy inference (top-level compress / CODE_MODE_OMNIBUS_TOOL_NAMES / profile default) applies bit-for-bit — owner constraint: a request without the header must not change behavior.

Behavior changes (disclosed)

Path Old New
plugin lane, header present n/a declaration decides: contains compress (or top-level compress) → surface on; else off — even against a recognized omnibus name
plugin lane, header absent name-inference (three rungs) unchanged, bit-for-bit
proxy lane structurally on unchanged (a stray header cannot turn it off)
outbound bodies — untouched
header egress — joins the existing x-bili-plugin* family behavior (that family is forwarded to upstream today; the pre-existing egress gap is tracked separately in #3905)

Why

#3600 and #3884 were the same judgment chain failing twice because the host renamed its code-mode omnibus tool (run_code → code_run). Name-matching can never be complete — every rename is a silent incident until someone reports it. Letting the host declare what it registered makes future renames a non-event. This is the first concrete step of the #3417/#3482 Step3+ ground-truth direction ("reachability truth = host manifest registration state"); host-side adoption (e.g. dsh code-mode presets stamping the header) follows separately and is not blocked by this PR.

Tests

  • tests/lane-decisions-b-class.test.ts: precedence rows — declaration rescues an UNRECOGNIZED omnibus shape; declaration beats a recognized-name inference (reverse direction); present-empty suppresses; absent keeps legacy both directions; top-level compress stays ground truth vs contradicting declaration; proxy immune; declaration outranks profile default (pi) — plus parser rows (absent/empty/trim/lowercase/array form).
  • tests/lane-decisions-matrix.test.ts: +2 e2e rows × 4 wires through the real server chain (declared-rescue → surface on; declared-suppress despite recognized omnibus → surface off).
  • Local targeted green: typecheck clean, b-class 7/7, matrix 74/74. Full suite = remote CI.

Config surface

None — new optional INBOUND header, not a config knob. No new env vars.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-20_exposed-tools-declaration (719bcf2)

Option A — Install this exact build (recommended)

npm install -g [email protected]

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3907.tgz
npm install -g package

Install instructions are refreshed on each push.

awork added 3 commits October 20, 2026 12:39
…le (#3884)

#3603's single-literal gate (RUN_CODE_TOOL_NAME = "run_code") went stale
when DSH 0.2.x moved Code Mode into the dsh-codemode plugin, whose
transport is named `code_run` (the reserved name `run_code` belongs to
dsh-tools, so the plugin registers its own). On every DSH 0.2.x code-mode
session the reachability conjunct failed and the compress surface stayed
off forever: nudge ARMED-SUPPRESSED at 42% usage with pendingT1 10x over
threshold, zero INJECT, fully silent (#3884).

- collect the known omnibus shapes in CODE_MODE_OMNIBUS_TOOL_NAMES
  (run_code / code_run), provenance-commented per shape; both detection
  sites match the set - lane-decisions reachability (the reported miss)
  and ptcNoteMode (proxy-lane exempt note, same-mechanism second site)
- matrix: dsh code_run row -> surface on + EMERGENCY twin; existing
  precision rows (get_weather / acp_status) stay the negative direction
- ptc-runcode-tools: code_run -> exempt note on all four wires; bash-only
  rows pin the negative direction (#3617 bidirectional discipline)

Targeted green: typecheck clean; lane-decisions-matrix 66/66;
ptc-runcode-tools 16/16; e2e-ptc-runcode-shape 8/8. Full suite = CI.
…ss surface off (#3884)

Observability hardening for the allowlist fragility class: when an armed nudge stays ARMED-SUPPRESSED because the lane surface is off for reachability (not user config), the diag line now carries surface=off(no-tools) or surface=off(top-level=[names]) — the next host omnibus rename shows up in bili.log next to the suppression label instead of requiring user archaeology (#3600 and #3884 were both diagnosed from user-reported dumps). No behavior change beyond log text.
@ranxianglei
ranxianglei force-pushed the 2026-10-20_exposed-tools-declaration branch from 1c66d99 to ffc415f Compare October 20, 2026 04:39
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

结论先行:合并冲突已解除(GitHub 实时 mergeable=true),本次无需我再推送。 处理中发现该分支正被并发实例同时 rebase,我已独立复现并验证了等价解法、并确认远端已正确合到最新 master,因此收手以避免重复劳动和 SHA churn。

八问:

  1. 是什么问题:PR [PR] feat: plugin lanes accept host declaration of exposed bili tools (#3906) #3907 的分支落后于 master,产生合并冲突(系统转发 merge_conflict / dirty),需 rebase 到最新 master 解决后才能合入。
  2. 什么原因导致的:master 在分叉后前进了多个提交,其中 6 个文件与本 PR 改动重叠;真正的文本冲突只有 CHANGELOG.md 一处——master 在 [Unreleased] 顶部新插了「快照渲染影子对账」块,本 PR 也在同一位置插了「### Added」块,两边抢同一行 → 冲突。其余 5 个重叠文件(src/server.ts、四个 prepare-* 适配器)改动不重叠,git 可自动合并。
  3. 影响范围与严重程度:只卡住本 PR 能否合入,不影响任何线上行为或其他用户。属「阻塞合入」,非功能缺陷。
  4. 怎么修复的:把 PR 的 3 个提交 rebase 到当前 master;CHANGELOG 冲突按「并集」解——两块都原样保留(master 的影子对账块在前、PR 的 Added 块紧随其后),零丢失、零改写长条目。本地核对:typecheck 通过;PR 触及的三个测试文件(lane-decisions b-class / matrix + ptc-runcode-tools)共 97 例全绿。
  5. 是否有回归问题:无。相对真实最新 master,净 diff 仍是原 PR 的那 12 个文件、内容与原 PR 一致;auto-merge 的文件经 typecheck + 四 wire 矩阵测试确认无语义漂移;未触碰任何 master 新增逻辑。
  6. 是否破坏缓存:不涉及——纯 git 历史操作 + CHANGELOG 文本,无运行时/缓存路径。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及(本次是解冲突,非功能改动;PR 本身引入的 x-bili-plugin-exposed-tools header 属原 PR 范围,非本次操作)。

为什么我没有再 push(关键):我本地开始 rebase 时,远端头还是旧的 3adb986f1;期间该分支已被并发实例 rebase 并强推了多次(我先后看到 1c66d99 → ffc415fe)。我独立完成的 rebase 结果与远端在本 PR 的内容上逐字节等价——唯一差异是并发方 rebase 到了更新的 master(现 tip 687096785,已并入 #3899 文档),因此多带了 #3899 对 README 的 15+15 行改动,那属于 master、不属于本 PR。而我的版本基于更旧的 master(838e975):若推上去,PR 相对真实 master 会显示成删除 #3899 刚合入的 README 文档(倒退)。GitHub 实时状态现已是 mergeable=true / mergeable_state=blocked(冲突已消除;blocked=等待必需检查/分支保护,属正常待合入态)。故按去重/防重复劳动原则收手,不再强推。

一个观察(仅记录,未处置):采样到的最近一次 CI 里 unused-exports 显示 failure。但采样时分支头仍在变动(我会话内已移动两次),该 CI 快照是瞬态的、且归属当前分支头的持有者,不在本任务(解冲突)范围内,我不据此立项;留待分支稳定后由对应流程复核。

判定:冲突已解除,无需我再操作;等 CI 全绿后由人合并即可。

The #3884 refactor moved ptcNoteMode off the direct constant onto
CODE_MODE_OMNIBUS_TOOL_NAMES, leaving RUN_CODE_TOOL_NAME referenced only
inside compress-tool.ts (building that set). The unused-exports gate
(#1440 P6) flags it as INTERNAL_ONLY; remove the leading export. No
behavior change - nothing outside the module imported it.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI auto-fix — resolved the failing unused-exports check directly on the PR branch (commit 719bcf215).

是什么问题
PR head 的 unused-exports 门禁(#1440 P6)红:src/compress-tool.ts 里 RUN_CODE_TOOL_NAME 被判定为 INTERNAL_ONLY —— 导出了但没有任何模块外部引用它。

什么原因导致的
本 PR 的 #3884 重构把 ptcNoteMode() 从「直接比对 RUN_CODE_TOOL_NAME」改成「查 CODE_MODE_OMNIBUS_TOOL_NAMES 集合」。改完之后,RUN_CODE_TOOL_NAME 只剩文件内部一处用法(第 278 行,用来构建那个集合),但行首的 export 还留着 → 门禁按规则报 INTERNAL_ONLY。

影响范围与严重程度
纯 lint/卫生类门禁失败,卡 CI;对运行时行为零影响。该常量本来就已经只在模块内使用,去掉 export 不改变任何运行期语义。

怎么修复的
把 RUN_CODE_TOOL_NAME 行首的 export 去掉(变回模块内常量)。它仍然被定义、仍在文件内用于构建 CODE_MODE_OMNIBUS_TOOL_NAMES,所以不是死代码,只是不再作为对外导出面暴露。一行改动。

是否有回归问题
无。全仓 grep 确认零处 import { RUN_CODE_TOOL_NAME };仅有的两处引用都是它自身定义和构建集合的那一处,均在 src/compress-tool.ts 内。行为完全不变。本地已跑同一门禁脚本:✓ unused-export gate: clean(exit 0)。

是否破坏缓存
不涉及——未触碰任何缓存 / 重试 / 增量游标 / 去重键逻辑。

是否改了设计方向
无。保留本 PR 自己的设计:CODE_MODE_OMNIBUS_TOOL_NAMES 依旧是对外导出的探测集(lane-decisions 与 ptcNoteMode 消费它);只是不再导出一个纯内部构件。

是否引入了新的配置
无新增 env / config / 默认值。


已在 PR 分支推送修复(ffc415fe6..719bcf215),失败的 unused-exports job 本地复跑已通过;等远程 CI 在新 head 上全绿。本轮为自动修复通道第 1 次尝试。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重:不重复。 独立检索 open+closed(exposed-tools、宿主声明 等关键词):#3905 = 存量 x-bili-plugin* 头被转发上游的卫生缺口,#3884/#3885 = run_code→code_run 事故与名字收敛修复,本 PR(#3906) = 声明通道机制本身——三者各管各的,无第四个覆盖同一机制的条目。

标签:pr / dsh / scope/wiring / p1 —— 动机与落地客户端是 dsh;改动面是新增入站头的协议边界;p1 因为本 PR 叠在 #3885 之上,合入即同时交付 DSH 0.2.x code-mode 压缩面从「全关」恢复可用的 p1 止血。

初审状态(完整八问结论随后):

@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

被超越:master 已含完整演进版(CODE_MODE_OMNIBUS_TOOL_NAMES/#4344/#4372),空挑证实无独特内容。关单收尾;误判请 reopen。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant