quilt kernel P3: replay-verify reconciliation — the drift detector - #3
Closed
SuperInstance wants to merge 1 commit into
Closed
SuperInstance wants to merge 1 commit into
SuperInstance wants to merge 1 commit into
Conversation
The dual-write is two sequential batches: D1 commits, then the WAL
commits. The window between them is where drift can live. This module
closes the loop: replay the ledger, diff against live rows, report
every divergence field-by-field.
- reconcileQuiltWal(database, rows, readers): refuses to reconcile a
tampered chain (chain_broken + firstBadSeq), then diffs replayed
nomination state (status/totals/votes/completedAt) and encounter
state (actor/target/species/publication/message/response) against
live D1. A mismatch IS the deliverable; reconciliation never mutates.
- entity discovery reads the bare-cell bind's kind field, never regexes
on ids — production interaction ids are numeric snowflakes, so cell
shape alone can't distinguish attempts from entities.
- verifyChain now returns {ok} | {ok:false, firstBadSeq} so tampering
points at its own break; all call sites updated.
- negative-ledger awareness: refusal rows are memories, not entities —
reconciliation never expects encounter rows for them.
tests/quiltKernelReconcile.test.ts: 4 tests — clean traffic zero
mismatches, D1-side drift flagged with wal/d1 values, tampered chain
refused with break location, vote drift between ledger and tally.
Full suite: 387 tests, 18/18 across the three kernel suites, only the
4 pre-existing artwork/env failures (identical on clean main).
Refs openclaw#48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Stacks on #2 ← #1. The dual-write is two sequential batches (D1 commits, then the WAL commits). The window between them is where drift can live. This module is the detector that closes the loop.
reconcileQuiltWal(database, walRows, readers):{ ok: false, reason: chain_broken, firstBadSeq }and refuses to reconcile.kindfield (never regexes on ids — production interaction ids are numeric snowflakes).A mismatch IS the deliverable — reconciliation never mutates, never throws on drift. And the negative ledger stays honest: refusal rows are memories, not entities; reconciliation never expects encounter rows for encounters that never were.
Also
verifyChainnow returns{ ok } | { ok: false, firstBadSeq }— tampering points at its own break. All call sites updated.Verification
tsc --noEmitcleanRefs openclaw#48