Descriptor-owner ruling on codex03's row 12a retired-BASE RED (6f545aad):
once a completed BASE retires to none, nothing durable tells the provider
that the local image is complete rather than a lazy seed. Retirement may
now be deferred, opt-in per store, so the installed descriptor stays that
evidence until the chunk layer has durably recorded local presence:
- DeferBaseRetirementV3 (the provider, at open, before Recover and any
publication) and AllowBaseRetirementV3 (the chunk layer, after durable
local presence) set an atomic gate on the publisher;
- retireBaseV3 is skipped while the gate is deferred; once allowed,
retirement happens on the next ordinary publication;
- every successful begin re-arms a lifted deferral, so a later install in
the same open needs its own durable presence before it may retire.
The publisher only reads the atomic under descMu: no new lock edge, no
format or durable field. Stores that never set the gate retire as
before, so a volume without a chunk layer cannot be stuck installed.
Control: a deferred store stays installed through publications whose
8.4 conditions hold, retires on the first one after Allow, and a second
install in the same open is deferred again. Mutants: a publisher that
ignores the gate; a begin that does not re-arm it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codex01 review of 7c6a29d8:
- P1: ValidateMigrationV3 lacked the checked extent end, so an aligned
geometry whose extent end overflows passed, the backup and the map were
written, and only the slot validation refused. The geometry check now
applies the same bounds (volume, extent, block, the checked WAL and
extent ends, the file end within MaxInt64), and the tool runs it, and a
file-size bound on the v2 WAL, before the WAL is read or anything is
written.
- P2: the scan allocated the v2 WAL size from the superblock before any
bound; it is now bounded by the file size first, with no wrapping sum.
- P2: a rerun that found the v2 chunk bitmap already renamed skipped the
directory fsync an earlier run may have failed; it now fsyncs it.
Controls: an overflowing extent end, a WAL past the file end and a WAL
size whose sums wrap are each refused with no byte written; a retirement
whose directory fsync failed is made durable by the rerun. Mutants: no
checked file end, no file-size bound, the rerun skipping the fsync. The
WAL-region overflow check alone is equivalent: the file-size bound also
refuses that case.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.4 section 10.1. The tool (cmd/sw-block/migrate.go) runs the
steps, each durable before the next: the read-only exhaustive scan and
the geometry check (a refusal changes no byte), the atomic operator
backup of the v2 superblock, the initial map sidecar (generation 1, every
chunk UNKNOWN, covered = the v2 checkpoint), the prepared slot B at 4096,
slot A at phase 0 (the commit point), slot B at phase 0, then the v2
chunk bitmap retirement, and prints the new descriptor hash. A rerun
decides from the slot bytes alone (the 10.1 table): a v2 A restarts with
a full rescan; a committed A finishes the rollover and the retirement; a
committed B only the retirement; a prepared B with an invalid A refuses
with ErrMigrationIncomplete; neither valid refuses. It never reads or
restores the backup.
core/storage/migrate_v3.go is the tool-only export: it reuses the row-1
slot codec and the row-6 map codec (no second encoder), keeps the extent
base (new WALSize = old - 4096), and opens or serves nothing.
Controls through the actual CLI entry and, tagged, the actual v3 open:
a clean migration (extent unchanged, backup, retirement, the old binary
refuses, an idempotent rerun, v3 serves the v2 blocks with an all-UNKNOWN
map), refusals changing nothing, a crash after each step, the old binary
after preparation, a partly and wholly overwritten prepared B, and the
backup never restored. Mutants: no clean scan, commit before prepare,
retire before the commit, no rollover on rerun, an unrefused incomplete
state, a clean initial map. Not yet: the shared advisory lock (12b) and
committed raw v2 fixtures (13c).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The activation limiter codex01 named: v3 WriteBatch (the real 8 KiB
multi-block write) and its replay/read path returned errV3NotYet. Dark:
- WriteBatch on a v3 store appends one multi-block record (type 0x04)
with LSNs first..first+n-1 and one CRC32C, so a crash keeps all of it
or none; the writer consumes the whole range (DESIGN 6.7, r16), the
map coverage follows every block's LSN, and each block's dirty entry
names its data offset inside the record. A single block is a write.
- One whole-record reader (readWholeRecordV3, blockOfRecordV3) serves the
store read, the flusher and codex03's dark offline reader: it sizes the
record from its type and Length, validates the whole record and the
block's LBA, LSN and offset in it. The read retry also compares the
data offset.
- Recovery's replay and the install-path replays (the reopen cut and the
same-open continuation) republish every block of a batch.
Controls: round trip across a crash in both modes, a torn batch (dropped
whole when unacknowledged, fail-closed when acknowledged), a crash
mid-batch (latched, never acknowledged, none served), the ack boundary,
the flusher, the offline reader and the map coverage. Mutants: block 0
reads, first-block replay, a split batch, a flusher at offset 0, an
offline reader indexing only block 0, no map coverage.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.4 section 10.1, the read-only half of `sw-block migrate-v3`:
cmd/sw-block/internal/v2legacy holds the frozen v2/impl1 superblock reader
(precondition 2: magic, version 2, walstore, impl version 1; impl 2 is
refused) and the one-record v2 entry probe, so the v3 open code keeps no
legacy reader and row 14 can delete the legacy production code.
ScanClean is precondition 3: it tries the frozen decoder at every byte
offset of the whole WAL region, circularly, and refuses any CRC- and
EntrySize-valid record of a known type whose type-derived footprint fits
the region (38 + Length for write, batch and padding; 38 for trim and
barrier, whose Length is an affected range) and whose last LSN is above
the checkpoint, plus any CRC-valid batch whose count cannot be
classified. Records at or below the checkpoint are ignored. It never
runs recovery or replay and writes nothing.
Controls: every record shape (wrapped, trim range, batch last LSN, zero
count, embedded in a payload, bad CRC) and real v2 stores (cleanly
closed scans clean; synced but never flushed refuses).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codex01 review of aa477c09 (pre-existing live-continuation P1): a
same-open installing Recover cleared the dirty map without replaying it.
With BASE LBA 1 = B0 and then install-lane LSN 11 at LBA 1 acknowledged,
the original handle could continue (r17.4), apply and acknowledge LSN 12
and complete, and a same-open read of LBA 1 then fell back to B0.
When the installing ID was begun in this open, the Recover now either
republishes the live install's trusted records (<= R) in the dirty map,
keeping the volatile map coverage (the BASE writes' UNKNOWN) as it is,
or, when the recovered cut is short of the live writer (damage under a
live install), latches the store so the handle cannot append behind the
gap; a physical reopen then decides intact or damaged. No DESIGN text
change.
Controls: codex01's exact schedule completed and read through the
original handle in the same open; a same-open Recover over a damaged
record fails closed. Mutants: no replay (serves B0), no latch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codex01 row 11b review (3c67ee56): a same-open Recover while this open's
install was live cached E and R but left the install's handle valid
(r17.4: until the next begin). That handle could apply and acknowledge
LSN 12 past the cut; a resume then fenced from the cached E and
fsync-erased the acknowledged record before the forward-only writer
refused to move back.
An installing Recover now records its recovered bounds only when the
installing ID was not begun in this open (a physical reopen). After a
same-open Recover the live install simply continues; a resume or a
fenced supersession refuses before any I/O. No DESIGN text change:
section 8.3's resume is the reopen case, and r17.3.1 already says a
same-open continuation keeps the live writer position.
Control: the held schedule (same-open Recover, the old handle applies
and acknowledges LSN 12, then a resume): the resume refuses, LSN 12's
bytes are unchanged, and a physical reopen still resumes and serves it.
Mutant: recording the cut on a same-open Recover erases LSN 12.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.4 section 8.3, "Resume (same ID)", store level and dark (no
current caller resumes: both receivers begin fresh install IDs). Under
installMu exclusive the resume appends nothing until all three hold:
1. trusted-through-W: the recovered suffix is intact (R >= W*) and E is
at or past the persisted retainedHead;
2. the 6.6 fence of [E, floor + WALSize) with fsync;
3. a publication of retainedHead = E (G3).
Otherwise it refuses with ErrInstallSuffixDamaged, writing nothing, and
the volume stays installing. The writer continues at E (forward only)
and the reopen's trusted install-lane records are replayed so the
completed image serves them. The installing Recover now keeps those
records with its recovered bounds.
Controls: an intact resume that serves the recovered LSN 11 and fences
the dropped LSN 13; a damaged suffix refused; E below the persisted head
refused, while a covering supersession anchors at P = that head and stays
resumable across a crash. Mutants: no fence, ignoring the damage, no
E >= head check, anchoring the supersession at P = E.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.4 sections 6.6 (G3) and 8.3, dark:
- An installing Recover keeps its recovered bounds (E, R, intact or
damaged) and moves the allocator state above every trusted record, but
fences, publishes and admits nothing; the outcome stays the typed
ErrBaseIncomplete.
- A superseding begin after that reopen checks the coverage rule, then
fences [E, floor + WALSize) and fsyncs before its two-slot installing
publication, so no record of the old install beyond E re-chains;
it anchors at P = max(E, the persisted retainedHead), never lowers
retainedHead, and restarts the writer at P (advanceHeadV3, forward
only, no LSN change). Reads and the flusher see a recovery boundary.
- A damaged suffix refuses nothing here: the supersession does not need
trusted-through-W, because the new BASE covers every record <= W.
Controls: the G3 revival schedule (A's LSN 13 beyond the gap would chain
on after B's 12 at the same position) and a covering supersession over a
damaged, acknowledged suffix (below W refused, at W installs and serves).
Mutants: no fence; trusted-through-W applied to the supersession.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.4 section 8.7, caller 2 (core/transport/replica.go, the
production default --recovery-mode=legacy):
- the first admitted MsgRebuildBlock of a connection, or an empty
rebuild's MsgRebuildDone, begins one install at the lineage's frontier
hint under a fresh random ID; a different hint on the connection is
refused; a reconnect is a new connection and so a superseding install
under the coverage rule;
- each block is written through the handle's WriteBase, never the
store-level WriteExtentDirect;
- MsgRebuildDone completes through the handle, then calls Sync, which is
ordinary once installed, and stops discarding the Sync error: a failed
completion or Sync closes the connection with no MsgBarrierResp.
Stores without the seam keep their pre-seam behaviour behind the legacy
handle (lazy BaseStager staging, WriteExtentDirect, AdvanceFrontier at
completion). The one behaviour change on them is the DESIGN 8.7 rule: a
Sync error on the done path no longer replies AchievedLSN 0 but closes
the connection. The live MsgBarrierReq handler keeps replying the gated
Sync's 0 while installing (section 7).
Tagged controls on a dark v3 replica: the positive and empty rebuilds,
the real BlockExecutor.StartRebuild -> doRebuild path, injected
MarkBaseComplete and Sync failures, and reconnect supersession.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codex01 row 10a review (66be344b): after the publisher's final check, a
queued append of the same install could fail and latch the store while
holding WALStore.mu; SyncInstallLog then returned H anyway. It now
rechecks stickyIOFault under WALStore.mu immediately before it moves the
acknowledged frontier and returns H (the #172 ack-boundary rule section 7
imports), and returns the fault instead.
Control: a held same-ID append whose pwrite fails between the
publication and the ack; the ack is refused and the acknowledged frontier
does not move. Mutant: no final locked check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.4 section 7 (O1-a), dark:
- While installing, the v3 logical Sync returns exactly (0,
ErrBaseInstalling): no batch, no new W; the gate is rechecked at the
completion under the leader role.
- SyncInstallLog(installID) on the narrow InstallLogSyncer (not on
LogicalStorage): under installMu shared it refuses outside an install
(ErrNotInstalling) or for another ID (ErrInstallIDMismatch), freezes the
cut H, fsyncs the WAL and publishes W = max(W, H) with BaseState still
installing, always mode A. A v2 store's SyncInstallLog is its Sync.
- The receiver's sendAck uses it until the session's own BaseDone, then
the ordinary Sync (the WAL lane can outlive BaseDone, r17.4).
Controls: the gate, the refusals, mode A on a lagged store with a crash,
the receiver's progress ack (tagged), and the receiver-only boundary.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plan row 9: SeedChunkFrontier uses the checkpoint's map/metadata barrier
and the sole descriptor publication. The mapped v3 checkpoint body is
extracted into publishCheckpointV3 (metadata and chunk barriers, owned-map
candidate outside every lock, the sole slot publisher under syncMu with the
recovery-lifetime check), which the flusher's checkpoint and the seed both
call. The v3 seed fsyncs the data, then raises W and CheckpointLSN to the
inherited frontier in that one publication, and moves the volatile
frontier only after it; a failure publishes nothing and a retry works. It
refuses local writes, an install, an attached chunk layer and a store
without an owned map, writing nothing.
The dark provider still refuses a HEAD restore onto a v3 store
(errV3RestoreNotYet in PrepareRestore, before any seed or claim) until the
v3 FreshFromHead restore on the owned map lands (codex03), so codex03's
TestDurableProviderV3_UnwiredHEADRestoreRefusesBeforeClaim stays as is.
WALStore.FormatV3 reports the dark format.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codex01 row 9b review (f08ee20c): the real Sender sends BaseDone from its
base lane while its WAL lane is still sending, but a completed install
refused every later WAL entry of the same session (the handle admitted
only while installing). DESIGN r17.4 (Claude01 ruling A):
- every begin bumps an install epoch; a handle is admitted only while no
later begin has run (checked under installMu shared);
- WriteBase stays installing-only under the handle's ID;
- ApplyInstallEntry is also admitted after the handle's own successful
MarkBaseComplete, while installed under its ID or retired, under the
8.1 order and gap rules;
- a later begin refuses the old handle with ErrInstallSuperseded, even
after both installs completed and retired.
Controls: the real receiver in the Sender order (BASE, WAL, BaseDone,
WAL, barrier), also across a crash and reopen; the store-level lifetime
control. Mutants: installing-only admission, no epoch check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.3.1 section 8.7:
- BaseInstallPreparer.BeginBaseInstall(baseLSN, installID) returns an
InstallHandle (WriteBase, ApplyInstallEntry, MarkBaseComplete). The v3
WALStore runs the row 9a begin; a v2 WALStore and stores without the
seam get the legacy handle, which keeps their exact pre-seam behaviour
(WriteExtentDirect, ApplyEntry, AdvanceFrontier(baseLSN)) and stages a
BaseStager store lazily before the first BASE block or completion.
parallelwal's staging step is renamed BaseStager.BeginBaseStage; the
legacy replica caller uses it unchanged (row 10 rewrites that caller).
- The dual-lane Receiver begins the install at SessionStart, inside the
counted section, at FromLSN under a fresh random ID; RebuildSession
writes, applies and completes only through the handle, and
MarkBaseComplete's error now fails the session with no ack.
- Tagged (swblock_format_v3_test) controls through the real receiver on
a dark v3 store: the positive rebuild, the held-write drain, the parked
frame for both lanes, and a superseded BaseDone failing without an ack.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codex01 row 9a review (60803a87), two P1s:
1. With W 1 and unacknowledged LSNs 2 and 3 appended, a begin at
BaseLSN 1 left 2 and 3 behind BaseCursor while the allocator went on
at 4; after complete an acknowledged write 4 met a hole at reopen
(strict R 1 < W 4; lagged could drop it). The begin now also needs
BaseLSN >= the highest appended LSN and is refused otherwise, writing
nothing; nothing is rewound or dropped.
2. A BASE write's UNKNOWN coverage was only in memory, and complete
published installed with the old clean map root. Complete now settles
step 2 like a checkpoint: one fsync, the metadata and chunk barriers,
a fresh owned-map candidate, and one installed publication carrying
it, under the leader role and the recovery-lifetime check. A guest
write that makes the candidate stale fails the completion.
Each has an actual-store control and a mutant. The held-test hooks now
always release in cleanup (P2).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.3.1 sections 8.1, 8.2, 8.4, 8.5 and 8.7 on the v3 store,
reachable only from tests:
- beginBaseInstallV3 takes installMu exclusive (draining the old ID's
admitted mutations), refuses BaseLSN below the acknowledged W
(published or not yet, mode C) or the checkpoint with the begin- or
supersede-specific error before any write, freezes P at the writer
head and publishes installing into both slots.
- installHandleV3.WriteBase and ApplyInstallEntry admit under installMu
shared and recheck the state and ID under it (ErrInstallSuperseded);
the install lane applies the order and gap rules and maps a full ring
to ErrBaseInstallNoSpace.
- markBaseCompleteV3 validates the ID under installMu exclusive, fsyncs
the BASE bytes and the install-lane suffix, publishes installed with
retainedTail >= BaseCursor, drops the superseded pre-BASE dirty
entries and moves the frontier to BaseLSN.
- installing -> none is refused (no abort, r17); installed -> none
retires only once the checkpoint covers BaseLSN and both slots carry
a tail at or past BaseCursor.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
(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>
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>