Skip to content

fix: route dsh title-gen requests through the side lane on dsh 0.2.1-alpha.2 (#2503) - #2554

Merged
ranxianglei merged 3 commits into
masterfrom
2026-10-09_dsh-alpha2-title-side-lane
Oct 10, 2026
Merged

ranxianglei merged 3 commits into
masterfrom
2026-10-09_dsh-alpha2-title-side-lane

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #2503

What changed (behavior-change disclosure)

dsh title-gen request lane: on dsh 0.2.1-alpha.2, title requests were treated as main turns — processed by the full pipeline under a forked persisted |sub:<fp> ghost session (one minted per dsh session). After this PR they ride the #388 verbatim passthrough under the raw conversation key — i.e. rc2 behavior is restored.

  • Wire bytes are unchanged: the request (including its new 4096 output budget) is forwarded verbatim; only the bili-side routing decision changes.
  • No config/env surface added. Pure routing fix.

Root cause

dsh 0.2.1-alpha.2 raised the base-bundle preset session-title-llm.maxOutputTokens from 64 → 4096 ("a ceiling against runaway output, not a length target — reasoning tokens count"). The value reaches the wire as max_completion_tokens. bili's side-lane heuristic (SIDE_REQUEST_MAX_TOKENS = 200, src/server/side-request.ts) therefore stopped matching dsh title requests; with no persona header stamped, the request looked like a main turn and — under the #1916 dsh persona fingerprint — forked onto a persisted |sub: session instead of passing through.

Wire evidence (hermetic fake upstream, real dsh binaries):

run title req max_completion_tokens tools
dsh 0.2.0-rc.2 direct 64 0
dsh 0.2.1-alpha.2 direct 4096 0
dsh 0.2.1-alpha.2 via bili (post-fix) 4096 (verbatim) 0

Fix

Recognize the dsh title sidecar structurally — same evidence-per-client pattern as KDD#9 / #2500:

  • src/server/side-request.ts: new pure predicate isDshTitleRequest() + DSH_TITLE_SYSTEM_PREFIX (fixed first line of dsh's title system prompt, stable on the wire across rc2/alpha.2). Same no-tools veto as isSideRequest so no future main turn can be demoted through this path.
  • src/server/handle.ts: conjunct gated on x-bili-plugin === "dsh" && non-main intent at BOTH decision points — sideRequestLike (persona keying/fork) and sideIntent (+ new sideLabel: "dsh title-gen sidecar (#2503)" for the lane log).
  • tests/dsh-title-side-lane.test.ts (new): truth cases for the predicate + the pre-fix gap pinned (isSideRequest misses alpha.2 titles, catches rc2 ones).
  • tests/side-lane-invariants.test.ts: isDshTitleRequest added to the audit: 全仓冗余审计与重构计划——server.ts 解体、客户端矩阵去重、死代码、AGENTS.md 模块图腐化 #1440 handle.ts import allowlist (same category as isServerToolUtilityCall: pure predicate, no threshold/session state).

Verification (rebased head bf2b48b)

  • typecheck clean; targeted side-lane suites 52/52 (incl. websearch-side-request fix(#2500): route Claude Code WebSearch sub-requests through the side passthrough #2508).
  • Real dsh 0.2.1-alpha.2 headless through bili (fake upstream): one raw-key persisted session only (no |sub:), title forwarded verbatim with 4096, acp_status tool call round-trip intact. Log: side request (dsh title-gen sidecar (#2503)) → passthrough + tag strip only, kernel state untouched.
  • Gated e2e ACP_TEST_E2E_DSH_NATIVE=1 vs alpha.2: scenario A red before (found session-…|sub:c7c06ab4dd220c80, assertion at tests/e2e/e2e-native-dsh-persona.test.ts:386) → green after.

Auto-merge gate self-assessment (§7.4)

Single-module scoped routing fix; regression test reproduces the original bug (gated e2e A red→green + unit cases); green on rebased head; no config schema / persistence / wire-shape / kernel change; pure fix:; clean 4-file diff; references issue; no load-bearing infra touched → eligible.

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-09_dsh-alpha2-title-side-lane (7c7ce2a)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2738-pr.2554.c3e95cd

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-pr2554.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到,开始审查 PR #2554(dsh title-gen side-lane routing fix)。先拉取分支核对代码与 CI 状态,随后给出结构化八问结论。

awork added 2 commits October 10, 2026 00:17
#2554 review: the new pure-predicate test pins isDshTitleRequest but nothing ungated pins the handle() wiring (both decision-point disjuncts). The gated e2e runs the rc.2 dsh pin where the legacy budget heuristic already catches titles, so it cannot catch a wiring regression. This drives the wiring hermetically on the OpenAI wire (dsh's actual shape) with the worst-case title-first ordering (#2156/#2160 anchor-claim hazard): verbatim forwarding incl. the alpha.2 4096 budget, zero kernel-state impact, no |sub:<fp> ghost minted at any point. Red-proofed against pre-fix handle.ts (fails on the verbatim assertion: the full pipeline appends the compression-tool system prompt).
#2554 review: lane-guard (#2170) only watched src/server/side-request.ts + lane-symbol lines in src/server.ts, but #1440's extraction moved the lane region into src/server/handle.ts — deleting a lane disjunct there would trip no gate. Extend the symbol watch to handle.ts (incl. the two new #2503 symbols). Behavior change: the guard is now stricter — any +/- line mentioning a lane symbol in handle.ts requires a paired side-lane suite update (same exposure server.ts already had).
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #2554 review 完成(含两处 review 补强 commit,已推到 PR 分支)

查重:open+closed issue/PR 全搜过,无重复项(与 #2500 server-tool utility、#2156/#2160 锚点链是同一机制族的不同实例,本 PR 引用正确,不另立项)。

审核过程(不是只看 diff):在 PR head 本地复现了全部关键路径——typecheck/unused-exports 干净、9 个 side-lane 相关套件全绿、对 resolveSideLane/passthrough/两个决策点的 header 读取逐一核对、并用 red-proof 实测了修复前行为(见下)。


结构化八问

1. 是什么问题:dsh 0.2.1-alpha.2 把 title sidecar 的预算从 64 提到 4096,bili 不再认得它是 side request——标题生成请求被当成主轮次处理,在 #1916 persona fingerprint 下 fork 出持久化的 |sub:<fp> ghost session(每个 dsh session 一个)。

2. 什么原因导致的:分层说清。表面现象 = ghost session + 标题垃圾进 kernel 状态。机制层根因 = side-lane 判定对 dsh title 依赖的是 wire 启发式(max_tokens ≤ SIDE_REQUEST_MAX_TOKENS=200)而非结构识别;alpha.2 把预算改成"防跑飞的天花板而非长度目标",启发式静默失配。修复选择结构识别(dsh title system prompt 的稳定首行 + no-tools veto),方向正确——这正是 KDD#9 evidence-per-client 模式,与 #2500 同构。我的 red-proof 还额外证实了一个 diff 里没写的细节:修复前 full pipeline 会把整段 compression-tool system prompt("Compression Philosophy / HOW TO COMPRESS / ACP TAGS / TOOLS…")追加进 title 请求的 system message 再转发——即标题生成一直在带着一坨压缩指令的 prompt 上跑,且该轮计入主/ghost session 的 stats。

3. 影响范围与严重程度:仅 dsh ≥0.2.1-alpha.2 用户(rc2 及更早不受影响);触发条件 = 每次 dsh 会话启动时的 title 生成。严重度:特定条件下有问题——每会话一个持久化 ghost session、title 轮污染 kernel 状态与 stats、浪费上下文;最坏排序(title 先于首个主轮到,#2156/#2160 类)下 anchor claim 可能把整个主会话 fork 到 ghost 上、ACP 管理调用全部路由进空 session。主会话数据本身不损坏。

4. 怎么修复的:纯谓词 isDshTitleRequest()(system 首行前缀匹配 + tools 存在即否决)在 handle() 两个决策点(sideRequestLike 与 sideIntent)各加一个 disjunct,gate 条件 x-bili-plugin === "dsh" && agent ≠ main,恢复 #388 verbatim passthrough(原始 key、wire 字节不变、kernel 状态不动)= rc2 行为回归。

5. 是否有回归问题:逐项审过的既有行为——① legacy ≤200 启发式未动,其他客户端 side request 行为不变;② no-tools veto 保证未来任何带 tools 的主轮次不可能经此路径被降级(防过度分流);③ 两个决策点读同一个 header(pluginRequestAgentHeader),无分叉风险;④ 与 serverToolUtility label 互斥(utility 必须有 tools,title 一票否决 tools),优先级无歧义;⑤ instructions-fingerprint lanes(#1104/#1107,codex/claude)消费的是不同谓词,不受影响;⑥ passthrough 语义与 rc2 title 完全一致(含 #554 local-413 guard)——"restore rc2"是 parity 不是新行为;⑦ 主轮次仍走 full pipeline(由我新加的 handle 级测试钉住 stats.requests 递增)。结论:无意回归未发现。 残留风险(非阻塞):e2e workflow 钉死 dsh 0.2.0-rc.2,自动化门禁覆盖不到 alpha.2 端到端路径;若未来 dsh 改 title prompt 首行或换 wire,carve-out 会静默失配、ghost-fork 复现——这是 KDD#9 文本证据模式的固有属性,建议 alpha.2 转正后 bump e2e pin(follow-up,owner 拍板)。

6. 是否破坏缓存:否。sidecar 不触碰主会话消息流/system 稳定性(raw-key session 的 inputTokens/contextTokens 前后不变,已断言钉住);无缓存键/重试游标/去重键变化。

7. 是否改了设计方向:否。沿用既有 KDD#9 证据许可模式,无架构/边界/数据流转向。

8. 是否引入新的配置:无 config/env/CLI 新增。DSH_TITLE_SYSTEM_PREFIX 是代码常量不是配置面。


Review 补强(已作为独立标注 commit 推入 PR 分支,head → 7c7ce2a)

  1. test: hermetic handle-level pin(tests/dsh-title-sidecar-handle.test.ts,新增):原 PR 的新测试只钉纯谓词,handle() 接线本身没有任何 ungated 测试钉住——gated e2e 跑的是 rc.2 pin(rc2 下 legacy 启发式本来就抓得住 title,删掉接线它也变红不了)。新测试按 dsh 真实形态(OpenAI wire、sidecar 无 persona header、title-first 最坏排序)驱动真实 handle():verbatim 转发(4096 预算原样)、零 kernel 状态影响、全程无 |sub: ghost。已 red-proof:回退 handle.ts 到 merge-base 后失败于 verbatim 断言(正是上面第 2 问发现的 prompt 注入差异)。
  2. fix(ci): lane-guard 盲区(.github/workflows/ci.yml):⚠️ CI 行为变更披露——lane-guard(dsh 回归防护:泳道判定真值表 + 侧请求不变量 + dsh e2e lane + 运行时金丝雀 + lane-guard(5 项) #2170)只盯 src/server/side-request.ts + src/server.ts 的 lane symbol 行,但 audit: 全仓冗余审计与重构计划——server.ts 解体、客户端矩阵去重、死代码、AGENTS.md 模块图腐化 #1440 抽取已把 lane region 搬进 src/server/handle.ts(未盯防):删掉本 PR 的任一 disjunct 不会触发任何门禁(本 PR 能过 guard 只是因为顺带改了 side-request.ts)。旧值→新值:guard 监听范围 {side-request.ts, server.ts lane symbols} → {+ handle.ts lane symbols,含新增的 isDshTitleRequest/DSH_TITLE_SYSTEM_PREFIX};效果是 guard 变严(handle.ts 里动 lane symbol 必须伴随 side-lane 套件更新,与 server.ts 原有暴露一致)。本地模拟确认:本 PR 在新 guard 下正常通过(handle.ts 命中 8 行 lane symbol,套件配对检查过)。

验证汇总

  • 本地(PR head):typecheck 干净、unused-exports 干净、side-lane 全套件 + 新测试 61/61 绿、red-proof 成立。
  • CI(新 head 7c7ce2a):26/26 success,含 lane-guard(新逻辑首跑)、4 平台 test matrix(含新测试)、dsh plugin lane、real dsh headless profile lane、e2e。
  • PR 状态:mergeable=true,与 master 无冲突(master 领先的 9 个提交与本 PR 零文件重叠)。

判定:可合并。 修的是根本原因(结构识别替代会随上游预设漂移的启发式),方向、实现、测试三层都立得住;两处补强把「接线无 ungated 钉」和「guard 盲区」这两个同机制族的洞堵上了。

@ranxianglei
ranxianglei merged commit c183076 into master Oct 10, 2026
26 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.207-master.c183076 (rolling master tag).

npm install -g billion-context@0.0.207-master.c183076  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

ranxianglei pushed a commit that referenced this pull request Oct 13, 2026
…-lane suite

The lane-guard (#2170, blind spot closed by #2554) requires a dedicated side-lane suite whenever src/server/handle.ts references a lane symbol. The google branch's !sideRequestLike gate legitimately trips it, so the pin must land with a side-lane suite edit. It belongs there anyway: side-request-isolation.test.ts now drives a dsh title-gen on the gemini wire through the proxy and pins that it rides the #388 verbatim passthrough (raw conversation key, no kernel state, no persona fork, anchor not stolen by an earlier side request). Removed the duplicate assertion from dsh-persona-fingerprint.test.ts.
@ranxianglei
ranxianglei deleted the 2026-10-09_dsh-alpha2-title-side-lane branch October 15, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dsh 0.2.1 Alpha.2更新了检查适配情况

1 participant