Repository navigation
Description
来源: ranxianglei/billion-context#1488 分析 acp-kernel 0.0.96 pin bump 时发现
Problem
v0.0.96's new reconcile-live-ids pipeline node (src/instance-reid.ts, inserted FIRST by buildNodes() in src/compress.ts) re-mints every LIVE message whose content-hash root appears in coveredMessageIds to root_1, root_2, ... in arrival order. Its discriminator — "any LIVE message carrying a covered id is a new instance, not the original" — conflates two distinct situations:
- A host replaying the very originals it was folded from. Every proxy-mode consumer executes compress server-side; the ephemeral tool call never enters client history; the next request resends the FULL history including the folded messages verbatim. Those resends ARE the originals, not new instances.
- A genuinely new duplicate message arriving later (the scenario the node was built for).
For case 1, pre-0.0.96 behavior was load-bearing: resent covered originals were pruned and replaced by the rendered summary block at the anchor. Post-0.0.96 they get _N ids, escape prune, survive into the outbound payload, and take FRESH refs (assignRefs first-wins: the bare id is still owned by the folded copy, so the live instance gets a brand-new number after each fold).
Repro (minimal, verified against both published tarballs)
40 alternating user/assistant messages → processTurn (no compress) → applyCompression([{m00001..m00015}]) (blocksCreated: 1) → client resends the full original history → second processTurn:
| 0.0.95 | 0.0.96 | |
|---|---|---|
| turn.messages after resend | 27 = acp_summary_b1 (system, at anchor) + 26 uncovered raws |
40 = all raws survive; covered 15 re-minted h_<root>_1; no summary in list |
| count_tokens-style projection (no tool call) | 40 → 26, in-place summary kept | 40 → 40, nothing pruned, no summary anywhere |
| same, with compress tool_use + tool_result appended | 42 → 27, tool pair survives as carrier | 42 → 40, tool pair gone |
Impact (measured on billion-context, pin-only diff)
- master CI fully green; pinned head red: 56/2919 unit failures (preflight-compress family, CCR v2, plugin lanes, count-tokens, protected-tools, grow-and-compress, folded-usage, ...) plus the real-codex e2e lane.
- Three distinct regressions for any host relying on "covered ⇒ replaced by rendered summary":
- Payload bloat — folded content returns to the wire every turn after a fold; compression is effectively undone.
- Summary-carrier loss in both modes — the in-place anchor disappears (proxy mode without tool call) AND the compress tool pair vanishes from prepared output (plugin mode); the model loses the compressed context entirely.
- Stale ref anchoring — ranges computed from state refs no longer match post-remint live ids → preflight fails with
start ref mNNNNN is absent from the current messages→ fail-fast 502 loop (observed end-to-end with the real codex CLI against a deterministic fake upstream).
Suggested fix
The discriminator must distinguish positional replay of the folded original from a genuinely new duplicate occurrence — e.g., only remint when the live occurrence does NOT correspond to the covered original being replayed (position/content-chain identity), or expose an opt-in/opt-out through Ports so hosts can declare their resend semantics. Whichever shape lands, the contract "a host that resends full history gets its covered originals replaced by the block rendering" must hold again, or be explicitly superseded with a documented migration path — sibling consumers that resend full history (billion-context-pi) likely hit the same wall (not independently verified).
Minimal repro script available on request.
Activity
ranxianglei commentedon Sep 27, 2026
[bot] 🏷 Verified — root cause confirmed, fix in PR #466.
Triage
Reproduced against origin/master head with the minimal repro from the issue (40 alternating messages → fold m00001..m00015 → full-history resend). Results match your 0.0.95-vs-0.0.96 table exactly: v0.0.96 behavior gives 40→40 with all 15 covered originals re-minted
h_<root>_1, noacp_summary_b1anywhere, and — beyond your table —b1.active=falseafter the resend (sync-blocks sees no covered base present once ids are re-minted, so the block deactivates too).Layer judgment: your analysis is the root cause, not a symptom. The
reconcile-live-idsdiscriminator ("any live message carrying a covered id is a new instance") conflates positional replay of the folded originals (#461) with genuinely new duplicates (#1476). The three measured regressions (payload bloat, summary-carrier loss in both modes, stale-ref 502 loop) are all downstream of that single conflation.Fix (PR #466)
Per-occurrence classification by positional fingerprint, no new config surface — so every full-history-resending host (billion-context, billion-context-pi) is fixed pin-only:
I chose auto-detection over a
Portsopt-in because the fingerprint is deterministic from data the kernel already has, and adding a per-host flag would leave exactly the kind of misconfiguration that caused this incident.Behavior change disclosure (old → new)
_Neach turn; escaped prune; summary lost carrier; block deactivatedroot_1..kWHY: restoring the pre-0.0.96 contract for the replay shape is the fix itself; #1476 protection is preserved and now tested for both shapes. No §7.3 contract touched (node ordering, wire format, ref immutability, state schema, zero-deps all unchanged).
Extra finding (same root cause, fixed in the same PR)
During analysis I hit a fourth regression your table didn't cover: if a block gets deactivated (a turn where the view carries neither raws nor summary), then the summary returns next turn, reconcile ran before sync's reactivation and saw the stored
active=false— its coverage vanished, so a genuinely new message carrying a covered id kept its bare id and was silently dropped by prune. Fixed by judging coverage with sync's own activation predicate (isBlockStillPresent, extracted fromsrc/sync.ts, recomputed against the current input). Same root cause as #461, so it ships in the same PR rather than a separate issue.Verification
tests/issue461-replay.test.ts: 7 unit + 4 end-to-end pipeline tests covering all shapes (full resend 40→27 with summary at anchor and stable refs; resend+dup; pruned-view+dup on post-resend state; tool-pair survival).tests/issue1476-reid.test.tsupdated to two-shape fixtures (its old "renumbers every live instance" expectation had encoded the buggy group-wide discriminator).中文摘要:修复了 reconcile-live-ids 把「宿主重发折叠原文」误判为「新重复实例」的问题(用位置指纹区分两种情形,重发的原文保留原 id 被 prune 替换为摘要,真正的新实例仍重铸),顺带关闭了同一根因导致的已停用块复活时新消息被静默丢弃的洞,PR #466 可以审查。
test(reid): pin single-base replay keeps original ids (#461)
fix: reconcile-live-ids keeps positional replays of folded originals (#…
test(reid): pin single-base replay keeps original ids (#461)
refactor(state): drop lastPassIds — superseded by stateless replay fi…