diff --git a/seaweed-block/core/storage/base_install_v3.go b/seaweed-block/core/storage/base_install_v3.go index 068765b184..3051e16f44 100644 --- a/seaweed-block/core/storage/base_install_v3.go +++ b/seaweed-block/core/storage/base_install_v3.go @@ -91,13 +91,20 @@ func (s *WALStore) beginBaseInstallV3(baseLSN uint64, id [16]byte) (*installHand } } // W includes every acknowledged LSN, published or not yet (mode C). + // BaseLSN must also cover every appended LSN: an unacknowledged record + // above BaseLSN would lie behind BaseCursor, so recovery from + // max(CheckpointLSN, BaseLSN) would meet a hole where the allocator + // continued (codex01 row 9a P1-1). Such a begin is refused, writing + // nothing; the records are never rewound or dropped to make room. w := max(d.W, v.wack.Load()) - if baseLSN < w || baseLSN < d.CheckpointLSN { + appended := v.appended.Load() + if baseLSN < w || baseLSN < d.CheckpointLSN || baseLSN < appended { refusal := ErrInstallBaseUncovered if d.BaseState == BaseInstalling { refusal = ErrInstallSupersedeUncovered } - return nil, fmt.Errorf("%w: BaseLSN %d, W %d, CheckpointLSN %d", refusal, baseLSN, w, d.CheckpointLSN) + return nil, fmt.Errorf("%w: BaseLSN %d, W %d, CheckpointLSN %d, appended %d", + refusal, baseLSN, w, d.CheckpointLSN, appended) } P := v.w.logicalHeadV3() // 8.1 step 2: the serialized writer's head // Step 3: installing into the fallback slot. @@ -113,7 +120,7 @@ func (s *WALStore) beginBaseInstallV3(baseLSN uint64, id [16]byte) (*installHand return nil, err } v.liveInstallID = id - v.preBaseHighest = v.appended.Load() + v.preBaseHighest = appended if err := v.pub.invalidateMapProofV3(); err != nil { // an install transition (9.1) return nil, err } @@ -242,11 +249,17 @@ func (h *installHandleV3) ApplyInstallEntry(lba uint32, data []byte, lsn uint64) return nil } -// markBaseCompleteV3 is DESIGN 8.2. Under installMu exclusive it validates -// the ID, makes the BASE extent bytes and the install-lane suffix durable, -// publishes installed with the same ID (retainedTail = max(retainedTail, -// P), 8.4) and then moves the in-memory frontier to BaseLSN. On any error -// the volume stays installing and the error propagates. +// markBaseCompleteV3 is DESIGN 8.2. Under installMu exclusive (no handle +// mutation is admitted) it validates the ID, then settles step 2 exactly as +// a checkpoint does: one fsync for the BASE extent bytes and the +// install-lane suffix (they share the file), the optional metadata and +// chunk barriers, and a fresh owned-map candidate that carries the UNKNOWN +// coverage the BASE writes set (codex01 row 9a P1-2). It then publishes +// installed with the same ID and that candidate in one publication +// (retainedTail = max(retainedTail, P), 8.4), stops serving the superseded +// pre-BASE records and moves the frontier to BaseLSN. A guest write that +// changes the map meanwhile makes the candidate stale and the completion +// fails. On any error the volume stays installing and the error propagates. func (s *WALStore) markBaseCompleteV3(id [16]byte) error { v := s.v3 if v == nil { @@ -258,36 +271,80 @@ func (s *WALStore) markBaseCompleteV3(id [16]byte) error { defer s.captureMu.Unlock() s.lifecycleMu.RLock() defer s.lifecycleMu.RUnlock() - v.syncMu.Lock() - defer v.syncMu.Unlock() - s.mu.Lock() - defer s.mu.Unlock() - if s.closed { + s.mu.RLock() + closed := s.closed + gen := v.recoverGen.Load() + s.mu.RUnlock() + if closed { return errors.New("storage: MarkBaseComplete after Close") } d := v.pub.current() if d.BaseState != BaseInstalling || d.BaseInstallID != id { return ErrInstallSuperseded } - // Step 2: the BASE extent bytes and the install-lane WAL suffix share the - // file; one fsync through the leaf makes both durable. + // Step 2. if err := s.syncFile(nil, s.fd.Sync); err != nil { return err } - // Step 3: installed, same ID. - if _, err := v.pub.publish(nil, nil, func(n *descriptorV3) error { + cp := d.CheckpointLSN // the checkpoint does not move here + if s.metadata != nil { + if err := s.metadata.BeforeCheckpointAdvance(cp); err != nil { + return err + } + } + if h := s.chunk.Load(); h != nil { + if err := h.sink.BeforeCheckpointAdvance(cp); err != nil { + return err + } + } + var prepared *preparedMapPublicationV3 + var mutateMap func(*descriptorV3) error + if v.ownedMap != nil { + var err error + if prepared, err = s.prepareOwnedMapCheckpointV3(cp); err != nil { + return err + } + } else if v.mapCandidate != nil { + var err error + if mutateMap, err = v.mapCandidate(cp); err != nil { + return err + } + } + // Step 3: installed, same ID, with the candidate, under the leader role. + v.syncMu.Lock() + defer v.syncMu.Unlock() + if !v.flushLifetimeValidV3(gen) { + return ErrMapCoverageStale // a recovery or reset ran meanwhile + } + installed := func(n *descriptorV3) error { + if n.BaseState != BaseInstalling || n.BaseInstallID != id { + return ErrInstallSuperseded + } n.BaseState = BaseInstalled n.RetainedTail = max(n.RetainedTail, d.BaseCursor) + if mutateMap != nil { + return mutateMap(n) + } return nil - }); err != nil { + } + var err error + if prepared != nil { + _, err = v.pub.publishMapV3(&s.mu, nil, prepared, installed) + } else { + _, err = v.pub.publish(&s.mu, nil, installed) + } + if err != nil { return err } + s.mu.Lock() + defer s.mu.Unlock() if err := v.pub.invalidateMapProofV3(); err != nil { return err } - // Records before P (LSN <= the highest appended at begin) are behind the - // installed BaseCursor and superseded by the BASE image: recovery never - // scans them, so the open store stops serving or flushing them too. + // Records before P (LSN <= the highest appended at begin, which the + // begin bounded by BaseLSN) are behind the installed BaseCursor and + // superseded by the BASE image: recovery never scans them, so the open + // store stops serving or flushing them too. for _, e := range s.dm.snapshot() { if e.LSN <= v.preBaseHighest { s.dm.compareAndDelete(e.LBA, e.LSN) diff --git a/seaweed-block/core/storage/base_install_v3_test.go b/seaweed-block/core/storage/base_install_v3_test.go index 264bad8c3b..db12bf6bd2 100644 --- a/seaweed-block/core/storage/base_install_v3_test.go +++ b/seaweed-block/core/storage/base_install_v3_test.go @@ -3,6 +3,8 @@ package storage import ( "bytes" "errors" + "path/filepath" + "sync" "sync/atomic" "testing" "time" @@ -240,16 +242,22 @@ func TestBaseInstallV3ApplyInstallEntryOrderAndGap(t *testing.T) { } } -// holdOnce returns a hook that parks the first call until release is -// closed, and reports through parked when it has parked. -func holdOnce() (hook func(), parked, release chan struct{}) { - parked, release = make(chan struct{}), make(chan struct{}) +// holdOnce returns a hook that parks the first call until release runs, +// and reports through parked when it has parked. The test's cleanup always +// releases, so a failing test never leaves a parked goroutine behind +// (codex01 row 9a P2). +func holdOnce(t *testing.T) (hook func(), parked chan struct{}, release func()) { + parked = make(chan struct{}) + gate := make(chan struct{}) + var once sync.Once + release = func() { once.Do(func() { close(gate) }) } + t.Cleanup(release) var armed atomic.Bool armed.Store(true) return func() { if armed.CompareAndSwap(true, false) { close(parked) - <-release + <-gate } }, parked, release } @@ -263,7 +271,7 @@ func TestBaseInstallV3HeldOldWriteDrainsBeforeANewBegin(t *testing.T) { s, _ := newStoreV3(t, WModeStrict) t.Cleanup(func() { crashRecoveryHardeningStore(t, s) }) hA := beginV3(t, s, 0, idA) - hook, parked, release := holdOnce() + hook, parked, release := holdOnce(t) s.v3.testInstallAdmitted = hook aDone := make(chan error, 1) go func() { aDone <- hA.WriteBase(7, blk(0xAA)) }() @@ -284,7 +292,7 @@ func TestBaseInstallV3HeldOldWriteDrainsBeforeANewBegin(t *testing.T) { bDone <- err case <-time.After(300 * time.Millisecond): } - close(release) + release() if err := <-aDone; err != nil { t.Fatalf("A's admitted write: %v", err) } @@ -318,7 +326,7 @@ func TestBaseInstallV3ParkedOldFrameIsRefusedAfterASupersession(t *testing.T) { s, _ := newStoreV3(t, WModeStrict) t.Cleanup(func() { crashRecoveryHardeningStore(t, s) }) hA := beginV3(t, s, 0, idA) - hook, parked, release := holdOnce() + hook, parked, release := holdOnce(t) s.v3.testInstallBeforeAdmit = hook aDone := make(chan error, 1) go func() { @@ -333,7 +341,7 @@ func TestBaseInstallV3ParkedOldFrameIsRefusedAfterASupersession(t *testing.T) { if err := hB.WriteBase(7, blk(0xBB)); err != nil { t.Fatal(err) } - close(release) + release() if err := <-aDone; !errors.Is(err, ErrInstallSuperseded) { t.Fatalf("parked A %s: err = %v, want ErrInstallSuperseded", op, err) } @@ -346,3 +354,101 @@ func TestBaseInstallV3ParkedOldFrameIsRefusedAfterASupersession(t *testing.T) { }) } } + +// codex01 row 9a P1-1: W 1 with unacknowledged LSNs 2 and 3 appended. A +// begin at BaseLSN 1 would put 2 and 3 behind BaseCursor while the +// allocator continues at 4: after complete, an acknowledged write 4 and a +// reopen from F = 1 meet the hole (strict: R 1 < W 4; lagged: 4 dropped). +// The begin is refused, writing nothing; a begin covering the appended +// LSNs installs, and the acknowledged write after it survives a crash. +// Mutant: bounding BaseLSN by W and the checkpoint only fails here. +func TestBaseInstallV3BeginRefusesBelowTheHighestAppendedLSN(t *testing.T) { + s, path := newStoreV3(t, WModeStrict) + writeSynced(t, s, 1, 1) + for lba := uint32(2); lba <= 3; lba++ { + if _, err := s.Write(lba, blk(byte(lba))); err != nil { + t.Fatal(err) + } + } + if w, a := s.v3.wack.Load(), s.v3.appended.Load(); w != 1 || a != 3 { + t.Fatalf("setup: acknowledged %d appended %d, want 1 and 3", w, a) + } + writes := countSlotWritesV3(s) + if _, err := s.beginBaseInstallV3(1, idA); !errors.Is(err, ErrInstallBaseUncovered) { + t.Fatalf("begin at BaseLSN 1 below appended 3: err = %v, want ErrInstallBaseUncovered", err) + } + if writes.Load() != 0 { + t.Fatal("a refused begin wrote a descriptor slot") + } + s.v3.testBeforeSlotWrite = nil + h := beginV3(t, s, 3, idA) + for lba := uint32(1); lba <= 3; lba++ { + if err := h.WriteBase(lba, blk(0x10+byte(lba))); err != nil { + t.Fatal(err) + } + } + if err := s.markBaseCompleteV3(idA); err != nil { + t.Fatal(err) + } + lsn, err := s.Write(4, blk(4)) + if err != nil || lsn != 4 { + t.Fatalf("write after complete: LSN %d err %v, want 4", lsn, err) + } + if _, err := s.Sync(); err != nil { + t.Fatal(err) + } + crashRecoveryHardeningStore(t, s) + r := mustReopenV3(t, path) + t.Cleanup(func() { crashRecoveryHardeningStore(t, r) }) + for lba, want := range map[uint32]byte{1: 0x11, 2: 0x12, 3: 0x13, 4: 4} { + if got := readV3(t, r, lba); !bytes.Equal(got, blk(want)) { + t.Fatalf("after reopen LBA %d = %x..., want %x", lba, got[0], want) + } + } +} + +// codex01 row 9a P1-2: a BASE write makes its chunk's coverage UNKNOWN only +// in memory. Complete settles the map like a checkpoint: the installed +// publication carries a fresh root with that UNKNOWN, so a crash and a +// mapped reopen keep it. Setup: chunk 2 is clean in the durable root (as a +// capture would leave it; set white-box, then checkpointed). Mutant: a +// complete that publishes installed without the map candidate reopens with +// chunk 2 clean and fails here. +func TestBaseInstallV3CompletePersistsTheMapUnknownOfBaseWrites(t *testing.T) { + path := filepath.Join(t.TempDir(), "mapped.v3") + s, err := createMappedWALStoreV3ForTest(path, 64, v3TestBlock, v3TestWAL, WModeStrict, 4) + if err != nil { + t.Fatal(err) + } + s.DisableAutoFlushForRecoveryTest() + writeSynced(t, s, 1, 1) + s.mu.Lock() + s.v3.mapEntries[2] = chunkLSNEntryV3{} + s.mu.Unlock() + if err := s.flusher.flushOnceInternal(false); err != nil { + t.Fatal(err) + } + if e := s.v3.pub.mapCurrent.entries[2]; e.Unknown { + t.Fatal("setup: chunk 2 is not clean in the durable root") + } + h := beginV3(t, s, 1, idA) + if err := h.WriteBase(9, blk(9)); err != nil { // LBA 9 is in chunk 2 + t.Fatal(err) + } + if err := s.markBaseCompleteV3(idA); err != nil { + t.Fatal(err) + } + crashRecoveryHardeningStore(t, s) + r, err := openWALStoreV3ForTest(path) + if err != nil { + t.Fatal(err) + } + r.DisableAutoFlushForRecoveryTest() + t.Cleanup(func() { crashRecoveryHardeningStore(t, r) }) + if st := r.v3.pub.current().BaseState; st != BaseInstalled { + t.Fatalf("reopen state %d, want installed", st) + } + if e := r.v3.pub.mapCurrent.entries[2]; !e.Unknown { + t.Fatal("chunk 2 reopened clean: the BASE write's UNKNOWN was lost at complete") + } +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 5a74794336..064198d434 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -289,7 +289,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-W-001` | v3 Sync acknowledges only after an fsync covers the batch. In mode C (the default) the slot carries the previous batch's acknowledged W and the batch's single fsync covers WAL and slot; in mode A the WAL fsync precedes a slot publication with W = H. Recovery refuses (`wal_corrupt`) when the contiguous prefix R above max(CheckpointLSN, BaseLSN) is below W* = max(slot W, max trusted DurableLSN). Mode C's only unprotected acknowledged data is the newest batch, against media corruption before the next Sync or the idle refresh; `SetWMode` and the refresh close that window. Flushed entries above the published checkpoint remain retry work, so a later Sync plus cycle can advance checkpoint and map coverage together. | M1 Recovering → Serving \| RecoveryFailed; M1 write lifecycle: Appended → Synced (v3) | `core/storage/walstore_v3.go` `WALStore.syncWALBatchV3`, `refreshW`, `SetWMode`, `recoverV3`, `appendWriteV3`; `core/storage/recovery_v3.go` `decideRecoveryV3`, `contiguousPrefixV3`; `core/storage/flusher.go` `flushOnceInternal` | `TestWALStoreV3CloseKeepsTheNewestSlotAAndItsW`, `TestWALStoreV3LegacySuperblockWritersRefuse` (`core/storage/walstore_close_v3_test.go`); `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3ModeCWindowIsExactlyTheNewestBatch`, `TestWALStoreV3RefreshAndSetWModeCloseTheWindow`, `TestWALStoreV3TornUnsyncedTailIsNeverAFalseCorrupt`, `TestWALStoreV3AppendWriteErrorLatchesTheStore`, `TestWALStoreV3FlusherWritesTheExtentButHoldsTheCheckpointUntilTheMap`, `TestWALStoreV3SyncRechecksTheFaultAtTheAckBoundary`, `TestWALStoreV3SetWModeWaitsForAHeldBatch`, `TestWALStoreV3NoBatchAcksUnderAStaleModeAfterSetWMode`, `TestWALStoreV3SetWModeCrashCases`, `TestWALStoreV3SameOpenRecoverResetsTheAcknowledgedFrontier`, `TestWALStoreV3InstallingScanErrorIsTypedNotReady`, `TestWALStoreV3FlusherCycleRunsTheIdleRefresh`, `TestWALStoreV3RefreshDuringRecoverWaitsAndPublishesNothing`, `TestWALStoreV3RecoverWaitsForABatchAckAndNothingRevivesTheCut`, `TestWALStoreV3OuterSyncCompletionIsRefusedAcrossARecovery`, `TestWALStoreV3FlusherCheckpointIsClampedToTheAcknowledgedW`, `TestWALStoreV3FlusherEmptyCycleRunsTheIdleRefresh` (`core/storage/walstore_v3_test.go`); `TestRecoveryV3Decision`, `TestRecoveryV3ContiguousPrefix` (`core/storage/recovery_v3_test.go`); `TestWALStoreV3_FlushedProgressRetriesAfterLaterSync` (`core/storage/walstore_flushed_progress_v3_test.go`) | `WALFormat` composed model (claude05, r14 run) | STUB | | `INV-WAL-V3-FENCE-001` | Before any append after a v3 recovery, the store zeroes exactly the logical WAL interval [E, floor+WALSize) (floor = both slots' same-nonce reuse floor) split at the physical wrap, fsyncs it through the leaf, then publishes retainedHead = E; no byte before E or outside the interval changes, so records dropped by one recovery never resurface after a second crash. | M1 Recovering → Serving (v3) | `core/storage/walstore_v3.go` `WALStore.fenceV3`, `recoverV3`; `core/storage/recovery_v3.go` `fenceRangesV3` | `TestWALStoreV3DroppedRecordsNeverResurfaceAfterASecondCrash`, `TestWALStoreV3NoFenceResurrectsInBothModes`, `TestWALStoreV3FenceTouchesNoByteBeforeTheHead`, `TestWALStoreV3RecoversAHistoryEndingAtTheLastRepresentableCursor` (`core/storage/walstore_v3_test.go`); `TestRecoveryV3FenceRangesAreExact` (`core/storage/recovery_v3_test.go`) | `WALFormat` `NoResurrection` (claude05) | STUB | | `INV-WAL-V3-RESET-001` | A v3 nonce/position reset is refused, writing nothing, unless the dirty map is empty (no entry names an old-incarnation WAL position) and every appended LSN is checkpointed (CheckpointLSN >= appended, hence = acknowledged W). It publishes the new nonce with an empty cursor space into one slot and then the other, and is successful only after both. A crash between the two opens the new incarnation; no reuse floor exists across the two nonces, and no writer binds until Recover's head publication completes the other slot. LSNs, W and the map root are unchanged. A read holds no lock across its WAL read; it validates the whole record it read (CRC, footer, type, LBA, LSN) against the resolving dirty entry and re-resolves on a mismatch, so a position reused by the new incarnation never serves another block (LSN allocation runs on across a reset; no nonce is checked). It reports WAL damage only for an unchanged entry with the same recovery generation before and after the attempt (bumped at the start and the end of every recovery and reset); a failed pread is substrate I/O. | M1 Serving → Serving (reset, dark) | `core/storage/reset_v3.go` `WALStore.resetIncarnationV3`, `descriptorPublisherV3.resetIncarnationV3`, `halfResetV3`; `core/storage/descriptor_v3.go` `mergeDescriptorV3Mode`; `core/storage/walstore_v3.go` open and `recoverV3` | `TestResetV3RefusesWhileUncheckpointed`, `TestResetV3RefusesTheCurrentOrAZeroNonce`, `TestResetV3RetainedButCheckpointedBytesDoNotBlock`, `TestResetV3PublishesBothSlotsAndOnlyThenHasAFloor`, `TestResetV3CrashOutcomes`, `TestResetV3OrdinaryPublicationsCannotChangeTheNonce` (`core/storage/reset_v3_test.go`); `TestWALStoreV3ResetRefusesUncheckpointedOrUnacknowledgedData`, `TestWALStoreV3ResetPublishesBothSlotsAndWritesRecoverAcrossACrash`, `TestWALStoreV3ResetCrashOutcomes`, `TestWALStoreV3HalfResetRefusesWritesUntilRecover`, `TestWALStoreV3ReadParkedAcrossAResetAndOverwriteReturnsItsOwnBlock`, `TestWALStoreV3ReadMissRecheckParkedAcrossAResetReturnsItsOwnBlock`, `TestWALStoreV3ReadOfADamagedLiveRecordIsAnIntegrityFault`, `TestWALStoreV3ReadAcrossARecoveryThatReusesTheSamePositionAndLSNIsNotDamage`, `TestWALStoreV3ReadIOErrorsAreSubstrateIONotWALIntegrity`, `TestWALStoreV3ReadAdmittedBetweenRecoverBumpAndClearIsNotDamage` (`core/storage/reset_store_v3_test.go`) | `WALFormat` reset (claude05 r4.5, pending) | STUB | -| `INV-WAL-V3-BASE-001` | A v3 BASE install begins only under `installMu` exclusive (draining the old ID's admitted mutations) and only when BaseLSN covers the acknowledged W (published or not yet) and the checkpoint; otherwise it is refused, writing nothing, with `ErrInstallBaseUncovered` or `ErrInstallSupersedeUncovered`. It publishes installing (BaseLSN, BaseCursor = the writer head P, the ID) into both slots before the first BASE mutation. BASE extent writes and install-lane applies go only through the handle, under `installMu` shared with the state and ID checked under it (`ErrInstallSuperseded`); the install lane keeps the order and gap rules. Complete validates the ID under `installMu` exclusive, fsyncs the BASE bytes and the suffix, publishes installed with retainedTail >= BaseCursor and stops serving the superseded pre-BASE records. installing -> none is refused (no abort); installed -> none retires only once the checkpoint covers BaseLSN and both slots carry a tail at or past BaseCursor. | M1 Serving → Installing → Serving (dark) | `core/storage/base_install_v3.go` `WALStore.beginBaseInstallV3`, `installHandleV3.WriteBase`, `installHandleV3.ApplyInstallEntry`, `WALStore.markBaseCompleteV3`; `core/storage/descriptor_v3.go` `baseTransitionAllowedV3`, `retireBaseV3` | `TestBaseInstallV3BeginPublishesInstallingIntoBothSlots`, `TestBaseInstallV3BeginRefusesBelowW`, `TestBaseInstallV3BeginCoversTheAcknowledgedNotYetPublishedW`, `TestBaseInstallV3BeginRefusals`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash`, `TestBaseInstallV3InstallingToNoneIsRefused`, `TestBaseInstallV3RetiresOnlyOnceTheCheckpointCoversBaseLSN`, `TestBaseInstallV3ApplyInstallEntryOrderAndGap`, `TestBaseInstallV3HeldOldWriteDrainsBeforeANewBegin`, `TestBaseInstallV3ParkedOldFrameIsRefusedAfterASupersession` (`core/storage/base_install_v3_test.go`); `TestDescriptorV3BaseTransitionTable` | `WALFormat` handle and BASE configs (claude05 R17c, pending) | STUB | +| `INV-WAL-V3-BASE-001` | A v3 BASE install begins only under `installMu` exclusive (draining the old ID's admitted mutations) and only when BaseLSN covers the acknowledged W (published or not yet), the checkpoint and every appended LSN (an unacknowledged record above BaseLSN would leave a hole behind BaseCursor; codex01 row 9a P1-1); otherwise it is refused, writing nothing, with `ErrInstallBaseUncovered` or `ErrInstallSupersedeUncovered`. It publishes installing (BaseLSN, BaseCursor = the writer head P, the ID) into both slots before the first BASE mutation. BASE extent writes and install-lane applies go only through the handle, under `installMu` shared with the state and ID checked under it (`ErrInstallSuperseded`); the install lane keeps the order and gap rules. Complete validates the ID under `installMu` exclusive, fsyncs the BASE bytes and the suffix, runs the checkpoint's metadata and chunk barriers and publishes installed with retainedTail >= BaseCursor together with a fresh owned-map candidate carrying the BASE writes' UNKNOWN (codex01 row 9a P1-2) and stops serving the superseded pre-BASE records. installing -> none is refused (no abort); installed -> none retires only once the checkpoint covers BaseLSN and both slots carry a tail at or past BaseCursor. | M1 Serving → Installing → Serving (dark) | `core/storage/base_install_v3.go` `WALStore.beginBaseInstallV3`, `installHandleV3.WriteBase`, `installHandleV3.ApplyInstallEntry`, `WALStore.markBaseCompleteV3`; `core/storage/descriptor_v3.go` `baseTransitionAllowedV3`, `retireBaseV3` | `TestBaseInstallV3BeginPublishesInstallingIntoBothSlots`, `TestBaseInstallV3BeginRefusesBelowW`, `TestBaseInstallV3BeginCoversTheAcknowledgedNotYetPublishedW`, `TestBaseInstallV3BeginRefusals`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash`, `TestBaseInstallV3InstallingToNoneIsRefused`, `TestBaseInstallV3RetiresOnlyOnceTheCheckpointCoversBaseLSN`, `TestBaseInstallV3ApplyInstallEntryOrderAndGap`, `TestBaseInstallV3HeldOldWriteDrainsBeforeANewBegin`, `TestBaseInstallV3ParkedOldFrameIsRefusedAfterASupersession`, `TestBaseInstallV3BeginRefusesBelowTheHighestAppendedLSN`, `TestBaseInstallV3CompletePersistsTheMapUnknownOfBaseWrites` (`core/storage/base_install_v3_test.go`); `TestDescriptorV3BaseTransitionTable` | `WALFormat` handle and BASE configs (claude05 R17c, pending) | STUB | | `INV-FE-FUA-SYNC-001` | A FUA write completes only after `Sync` succeeds. | M1 Serving (frontend) | `core/frontend/nvme/io.go` `IOHandler.write`; `core/frontend/ublk/dispatch.go` `handler.serve` | `TestNVMeWriteFUACompletion` (`core/frontend/nvme/fua_test.go`); `TestDispatch_WriteFUASyncsBeforeCompleting` (`core/frontend/ublk/dispatch_test.go`) | — | ACTIVE | | `INV-FE-FLUSH-SYNC-001` | A flush is a `Sync` of the backend, and a failed `Sync` fails the command instead of acknowledging it. | M1 Serving (frontend) | `core/frontend/nvme/io.go` `IOHandler.Handle`; `core/frontend/ublk/dispatch.go` `handler.serve` | `TestT3b_NVMe_Flush_DispatchesToBackend` (`core/frontend/nvme/t3b_flush_test.go`); `TestDispatch_FlushSyncs`, `TestDispatch_BackendFailuresAreReportedNotAcknowledged` (`core/frontend/ublk/dispatch_test.go`) | — | ACTIVE | | `INV-FE-LINEAGE-GATE-001` | Every `Read`, `Write` and `Sync` re-checks `{volume, replica, epoch, endpoint version}` and health against the current projection; any drift returns `ErrStalePrimary`. The volume-ID comparison is code reading: no cited test varies the volume ID. | M3 Primary → Supporting \| Excluded (I/O side) | `core/frontend/durable/storage_adapter.go` `gate`, `lineageCheck` | `TestT3a_StorageBackend_FenceCheck_Epoch`, `TestT3a_StorageBackend_FenceCheck_EV`, `TestT3a_StorageBackend_FenceCheck_Replica`, `TestT3a_StorageBackend_FenceCheck_Healthy` (`core/frontend/durable/storage_adapter_test.go`); `TestG8A_SupersedeFact_FencesOldPrimaryDurableBackend` (`core/host/volume/g8a_stale_fence_test.go`) | — | ACTIVE |