Per T4d mini-plan v0.4 §2.4 expanded scope. Part A of three: smaller
substrate cleanups + lifecycle hardening land first; Path B fold
(ReplicationVolume↔adapter wiring + WithEngineDrivenRecovery real)
follows as part B; Windows cleanup + L2 matrix as part C.
T4c §I row 6 closure (RecoveryMode interface method):
- core/storage/logical_storage.go — add RecoveryMode() to
LogicalStorage interface (returns substrate's tier-1 sub-mode
per memo §5.1 / §13.0a)
- core/storage/store.go BlockStore.RecoveryMode() →
RecoveryModeStateConvergence (in-memory; ScanLBAs synthesizes)
- core/storage/walstore.go WALStore.RecoveryMode() →
RecoveryModeWALReplay (V2-faithful per-LSN)
- core/storage/smartwal/store.go Store.RecoveryMode() →
RecoveryModeStateConvergence (per-LBA dedup)
- core/transport/catchup_sender.go — replace duck-typed
CheckpointLSN probe with e.primaryStore.RecoveryMode() interface
call. Forwards cleanly through component framework wraps via
embedded LogicalStorage.
- core/replication/component/faults.go godoc — replace stale
"MASKED by wrap" limitation note with T4d-4 closure note;
AssertSawRecoveryMode now works correctly under wraps
T4d-4 lifecycle (BUG-005 non-repeat):
- core/replication/volume.go — Stop() canonical entry point added
(delegates to existing Close); semantic clarity over Close().
Both methods are equivalent in T4d-4; Stop() is the named entry
for "stop volume lifecycle activity" while Close() retained for
backward compatibility. Future expansions (drain pending I/O,
stop background goroutines) land in Stop().
- INV-REPL-LIFECYCLE-HANDLE-BORROWED-001 pinned by
TestReplicationVolume_Stop_DoesNotCloseBorrowedStore: store is
STILL usable after volume.Stop (substrate handle is borrowed,
never closed by us — BUG-005 discipline)
- TestReplicationVolume_Stop_Idempotent: second + later Stop calls
are no-ops returning nil
- TestReplicationVolume_Stop_TearsDownPeers: empty-set lifecycle pin
Tests added (5 new):
- TestReplicationVolume_Stop_Idempotent
- TestReplicationVolume_Stop_DoesNotCloseBorrowedStore
- TestReplicationVolume_Stop_TearsDownPeers
- TestStorageRecoveryMode_BlockStore_StateConvergence
- TestStorageRecoveryMode_Walstore_WALReplay
- TestStorageRecoveryMode_LogicalStorageInterface_HasMethod
(compile-time fence pinning RecoveryMode is on the interface,
not just on substrate impls)
NOT in part A (deferred to part B / C):
- ReplicationVolume↔adapter wiring (Path B fold, part B)
- WithEngineDrivenRecovery real binding (Path B fold, part B)
- Full L2 integration matrix (part C)
- Windows TempDir cleanup race (part C)
- Test rename per kickoff §5 (part C)
- sessionID coordination (T4c §I row 5; part C — minor)
22 packages green; 0 failures. Forward-carries: T4c-2 + T4d-1 +
T4d-2 + T4d-3 invariants all green; new RecoveryMode plumbing
preserves T4c-2 INV-REPL-RECOVERY-MODE-OBSERVABLE.
Refs: T4d mini-plan v0.4 §2.4 (architect-ratified expanded scope);
T4c §I row 6 (substrate RecoveryMode method); kickoff §2.1 (BUG-005
non-repeat lifecycle); G-1 sign 80036404c (G-1 v0.2 + planning
artifacts).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
QA round-39 Stage 1 flagged 4 framework gaps blocking deferred
scenarios. This commit closes 3 of 4 with primitives + demos;
4th (engine-driven recovery) is API-stubbed pending T4d wiring.
Closed gaps:
(1) WithPrimaryStorageWrap(fn) builder option
- Cluster.WithPrimaryStorageWrap installs a substrate transform
before BlockExecutors bind; wraps may override any LogicalStorage
method. Three pre-built wraps in faults.go:
- NewRecycledScanWrap() — always returns ErrWALRecycled
- NewSeverDuringScanWrap(N, err) — emits N entries then severs
- NewObservedScanWrap(*atomic.Int32) — counts emit observations
- Demos: TestComponent_RecycledScanWrap_EscalatesToRebuild,
TestComponent_SeverDuringScan_PartialProgress,
TestComponent_ObservedScanWrap_CountsEmits
(2) Live-ship primitive driving ReplicationVolume.OnLocalWrite
- Cluster.WithLiveShip() builder option spins up StorageBackend +
ReplicationVolume; configured replicas auto-registered as peers
- PrimaryWriteViaBackend(lba, data) writes through the production
data-plane entry → WriteObserver hook → fan-out to replicas
- PrimaryWriteViaBackendN(n) batch helper
- Demo: TestComponent_LiveShip_PrimaryWriteViaBackend_FansOut
(4) Mid-stream drop helper SeverDuringScan
- Implemented as NewSeverDuringScanWrap above; counts entries via
atomic.Int32 inside the substrate wrap and returns the configured
sever error after N successful emits
- Robust to substrates with fewer than N entries (no-op rather than
fail-closed, so scenarios are emit-count-tolerant)
API-stubbed for T4d:
(3) WithEngineDrivenRecovery() — option records intent, emits a
one-shot t.Logf warning at Start, runs as direct-executor mode.
Forward-carry: when T4d wires ReplicationVolume↔adapter, this
option swaps the adapter-aware constructor in. Demo:
TestComponent_EngineDrivenRecovery_StubWarning pins the API
shape so scenarios authored today won't need to change when
behavior lands.
Known limitation documented in faults.go: substrate-extension
methods (e.g. walstore.CheckpointLSN) are MASKED by the wrap
because Go embedding only exposes interface methods. The catch-up
sender's recovery_mode label probe duck-types CheckpointLSN; under
a wrap, it always sees state_convergence regardless of underlying
substrate. Forward-carry: refactor mode-label detection behind a
substrate-reported RecoveryMode() method that wraps can forward.
5 new demos = 9 matrix rows (smartwal+walstore where applicable).
go test ./... -count=1 → 22 packages green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>