Skip to content

fix: reap zombie fold blocks after unannounced host history deletion (#2695) + host-compaction cache proofs - #2707

Merged
ranxianglei merged 3 commits into
masterfrom
2026-10-10_cache-proof-compaction
Oct 11, 2026
Merged

ranxianglei merged 3 commits into
masterfrom
2026-10-10_cache-proof-compaction

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Fixes #2695. Refs #2596, #2658.

kernel-change: stop new cluster extensions from resurrecting dead fold blocks (#2695) — owner-approved in the working session (2026-10-11); host-only mitigations cannot observe pre-remint cluster aliasing, so the identity fix belongs in remintCoveredLiveIds. Kernel 0.0.114 → 0.0.115.

Problem

An unframed host-side history deletion (client decimates its own resent history — "native compaction" without the framing contract) orphans proxy-mode fold blocks. Two failure layers:

  1. Flap (kernel layer): a new duplicate instance landing on a dead block's covered number resurrects the block in syncBlocks ("some covered id present"), rendering a carrier for content the instance was never part of; the next pass the collision mints elsewhere and the block dies again — an every-other-turn carrier flap that keeps invalidating the prefix cache forever.
  2. Zombie persistence (host layer): nothing ever retires the orphaned blocks — destroy-escalation only logs, detectUnannouncedHistoryRewrite's two gates are both bypassed by this rewrite shape, and claims stays empty.

Fix

Kernel (kernel/src/instance-reid.ts) — remintCoveredLiveIds now also dodges INACTIVE blocks' covered ids, gated by cluster-root continuity: renumber only when some sibling of the same root was live last pass (the arriving instance is a new extension of a continuing cluster). Sound because a block inactive at pipeline start cannot have any of its own covered ids in lastPassIds (sync would have kept it alive). A whole-root arrival new to lastPassIds — a client rewinding to a checkpoint that still holds the folded originals — keeps the converter's ids so the block legitimately resurrects (#462 economy restored). All existing #1476/#462 semantics preserved (kernel suite 1266/1266).

Host (src/fold-reconcile.ts + src/session.ts) — per-block zombie streak in the existing fold-coverage ledger (foldCoverageByBlock[bid].z): majority-absent (2*(p+r) < t, same signals already computed) increments, any majority-present pass resets. At z >= FOLD_DRIFT_ESCALATE_PASSES (3), proxy mode only (pluginAgent === undefined; plugin folds legitimately replace covered history), the block is reaped: removed from state.blocks (sticky — deactivation is reverted by syncBlocks' unconditional active=true), recorded in preCompactionArchive (#395 semantics — derived decompression stays available), refs pruned, anchors/order/positions/coverage stripped, orphan-reap conflict event recorded.

Proofs carried

Config surface

No config changes — no new knobs; the streak reuses FOLD_DRIFT_ESCALATE_PASSES and the existing coverage ledger.

…2695)

Host-side deletion of history without a compaction frame (Claude Code
context editing, dsh native checkpoints on lanes without the rebase fix)
orphans fold blocks. syncBlocks keeps them alive forever via arrival-
order cluster ids re-derived by identical later messages, and the remint
feedback loop flaps one carrier in and out every turn - permanent
mid-list churn, i.e. prefix-cache misses on every request (#2596).

Host-only fix (no kernel changes): foldCoverageByBlock records a zombie
streak (z) - consecutive passes with a majority of a block's covered ids
absent from the inbound. After FOLD_DRIFT_ESCALATE_PASSES such passes in
proxy mode, reapDestroyedSubstrate removes the block from state.blocks
(removal is sticky; active=false would be resurrected by syncBlocks),
archives it via the #395 preCompactionArchive path (blockContents stay
for derived decompress), prunes refs, strips anchors/order/coverage, and
records an orphan-reap conflict event. Plugin mode is exempt (covered
ids are legitimately absent after the agent's own compress).

Proofs added (user request: cache proofs covering host compaction):
- cache-proof HOSTCOMPACT (chat wire): decimated replay drops orphan
  carriers, re-arms cleanly; zombie flap bounded (regression pin - red
  on master: zombie rides every later fold round-2, green with reap).
- cache-friendly-plugin P6 (dsh native-compaction rebase, 4 wires):
  checkpointed replay rebases blocks cleanly, era-stable tags, prefix
  append-stable after the rebase turn; red on pre-#2664 masters for
  anthropic/google.

Refs #2596 #2658. Kernel root-fix proposal (remint coveredBases should
scan inactive blocks; instance identity for duplicate clusters) filed in
#2695.
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-10_cache-proof-compaction (3956f57)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2928-pr.2707.1ad6eef

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr2707.tgz
npm install -g package

Install instructions are refreshed on each push.

#2695)

remintCoveredLiveIds now also dodges INACTIVE blocks' covered ids when the
same cluster root shows prior-pass continuity — the exact shape a new
duplicate instance lands on a dead block's number and resurrects it in
sync, rendering a carrier for content the instance was never part of (the
every-other-turn carrier flap). A whole-root arrival that is new to
lastPassIds (client rewind to a checkpoint still holding the folded
originals) keeps the converter's ids so the block legitimately resurrects.

kernel: 0.0.114 -> 0.0.115
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.241-master.6819ece (rolling master tag).

npm install -g billion-context@0.0.241-master.6819ece  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant