Skip to content

feat(cloud): bound the imported-replay prefix blind spot with a re-anchor cadence - #700

Merged
Neonforge98 merged 1 commit into
developfrom
feat/imported-replay-bounded-reanchor
Aug 6, 2026
Merged

feat(cloud): bound the imported-replay prefix blind spot with a re-anchor cadence#700
Neonforge98 merged 1 commit into
developfrom
feat/imported-replay-bounded-reanchor

Conversation

@Neonforge98

Copy link
Copy Markdown
Collaborator

Problem

#692's bounded incremental path validates ordered turn ids, a Merkle frontier, and the reread overlap — but a historical rewrite that preserves every provider-native turn id outside the overlap is undetectable from the compact checkpoint, and the PR documented that blind spot as lasting "until another invariant fails or a future full re-anchor occurs". Nothing scheduled that re-anchor, so the window was unbounded.

Solution

ImportedReplayCheckpoint gains an optional incrementalPassCount (absent reads as 0, so persisted checkpoints stay compatible in both directions). Each bounded pass increments it; at IMPORTED_INCREMENTAL_REANCHOR_EVERY = 64 the preparer declines the checkpoint and the pass takes the existing full authoritative read:

  • an intact prefix validates against the cursor's chain commitment, rides the ordinary delta append, and stamps a fresh count-0 checkpoint — no upload cost for the healthy case;
  • a mutated prefix now fails the chain comparison at a bounded horizon (~64 appended turns) and pays the designed epoch rewrite.

The forced reread amortizes the O(total) read to under 2% of passes; it reuses the untouched full-read path rather than adding a new one.

Verification

  • New engine test: the counter advances across bounded passes, an exhausted budget forces exactly one full read that still APPENDS (never rewrites an intact history), and the fresh checkpoint restarts at zero.
  • Existing incremental/migration/shrink suites green (63 tests across the three files); pnpm typecheck clean.

The bounded incremental path cannot detect a historical rewrite that
preserves every provider turn id outside its reread overlap; until now
that blind spot lasted until some other invariant happened to fail. The
checkpoint gains an incrementalPassCount (optional; absent reads as 0),
and after 64 consecutive bounded passes the preparer declines the
checkpoint so the pass takes the full authoritative read: an intact
prefix validates against the chain commitment and rides the ordinary
delta append with a fresh count-0 checkpoint, while genuine prefix
mutation is caught at the bounded horizon and pays the designed epoch
rewrite. The forced reread amortizes O(total) I/O to under 2% of passes
and uploads nothing by itself.

Pre-commit hook ran. Total eslint: 18, total circular: 0
@Neonforge98
Neonforge98 merged commit fe85123 into develop Aug 6, 2026
3 checks passed
@Neonforge98
Neonforge98 deleted the feat/imported-replay-bounded-reanchor branch August 6, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant