Repository navigation
[PR] fix(#5122): degrade fork adoption when zero fold state inherited - #5126
ranxianglei wants to merge 13 commits into
Conversation
A DSH GUI clone returns 201 with inheritedBlocks=[] when the client's matchForkPrefix collapses to a tiny branch point (compressed + reasoning sessions), yet the client only reads `replayed` and claims "adopted" — setting publicForkReceipt and skipping the #1486 resume-inheritance recovery. The child then replays the whole parent raw (~1.4M tok) and preflight runs for minutes before the client gives up. Server: log the degenerate case (was silent) and expose `parentBlocks` in the fork response (additive field; old clients ignore it). Client: when parentBlocks>0 && inheritedBlocks===0 && the child carries more history than the verified prefix (branchPoint < core.length), return "degraded" instead of "adopted" so publicForkReceipt stays unset and the #1486 resume-inheritance recovery path can run on the next turn. Stop-the-bleed / detectability only. The root cause — fork rebuilds the child from the client-chosen branch-point prefix, so a collapsed branch point inherits nothing — is tracked in #5123 and needs the verbatim row-clone redesign (human review: load-bearing identity/contentStore).
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.9225-pr.5126.00bf797This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5126.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 查重: 不重复。 本票是根因票 #5123(平台号;GitHub #5122)的 Phase 1 修复 PR;检索 open issues/PRs 无其他在途项触碰 fork adoption 路径。 已审 PR #5126(head 核心结论:「诚实化」一半成立,「解锁恢复」一半不成立——PR 描述过度承诺。 查证事实链:
原票「期望修法」第 1 条(「不匹配 → degraded,让 resume-inheritance 兜底能跑」)存在同一因果误读——把客户端判定与服务端 receipt 混为一谈了。 回归审查(diff 触碰的既有行为):
测试有效性: 4 个 client gate 测试(degrade / adopt-with-blocks / adopt-parent-empty / legacy-no-field)+ 1 个 server field 测试,双向断言齐备、断言有牙;但没有测试钉住「恢复路径」——因为它并没有被打开,与上述发现一致。 八问:
处置建议(需拍板):
收工判定:代码质量可合(无回归、CI 绿、diff 干净),但描述承诺与实际行为不符,建议先定 A/B 再合。合并由你执行。 |
Phase 1 keyed the client's degrade decision off the additive parentBlocks count plus a local branchPoint<core.length check. That re-derives server state on the client and silently no-ops when a mixed-version peer lacks the new field. Per review, move the judgment to the server: it computes degraded = (inherited 0 blocks while the parent held some) from its own ledger and sends an additive boolean; the client honors it directly and no longer second-guesses with a truncation gate. Old clients ignore the flag. Adds a test pinning that the client degrades on the flag even for a full local match (no residual truncation gate), and pins degraded:false for a healthy never-compressed parent clone.
…e + honest blockStatus Fork adoption builds the child from the client-declared branch-point prefix and matchForkPrefix caps that prefix at the first identity mismatch. On compressed sessions re-projected by hosts (reasoning dropped to text, tool-call args re-stringified) every such cell broke the hash, so branchPoint collapsed to ~4-5 and the full-containment block filter inherited ZERO parent blocks — voiding all prior compaction (the #5122 1.4M-tok replay). - forkIdentityHashOf/forkMessageIdentityHash (client+server, kept byte-identical): drop contentType (a reasoning cell and a text cell with the same text are the same history cell) and JSON-canonicalize tool-call text (re-stringified args differ only in whitespace). role/text/toolName/toolCallId/thinkingTokens/ summaryOfBlockId/toolIsError remain hard gates. sameSnapshotView stays byte-exact on purpose so CoW never retains a stale snapshot. - fork response: add tri-state blockStatus (inherited/none-inherited/ nothing-to-inherit) alongside status + degraded, resolving the "status:exact + inheritedBlocks:[]" contradiction for receipt readers. - scripts/align-check.mjs: read-only index.db oracle measuring strictPrefix / ordered-align depth per identity mode + which parent blocks are fully inheritable (owner-provided acceptance harness for this fix). Behavior change (intended): fork prefix verification is now tolerant of serialization/projection noise, so affected forks match deeper and inherit more blocks via the existing filter. Content-level divergences still truncate the match (hard gates unchanged). Stabilizes the common case; the residual deep-block case (prefix capped low by genuine reorderings) needs the verbatim clone (Option A), tracked in this PR.
(ai: vllm-qwen/qwen3.8-27b) CI 红已修复并推送:merge ci-fixes 进 PR 分支,新 head 结构化八问
注:作者车道自己的提交 判定:继承红已按收敛流程(ci-fixes)修复并推送,待矩阵重跑终态确认。 |
(ai: vllm-qwen/qwen3.8-27b) ✅ 重跑终态:新 head |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-synced to latest master ( |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Status confirmed (continuing the churn-sync loop): branch synced to master |
Resolve the fork-identity hash field-set conflict as the union of #5123 serialization-tolerance (drop contentType, JSON-canonicalize tool-call text) and #4266 signed-content carriers (drop thinkingTokens value; add thinkingSignature/googleThoughtSignature/redactedPayloadDigest). Pinned by tests/dsh-fork-adopt.test.ts parity + tests/issue4266-fork-thinking-gate.test.ts drift pins.
master moved past the previous sync (dc041dd) by the web handoff-render (#6260) + anthropic trailing-system (#5432/#5441) + snapshot-write-lifecycle (#6186) landings. None of those commits modify src/plugin.ts or src/agent/fork-adopt.ts (master's version of both == merge-base), so this merge is clean and preserves the #5123/#4266 union resolution untouched.
Conflict re-resolved and pushed (auto-fix lane). Master moved past the previous sync while this branch was open, so the PR went dirty again — this run re-synced it. Live state at start: master had advanced Key finding: none of those new master commits touch What I did:
(One transient hiccup: CI status (live): the mirror check snapshot still reflects the previous head 八问
判定:合并冲突阻塞已清除(分支现含 master,mergeable 将转 clean),待新 head |
Stale trigger — no action taken. Verified live this run: master is unchanged at The "dirty" in the trigger came from a pre-push snapshot. The live mirror state is CI on No re-sync or push performed (local == remote == contains master). Merge stays human-only. |
What
Phase 1 (stop-the-bleed) for #5122 — makes the false-success honest and opens the recovery path that was previously hard-skipped. It does not restore the parent's compression by itself, and it does not fix the root cause (tracked in #5122).
Symptom
DSH GUI clone ->
POST /__bili/plugin/forkreturns 201 withinheritedBlocks: [], but the client only readsreplayedand reportsoutcome:"adopted". That setspublicForkReceipt, which skips the #1486 resume-inheritance fallback entirely (skipReason="publicForkReceipt"). The child ends up with 0 collapsed blocks -> replays the whole parent raw (~1.4M tok) -> preflight runs ~300s -> client disconnects.Root cause (confirmed against code)
handlePluginFork(src/plugin.ts) builds the child from the client-declared branch-point prefix:prefix = snapshot.orderedMessages.slice(0, request.branchPoint.messageCount); blocks are filtered by full containment in that prefix's rawIds. When the client'smatchForkPrefixcollapses to a tiny branch point (compressed + reasoning sessions where reasoning->text rewrites and tool-call JSON re-serialization diverge the identity hash), the prefix holds only ~4 rawIds -> no parent block is fully contained -> 0 blocks by construction. The child's later rows come from the client's lossy replay, not a server-side clone.What this PR changes
Server (
src/plugin.ts): computesdegraded = (inherited 0 blocks while the parent held some)from its own ledger; logs it (was silent); adds an additivedegradedboolean (+parentBlockscount for diagnostics) to the fork response. Old clients ignore both.Client (
src/agent/fork-adopt.ts): honors the server'sdegradedflag directly (server-authoritative — no client-side recomputation, robust across mixed-version peers). On degrade it returns{outcome:"degraded"}, leavingpublicForkReceiptunset so the #1486 resume-inheritance path is not hard-skipped on the next turn.What this does NOT do (honest scope)
Degrading opens the resume-inheritance recovery path, but that path is itself best-effort against the client's re-projection: block adoption (
src/fork-adoption.ts:175) requires every cell of a block to be present in the client's resent content-hash set, and that set is built from the same lossy projection (reasoning dropped, tool-call JSON re-serialized) that collapsedmatchForkPrefix. So deep fold blocks are very likely NOT recovered by Phase 1 alone — it restores visibility + an honest status + a best-effort ref-seeding door, not guaranteed compression. Full recovery is the root-fix work below.Behavioral change (flagged)
A degenerate fork can now return
degraded(notadopted) when the server inherits zero blocks while the parent had some. Old behavior silently claimedadopted. Fires only in the pathological case; a healthy fork (blocks inherited, or a never-compressed parent) still returnsadopted. No effect on old clients (the gate keys off the additivedegradedflag they ignore).Root fix (NOT in this PR — pending decision in #5122)
The definitive fix makes the child's state independent of the client's lossy verified prefix (verbatim row-clone of the parent at fork time). Options A/B/C plus a decisive open question — does the DSH client send the inherited state verbatim on the next turn, or its own re-render (which decides whether a bili-only fix can hold, since
syncBlocksdeactivates blocks whose source messages are absent from the wire)? — are being decided in #5122. Stays ONE issue/PR per the coherence policy.Tests
tests/dsh-fork-adopt.test.ts: 5 client-side tests (degrade-on-flag / trust-flag-even-on-full-match / adopt-healthy / adopt-zero-block-parent / legacy-no-flag backward-compat) + 1 server-side test assertingdegraded:false+parentBlocksfor a never-compressed parent. Targeted file green (26/26); full suite = remote CI.Config surface
None. No new config fields / env vars / CLI flags.
Refs #5122