pingqiuandClaude Opus 4.7 a96373dda9 transport: pin protection + ack-feedback advance + release tests
Pins the user-stated architectural invariant:

  Steady: WalShipper handles NotifyAppend (recv) + emit (peer).
  Recovery session: pin floor PROTECTED at fromLSN so substrate WAL
    retention can't recycle entries the session still needs.
  Pin advances via FEEDBACK: replica BaseBatchAck → recovery.Sender
    readerLoop → coord.SetPinFloor → pin advances; substrate may
    now recycle below the new floor.
  Session end: pin released.

Tests:

  + TestPin_ProtectedDuringSession_AdvancesViaFeedback_ReleasedOnEnd —
    full single-replica lifecycle:
      1. coord.StartSession → pin = fromLSN
      2. RecoverySink.StartSession → WalShipper Backlog;
         pin still = fromLSN (shipper mode change must NOT move pin)
      3. coord.SetPinFloor(replica, ackLSN, S) — simulates
         readerLoop's BaseBatchAck translation; pin advances
      4. Out-of-order lower-LSN ack: pin must NOT regress
      5. RecoverySink.EndSession → shipper Realtime;
         pin survives (sink.EndSession is shipper-side, doesn't
         release coord pin)
      6. coord.EndSession → pin released to 0

  + TestPin_MultiSession_MinPinAcrossActiveSessions — cluster-wide
    invariant: WAL retention gated by min pin across all active
    sessions. Slow replica's pin floors the whole cluster; fast
    replicas advancing past it don't unlock recycling. After all
    sessions end, anyActive=false and no floor is enforced.

Together these confirm the user's architecture: WalShipper-side
mode transitions and coord-side pin lifecycle are orthogonal —
sink.EndSession ≠ session-pin-release; only coord.EndSession
releases. Production callers (recovery.Sender.Run defer) call BOTH
on every exit path, which is what the existing wiring already does.

go test ./core/recovery/ ./core/transport/ ./core/replication/{,component} —
all PASS (no regressions; 2 new tests).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 00:49:04 -07:00
Languages
Go 84.7%
Rust 7.7%
Shell 2.7%
templ 1.5%
Java 1%
Other 2.2%