pingqiuandClaude Opus 4.7 845c81071d transport: RecoverySink adapter scaffolding + rules-1+2 tests
Pre-decision parallel work for P2d (per architect ratification): the
transport-side adapter that satisfies recovery.WalShipperSink by
duck typing, plus integration tests that pin architect P1 review
rules 1+2. No wire-format branching — the adapter inherits whatever
EmitFunc executor.WalShipperFor wired in. P2d resolves MsgShipEntry
vs frameWALEntry; this adapter survives that decision either
unchanged (if "unify on MsgShipEntry") or via swap of the underlying
shipper construction (if "use frameWALEntry on dual-lane port" or
envelope tag).

RecoverySink:
  - NewRecoverySink(executor, replicaID, sessionConn/Lineage,
    steadyConn/Lineage)
  - StartSession: updateWalShipperEmitContext(session) BEFORE
    WalShipper.StartSession (rule 1)
  - DrainBacklog / NotifyAppend: thin delegate
  - EndSession: WalShipper.EndSession FIRST, then
    updateWalShipperEmitContext(steady) (rule 2)

Tests (lifecycle ordering only — no wire decode):
  + TestRecoverySink_StartSession_InstallsSessionContext —
    direct post-condition, white-box check on entry.emitConn /
    emitLineage after StartSession returns.
  + TestRecoverySink_DrainBacklogEmits_UseSessionContext —
    rule 1 indirect: install recording EmitFunc; assert every
    backlog drain emit captures session context. Stale context
    would surface immediately on the first drain emit.
  + TestRecoverySink_EndSession_RestoresSteadyContext —
    rule 2 direct: post-EndSession entry context == steady.
  + TestRecoverySink_NotifyAppendAfterEndSession_UsesSteadyContext —
    rule 2 indirect: post-EndSession Realtime emit captures
    steady context at emit time.
  + TestRecoverySink_FullLifecycle — combined ordering across
    StartSession → DrainBacklog → EndSession → post-session
    NotifyAppend; each phase's emits use the expected context.
  + TestRecoverySink_SatisfiesWalShipperSink — compile-time
    duck-type check via locally re-declared interface (no
    recovery import to keep cycle-free option open).

Recording EmitFunc strategy: replace per-replica WalShipperEntry's
shipper with a fresh one whose EmitFunc reads emitConn/emitLineage
under emitCtxMu (same lock discipline as production) and records
into a slice. This captures the at-emit-time context — the only
honest evidence of rule-1 / rule-2 ordering without coupling to
wire format.

go test ./core/transport/ ./core/recovery/ ./core/replication/{,component} —
all PASS (incl. existing test suite, no regressions).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 23:57:52 -07:00
Languages
Go 84.6%
Rust 7.8%
Shell 2.7%
templ 1.6%
Java 1%
Other 2%