Repository navigation
[PR] fix(#4778): keep the raw key when a tag change rides on a host-side history rewrite - #4782
Conversation
…ost-side history rewrite (#4778) DSH NEXT's goal auto-continuation rewrites the prior per-turn system messages in its own log (persisted empties resented on every later request) while each turn also ships a fresh leading system prompt. The mid-history rewrite breaks BOTH tag-change migration rungs (head fragments, byte-exact chain), so the whole main conversation was re-keyed onto an empty |sub:<fp> lane — orphaning the root lane's fold state and forcing a multi-million-token preflight on every request until a restart minted yet another lane. Add a third tag-change rung: when the recorded body still sits verbatim inside the incoming (>= CONTINUATION_MIN_RUN consecutive same-index content-cell fragment agreements, harness-state cells excluded from both sequences before alignment) AND the incoming extends past the recorded, migrate instead of fork. Guardrails preserved by design: self-contained strangers under a reused id share no positional content (overlap gate), stale shorter replays cannot rewind the live skeleton (length gate), shallow aux blobs never qualify (mainShaped gate), scattered sub-threshold agreement still forks (threshold gate). Regression suite: tests/issue4778-dsh-goal-subfork.test.ts (unit state machine + e2e dsh openai lane; verified to fail pre-fix on exactly the goal rows). Targeted persona/session suites (9 files, 67 tests) + typecheck green locally.
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 本 PR 就是 #4778 的修复交付(Closes #4778),无其他在途 PR 触碰 标签:bug, dsh, scope/kernel, p1(主对话永久不回复 = 「不能用」类,按 2026-10-19 owner 规则定 p1;会话核心键判定归 kernel 域)。 以下是对 PR 本身(而非 issue 结论)的独立审核——读了完整 resolver 状态机、handle.ts 五个接线点、affinity-neutral 投影行为、测试文件全文,并本地实跑验证。 结构化八问
测试有效性(单独说)新测试文件 CI 状态与收工判定写此回复时 PR head(92e9e5a)的全部 CI lane 仍在 queued/运行中, 审核结论:通过。 修的是根因(tag-changed 分支缺「宿主改写自身历史」的证据路径)而非堵症状;护栏四腿双向钉死;回归面逐项清点无意外变更;行为变更已在 PR 正文按旧→新披露。CI lane 转绿后即可合并(合并由 owner 执行)。 |
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6263-pr.4782.3558273This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4782.tgz
npm install -g packageInstall instructions are refreshed on each push. |
master window commits 293ae65/de5e03659 bumped kernel/package.json to 0.0.165 without regenerating the lockfiles; lock-sync re-resolution then rewrites the stale recorded versions (root 0.0.163, kernel 0.0.164) and fails. Pure recorded-version sync via npm install --package-lock-only; no dependency or semantic change.
…on the #4778 continuation rung Second #4778 trigger reported in-thread: a mid-session provider switch re-keys the conversation onto an empty |sub: lane when the new wire resends per-turn system cells the old wire never carried in-array. Clean re-renders were already absorbed by the head-fragment rung (#2791 wire-neutral projection); the dsh-NEXT mid-history-systems shape needs the #4778 rung (red pre-fix, green post-fix). The reasoning-asymmetry row pins the honest boundary: thinking text rides the fragment on the wire that carries it, so a renderer that drops it still forks — making the identity hash think-blind is an owner decision, not a silent formula change.
(ai: vllm-qwen/qwen3.8-27b) 状态:冲突已在本地解决并验证通过,但推送被镜像 502 挡住,尚未落到上游。 这是本轮(自动修复 attempt 1/2)的唯一未完成项——冲突本身不需要任何设计决策,attempt 2 或人工在传输恢复后一条命令即可收尾。 冲突是什么、怎么解的把
安全核验后才取 master 侧:
重要:没有覆盖远端新提交。 动手时发现远端 PR 头已从原 head 本地验证(§7.2 定向)
阻塞点(精确)git 传输层(本地镜像代理)对 fetch 与 push 持续返回 HTTP 502 Bad Gateway。首次 fetch 成功,随后会话中段起一直 502;我累计重试约 22 次(跨度约 4 分钟)全部同一错误。非命令/参数问题,是基础设施可用性故障。 合并对象已安全落在本地分支( 收尾方式(传输恢复后)
结构化八问
收工判定:冲突解决+验证已完成,唯一待办是把 |
…-goal-subfork # Conflicts: # kernel/package-lock.json # package-lock.json
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.879-master.b02370a # this exact build
npm install -g billion-context@master # always the newest merged build
|
Follow-up merge after master advanced past c499b14 mid-resolution (#4969/#4970/#4972/#4971 blog+billing, #4544 event-loop-yield, #4678 mysql-v8-dedup, #4782 dsh-goal-subfork). Conflicts: - src/server/prepare-responses.ts: import hunk unioned again - kept this branch's fold-reconcile import line (superset of master's: adds noteBiliToolSurface/outboundBiliSurface); master's yieldToEventLoop lines from #4528 landed in all four prepare files untouched. - tests/golden/storage-render/{anthropic,chat,google,responses}.json: regenerated from the merged tree via scripts/update-storage-render-goldens.ts; output byte-identical to the previous round's regeneration (master's new commits did not change these golden conversations' outbound wire or persisted state) and differing from master only by this branch's image-rescale armed-state latch digests. Verification: no conflict markers remain; targeted suites green (golden-storage-render + fold-reconcile + issue3400-image-rescale = 109/109); typecheck clean. Full-suite verdict deferred to CI on the pushed head.
What / why
#4778: DSH NEXT's goal auto-continuation rewrites the prior per-turn system messages in its own log (cleared to empty content, persisted, resent on every later request) while each turn also ships a fresh leading system prompt. In
resolveSessionOrder's tag-changed branch this breaks BOTH existing migration rungs (head-fragment equality, byte-exact prefix-affinity chain), so the entire main conversation was re-keyed onto an empty<id>|sub:<fp>lane. The root lane's fold state (112 active blocks in the reporter's session) became unreachable, every request ran a ~6M-token preflight compression that never finished forwarding, and each restart minted yet another|sub:lane.A second trigger landed in-thread (mid-session provider switch, e.g. anthropic→openai on dsh desktop): the new wire re-renders the same transcript AND resends per-turn system cells the old wire never carried in-array — same failure domain, same fix.
Fix
A third rung in the tag-changed branch (
src/session-resolve.ts): whenCONTINUATION_MIN_RUN(8) consecutive same-index content-cell fragment agreements, compared over conversation cells only (harness-statesystem/developercells excluded from both sequences before alignment, so host-side insertion/removal/emptying of per-turn system entries cannot shift the alignment),the anchor migrates to the raw key instead of forking. Exact per-cell sha256 comparison throughout — no fuzzy similarity (MESSAGE-IDENTITY doctrine); an 8-run agreement between distinct conversations is cryptographically impossible.
All four guardrail legs are pinned with negative rows (#3617 gate discipline): self-contained stranger under a reused id (overlap gate), stale shorter replay (length gate), shallow review blob (mainShaped gate), scattered sub-threshold agreement (threshold gate). Existing pinned fork rows in the persona suites all survive unchanged (verified by running them).
Behavior change (old → new)
Tag-changed requests that previously forked onto
|sub:<fp>now migrate to the raw key when they carry ≥8 consecutive same-index content-cell agreements with the recorded skeleton AND are not shorter than it. Intended: this is the fix itself — the affected class is "same conversation whose host rewrote part of its own persisted log or re-rendered it on another wire" (dsh goal turns, dsh provider switches). Unaffected: strangers/replays/blobs as above; non-tag-changed paths untouched.Documented boundary (pinned by a control row): renderer-divergent reasoning text (thinking blocks on one wire, absent on the other) still breaks the per-cell fragments, so such a switch forks until the identity-hash formula question is decided — that is an owner decision, deliberately NOT changed here.
Recovery for already-forked sessions
Self-healing: after upgrading, the first request of a stuck session passes the new rung (its full history still contains the recorded root body) and migrates back onto the raw lane with its existing folds. No data migration needed. Orphaned
|sub:lanes remain in storage (harmless; normal GC territory).Tests
tests/issue4778-dsh-goal-subfork.test.ts— unit state machine against the issue's exact topology (settle → goal rewrite → steady state) + e2e through the wired dsh openai lane. Verified pre-fix: exactly the two goal rows fail (derived-persona), controls pass.Related (not fixed here): #4686 / PR #4703 (UI read side following a fork — same
|sub:family, different symptom), #3149/#3150 (title sidecar ghost lanes), #2944/#3397 (resolver lineage this extends), #4720 (in-thread finding: nudge baseline stamped from an estimate — registered there), #3978 (preflight resumability — already tracked, data point registered there).Closes #4778