Repository navigation
[PR] fix: fork delayed completion — child session where the first request races ahead and lands is no longer permanently latched by CHILD_CONFLICT (#3025) | [PR] fix: fork 迟补全——首条请求抢跑落地的子会话不再被 CHILD_CONFLICT 永久闩死 (#3025) - #3039
Open
ranxianglei wants to merge 3 commits into
Open
ranxianglei wants to merge 3 commits into
ranxianglei wants to merge 3 commits into
Conversation
added 3 commits
October 13, 2026 19:40
…VAILABLE (#3011) Client (src/agent/fork-adopt.ts): classify degraded outcomes by structured verdict instead of a reason-string regex. The regex only matched 'error' / 'http 5xx', so the incident's 'snapshot http 409 SNAPSHOT_UNAVAILABLE' was treated as terminal after ONE attempt and the child's inheritance was permanently abandoned in-process. Each result now carries an explicit retryable flag: snapshot GET retries on network errors, HTTP >=500, and 409 code SNAPSHOT_UNAVAILABLE (a residency gap that self-heals on the parent's next request); 404 PARENT_NOT_FOUND and other 4xx stay terminal. Fork POST classification unchanged (network/5xx retryable). Give-up now logs an explicit 'permanently disabled' line distinct from the transient 'will retry' line. Server (src/plugin.ts): new forkSourceMessages() selects the raw source view. The retained copy (pluginSnapshot) stays primary; when it is missing (the residency gap: LRU eviction or host restart losing an unpersisted copy) the recent raw view session.lastMessages is served instead — it is persisted unconditionally and re-stamped by every parent request. A head-divergent tail wins over a frozen pre-compaction retained copy (zero-overlap guard case), so the served identities survive native compaction rebases. Folded tails never serve. The retention-cap refusal (#2433) stays first. Fork materialization uses the same selection, so a zero-branchpoint child keeps its legitimate empty snapshot. Server (src/session.ts): resetSessionCompression clears the stale publicSnapshot* metadata so a rebased parent cannot fail the list-level stored-refs check against the old view.
…s gate) Review fix for #3011/#3024: forkSourceMessages is only referenced inside src/plugin.ts (forkSnapshot + handlePluginFork); no test or module imports it, so the leading export tripped scripts/check-unused-exports.mjs (INTERNAL_ONLY). Drop the keyword per the gate's own remediation — no behavior change.
) A child whose first stamped request landed before adoption gets registered server-side during that request (recordPluginSession runs before forwarding), after which every fork POST met 409 CHILD_CONFLICT forever — permanent loss of inheritance (zero-fold start). Server-side late completion: when POST /__bili/plugin/fork finds an existing child without a receipt, strict eligibility under both locks (no receipt, no materialization, zero self-blocks, full-length identity-hash equality with the requested prefix, per-ref numbering consistency) now completes the inheritance IN PLACE on the live session instead of hard-conflicting: - shared completeForkTarget() for fresh and late paths; late children keep their own rules/nudge/stats/metadata (they already ran a real request); - parent -> child lock order is the only two-lock path (no deadlock); - late path flushes eagerly (publishForkSession's fresh-session guard rejects resident sessions) so receipt + inheritance land in one write; - ineligible children (own turns, self-fold, ref drift) still 409 as before. Behavior change: a strict subset of former 409 CHILD_CONFLICT outcomes now returns 201 with additive field lateAdopted: true (race-lost victims only); all other 409s unchanged (same codes/text). PLUGIN.md §8 updated. Tests: 5 new regression tests driving the real race shape (verified red on pre-fix code): repro+idempotency+live-inheritance, own-turns/self-fold/ref- drift negatives, child-lock concurrency.
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3434-pr.3039.11c7144This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3039.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Owner
Author
(ai: vllm-qwen/qwen3.8-27b) PR #3039 审查完毕。结论先行:代码成立,CI 本 head 全绿(34/34),可合;建议先合 #3024。按八问体例如下。 审查过程与证据
八问
收工判定可合——§7.4 人审域(向活会话 seed refs/blocks + 响应形状扩展),不走 auto-merge,等你合并。建议顺序:先合 #3024 再合本 PR(本分支基于 #3024 的 tip 构建,先合 #3024 后本 PR rebase 自动收敛为单个新提交;直接合也可以,只是 #3024 的内容会随本 PR 一起进 master)。 |
This was referenced Oct 20, 2026
Open
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3025
是什么
服务端迟补全(owner 已拍板的方向一):子会话的首条 stamped 请求若在 adoption 之前落地,该请求处理中 recordPluginSession 就把 child 注册进 conversations 表——此后任何 fork POST 都撞
409 CHILD_CONFLICT,继承永久丢失(零折叠起步)。本 PR 让服务端在「child 存在但从未分叉且仍是纯前缀」时把继承就地补全到已存在的会话上,而不是硬冲突。基于 #3024 分支当前 tip 构建(
480c62cf2+9d44414ac);#3024 合并后 rebase 即自动收敛。复用 #3024 的forkSourceMessages()源视图选择。机制
replay()对「child 存在但无匹配 receipt」不再就地结算 409,改为下放到锁内裁决;锁前用廉价lateCandidate()探测(可解析 + 无 receipt + 从未物化 + 零自折叠 block)放行注册门。资格在窗口内只会退化不会改善,锁前探测是 sound 的;权威判定在两把锁内重跑。byRaw[rawId] === ref ?? BLOCKED_REF——编号分歧 = 拒绝而非写坏,防 kernel 版本编号漂移)。completeForkTarget(..., late=true)把 blocks/refs/计数器/raw baseline/content store/receipt 就地物化到活会话;不合格 → 与现状完全相同的409 CHILD_CONFLICT。!late分支)与原代码字节级一致。flushSync(child)替代publishForkSession(其 fresh-session 守卫会拒绝已在池中的会话),receipt 与继承一次写入落地([plugin] fork snapshot maintenance is O(full history) every request + snapshot persisted into every session file #2077 连续性:崩溃窗口不留「有 block 无 receipt」的再闩死残态)。行为变更披露(owner policy 2026-09-22)
409 CHILD_CONFLICT的一个严格子集现在返回201——仅限未分叉且字节级同前缀的竞态败北者(正是 [Bug] Fork adoption server-side completion window: After the child session's first degraded request is committed, POST fork is permanently latched by 409 CHILD_CONFLICT, preventing retroactive adoption | [Bug] fork adoption 服务端完成窗口:子会话首条降级请求落地后,POST fork… #3025 闩死受害者)。其余 409 全部不变(同 code、同 error text)。lateAdopted: true。客户端对 201/200 一律视为 adopted(fork-adopt.ts:457)——零客户端改动。PARENT_REVISION_CONFLICT/BRANCH_POINT_CONFLICT——同为 409、客户端同样终态处理。为什么不是另两个方向(issue §建议方向)
测试
tests/plugin-fork.test.ts 新增 5 个回归测试,驱动真实竞态形态(child 先把继承历史作为真实模型请求发出去,fork POST 随后到达):
201 lateAdopted,继承父折叠(下一条请求转发 summary 而非原文)、幂等重放200 replayed、child snapshot 服务前缀;已验证 pre-fix 代码上 red(repro + 并发两个正例失败于 409/503)、post-fix green;plugin-fork / dsh-fork-adopt / pi-omp-fork-adopt 三套件 103 全绿。全量回归以远程 CI 本 head 为准。
§7.4 说明:向活会话 seed message refs/blocks 且新增响应字段 → 人审域,不走 auto-merge。