Repository navigation
fix(fork-adoption): adopt CCR content-store entries for covered/cited refs (#1341) - #1361
Conversation
… refs (#1341) Fork adoption cloned blocks/blockContents/messageRefs but not the kernel content store, so every ref the fork advertised as retrievable (adopted block covered refs, placeholder-cited refs) was an acp_retrieve miss - or, until the kernel placeholder-as-original fix lands, a fake hit after the child's first fold. Adopt a ref-filtered independent clone of the parent store seeded by the union of (a) adopted blocks' effectiveMessageIds refs and (b) refs cited by placeholder-shaped incoming messages. cloneStoreForRefs returns null when nothing matches (no artifact/dirty flag for CCR-less forks); the slice goes through adoptContentStore so the child persists its own companion. Tests: tests/fork-ccr-adoption.test.ts (5) covering the issue's acceptance criteria incl. fold-then-fork true-original retrieve and restart survival.
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-1361Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr1361.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review complete — verdict: mergeable. CI 10/10 green; local typecheck + targeted suites pass on head ① Direction (vs #1341): implements exactly the issue's proposed fix at the root cause — the adoption path ( ② Regression review — existing behaviors on touched paths, each checked:
③ Code: ④ Tests: all five have teeth — removing the adopt call fails tests 2–4; shared mutable state fails 1–2; restart survival (exactly one ⑤ Diff: 3 files, +425/−16, every line on-purpose (doc updates consistent with the change). Clean. Evidence: CI 10/10 success (test ubuntu-22/24, windows-22/24, build-artifact, version-guard, hermetic registry e2e, codex/pi zero-token e2e, CODEX_HOME overlay). Local on head: typecheck clean; Residual (kernel-side, correctly scoped out): the fold-path poison guard keys on the placeholder message's own ref, so folding a view containing placeholders can still record placeholder text under that child-local ref — complementary to the pending kernel fix; AC2 "no worse than today" holds. 可以合并:fork 采纳时按引用过滤克隆父级 CCR 内容存储(覆盖 ∪ 被引用),修复分叉子会话对 covered/cited refs 的 retrieve 全 miss(及内核修复前的假命中)问题;既有行为已逐项清点、无意外回归,行为变更已在 PR 中披露,CI 10/10 与本地定向验证全绿。 |
|
Deep review: ✅ merge. Verified on the triple-stacked tree (#1367+#1361+#1360, all merges clean; typecheck + full suite green on the stack; this PR's 6 tests pass in isolation AND on the stack). Design holds up. The union seed — covered refs of adopted blocks ∪ refs cited by placeholder-shaped incoming messages — is exactly the retrievability surface the fork advertises: block summaries cite covered refs, and a placeholder's citation is the only link back to an original that left the view (arrival-time storing skips placeholder text by design, so nothing else can restore it). Points I probed specifically:
Non-blocking observation: |
[bot] 🏷 Thanks for the independent deep-review pass — the triple-stack verification (#1367+#1361+#1360, clean merges, typecheck + full suite green on the stack) is exactly the extra evidence my single-branch local run couldn't provide, since it covers the hot-file interplay between these three PRs. We also converged independently on the same non-blocking observation ( Nothing further from my side — the PR is ready for you to merge whenever you like: #1361 中文:双方独立复核结论一致(可合并),且你在 #1367+#1361+#1360 三方堆叠树上验证全绿,PR 已就绪,等待你合并。 |
What / why
Fork adoption (
src/fork-adoption.ts) cloned blocks,blockContents, andmessageRefsfrom the parent — but not the kernel CCR content store. The forked session advertised refs as retrievable (adopted block summaries cite their covered refs; v2 covered-span display + placeholder citations in the incoming view) while everyacp_retrieveon them missed. Until the kernel's placeholder-as-original fix lands, the child's first fold additionally stored placeholder text as "originals", converting those honest misses into invisible fake hits (storeCoveredOriginalsis wired into the shared fold path atsrc/stream.ts:262on current master).This PR adopts a ref-filtered independent clone of the parent's store, seeded by the union of:
effectiveMessageIds(looked up directly instore.byRef) — catches arrival-time-stored entries whose messages were already folded pre-fork;New
cloneStoreForRefs()(src/store.ts): copies exactly the namedbyRefentries plus theirbyHashpayloads (dedup inherent — content-addressed), shallow-copied entry objects (no shared mutable state with the parent), returnsnullwhen nothing matches so CCR-less/empty forks create no artifact and no dirty flag. The slice flows through the existingadoptContentStore, which setscontentStoreDirty→ the child persists its own companion envelope.Behavior change (flagged)
acp_retrieveon adopted covered/cited refs = miss (post-first-fold: fake hit returning placeholder text, pending kernel fix).[fork-adoption] … adopted N CCR content-store entr(y/ies) …. No wire-shape, config-schema, or persistence-format change. Parent store read-only (append-only / first-write-wins preserved). acp-kernel pin untouched (0.0.93).Residual (kernel-side, out of scope here): the fold-path poison guard keys on the placeholder message's own ref, so folding a view containing placeholders can still record placeholder text under that message's own child-local ref; the kernel fix remains complementary for non-fork store-loss scenarios.
Tests
New
tests/fork-ccr-adoption.test.ts(5 tests), mirroring the real request pipeline (processTurn+applyRanges):cloneStoreForRefsunit: filter, hash-dedup, mutation independence, null-on-empty;acp_retrieveon the covered ref hits with the exact true original; edited-tail ref deliberately NOT carried;.content-store.jsoncompanion → evict → reload → retrieve hits again;Pre-flight
Closes #1341