pingqiuandClaude Opus 4.7 de2dceaf32 recovery+transport: pre-decision integration helpers (P2d-parallel)
Two parallel-safe wiring helpers that don't lock in the dual-lane
wire-body format (P2d still architect-gated) but unblock the
production wiring sequence so the format swap, when it lands, is
mechanical.

transport.BlockExecutor.SnapshotEmitContext(replicaID):
  - Accessor that returns the per-replica WalShipper's current
    (emitConn, emitLineage) under emitCtxMu — same lock discipline
    as production EmitFunc.
  - Honest signal when no entry exists: returns (nil, zero) so
    callers can pass through to NewRecoverySink as the steady-
    restore values without a special case.
  - Canonical caller pattern (P2d-post): snapshot BEFORE
    constructing RecoverySink → pass to NewRecoverySink as the
    steady context → EndSession's rule-2 restore lands the right
    values.

recovery.PrimaryBridge.StartRebuildSessionWithSink(...):
  - New entry point that accepts an external WalShipperSink (e.g.,
    transport.RecoverySink wrapping the per-replica WalShipper).
  - Existing StartRebuildSession unchanged — continues to use the
    bridging senderBacklogSink path (legacy compatible).
  - Internal startRebuildSessionLocked is shared between the two
    public methods; switches between NewSenderWithBacklogRelay and
    NewSenderWithSink based on whether sink is nil.
  - Fail-closed: nil sink → explicit error (callers that want the
    bridging path call StartRebuildSession explicitly).

Tests:
  + TestSnapshotEmitContext_NoEntry_ReturnsZero
  + TestSnapshotEmitContext_AfterUpdate_ReturnsCurrent
  + TestSnapshotEmitContext_ThenRecoverySink_RestoresCaptured —
    end-to-end of the canonical wiring pattern: snapshot → build
    sink with snapshotted steady → run session → assert restored
    context matches snapshot.
  + TestPrimaryBridge_StartRebuildSessionWithSink_NilRejected
  + TestPrimaryBridge_StartRebuildSessionWithSink_InvokesSinkLifecycle —
    sink receives StartSession + DrainBacklog + EndSession in order
    when invoked through the bridge's public surface.
  + TestPrimaryBridge_StartRebuildSession_StillUsesBridgingSink —
    regression: legacy entry point still installs senderBacklogSink.

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

Production enable still requires P2d (wire body format / applier
owner / replay source). These helpers are "ready but not switched
on" — calling StartRebuildSessionWithSink today would produce a
wire-format mismatch on the dual-lane port (executor's EmitFunc
encodes MsgShipEntry; recovery.Receiver decodes frameWALEntry).
The §10 decision request on seaweedfs/feature/sw-block resolves
that.

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