pingqiu 5b097689ad G6 §1.H code-start audit: PROCEED-with-minor-patch verdict
Per G6 mini-plan v0.1 §2 #1, sw publishes audit findings as a
commit note before any production code change.

AUDIT METHOD: greped seaweed_block/core/{storage,transport,engine}
+ cmd/blockvolume for the WALRecycled chain; cited apply.go +
recovery_session.go + walstore_recovery.go line numbers as evidence.

PER-INV FINDINGS:

[1] Substrate-layer WALRecycled production
    Location: core/storage/walstore_recovery.go:72-73 +
    core/storage/smartwal/recovery_scan.go:96-97
    Both walstore + smartwal return
    storage.NewWALRecycledFailure(ErrWALRecycled, detail) — TYPED
    *RecoveryFailure envelope (NOT bare sentinel). Status: ✅ wired.

[2] Transport-layer mapping (storage error → engine kind)
    Location: core/transport/recovery_session.go:35-48
    classifyRecoveryFailure uses errors.As(err, &rf) to extract
    StorageRecoveryFailureWALRecycled → engine.RecoveryFailureWALRecycled.
    Called from core/transport/executor.go:520 at finishSession.
    Status: ✅ wired.

[3] Engine-layer dispatch (RecoveryFailureWALRecycled → StartRebuild)
    Location: core/engine/apply.go:applySessionFailed lines 519-547
    On e.FailureKind == RecoveryFailureWALRecycled:
      - Decision = DecisionRebuild
      - RebuildPinned = true
      - Attempts = 0
      - Emit PublishDegraded (diagnostic surface)
      - Emit StartRebuild IMMEDIATELY (provided !hasActiveSession,
        which holds at this point because Phase just set to
        PhaseFailed)
    Cited INV: INV-REPL-REBUILD-EMITTED-ON-WAL-RECYCLED.
    Status: ✅ wired.

[4] Runtime per-peer dispatch (engine command → wire)
    Location: G5-5C Batch #7 PeerCommandExecutor +
    PeerAdapterRegistry (core/host/volume/peer_*).
    PeerCommandExecutor.StartRebuild → transport.BlockExecutor.
    StartRebuild → wire-level rebuild_sender.
    Status: ✅ wired (verified by G5-5C component test
    g5_5c_restart_catchup_test.go which exercised the rebuild
    branch on smartwal store).

[5] --wal-retention-* flag
    Location: cmd/blockvolume/main.go (parseFlags)
    Status: ❌ NOT PRESENT. Must be added for §1.A α binding.
    Plumbing: flag → durable provider construction → walstore /
    smartwal recovery_scan. Estimate: ~40 LOC across 3 files.

[6] Current retention mechanism
    walstore.go is append-only (no physical wraparound; no
    Truncate calls beyond initial file resize). The 'recycle' is
    purely the checkpointLSN-based logical gate at recovery scan
    time. To implement α: relax walstore_recovery.go:67 from
    'fromLSN <= checkpointLSN' to 'fromLSN <= checkpointLSN -
    retentionLSNs'. Mirror in smartwal/recovery_scan.go.

QA D OBSERVATION INTERPRETATION:
The 'no rebuild dispatch in 5s window' observation is most likely
(a) — existing-and-correct chain — combined with (i) rebuild
execution time on the wire exceeds 5s for the scenario, AND
(ii) no explicit 'rebuild starting' log line exists today; only
'executor: rebuild complete, sent N blocks' fires AFTER completion.
This is a TEST DESIGN issue (window too short + no start marker),
not a missing dispatch. G6 hardware step #5 fixes both via:
- wait_until_rebuild_dispatched helper polling for new marker
- new log marker at rebuild session START in rebuild_sender.go

OVERALL VERDICT: PROCEED-with-minor-patch.

§1.H halt-condition: NOT triggered. The engine FSM + transport
mapping + substrate envelope + runtime per-peer dispatch are all
already wired and tested individually. The gap is at the
operability boundary, not the recovery substrate.

WORK ENVELOPE (per §1.A α + §1.H findings):
1. Add --wal-retention-lsns flag in cmd/blockvolume/main.go
   (~10 LOC). Default value TBD — recommend 10000 LSNs.
2. Plumb retention into walstore.New + smartwal.openInitialized
   constructors (~15 LOC).
3. Relax recovery scan gate to honor retention (~10 LOC each
   in walstore_recovery.go + smartwal/recovery_scan.go).
4. Add explicit rebuild-START log marker in
   transport/rebuild_sender.go (~5 LOC) so QA's
   wait_until_rebuild_dispatched helper has a deterministic
   marker (NOT just rebuild-complete which fires post-run).
5. Add engine-layer table-driven test pinning
   RecoveryFailureWALRecycled → Decision=Rebuild +
   RebuildPinned=true + StartRebuild emit; negative case for
   Transport / SubstrateIO failure kinds (~80 LOC test).
6. Add walstore + smartwal substrate test for retention gate
   (fromLSN within retention → scan succeeds; fromLSN past
   retention → ErrWALRecycled) (~40 LOC test).
7. New INV inscribed: INV-G6-RETENTION-POLICY-OPERATOR-VISIBLE
   (per §1.A α) + INV-G6-WALRECYCLE-DISPATCHES-REBUILD +
   INV-G6-CATCHUP-CONVERGES-WITHIN-RETENTION +
   INV-G6-ENGINE-NO-REBUILD-PINNED-ON-OTHER-FAILURES.

TOTAL ESTIMATE: ~160 LOC production + ~120 LOC tests.

NEXT STEPS:
- sw: code per work envelope above. First commit: rebuild-START
  log marker (unblocks QA harness work). Then: --wal-retention-lsns
  flag + plumbing. Then: tests.
- QA: now unblocked to write wait_until_rebuild_dispatched helper
  + extend D-scenario script for §2 #4 + #5 in single run per #6.

This audit fulfills §2 #1 (audit-published-as-commit-note before
production code change).
2026-04-28 01:44:00 -07:00
Languages
Go 84.6%
Rust 7.8%
Shell 2.7%
templ 1.6%
Java 1%
Other 2%