Skip to content

fix: dsh persona fingerprint parity for the Responses wire (#2203) - #2232

Merged
ranxianglei merged 4 commits into
masterfrom
2026-10-06_dsh-responses-persona-fork
Oct 7, 2026
Merged

ranxianglei merged 4 commits into
masterfrom
2026-10-06_dsh-responses-persona-fork

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Closes #2203

What / why

Production repro (bili 0.1.185, DSH Web profile, /v1/responses, clientHint=dsh, session a215f0cf…): the DSH auto-review persona (fixed REVIEW_POLICY instructions + one flattened transcript blob, no tools, ~384K budget) walked the FULL pipeline under the MAIN session id — 19 requests interleaved 13→2→16→2 msgs in one view, CACHE SEAM ~189K × 10, compressionCount=0, [fold-reconcile] system prompt changed (3859 ↔ 13927 chars) oscillating in the same session. Same install forked correctly on the Anthropic wire (|sub: rows present) but every DSH Responses session stayed on the raw id.

Root cause: in the identity ternary (src/server.ts), the Responses branch only consulted instructionsFingerprintApplies — the codex/claude-only inverted allowlist — plus the plain-proxy stableSystemAnchor branch. x-bili-plugin: dsh over /v1/responses therefore keyed VERBATIM under the raw conversation id: review personas interleaved into the main session, kept breaking its prefix cache and clobbering its usage baseline/snapshots. The persona fingerprint existed for openai/anthropic only.

Fix (rebased onto 86191d6, aligned with #2247/#2250)

Behavior change (old → new)

ONLY x-bili-plugin: dsh traffic on the Responses wire:

No other traffic class is touched: codexTurn, stableSystemAnchor (plain proxy), codex/claude instructions personas, opencode/grok/plugin lanes keep byte-identical identity paths.

Tests

  • New responses parity e2e in tests/dsh-persona-fingerprint.test.ts: main anchors raw key → review forks |sub:<fp> → repeated reviews reuse the fork → main state untouched → conversations map keeps both entries under correct ids → instructions-less rides raw. Stash-proofed: FAILS on unmodified code AND on pristine master (verified at both c4ae707 and the current 86191d6 — AssertionError: 'review request landed on its own forked session'), passes with the fix.
  • tests/side-lane-truth-table.test.ts: "responses" added to the resolveSideLane exhaustive protocol loop + pin that the production auto-review shape (no tools, explicit-large or absent budget) stays OFF the side lane.
  • tests/side-lane-invariants.test.ts invariant (E): tiny-budget tool-less dsh request on /v1/responses rides the raw key verbatim (no fork minted, no state touch) while the full-budget review shape still forks and stays canary-clean.
  • Local: typecheck clean; 48/48 across dsh-persona-fingerprint, dsh-persona-continuity, side-lane-truth-table, side-lane-invariants, pi-subagent-registry, e2e-stable-system-anchor, codex-turn-isolation, e2e-session-identity.

Rebase notes

Two rebases, both mechanical (no behavior change):

  1. After fix(#2241): continuity-aware dsh persona anchor — model switches migrate the anchor instead of forking the main lane #2247 (dsh-persona-continuity) landed: the Responses lane uses the same continuity-aware persona anchor as the anthropic/openai lanes instead of the original kernel-subagentNamespace formulation (fork id format unchanged: <rawId>|sub:<sha256[0..16]>). The earlier labeled drive-by commit (pi-subagent-registry fake, filed as [bug] master red since #2209: pi-subagent-registry factory-wiring test broken — single-slot test fake cannot hold #2186's second session_start handler #2236) is DROPPED — that fix reached master independently via fix: pi-subagent-registry fake stores per-event handler arrays (#2234) #2235 (782bb22e9).
  2. After fix: codex / claude-over-Responses instructions drift migrates the persona anchor instead of forking (#2250) #2271 generalized dshPersonaNamespace → personaNamespace and extended it to the codex/claude-over-Responses instructions lanes (codex 线 responses 身份仍走 instructions-hash subagentNamespace:同 id 下 instructions 中途变更会 fork 主 lane 丢压缩(#2241 同款暴露,未审计) #2250): this PR's new Responses call site now references the renamed export personaNamespace (final small commit), plus a one-space indent repair on the stableSystemAnchor condition line that the rebase carried. Re-verified on head 31adfb4d7: typecheck clean; 48/48 across the same suites; the responses parity e2e still FAILS on pristine master 86191d6ac and passes here.

No config surface / persistence format / kernel changes.

Remaining facet (tracked in #2203, NOT in this PR): the google-native wire also lacks the dsh clause — enabling it there follows the KDD#9 evidence-per-client discipline (needs traffic evidence for that specific host/wire shape first).

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-06_dsh-responses-persona-fork (31adfb4)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2457-pr.2232.632b5b1

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-pr2232.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] 🏷 Review 完成(代码 + 回归 + 测试有效性 + CI 逐层核过)。结论:可合——本轮 CI 跑在 c3661fff2,lane-guard 应转绿;四个全量 test job 的 red 是 master 既有问题,与本 PR 无关。

审核过程

  • base bd33b11 即当前 master tip,分支无 stale-base 问题;单 commit + 我补的 lane-guard commit,diff 干净(3 文件 → 4 文件,无跑题改动)。
  • 本地:typecheck clean;定向套件 33/33 绿(dsh-persona-fingerprint / e2e-stable-system-anchor / codex-turn-isolation / side-lane-truth-table / side-lane-invariants / e2e-session-identity);stash-proof:只把 src/server.ts 回退 master,新 e2e 立即 FAIL——测试有牙。全量回归交给 CI。

代码审查要点

  1. 拆分条件 || (dshPersona && !sideRequestLike)(src/server.ts:2298):正确。Responses 泳道身份原先只走 instructionsFingerprintApplies 白名单(仅 codex/claude),dsh 不在内——这就是 [design/bug] DSH auto-review 与主会话共用 session 持续制造 CACHE SEAM;建议拆分为可压缩的 derived review lane #2203 floor 4 定位的缺口。kernel namespaceFor(kernel/src/wire/responses.ts:733)对空/非 string instructions 返回 verbatim,「非锚定」性质成立;无 instructions 的辅助调用继续骑 raw key(新 e2e phase 6 钉死)。
  2. stableSystemAnchor 加 !dshPersona(src/server.ts:2284):必要且最小。下游锚定机制虽有 !pluginMode 门,但身份选择在它之前发生——operator 开锚时 dsh-responses 会被 key verbatim、吞掉拆分;而 dsh 不打 x-bili-plugin-agent,原条件里的 header 检查看不见它。openai/anthropic 两泳道本来就没有锚分支,此排除恢复三泳道 parity。
  3. rawPersonaIdentity 扩展 responses 情形:查过一个潜在误报——codex root thread 下 responsesIdentity.value === codexTurn.value === conversation(src/server.ts:2148),personaForked=false,不会误盖 canary 戳;非 dsh 流量的 designNamespaced 集合与改前完全一致(旧第二子句覆盖的情形现被第一子句等价覆盖)。recordPluginSession 经 consumePluginRegisterFor 身份注册可达 dsh 流量,fork 按 split id 记录——正是补上 responses 上的 Subagent first token stalls 1-2min: withSessionLock covers full forward + slow flash upstream first byte #970/[bug] dsh:side request 先到会抢走 persona 锚点,主会话被 fork 到 |sub:<fp>,原生 compress 永久失败 #2156 单值 map 类。
  4. scope 纪律:只影响 /v1/responses 上带 x-bili-plugin: dsh 的请求;codex/claude/opencode/google 泳道零 diff;affinityToken 仍用 raw identity,上游 prefix-cache 连续性不受影响。

回归审查(既有行为清点)

触碰路径的既有行为 结论
dsh-over-openai/anthropic persona split(#1916) 保持,零 diff
codex/claude-over-Responses instructions 指纹拆分(#1104/#970) 保持,stamp 结果不变
side-request bypass(#388/#2156) 保持,同一 sideRequestLike 谓词、同一三泳道 gating
codex turn 分区(#316) 保持(见上第 3 点核验)
google-native 有意不动——无生产证据,按 KDD#9 evidence-per-client 留在 #2203 跟踪
config surface / persistence / kernel 无变更(kernel-guard/version-guard 绿)

行为变更 old→new 与 PR 描述一致且已披露:dsh-responses review 请求从 raw-key 走主会话管线 → <id>|sub:<fp> 独立会话(main 保持 raw key)。

测试有效性

新 e2e 六阶段全覆盖 PR 声称(anchor → fork → fork 复用 → main 稳定 → conversations-map 纪律 → instructions-less aux),断言咬 session 身份/stats 计数/snapshot 长度/metadata stamp,不是恒真断言;stash-proof 通过。

CI 状态与我的处置

  • lane-guard red(本 PR 触发):diff 给 server.ts 新增了 sideRequestLike 消费者,dsh 回归防护:泳道判定真值表 + 侧请求不变量 + dsh e2e lane + 运行时金丝雀 + lane-guard(5 项) #2170 纪律要求配套 side-lane 套件更新。我到分支时已有一个 truth-table pin(7af68e4ad,agent 推的,覆盖 gate 函数级);我又补了一个集成级 e2e(c3661fff2,tests/side-lane-invariants.test.ts 新增 test E)——两者互补而非重复:单元表抓不住「gate 判决没被正确消费」(若有人日后从 identity 条件里删掉 !sideRequestLike,单元表仍绿、生产会 mint junk fork,test E 直接红)。test E 同样 stash-proof 过;三个相关套件 21/21 绿。
  • 四个全量 test job red(ubuntu/windows × node 22/24):master HEAD bd33b11 上同样四个 job 同样 red——既有问题,非本 PR 引入。日志 API 取不到(404),无法定性失败模式,在此标记请 owner triage;不阻塞本 PR。

结构化七问

  1. 是什么问题:DSH auto-review 与主会话共用一个 conversation id,Responses wire 上 persona 拆分机制缺位,review 请求污染主会话 snapshot/baseline/CACHE SEAM([design/bug] DSH auto-review 与主会话共用 session 持续制造 CACHE SEAM;建议拆分为可压缩的 derived review lane #2203 生产复现)。
  2. 什么原因导致:拆分机制落地时只实现了 openai/anthropic 两泳道;Responses 泳道身份解析走 instructionsFingerprintApplies 白名单(仅 codex/claude),dsh 不在名单内,全部请求 verbatim keyed。机制 parity 缺口,非设计缺陷。
  3. 怎么修复的:在 Responses 泳道补齐既有白名单机制(拆分谓词 + 锚定排除 + split id 记录),零新设计、零 kernel 变更。
  4. 是否有回归问题:无。上表逐项清点完毕;唯一行为变更即披露的 dsh-responses 拆分。
  5. 是否破坏缓存:上游 prefix cache 不受影响(affinityToken 用 raw identity);fork 本身消除了两条 lineage 交替制造的假 seam;conversations map 单值纪律保持并新增钉死。
  6. 是否改了设计方向:否——同一 persona-fingerprint 机制补第三条 wire;google-native 缺口继续等生产证据([design/bug] DSH auto-review 与主会话共用 session 持续制造 CACHE SEAM;建议拆分为可压缩的 derived review lane #2203 跟踪)。
  7. 是否引入新配置:否。

判定:可合。 等 c3661fff2 这轮 CI 确认 lane-guard 绿即可合并;四个全量 red 建议另案 triage(master 既有)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI 终态确认(c3661fff2,ci.yml run 37421200786):

  • lane-guard → success ✅(truth-table pin 7af68e4ad + 我补的集成级 test E c3661fff2 解决了该 gate)
  • version-guard / kernel-guard / docs-coverage / docs-sync → success ✅
  • 全部 e2e lane → success ✅(dsh plugin lane、real codex/pi/opencode/dsh headless、hermetic registry ubuntu+windows、image billing、OpenCode V2 WS、theorem 等)
  • 仍红:仅 4 个既有 test matrix job(ubuntu/windows × node 22/24)——与 master 基线一致,非本 PR 引入。

补充证据与处置:抽查了近期其他分支的 CI run(degen-close-strip、cache-ledger-coverage-accrual、pi-subagents-config-home ×2),失败集合与本 PR 完全相同(仅这 4 个 job,其余全绿)→ 这是 master 基线级别的全量套件问题,影响所有分支。已按流程立项 #2238(带来源标记,含 run ID 证据表与建议步骤;agent PAT 无 check-run 日志下载权限,具体失败用例需从 GitHub UI 看日志定性)。

最终判定:可合。 本 PR 自身的所有门禁(guard + e2e + lane-guard)全绿;剩余 4 红属 #2238 跟踪的 master 既有问题,不构成本 PR 阻塞。PR mergeable=true,等 owner 合并。

@ranxianglei
ranxianglei force-pushed the 2026-10-06_dsh-responses-persona-fork branch from 21ce731 to fdb5ca9 Compare October 6, 2026 06:41
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 冲突已解决:rebase 到当前 master(2f6fe8bce,含刚合入的 #2233 pi-subagents)并推回分支,新 head fdb5ca981。PR 状态已转 mergeable=true / mergeable_state=blocked(blocked = 等 CI,非冲突)。

处理方式:两侧文件零重叠——master 前进只碰 src/config.ts、src/agent/pi-subagents.ts、tests/pi-*、docs;本 PR 只碰 src/server.ts、src/session-id.ts、tests/dsh-persona-fingerprint.test.ts、tests/side-lane-invariants.test.ts。rebase 零冲突(三个 commit 原样重放),force-push 回特性分支(仅 master 禁 force-push)。rebase 后验证:typecheck clean、定向套件 35/35 绿。CI 正在新 head 上重跑。

一并披露一件事:rebase 前 fetch 时发现远端分支 tip 不是我的上一 head c3661fff2,而是其上多叠了一个 commit 21ce73108("fix(tests): multi-handler fake Pi … (#2236)",ework-agent,今日 14:27)——另一个 agent 会话把中间提交推到了本 PR 分支上,我的 force-push 将其覆盖。随后立即做了丢失核查:该 commit 只改 tests/pi-subagent-registry.test.ts(+20/-11,fake Pi 单 handler 槽 → per-event handler 数组 + fire() helper);而 open PR #2237(branch 2026-10-06_pi-fake-handler-array,commit 720f66dc8 "test: pi-subagent-registry fake pi keeps per-event handler arrays like real pi (#2234)")是同一修复——同文件、同规模(+21/-11)、同结构标记(PiHandler / Map<string, PiHandler[]> / fire())。结论:21ce73108 是同一修复的中间重复品,内容完整由 #2237 承载,无丢失,未做 rescue push。提醒:向他人 PR 分支叠推中间提交会被该分支的正常 rebase/push 覆盖,建议各会话只推自己的分支。

七问

  1. 是什么问题:master 合入 feat: pi.subagents config home in billion-context.json (#2230) #2233 后前进,系统检测本 PR 与 base 冲突(dirty)。
  2. 什么原因导致:base 历史移动触发 mergeability 重算;实质两侧零文件重叠、无真实文本冲突,属 base 过旧 + 远端 tip 曾被临时叠压的状态组合。
  3. 怎么修复的:rebase 三个 commit 到新 master tip、零冲突、force-with-lease 推回特性分支;diff 内容一个字节未变(仅 parent 指针移动)。
  4. 是否有回归问题:否。diff 未变 → 首轮 review 的全部既有行为清点结论继续成立;rebase head 上 typecheck + 定向 35/35 绿。
  5. 是否破坏缓存:不涉及(无任何缓存相关路径变化)。
  6. 是否改了设计方向:否。
  7. 是否引入新配置:否。

判定:可合。 等新 head CI 收尾(预期与上轮一致:guard/e2e 全绿,仅剩 #2238 跟踪的四个既有 test red)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI 终态(rebase 后 head fdb5ca981,run 37425200770):

除该 flake 外无任何阻塞项。合并就绪,等 owner。

@ranxianglei
ranxianglei force-pushed the 2026-10-06_dsh-responses-persona-fork branch from fdb5ca9 to 370e149 Compare October 6, 2026 12:29
ework-agent added 4 commits October 7, 2026 16:01
DSH auto-review traffic over /v1/responses keyed verbatim under the raw session id (the instructions allowlist covers codex/claude only), so review personas interleaved into the main session and kept breaking its prefix cache. Route dsh-over-Responses through the same continuity-aware persona anchor as the anthropic/openai lanes (#2241): history-discontinuous review blobs fork onto |sub:<fp>, model switches migrate the anchor on the raw key. rawPersonaIdentity gains the dsh-scoped responses case so forks record under their suffixed id (#970 map discipline).
…uard)

The identity branch gained a new sideRequestLike consumer on the responses wire (dsh persona split suppression), which trips the #2170 lane-guard. Pin the interaction in side-lane-invariants (E): a tiny-budget tool-less dsh request on /v1/responses rides the raw key verbatim while the full-budget review shape still forks and stays canary-clean.
#2203)

Rebased onto master after #2271 generalized dshPersonaNamespace to
personaNamespace: the new responses call site still referenced the old
export name (compile break), and the rebase carried a +1-space indent
drift on the stableSystemAnchor condition line.
@ranxianglei
ranxianglei force-pushed the 2026-10-06_dsh-responses-persona-fork branch from 370e149 to 31adfb4 Compare October 7, 2026 08:04
@ranxianglei
ranxianglei merged commit e1b4345 into master Oct 7, 2026
27 checks passed
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.101-master.e1b4345 (rolling master tag).

npm install -g billion-context@0.0.101-master.e1b4345  # 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.

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.

[design/bug] DSH auto-review 与主会话共用 session 持续制造 CACHE SEAM;建议拆分为可压缩的 derived review lane

1 participant