pingqiuandClaude Opus 4.7 3b54576e2f T4c-2: catch-up muscle port + state machine + ScanLBAs interface seam
Per design memo §7a + G-1 V2 read signed at v3-phase-15-t4c-2-g1-v2-read.md.
Round-35 architect collapse: T4c-2 covers walstore wal_replay inner-loop
muscle port (V2-faithful, narrow G-1 scope), smartwal state_convergence
production promotion, peer state machine extensions (CatchingUp /
NeedsRebuild), and observability surfacing.

Storage substrate (G-1 §3 row #4 — interface seam):
- Unified RecoveryEntry + ErrWALRecycled + RecoveryMode types in
  core/storage/recovery_contract.go (memo §5.1, §13.0a)
- LogicalStorage.ScanLBAs interface method added; substrate dispatch
  is via interface, not type-switch
- walstore POC promoted: walstore_recovery_poc.go → walstore_recovery.go;
  ScanFrom → ScanLBAs; uses unified storage.RecoveryEntry
- smartwal POC promoted: recovery_poc.go → recovery_scan.go;
  ScanFrom → ScanLBAs; type alias to storage.RecoveryEntry
- BlockStore implements ScanLBAs (state-convergence-equivalent
  synthesis since in-memory has no WAL retention; uses walHead as
  scan-time LSN so caller's targetLSN cap doesn't accidentally skip
  every entry)

Catch-up sender muscle port (G-1 §3 narrow-scope inner loop):
- core/transport/catchup_sender.go body rewritten: replaces
  AllBlocks-walk with primaryStore.ScanLBAs(0, fn) + per-entry
  ShipEntry write
- INV-REPL-CATCHUP-CALLBACK-RETURN-NIL-CONTINUES honored: callback
  skips entries past targetLSN by returning nil (not error)
- INV-REPL-CATCHUP-LASTSENT-MONOTONIC honored: lastSent only
  advances after successful frame write
- INV-REPL-CATCHUP-DEADLINE-PER-CALL-SCOPE honored: SetDeadline at
  entry, cleared at exit (deferred)
- INV-REPL-CATCHUP-TARGET-NOT-REACHED-VS-RECYCLED-DISTINGUISHED:
  ErrWALRecycled wrapped as tier-class change; target-not-reached
  surfaces as separate stream-level error
- INV-REPL-CATCHUP-COMPLETION-FROM-BARRIER-ACHIEVED-LSN (§4.2
  binding): completion judged from BarrierResponse.AchievedLSN, not
  from a separate MsgCatchupDone marker; recovery_mode label
  surfaces in success log per memo §5.1

Engine (G-1 §4.1, §4.3):
- RecoveryRuntimePolicy.MaxRetries field added; per-kind defaults
  match V2 maxCatchupRetries=3 (wal_delta), 0 (full_extent), 1
  (partial_lba)
- applySessionFailed maps ErrWALRecycled in failure reason →
  recovery.Decision = Rebuild (G-1 §4.3 Option B); engine→storage
  decoupling preserved by string-match on the sentinel text rather
  than importing storage package

Peer state machine (memo §2.2):
- ReplicaCatchingUp + ReplicaNeedsRebuild states added
- SetState method with table-driven replicaStateTransitionAllowed
  gate; rejects illegal transitions (NeedsRebuild is terminal in
  T4c per memo)

Tests (15 new):
- core/transport/catchup_sender_test.go (8 tests: 2 V2-mirror +
  6 invariant pins for §5.1-§5.5 + §4.2 binding + sentinel + mode-label)
- core/replication/peer_state_machine_test.go (4 tests: allowed
  transitions, rejected transitions, NeedsRebuild terminal,
  String forms)
- core/engine/recovery_test.go (3 new: MaxRetries per-kind defaults
  pin, WAL-recycled escalation pin, non-recycled non-escalation
  pin)

go test ./... -count=1 → all 21 packages green.

Catalogue invariants queued for §3.3 inscription at T4c batch close:
INV-REPL-CATCHUP-CALLBACK-RETURN-NIL-CONTINUES,
INV-REPL-CATCHUP-LASTSENT-MONOTONIC,
INV-REPL-CATCHUP-DEADLINE-PER-CALL-SCOPE,
INV-REPL-CATCHUP-TARGET-NOT-REACHED-VS-RECYCLED-DISTINGUISHED,
INV-REPL-CATCHUP-RECYCLE-ESCALATES,
INV-REPL-CATCHUP-COMPLETION-FROM-BARRIER-ACHIEVED-LSN,
INV-REPL-PEER-STATE-CATCHINGUP,
INV-REPL-RECOVERY-MODE-OBSERVABLE.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 02:59:53 -07:00
Languages
Go 84.5%
Rust 7.9%
Shell 2.7%
templ 1.6%
Java 1%
Other 2%