Repository navigation
fix(fork): close the derived-blocks gate only on real block adoption (#3351) - #3374
Conversation
…3351) maybeAdoptDerivedFork set metadata.derivedBlocksAdopted = true unconditionally right after maybeAdoptResume, even when the registered parent had zero folded blocks at first contact. Because the request-time link lands exactly once (handle.ts gates it on derivedFromSessionId === undefined), that prematurely- persisted marker made every later boot sweep skip the session — so a multi-hop grandchild whose intermediate parent was still young (no folds yet) permanently lost block inheritance and kept replaying its full raw history (#2807 symptom recurrence in a P->C->G topology). maybeAdoptResume now returns { adoptedActive, seededRefs } and the gate closes only when adoptedActive > 0 — the same discipline reconcileDerivedLineage already applies (it sets the marker solely on a successful adoption). Ref-only seeding against a young, block-less parent leaves the door open so a later boot can adopt the blocks the parent folds afterwards. Regression tests pin both directions: the gate stays OPEN when the registered parent has no blocks at first contact (fails under the old unconditional set), and CLOSES when the parent carries fully-present blocks.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3975-pr.3374.eb76cbcThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3374.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。按本机制(弱链接 方向判定(独立重核,非照抄 issue):原 issue #3351 方向正确,根因定位准确。我对 master 逐条复核了机制链:
回归审查(既有行为逐项):
代码与测试有效性:
CI:head b7c090d 远程 CI 全绿(static-gates、ubuntu/windows × node 22/24 共 6 个 test shard、kernel-guard、config-surface-guard、docs-sync、version-guard、pi-subagents-guard、build-artifact 等全部 success;real-client e2e lane 按环境门控 skipped,属正常)。 结构化八问
行为变更披露(旧→新):旧 = 弱链接子会话首触即无条件关 收工判定:可合入。一个决策点提请 owner:原 issue #3351 标注「需 owner 拍板——属行为变更」,本修复为放宽且已完整披露,合并即视为批准该关条件;若坚持 issue 字面公式一行即可回退,但该公式修不好本 bug,不建议。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.510-master.269accd # this exact build
npm install -g billion-context@master # always the newest merged build
|
What & why
A weak-link (plugin-register) fork child permanently lost block inheritance when its registered parent had no folded blocks at first contact. In a multi-hop fork
P→C→G, if grandchildG's first request missed the byte-exact prefix match (weak path) while intermediate parentCwas still young (zero folds),maybeAdoptDerivedForkclosedmetadata.derivedBlocksAdopted = trueunconditionally right aftermaybeAdoptResume. Because the request-time link lands exactly once (handle.tsgates that block onderivedFromSessionId === undefined), the prematurely-persisted marker made every later boot sweep (reconcileDerivedLineage) skipG— soGcould never adopt the blocksCfolded afterwards, and kept replaying its full raw history each turn (the #2807 "~480K session rejected as ~1.4M" symptom, recurring in a multi-hop topology).Fix
maybeAdoptResumenow returns{ adoptedActive, seededRefs }, andmaybeAdoptDerivedForkcloses the gate only whenadoptedActive > 0— the same disciplinereconcileDerivedLineagealready applies (it sets the marker solely on a successful adoption). Ref-only seeding against a young, block-less parent leaves the door open so a later boot can adopt the blocks the parent folds afterwards.Note: the issue's suggested close-condition was
adoptedActive > 0 || seededRefs > 0. That would not fix the reported case — at first contact a young parent already has refs (soseededRefs > 0) but no blocks, so the gate would still close. Closing must track block adoption specifically (the flag is namedderivedBlocksAdopted); mirroring the sweep's exact condition is what actually restores eligibility. This also matches the issue's stated principle ("share the same gating discipline as the boot sweep") more faithfully than the literal formula.Behavior change (old → new)
derivedBlocksAdoptedwas set unconditionally at first contact, whether or not any block was adopted.kernel/change.derivedFromSessionId === undefined), so the only added work is a cheap boot-sweep re-scan for children whose parent remains empty.Tests
tests/derived-fork-block-inheritance.test.ts:derived-fork-block-inheritance4/4; related suitesfork-adoption-plan,fork-ccr-adoption,pi-omp-fork-adopt,lineage-reconcile-boot(AC9–AC12) all green (35/35). Full-suite verdict is the remote CI on this head.Fixes #3351