Commit Graph
1365 Commits
Author SHA1 Message Date
pingqiu f3e4c22ddb feat(storage): use owned maps instead of C11 bitmap in impl3 capture 2026-11-17 08:12:13 -08:00
pingqiu e6c45d5906 docs(storage): bind owned-map eviction to capture coverage 2026-11-17 08:05:51 -08:00
pingqiu 037db1e6cd fix(storage): gate eviction on owned-map capture dirt 2026-11-17 08:04:41 -08:00
pingqiu 673fdf3015 docs(storage): record dark capture map token coverage 2026-11-17 08:02:06 -08:00
pingqiu f7953bd792 fix(storage): retain covered map knowledge across captured reopen 2026-11-17 08:00:33 -08:00
pingqiu 3c6e025da8 feat(storage): select and settle captured chunks through owned maps 2026-11-17 07:57:01 -08:00
pingqiu f4ed786d84 test(storage): refuse queued Sync after map persistence fault 2026-11-17 07:43:40 -08:00
pingqiu d9b5034a07 test(storage): cover checkpoint barriers and recovery map cache 2026-11-17 07:42:07 -08:00
pingqiu c2f8a5aee1 test(storage): exercise held and uncertain real map checkpoints 2026-11-17 07:40:16 -08:00
pingqiu 623ffedb69 feat(storage): publish owned map proofs through real checkpoints 2026-11-17 07:38:41 -08:00
pingqiuandClaude Opus 5.5 0193516bc0 storage: bump the v3 recovery generation at the end of a recovery too (codex01 P2)
Recover bumped recoverGen before dm.clear only. A read already admitted
could capture the new generation with the old dirty entry in that
interval, see the fenced bytes, then find the same LBA/position/LSN
rewritten after the recovery: tuple and generation matched, a false WAL
integrity failure. Recover and reset now also bump it at their end (on
every path), the start+end pattern of the map proof epoch, so any overlap
changes the generation a reader compares before and after its attempt.
The outer Sync completion's equality check is unchanged in meaning.

Control (held, actual Read/Recover/Write): a read admitted before its
generation capture, released after the start bump and before the clear,
resolves the old entry, sees the fenced bytes after the recovery and the
same-tuple rewrite, and returns the new write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 07:03:39 -08:00
pingqiuandClaude Opus 5.5 54de8ab8ac storage: v3 read damage verdict bound to one recovery lifetime; read I/O is substrate I/O (codex01 P2s)
(1) A same-open Recover can fence a dropped record and re-allocate its
LSN to the same LBA at the same position: a read parked across it saw the
fenced bytes and, finding the entry unchanged, reported false WAL damage.
The unchanged-entry verdict now also requires the same recovery
generation (a reset bumps it too) across the attempt; otherwise the read
retries and returns the new write.

(2) A failed or short pread (including io.EOF: the WAL region lies inside
the file) is a substrate I/O failure, never WAL integrity. Only a record
that was read and fails validation within one stable lifetime is damage.

The comment no longer implies a nonce check: LSN allocation runs on across
a reset, and LBA+LSN+CRC identify the resolved write.

Controls: a parked read across a reusing same-open recovery returns the
new write; a truncated file and a failing fd give substrate I/O.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 06:19:50 -08:00
pingqiuandClaude Opus 5.5 63d1f4a4ae storage: v3 reads validate the whole record they read (codex01 row 8 P1)
A Read that resolved an LBA's WAL position held no lock across its pread.
Parked there, the real flusher could checkpoint and release the entry, a
reset restart the cursor at 0 and Write(2, B) reuse the position; the
resumed read checked only the header type/length and returned B for LBA 1.
The same held after OnReadMiss.

readDirtyV3 now validates the whole record after the payload read (CRC,
footer, write type, LBA and LSN against the resolving dirty entry) and
re-resolves on a mismatch: the entry gone means the extent holds the
block; the entry unchanged means WAL damage (a WAL integrity failure).
No lock is added; the lock graph is unchanged.

Controls: the parked direct Read and the parked post-OnReadMiss recheck
across flush, reset and overwrite return LBA 1's own block; a damaged live
record is a WAL integrity failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 06:08:43 -08:00
pingqiuandClaude Opus 5.5 57e8c9e580 storage: a v3 Close never writes the legacy superblock (codex01 P1)
WALStore.Close serialized the legacy superblock and pwrote it at offset
0, which on a v3 file is descriptor slot A: strict create A1, Recover B2,
Write+Sync A3/W1, Close destroyed A, reopen selected B2/W0. A v3 Close now
writes nothing (acknowledged state is already in the slots and the WAL).
Both legacy offset-0 writers (writeSuperblockMetadata and
syncDirectFrontierMetadata, behind the checkpoint, v2 recovery,
SeedChunkFrontier and the direct-frontier Sync) refuse on a v3 store with
errV3LegacySuperblockWrite.

Controls: Close -> reopen in strict and lagged mode with the newest
publication in slot A; the two legacy writers refuse and leave slot A
untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 06:04:14 -08:00
pingqiuandClaude Opus 5.5 9ba7f7f54b storage: v3 nonce/position reset, dark (format v3 plan row 8)
Publisher: the reset publication mode of the single publisher (a new
nonzero nonce, an empty cursor space, ordinary rules otherwise), ported
onto the row 7 publication core; step 2 into one slot, step 3 into the
other, a step-3 failure latches.

Store: WALStore.resetIncarnationV3 quiesces (captureMu exclusive ->
lifecycleMu -> syncMu -> s.mu), refuses with ErrResetNotPreserved and no
write unless the dirty map is empty and CheckpointLSN >= appended ==
acknowledged W, publishes both slots under a fresh random nonce at cursor
0, recreates the WAL writer, bumps the recovery generation and
invalidates the map proof epoch. An open across a half-published reset
binds no writer; Recover's head publication completes the other slot and
creates it.

Not TLC-cleared: nothing in production calls it until the reset model
(r4.5) passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 05:45:31 -08:00
pingqiu dcc214e2d8 feat(storage): own maps before opening dark v3 stores 2026-11-17 05:40:18 -08:00
pingqiu 978b6f8e48 fix(storage): validate both map generations before binding 2026-11-17 04:05:10 -08:00
pingqiu c4be91b7e8 test: keep extent materialization visible with retained retry entries 2026-11-17 03:55:26 -08:00
pingqiu b2097f5b8b storage: retain flushed v3 entries until checkpoint coverage can advance 2026-11-17 03:54:17 -08:00
pingqiu 48ca086de9 Merge remote-tracking branch 'origin/feat/walstore-format-v3' into work/format-v3-map-row7-integration 2026-11-17 03:46:34 -08:00
pingqiuandClaude Opus 5.5 9473fc5f3a storage: clamp the v3 flusher checkpoint to the acknowledged W (row 5f)
A v3 checkpoint never exceeds W (DESIGN 2.2 item 5, 9.1 predicate 2:
CheckpointLSN <= mapCoveredCheckpoint <= W). The flusher may flush dirty
entries no Sync has acknowledged, so persistCheckpointV3 now clamps its
candidate to the acknowledged W; the unsynced records stay retained in the
WAL until a Sync covers them. (Raised by claude05's CkptUnsynced model
note; Claude01 ruled the v3 rule is CheckpointLSN <= W.)

The map candidate is prepared first, outside every lock, for the clamped
checkpoint. The publication is a W publisher, so it runs under the v3
leader role (syncMu -> s.mu -> descMu), like Sync, refreshW and SetWMode,
and cannot straddle a recovery; if a recovery lowered the acknowledged W
below the prepared candidate meanwhile, the cycle publishes nothing.

Control: an acknowledged LSN 1 and an unsynced dirty LSN 2 through a
flusher cycle (stub map candidate) give checkpoint = covered = 1, the tail
unchanged, and both LBAs readable after a crash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:42:42 -08:00
pingqiuandClaude Opus 5.5 e632d0e83e storage: serialize v3 Recover against every W publisher (row 5d amend)
codex01 row 5d review (3e76473c, AMEND): the start-only recovery epoch
did not cover a capture during recovery (schedule A), a batch recovered
between its publication and its ACK (schedule B), or the outer Sync()
completion. Structural seam per Claude01, replacing the epoch checks.

Lock graph: captureMu -> lifecycleMu -> syncMu (v3 leader) -> s.mu ->
descMu -> fileSyncMu. Checked first: no Recover caller holds s.mu or
descMu (durable.Recover, sparrow persist and tests call it from outside),
and no publisher takes syncMu while holding s.mu (committer goroutine,
flusher after dropping its read lock, SetWMode after Sync).

- Recover (v3) holds syncMu for its whole run, after lifecycleMu and
  before s.mu, and bumps recoverGen under syncMu and s.mu.
- The Sync batch (capture -> publish -> final ACK), refreshW and SetWMode
  hold syncMu throughout, so no publication or ACK straddles a recovery;
  the per-publication epoch checks are removed.
- The outer Sync() completion, which cannot hold syncMu across its
  committer wait, captures recoverGen with targetHead under s.mu.RLock
  and rechecks it under syncMu -> s.mu at completion; a moved generation
  refuses the ack (errV3RecoveredMeanwhile).
- Held controls: refresh during a held Recover (A); Recover during a batch
  held before its ACK (B); the outer completion across a recovery, with a
  fresh-lifetime positive. heldV3 releases the hold and joins every worker
  with a bound in cleanup, before the store crash cleanup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:31:38 -08:00
pingqiu f3a2b35c94 storage: invalidate bound map proofs at actual Recover start and end 2026-11-17 03:17:19 -08:00
pingqiuandClaude Opus 5.5 3e76473c07 storage: drop v3 W publications that a recovery has superseded (row 5c amend)
codex01 row 5c review (87a922fa, AMEND). Lock graph first, unchanged:
syncMu (v3 leader) -> s.mu -> descMu -> fileSyncMu; Recover holds
s.mu -> descMu -> fileSyncMu and never takes syncMu. No edge is added.

- P1: a flusher refresh could read Wack 2 and pause while a same-open
  Recover dropped record 2 and reset Wack to 1; the resumed refresh then
  published W 2 and the next Recover reported a false wal_corrupt. Every
  recovery now bumps a recovery epoch first thing (under s.mu, before it
  reads the descriptor). Every publication of a W derived from cached
  wack/appended values (Sync batch, refreshW, SetWMode) captures the epoch
  with them and rechecks it inside its publication mutate, under descMu: a
  superseded publication is dropped (errV3RecoveredMeanwhile; the refresh
  treats it as nothing to do). A publication that wins the race completes
  before the recovery reads the descriptor, so its W is genuine.
  Held real-flusher control: the refresh caches W 2 and parks, the same
  instance recovers to R 1, the refresh resumes and publishes nothing, and
  the next Recover succeeds.
- P2: held tests register the store crash with t.Cleanup before the
  release cleanup, so a failure releases the hold before shutdown.
- P2: the empty-dirty-set refresh branch has its own control.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:09:02 -08:00
pingqiu 3cf779490e test: cover real-store WAL dispatch after a held read miss 2026-11-17 03:06:47 -08:00
pingqiu 90bd02b37d Merge remote-tracking branch 'origin/feat/walstore-format-v3' into work/format-v3-map-row7-integration 2026-11-17 03:04:56 -08:00
pingqiu b77b5acaff fix: bound map allocation before root I/O and pin digest controls 2026-11-17 02:59:30 -08:00
pingqiu dc6e94e4cd docs: bound dark map publication claims before real lifecycle wiring 2026-11-17 02:58:28 -08:00
pingqiuandClaude Opus 5.5 87a922fa18 storage: reset the v3 acknowledged frontier on recovery; wire the idle refresh (row 5b amend)
codex01 row 5b review (b8950a26, AMEND):
- P1: recoverV3 sets the volatile acknowledged W to the recovered prefix
  R instead of keeping an older in-memory maximum. A same-open recovery
  that drops mode C's newest batch could otherwise let refreshW publish a
  W the WAL no longer holds, and the next Recover report a false
  wal_corrupt. Control: same-instance Recover -> refresh -> Recover with
  the exact kept and fenced bytes.
- P2: a scan error under an installing descriptor keeps the typed
  ErrBaseIncomplete outcome (cause preserved, not labelled damaged).
- P2: the real flusher cycle runs the mode-C idle refresh, also when no
  dirty entries remain. Control drives flushOnceInternal (no timing oracle).
- P2: the held controls use bounded handshakes and register their release
  as test cleanup before the held goroutine starts.
- Row 7 handoff: Read's post-OnReadMiss dirty-map recheck dispatches to
  the v3 WAL reader.
The LSN-order dependency is closed by codex03's writer enforcement
(2f201a5a..f0fd2916) and DESIGN r16.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 02:56:12 -08:00
pingqiu edb917045e test: isolate open-domain proof binding and persistence overlap invalidation 2026-11-17 02:54:55 -08:00
pingqiu cb8a0fb819 storage: validate dark map publication against merged coverage and volatile proof 2026-11-17 02:54:55 -08:00
pingqiu f0fd2916cc test: compose kept-frontier writer control with the row5b real store 2026-11-17 02:47:43 -08:00
pingqiu 82263a5930 test: pin descriptor LSN floor and document the physical-order guard 2026-11-17 02:46:55 -08:00
pingqiu 2f201a5aa2 storage: enforce strictly increasing physical v3 WAL LSNs 2026-11-17 02:46:55 -08:00
pingqiuandClaude Opus 5.5 b8950a262f storage: run the v3 format inside the real WALStore; fold codex01 row 5 review (format bump row 5b)
Integration seam ruling (Claude01, hub 10:22Z): v3 lives inside the real
*WALStore with version-dispatched internals, selected only through a
test-only create/open; production Create/Open stay v2 until row 12b.
The parallel walStoreV3 type from row 5 is removed; its logic is now the
store's v3 internals.

- walstore.go: a v3 field, set before the committer and flusher start
  (openInitializedInternal init hook). Dispatch at the v2-coupled points:
  Write appends through walWriterV3 with DurableLSN = Wack; Read uses the
  v3 record layout; Recover runs recoverV3 (R < W*, replay <= R into the
  dirty map, the exact fence, head = E, writer restored to E);
  syncWALBatch runs the C/A modes through the row-3 publisher under the
  v3 leader role; persistCheckpointReleasing publishes through it.
  WriteBatch, ApplyEntry, WriteExtentDirect refuse (errV3NotYet) and
  AdvanceFrontier is a no-op on v3 until their rows.
- flusher.go: readDirtyRecord decodes and validates v3 records.
- The v3 checkpoint/tail publication takes a map candidate hook for row
  7; without it the checkpoint and tail do not move (no fabricated
  coverage; the WAL stays retained).

codex01 row 5 review (40b7614f, AMEND):
- P1: the batch acknowledgement rechecks the store fault under s.mu
  before advancing Wack, closing the window where a queued append latches
  after the publisher's check. Held control in both modes.
- P1 (LSN order): recovery keeps the physical-prefix rule, which DESIGN
  r16 makes canonical (the WAL is LSN-strictly-increasing); a
  contradictory chain while installing is wrapped as ErrBaseIncomplete.
  The ErrWALLSNOrder writer refusal is codex03's row-4 change.
- P2: fence ranges use interval length, never floor+WALSize; a history
  ending at the last representable cursor recovers.
- P2: SetWMode evidence: a held C batch acks under C before the mode
  changes; no batch acks under a stale mode; crash cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 02:40:41 -08:00
pingqiu 2a658d5dcf test: refuse map counters before allocation or I/O with typed exhaustion 2026-11-17 02:23:36 -08:00
pingqiu d2a778f849 storage: persist dark v3 chunk LSN maps as owned immutable COW generations 2026-11-17 02:22:32 -08:00
pingqiuandClaude Opus 5.5 40b7614faf storage: v3 store core, W modes C/A, R<W* recovery and the drop fence (format bump row 5)
DESIGN r15 sections 6.1 to 6.6 (f2122d66), PLAN row 5 (b870a569). Dark:
the only constructor is createWALStoreV3ForTest; the v2 path is unchanged.

- recovery_v3.go (pure): scan start max(BaseCursor, retainedTail) (G2),
  floor F, contiguous prefix R and its end E over the row-4 trusted chain,
  the R < W* decision (wal_corrupt when serving; ErrBaseIncomplete, plus
  ErrInstallSuffixDamaged and WALIntegrity when damaged, while installing),
  and the exact fence ranges over [E, floor+WALSize), split at the wrap.
- walstore_v3.go: open selects a slot, scans (row 4), decides, replays the
  records <= R last-writer-wins, fences and fsyncs the exact ranges through
  the leaf, publishes retainedHead = E, restores the writer to E, and only
  then admits. Sync mode C publishes the previous batch's W, so one fsync
  covers WAL and slot; mode A fsyncs the WAL, then publishes W = H.
  refreshW, and SetWMode under the group-commit leader role, publish
  W = Wack. An append pwrite error latches the store-global fault.
- Tests: I1 across reopen in both modes; the C window (newest batch
  truncated in C, wal_corrupt in A; second-newest wal_corrupt in both);
  refresh and SetWMode(A) close it; a torn unsynced tail is never corrupt;
  the G1 resurrection schedule (and its no-fence counterexample); a
  byte-exact fence at an unaligned E; the append write-error latch.
- invariants.md: INV-WAL-V3-W-001 and INV-WAL-V3-FENCE-001 (STUB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 02:10:55 -08:00
pingqiu f93e17d80a test: refuse WAL appends after uncertain descriptor publication 2026-11-17 02:04:15 -08:00
pingqiu 6837fc6fca test: pin v3 cursor restore to validated incarnation without publication 2026-11-17 02:04:15 -08:00
pingqiu cd074a7b0c test: preserve last acknowledged v3 record at cursor exhaustion 2026-11-17 02:04:15 -08:00
pingqiu f3cccff9cc docs: bind dark v3 writer scan guards and proof scope to invariant ledger 2026-11-17 02:04:15 -08:00
pingqiu 7e4fe4a2b9 test: cover payload opacity, source bounds and concurrent v3 cursor allocation 2026-11-17 02:03:59 -08:00
pingqiu 7fb5e8798c storage: bind dark v3 WAL writer and scan to nonce and logical cursor 2026-11-17 02:03:59 -08:00
pingqiuandClaude Opus 5.5 f031f03d1b storage: latch a v3 slot write error inside the fsync leaf (row 3 amend 2)
codex01 row 3 round 2 (092784eb, AMEND, one P1): the store fault for a
slot write error was latched after syncFile released fileSyncMu, so an
independent store Sync queued on fileSyncMu could fsync and acknowledge
through the uncertain slot. The write callback now latches before it
returns, inside the leaf. Control: a store Sync queued behind a failing
full or partial slot write is refused without fsync, with the harness
running it right after the unlock and before the publisher resumes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 01:58:38 -08:00
pingqiuandClaude Opus 5.5 092784eb80 storage: v3 publisher latches slot write errors and pins the uncertain candidate (row 3 amend)
codex01 row 3 review (c9790ac4, AMEND):
- P1: a slot pwrite error (full or partial), like an fsync error, now
  latches a publisher failure (ErrDescriptorPublishUncertain) and the store
  fault through descriptorIOV3.latch, retains the uncertain candidate, and
  refuses every further publication, rollover and reuse with no further
  I/O until reopen reads the slots back (DESIGN 5 failure rule). The v2
  syncFile leaf is unchanged.
- P2: publication-side counter checks return ErrCounterExhausted before
  any write; installed -> installing is refused (not an 8.5 edge).
- Tests: full and partial slot write then error (refusals, no further
  writes, no reuse, store fault latched, reopen selects the previous gen
  after a torn write and the new gen after a complete one); counter
  exhaustion for W, checkpoint, head and map generation; the extra edge.
- invariants.md: INV-WAL-V3-PUBLISH-001 statement and tests updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 01:52:02 -08:00
pingqiuandClaude Opus 5.5 c9790ac474 storage: v3 descriptor publisher, lock graph and metadata-only rollover (format bump row 3)
DESIGN r15 sections 4, 5 and 5.1 (f2122d66), PLAN row 3 (b870a569).
Dark: used by no production path yet; the v2 checkpoint path is
unchanged (retired in row 14a). Wiring into the v3 store follows rows 4/5.

- descriptor_v3.go: publish takes WALStore.mu (snapshot only) then descMu,
  releases the store lock before slot I/O, and writes the fallback slot
  with slotGen+1 through the syncFile leaf. It rebases onto the
  authoritative descriptor, max-merges W and the checkpoint, refuses
  identity/geometry/nonce changes, tail regression, map root changes
  without a higher generation and BASE edges outside 8.5, validates the
  whole slot, and rechecks the sticky fault at the success boundary.
  reuseFloor is min of both tails within one nonce (none across nonces);
  rolloverIfPinned republishes unchanged when the fallback pins reuse.
- Tests: alternation and reopen selection, monotonic merge, 40 concurrent
  publishers, a lock-order recorder, sticky fsync and success-boundary
  refusals, full-ring rollover and its failure, mixed nonces, BASE edges.
- invariants.md: INV-WAL-V3-PUBLISH-001 (STUB until activation).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 01:43:52 -08:00
pingqiu 162ebc99fe docs: clarify record vector scope and separate RED evidence 2026-11-17 01:37:23 -08:00
pingqiu 94aca469ac test: pin independent nonzero batch and trim record vectors 2026-11-17 01:36:07 -08:00
pingqiu 26f4cb77eb storage: add dark impl-3 record codec and byte contract tests 2026-11-17 01:33:31 -08:00