Commit Graph
7 Commits
Author SHA1 Message Date
pingqiu bd6f475b9b transport: advance live ship cursor after recovery 2026-05-01 23:53:34 -07:00
pingqiu ccc3ca6cb3 transport: route live WAL through single feed ingress 2026-05-01 23:24:55 -07:00
pingqiu 8c4aa52392 transport: refresh live ship session after recovery 2026-05-01 22:27:21 -07:00
pingqiu 3ccf2ec729 transport: gate live WAL through active recovery session 2026-05-01 22:03:12 -07:00
pingqiuandClaude Opus 4.7 a08dea1574 test: legacy header annotation per §8.2.4 — recover(a,b) band marker
Commit 2 of the QA→SW handoff (`recover-semantics-adjustment-plan.md`
§8.2.7 step 3). Header-only annotation pass on the 19 _test.go
files in seaweed_block that reference `targetLSN` or `walApplied`
as completion-authority terms (discovery: `grep -rlE
'targetLSN|walApplied' --include='*_test.go' core/`).

Each file gets a 2-line header right after the package decl,
verbatim per §8.2.4:

    // Completion oracle: recover(a,b) band — NOT recover(a) closure.
    // See sw-block/design/recover-semantics-adjustment-plan.md §8.1.

Six of the 19 are deeply primary.H-bound (assertions tied to
`replica.H == primary.H` or `achieved == primary.H`) and get an
extra `migrate-candidate` line per §8.2.4:

    // migrate-candidate: depends on primary.H semantics, see §8.1 Tier-5 migration

The migrate-candidate set:
  - core/transport/pillar2_assembled_test.go
  - core/transport/pillar3_convergence_test.go
  - core/transport/walshipper_pin_protection_test.go
  - core/transport/transport_test.go
  - core/transport/catchup_sender_test.go
  - core/recovery/e2e_test.go

Anti-discipline checks (§8.2.8) honored:
  - No assertion changes — header text only.
  - migrate-candidate kept on its own line, not merged with the
    standard 2-line annotation.

Note on count: §8.2.4 cited "~95 files" against the broader audit
pattern (TargetLSN/AchievedLSN/FrozenTarget/TryComplete). The
narrower §8.2.4 grep (targetLSN|walApplied) targets the actual
completion-authority surface and yields 19 files in the
seaweed_block tree. Build + tests clean post-annotation.

Source: sw-block/design/recover-semantics-adjustment-plan.md §8.2.4.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 13:07:00 -07:00
pingqiu 1c6dc56107 T4b-3: ReplicaPeer.Barrier + Fence wrappers (peer-level seam)
New leaf task introduced by QA round-23 §0-B review. T4b-3 originally
planned for ReplicaPeer.Fence-only; QA's peer-state-mutation locality
check surfaced that DurabilityCoordinator must consume peer.Barrier
(not peer.executor.Barrier) so the error → Invalidate translation
lives at the per-peer execution layer — matching V2's WALShipper-
internal markDegraded locality. T4b-3 now ships both Barrier + Fence
wrappers as a leaf before the T4b-4 DurabilityCoordinator muscle port.

Invariant pinned: INV-REPL-BARRIER-FAILURE-DEGRADES-PEER at the V3
per-peer layer, mirroring T4a-3's Ship → Invalidate translation.

Changes:

  core/transport/executor.go
    Extract FenceSync(replicaID, lineage) error — synchronous fence
    exchange returning a descriptive error on any dial / send /
    recv / lineage-mismatch failure. Refactored existing async
    doFence to wrap FenceSync + adapt the error to the callback-
    based FenceResult. Behavior unchanged for existing async
    callers (engine recovery path); T4b-3 peer wrapper gets a
    clean sync surface.

  core/replication/peer.go
    New ReplicaPeer.Barrier(ctx, targetLSN):
      - Passes peer.lineage UNCHANGED to executor.Barrier — does
        NOT override lineage.TargetLSN with the caller's targetLSN.
        Replica's acceptMutationLineage rejects same-authority
        messages that change TargetLSN, so override would self-
        reject. Caller's targetLSN is coordinator-layer-only
        (compared against ack.AchievedLSN for mode arithmetic).
      - MUST NOT gate on state == Degraded per V2 "always attempt
        BarrierAll" invariant (architect §4.3 note in G-1 doc).
        Only post-Close gate applies.
      - On transport error: p.Invalidate(reason) + state=Degraded
        (INV-REPL-BARRIER-FAILURE-DEGRADES-PEER pin).
    New ReplicaPeer.Fence(ctx, lineage):
      - Takes caller-supplied lineage (not peer-owned) because
        fence semantic is "confirm this specific authority tuple"
        — coordinator or recovery path chooses which lineage.
      - Delegates to executor.FenceSync.
      - Same error → Invalidate translation.

Tests (5 required per QA spec):

  - TestReplicaPeer_Barrier_Happy — round-trip against real
    ReplicaListener; ack.Lineage == peer.lineage byte-exact;
    state remains Healthy
  - TestReplicaPeer_Barrier_ErrorPropagates_MarksDegraded —
    unreachable replica; Barrier returns error; peer transitions
    Healthy → Degraded. INV-REPL-BARRIER-FAILURE-DEGRADES-PEER
    pin at peer layer.
  - TestReplicaPeer_Fence_Happy — fence exchange at peer.lineage
    against real replica; state stays Healthy
  - TestReplicaPeer_Barrier_AfterClose_Errors — post-Close call
    returns 'closed' error; no panic
  - TestReplicaPeer_Fence_AfterClose_Errors — post-Close call
    returns 'closed' error; no panic

Verification: full 21-package repo suite green. G-2 tri-line godoc
on Barrier, Fence (Called by / Owns / Borrows) + FenceSync on
executor. G-3 cumulative. Existing T4b-2 Fence tests pass after the
doFence → FenceSync refactor (behavior preserved).

Third task in T4b batch. Next: T4b-4 DurabilityCoordinator (muscle
port; G-1 pre-signed by QA in revised artifact at sw-block/design/
v3-phase-15-t4b-4-g1-v2-read.md) against the peer.Barrier surface.
2026-04-23 18:51:49 -07:00
wzcheng99 debeb55f28 T4a-3: ReplicaPeer (leaf) — per-replica runtime handle
Introduces core/replication/ package and ReplicaPeer — the per-remote-
replica runtime handle that bridges ReplicationVolume fan-out (T4a-4)
to the transport layer (T4a-2). T4a-3 is the Opt-4 leaf: ships first,
then ReplicationVolume consumes it.

Surface (~220 LOC production + 230 LOC tests):
  - ReplicaTarget: authoritative addressing + lineage from master
    assignment (Epoch, EndpointVersion, DataAddr, ControlAddr).
  - ReplicaState: Unknown / Healthy / Degraded. T4a scope only;
    CatchingUp / Rebuilding / NeedsRebuild arrive at T4c with the
    recovery pipeline.
  - NewReplicaPeer: registers a live-ship session in the executor
    using a fresh peer-local SessionID + target.{Epoch,
    EndpointVersion} + constant liveShipTargetLSN = 1. Steady-state
    live-ship session; recovery-bound sessions (with engine-frozen
    TargetLSNs) arrive at T4c.
  - ShipEntry: state-gated fan-out leaf. Healthy → executor.Ship;
    Degraded / closed → reject at peer without dialing. On Ship
    error: mark Degraded + log reason (forward-carry CARRY-1 from
    T4a-2). Caller-supplied lineage is informational for T4a (peer
    owns its session); T4b/T4c may tighten when recovery sessions
    thread through.
  - Invalidate: explicit Healthy → Degraded mutation for authority-
    driven peer-down (no-op on closed peer).
  - Close: idempotent; invalidates the peer's executor session via
    InvalidateSession. Does NOT close the executor — caller owns
    executor lifecycle (BUG-005 discipline).

BlockExecutor gets one new public method:
  - RegisterLiveShipSession(lineage): thin wrapper around internal
    registerSession, needed because ReplicaPeer in core/replication
    needs to register its live-ship session from outside
    core/transport. Tri-line godoc contract attached.

Gate G-2: every public symbol in both files carries a Called by /
Owns / Borrows tri-line contract. PR-rejectable if any symbol lacks
the three-line contract.

Forward-carry CARRY-1 closed: ShipEntry → Invalidate + Degraded on
transport error. Pin test TestReplicaPeer_ShipEntry_ConnFailure_
MarksDegraded asserts (a) first Ship returns dial/write error, (b)
state transitions Healthy → Degraded, (c) subsequent ShipEntry is
rejected at peer without touching the wire. This closes catalogue
§3.2.1 C4 from PARTIAL to DONE.

Tests (6, all green):
  - TestReplicaPeer_ShipEntry_Happy — byte-exact arrival, state
    stays Healthy.
  - TestReplicaPeer_ShipEntry_ConnFailure_MarksDegraded — CARRY-1
    pin.
  - TestReplicaPeer_Invalidate_MovesToDegraded — authority-driven
    path.
  - TestReplicaPeer_Close_Idempotent — double-Close is safe;
    post-Close ShipEntry errors with "closed".
  - TestReplicaPeer_NewReplicaPeer_RejectsNilExecutor.
  - TestReplicaPeer_NewReplicaPeer_RejectsZeroAuthority — fails fast
    at construction rather than at first ship when lineage would be
    rejected by replica's acceptMutationLineage.

Per T4a-3 context note: tests drive against a real
*transport.BlockExecutor + real *transport.ReplicaListener, not
against a ReplicationVolume caller stub (Opt-4 leaf ordering).

Full core/transport + core/replication + core/adapter suites green.
G-3 preserved.
2026-04-23 14:44:35 -07:00