Repository navigation
fix(#2241): continuity-aware dsh persona anchor — model switches migrate the anchor instead of forking the main lane - #2247
Conversation
…continues the raw key's chain keeps the raw key The dsh persona fingerprint (db21309) forked on ANY system-text change under the id, on the assumption that dsh composes its main system once per session. /model breaks that assumption: dsh rebuilds the main system per model, so every model switch forked the MAIN lane off the raw key while the host kept stamping the bare id — compression then hit the frozen husk forever (#2241: 266,966 pendingT1 tokens, 0 folds). Swap the fork trigger for prefix-affinity identity semantics (#1106/#1148: content is identity, system drift is evolution): - src/prefix-affinity.ts: chainContinues(messages, sessionId) — the stored chain is a byte-exact head-anchored prefix of the incoming list (equal-depth byte-exact replay counts too). - src/persona-anchor.ts (new): resolvePersonaKey — first-seen claims, same-system matches, and on system change: history continues the raw key's chain → MIGRATE the anchor (compression state stays); history discontinuous (auto-review flattened blob) → fork onto <id>|sub:<fp> exactly as before. Empty system stays non-anchoring. Fork id format unchanged (#2244 personaForkTarget compatible). - src/server.ts: both dsh persona call sites (anthropic + openai) now route through dshPersonaNamespace; migrations log one info line. - Restart race self-heals: chains are permanent (#1724), so even if a review claims the raw anchor after a restart, the next main turn's continuity check runs against the persisted chain and migrates back. Tests: dsh-persona-continuity (unit state machine + openai e2e: switch/ switch-back/review-forks/diverged-forks; anthropic e2e); fingerprint suite unchanged (review isolation, side-request verbatim, allowlist); side-lane-invariants (D) now uses the realistic flattened review blob (a history-replaying different-system request is the same conversation evolving post-fix, not a persona fork).
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2336-pr.2247.28c2976This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2247.tgz
npm install -g packageInstall instructions are refreshed on each push. |
The new e2e rigs shared the ambient prefix-affinity snapshot: startServer's hydratePrefixAffinity() imports the chains the PREVIOUS local run of this file persisted (deeper dshc-* entries), so chainContinues rejects the shorter replay (msgs.length < entry.depth) and forks instead of migrating — green on a clean machine/CI, deterministic red on any second run. Sandbox XDG_* per file and per rig, matching tests/side-lane-invariants.test.ts. No behavior change — review fix for PR #2247.
[bot] 🏷 PR review 完成。方向正确、机制成立,已在 PR 分支上直接修掉两个 review 发现的小问题(带标注 commit),当前 head 结构化七问1. 是什么问题 2. 什么原因导致的 3. 怎么修复的 4. 是否有回归问题 review 中发现并直接在分支上修的两个小问题:
5. 是否破坏缓存 6. 是否改了设计方向 7. 是否引入了新的配置 验证状态(head c74175d)
顺带提醒(不阻塞)#2244 与本 PR 都写了 收工判定:可合(待剩余 3 个矩阵格套件跑完;按目前证据——含一格全量套件已绿——预期全绿)。 |
[bot] 🏷 补充:head |
|
新提交审核了吗 |
[bot] 🏷 审了。刚重新 fetch 确认:分支 head 仍是我上一轮审核的 审核期间新增的两个 commit 都覆盖在结论里:
|
…conversation key Adds tests/e2e/e2e-native-dsh-persona.test.ts to the real-dsh native lane (runs on every PR): two turns of one real dsh headless session (--session-id adoption) with the profile default model flipped between them, so dsh recomposes its main system per model — the exact incident trigger. Asserts one stable conversation id on the wire, a real model switch, a continued history, and exactly ONE persisted bili session under the RAW key (no |sub: sibling, requests >= 2, refs accumulated). Verified both directions locally: pre-fix master fails with the |sub: fork, the fix build passes. The lane's dsh install bumps 0.1.5-rc.3 -> 0.2.0-rc.2 for --session-id; the existing base-lane suite passes against 0.2.0-rc.2 (verified locally).
…eview scenario behind a verified blocker gate Scenario A now asserts dsh's title-generation side request rides the same conversation id without stealing the raw key or minting a persisted |sub:. Scenario B (auto-review still forks) is written and kept ready, but gated behind ACP_TEST_E2E_DSH_AUTO_REVIEW: verified against dsh 0.2.0-rc.2 that the review gate arms only when permissionPresets.current(session) === "auto", headless sessions carry no preset, Auto has no default/env/CLI surface (web-UI /permission auto only), and the settings.yaml legacy import does not settle within a one-shot run. The review fork shape stays pinned by the harness e2e in dsh-persona-continuity.test.ts until dsh grows a headless preset surface.
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.74-master.ad514ed # this exact build
npm install -g billion-context@master # always the newest merged build
|
…he codex / claude-over-Responses instructions lanes (ranxianglei#2250) An instructions drift mid-conversation (model switch, AGENTS.md edit, -c override, codex upgrade reassembly) forked the main lane off its raw key onto |sub:<fp> — zero compression state, refs re-minted (ranxianglei#2241 exposure shape). The drift now MIGRATES the anchor when the replayed input continues the raw key's prefix-affinity chain; a genuinely fresh task reusing the id (ranxianglei#150) still forks. Kernel subagentNamespace swap at the responses call site; dsh lanes unchanged (already ranxianglei#2247); fork id format identical.
…semantics (#2601) The fixture's switch turn was a byte-exact extension of the anchor turn, so on master (with #2247's continuity-aware migration, which postdates this branch's base) it MIGRATES the anchor instead of forking — all five routing tests died in setup. The field incident (#2601) proves the real switch breaks the chain (history rewrite or cross-lane normalization), so the switch turn now drifts the first historical message to reproduce a genuine fork. Adds one test pinning the boundary: a byte-stable same-lane switch migrates (no fork), and bare-id native calls stay on the raw key with nothing to reroute to.
Closes #2241 (root fix; complements the routing-side stopgap #2244).
Problem
db21309 keyed dsh traffic by id + system-text hash with kernel first-seen
anchor semantics, assuming "dsh composes its main system once per session,
so main turns never fork mid-conversation".
/modelbreaks the assumption:dsh rebuilds the main system per model, so every model switch forked the
MAIN lane onto
<id>|sub:<fp>. The host only stamps the bare id, socompression kept hitting the frozen husk on the raw key — #2241's incident:
266,966 pendingT1 tokens, 0 folds for 38 minutes, 9/9 compress rejections.
Fix — prefix-affinity identity semantics at the anchor decision
The fork trigger changes from "system text changed" to "system text changed
AND the incoming history does not continue the raw key's chain":
src/prefix-affinity.ts— newchainContinues(messages, sessionId):the stored chain is a byte-exact head-anchored prefix of the incoming
list (equal-depth byte-exact replay counts too). Cryptographic prefix
equality is the discriminator; no new state.
src/persona-anchor.ts(new) —resolvePersonaKey: first-seen claimsthe raw key; same system matches; system change + continuing history
migrates the anchor (same conversation — blocks/refs/ledger stay);
system change + discontinuous history (the auto-review flattened blob)
forks onto
<id>|sub:<fp>exactly as before. Empty system staysnon-anchoring (kernel semantics).
src/server.ts— both dsh persona call sites (anthropic + openai) routethrough it; one info log per migration.
<rawId>|sub:<sha256(system)[0..16]>unchanged → [PR] fix: follow the live persona fork when a host-stamped dsh id hits a frozen anchor (#2241) #2244personaForkTargetrouting stays compatible (defense in depth forrestart races).
Restart race self-heals: chains are permanent (#1724), so even if a review
claims the raw anchor after a proxy restart, the next main turn's
continuity check runs against the persisted chain and migrates the anchor
back — strictly better than the old first-seen-only rule.
Behavior matrix
/modelswitch mid-conversation<id>|sub:<fp>, stable across callsTests
tests/dsh-persona-continuity.test.ts(new): resolver state machine(claim/match/passthrough/migrate/fork, anchor never moves on fork) +
openai e2e (switch keeps raw key, refs accumulate, review still forks,
switch-back migrates again, diverged forks) + anthropic e2e.
tests/dsh-persona-fingerprint.test.ts: unchanged, all 7 still green(review isolation, side-request-first, allowlist).
tests/side-lane-invariants.test.ts(D): the review fixture now uses therealistic flattened single-blob shape — the old fixture replayed the main
history byte-exact under a different system, which post-fix semantics
correctly classify as "same conversation evolved" (the [[bug] dsh 0.1.185: main lane forks itself on a mid-session model switch, orphaning the persona anchor — every native compress is refused (9/9, not covered by #2157) #2241 fix itself).
Local: targeted suites 67/67; typecheck clean. Full suite via CI.