pingqiu ca21ed83d3 G6 #2-5: --wal-retention-lsns flag + walstore retention gate + tests
Per G6 §1.A α binding (architect 2026-04-29) + §1.H audit
PROCEED-with-minor-patch verdict at seaweed_block@5b09768.

§1.A α implementation (operator-tunable WAL retention window):

- core/storage/walstore.go (+27 LOC): new field
  recoveryRetentionLSNs uint64 + SetRecoveryRetentionLSNs/
  RecoveryRetentionLSNs accessors. Zero (default) preserves
  pre-G6 strict checkpoint-driven recycle.

- core/storage/walstore_recovery.go (+15 LOC, 8 LOC reshape):
  recovery scan gate relaxed from
    if fromLSN <= checkpointLSN
  to
    floor = checkpointLSN - retentionLSNs (saturating to 0)
    if fromLSN <= floor
  Boundary semantic preserved: == floor is rejected, > floor
  accepted. Diagnostic detail string extended with retentionLSNs
  + floor for forensics.

- core/frontend/durable/provider.go (+22 LOC): new ProviderConfig
  field WALRetentionLSNs; plumbed into both openExisting (line 346)
  and createFresh (line 374) walstore paths via
  ws.SetRecoveryRetentionLSNs. ImplSmartWAL ignores the flag
  (ring capacity bounds retention; documented in godoc).

- cmd/blockvolume/main.go (+12 LOC, 1 reshape):
  --wal-retention-lsns flag (uint64, default 0). Help text
  documents substrate-specific semantics (walstore honors;
  smartwal sizes via --durable-blocks). Plumbed into
  durable.ProviderConfig.WALRetentionLSNs.

§2 #3 engine table-driven dispatch test:

- core/engine/g6_walrecycle_dispatch_test.go (NEW, ~190 LOC):
  TestG6_SessionFailed_DispatchByFailureKind_TableDriven (3
  subcases): WALRecycled → Decision=Rebuild + RebuildPinned=true
  + StartRebuild emit; Transport / SubstrateIO → no rebuild pin,
  retry catch-up.
  TestG6_RebuildPinned_StaysSticky_AcrossProbe: post-WAL-recycled
  pin survives a fresh probe that would classify as catch-up;
  Decision stays Rebuild; no StartCatchUp emit.
  TestG6_WALRecycled_PublishDegradedSurfaceFires: PublishDegraded
  AND StartRebuild emit on the same Apply (operator-visible
  signal alongside recovery dispatch).

§2 substrate retention-gate tests:

- core/storage/walstore_retention_test.go (NEW, ~150 LOC):
  4 tests covering Default/Zero=strict-recycle (pre-G6 baseline),
  NonZero=widens window with floor=checkpoint-retention,
  LargerThanCheckpoint=clamps to 0 (saturating subtraction),
  TypedFailureKind=*RecoveryFailure envelope preserved (load-
  bearing for transport's classifyRecoveryFailure path).

Test results:
- core/storage/ TestWALStore_RecoveryRetention_*: 4/4 PASS
- core/engine/ TestG6_*: 3 tests + 3 subcases = 6/6 PASS
- Full ./... regression: in progress (will report after).

Pinned by:
- INV-G6-RETENTION-POLICY-OPERATOR-VISIBLE (§2 #2 + #4 hardware
  retention-OK case)
- INV-G6-CATCHUP-CONVERGES-WITHIN-RETENTION (§2 #4 hardware)
- INV-G6-WALRECYCLE-DISPATCHES-REBUILD (§2 #3 engine + #5 hardware)
- INV-G6-ENGINE-NO-REBUILD-PINNED-ON-OTHER-FAILURES (§2 #3 negative
  control: Transport / SubstrateIO do NOT pin rebuild)

Halt-condition NOT triggered. Full audit plumbing was already in
place (T4d-1 typed envelopes + T4d-1 transport mapping + apply.go
WALRecycled branch); G6 #2-#5 add only the operator knob, the
substrate gate relaxation, and the test pins.

Next: QA harness extension (wait_until_rebuild_dispatched)
unblocked by commit #1's rebuild-START log marker; D-scenario
extended for §2 #4 + #5 single-run per §2 #6.
2026-04-28 02:02:44 -07:00
Languages
Go 84.5%
Rust 7.9%
Shell 2.7%
templ 1.6%
Java 1%
Other 2%