Repository navigation
[PR] fix: follow the live persona fork when a host-stamped dsh id hits a frozen anchor (#2241) - #2244
ranxianglei wants to merge 2 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2808-pr.2244.ca38aa7This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2244.tgz
npm install -g packageInstall instructions are refreshed on each push. |
4c834ec to
df8ffed
Compare
[bot] 🏷 ## PR #2244 审查结论(七问体例) 审查动作:核对分支代码 → 发现分支落后 master 177 个提交(base 5e43209 vs 当前 c23f365,期间 #1875 ProxyToolResult 重构、#2157/#2156 persona-anchor 修复都落在同一函数上)→ rebase 到当前 master(干净应用,零冲突,diff 与原 PR 逐字节一致)→ 在 rebase 后的 head 上跑定向验证 → 已 force-push 回 PR 分支( 七问
测试有效性(质量关)新套件是真测试:完整 server + SSE-framed mock upstream(喂 witness 环的唯一线上形状),oracle 是块落点(fork vs husk)+ 仅存在于 fork 的 ref(m00013–m00015 在 husk 上必然 定向结果(rebased head):新套件 5/5 + diff 整洁度单提交、3 文件、+376/-4,每一行都属于本修复;无锁文件/生成物连带变更(本地 install 产生的 lockfile 扰动已在推送前还原)。 判定:可合并——等 rebase 后 head( |
…se history 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 (ranxianglei#2241: 266,966 pendingT1 tokens, 0 folds). Swap the fork trigger for prefix-affinity identity semantics (ranxianglei#1106/ranxianglei#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 (ranxianglei#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 (ranxianglei#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).
…rozen anchor (#2241) A mid-session model switch in dsh changes the main lane's system text, so the persona fingerprint forks THAT lane onto <id>|sub:<fp> while the host keeps stamping the bare id on every tool call (dsh-native reads its own session id, it cannot know the proxy-invented suffix). Tool routing then honored the native caller over the outbound witness (#2024) and executed every compress against the frozen pre-switch parent anchor: 'every ref is unknown', 9/9 refused in the field. handlePluginTool now resolves the conflict against known namespaces before honoring the native caller (personaForkTarget): an outbound witness bound to <conversationId>|sub:* is the same conversation's persona fork and is followed; with no witness (proxy restart empties the ring), a persisted conversations entry under that prefix that is STRICTLY fresher than the parent's entry wins. Both paths are lane-gated to dsh (personaForkLaneApplies) because Claude Code subagents reuse the |sub: key shape for unrelated splits (#970). Non-dsh lanes, non-child witnesses, non-native callers and stale/absent children keep their exact prior semantics; a fork target that fails to resolve degrades to the legacy path. Regression suite: tests/issue2241-persona-fork-tool-routing.test.ts (witness incident repro, restart registry variant, stale-child no-reroute, lane gate, unchanged 409 fail-closed) on SSE-framed upstreams — the wire that feeds the witness ring. Fixes #2241
…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.
df8ffed to
bdf9ab3
Compare
|
(ai: zhipuai-lb/glm-5.3) 陈旧票清理(第三批动作①):目标 issue #2241 已关。为避免重复劳动关闭本 PR;如判断有误请直接 reopen 并留言。 |
What & why
#2241: in dsh native mode a mid-session
/modelswitch changes the main lane's system text, so the persona fingerprint (KDD #9) forks that lane onto<id>|sub:<fp>— while the host keeps stamping the bare id on every tool call (src/agent/dsh-native.tsreads its own session id; it cannot know the proxy-invented suffix). Tool routing then honored the native caller over the outbound witness (#2024) and executed every compress against the frozen pre-switch parent anchor ("husk") —every ref is unknown, 9/9 refused over 38 minutes in the field incident. Not covered by #2157 (side requests stealing the anchor): here the flocking party is the main lane itself.Fix
In
handlePluginTool, BEFORE honoring the native caller, resolve the conflicting id against known namespaces (newpersonaForkTarget, src/plugin.ts):<conversationId>|sub:*is the same conversation's persona fork (the exact emitter of this call): follow it.conversationsentry keyed<conversationId>|sub:*that is STRICTLY fresher than the parent's entry wins. Strictly-fresher keeps the parent authoritative when the model switched back and re-anchored on the raw key.Both variants are gated by
personaForkLaneApplies(parent.metadata.pluginAgent)(src/session-id.ts — mirrors the dsh allowlist ofdshPersonaFingerprintApplies): Claude Code subagents produce the same|sub:key shape for UNRELATED splits (#970), so an ungated reroute would misroute claude main-lane tool calls onto subagent sessions whenever a short-arg witness collides. If the fork target fails to resolve, the existing verbatim-id fallback re-degrades to the stamped session (legacy behavior).Behavior change (old → new)
<id>|sub:*The response body still echoes the host's own conversation id; no wire-format change for any client.
Config surface
None — no new env vars, config fields, or CLI flags.
kernel-change
None — no files under
kernel/touched.Verification
tests/issue2241-persona-fork-tool-routing.test.ts— 5 cases: witness incident repro, restart registry variant, stale-child no-reroute, lane gate (non-dsh keeps Codex Code Mode 压缩失败:MCP shim 忽略每次调用的 _meta.threadId,错误使用过期 env ID #2024 semantics), unchanged 409 fail-closed. Upstreams are SSE-framed chat.completion.chunk streams (real dsh traffic shape; the only wire whose tool_calls deltas feed the witness ring). 5/5 pass.dsh-persona-fingerprint,e2e-plugin-tool-routing,host-native-caller,issue2072-native-caller-stamping(12/12).npm run typecheckclean;npm run buildOK. Full suite + e2e left to CI per local-test discipline.Residual (out of scope, already noted in the #2156 triage): persistent anchoring of the first-system-owns-the-raw-key invariant across proxy restarts is a kernel-boundary design decision; the registry variant above bounds its blast radius for tool routing meanwhile.
Closes #2241