pingqiuandClaude Opus 4.7 32b16004fa feat(recovery): §IV.2.1 marker-only slice — PrimaryWalLegOk observation + cutID
First behavioral wave of the recover(a) migration now that Gate G0 is
closed. OBSERVABILITY ONLY — no completion-predicate replacement,
no semantic change to BarrierReq emission gating. The recover(a,b)
band path stays GREEN as today; this commit adds the §IV.2.1
PrimaryWalLegOk observation tuple and Option B cutID counter so QA's
hardware oracle (§8.2.6) can wire round-trip grep in parallel with
A/B/C-class implementation.

Anti-discipline checks (§8.2.8) honored:
  - All 5 marker fields per the §8.2.6 schema (no simplification).
  - Conformance stubs in core/recovery/recover_a_conformance_test.go
    remain SKIPPED — predicate replacement is the A-class wave.

Substrate changes:

  WalShipper (core/transport/wal_shipper.go):
    + firstLiveEmitted atomic.Bool — set on first EmitKindLive emit
      (fast-path or post-CASE-A residual); reset on StartSession.
      Implements PrimaryLiveTail's per-session monotonic property.
    + ProbeBarrierEligibility() — single-shot snapshot under shipMu
      returning (debtZero, liveTail, walLegOk, cursor, head). The
      §IV.2(2) guard is simplified at this layer to "ever emitted
      Live" — component-layer exercises the real guard.

  RecoverySink (core/transport/recovery_sink_adapter.go):
    + ProbeBarrierEligibility delegate — duck-types the
      barrierEligibilityProbe interface in core/recovery so the
      dual-lane production path can populate marker logs.

  PeerShipCoordinator (core/recovery/peer_ship_coordinator.go):
    + barrierAttempt counter on peerShipState — increments per
      NextBarrierCut call within a session; resets to 0 at
      StartSession (per architect Option B in plan §8.2.6).
    + NextBarrierCut(replicaID) (cutID, error) — first call per
      session yields 1; pre-§IV.2.4 wire change this is a
      coordinator-local sequence; post-C-class it becomes the
      wire CheckpointCutSeq with no log-prefix change.

  Sender.Run (core/recovery/sender.go):
    + barrierEligibilityProbe interface (optional, sink-side).
    + Two log lines per BarrierReq round-trip (5 fields each per
      §8.2.6 schema):
        replication: barrier prepare replica=<id> sessionID=<n>
          cut=CCS:<cutID> PrimaryDebtZero=<bool> LiveTail=<bool>
          WalLegOk=<bool> cursor=<n> head=<n>
        replication: barrier handshake cut=CCS:<cutID>
          achieved=<n> match=<bool>
      Pre-C-class `match=true` unconditionally — the same cutID
      flows from prepare to handshake by construction. Post-C-class
      becomes the real wire-vs-engine compare.
    + Markers fire only on the dual-lane production path (sink
      implements barrierEligibilityProbe); bridging-sink path
      doesn't emit them — pre-§IV.2.1 markers are dual-lane-only
      per the §8.2.6 hardware oracle scope.

Tests:

  core/transport/probe_barrier_eligibility_test.go (new):
    - FreshShipper_DebtZero — at construction, cursor==head==0,
      walLegOk via debtZero.
    - LiveEmitFlipsLiveTail — fast-path Live emit sets liveTail
      monotonically.
    - StartSessionResetsLiveTail — per-session monotonic reset
      contract.

  core/recovery/peer_ship_coordinator_test.go:
    + TestCoordinator_NextBarrierCut_MonotonicPerSession —
      first-call-yields-1, monotonic increment, per-session reset
      on StartSession-after-EndSession.

What this commit does NOT do (waiting for A-class wave):
  - Replace `walApplied >= TargetLSN` predicate in TryComplete.
  - Replace `achievedLSN >= targetLSN` in CanEmitSessionComplete.
  - Replace Sender.Run's success-path FailureContract on
    `achieved < target`.
  - Add CheckpointCutSeq to BarrierReq/Resp wire payload.
  - Un-skip conformance stubs.

Each of those is its own slice that turns ≥1 conformance stub
SKIP→GREEN as it lands.

Refs: recover-semantics-adjustment-plan.md §8.2 / §8.2.6
(Option B cutID); v3-recovery-algorithm-consensus.md §IV.2.1
(PrimaryDebtZero / LiveTail / WalLegOk); §I P8 (recover(a) vs
recover(a,b)). Companion to the QA→SW handoff commits 599f60e /
a08dea1 / faafa46.

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