pingqiu 602fc0d8ca G5-5C #4: engine boundary tests — dispatch / Case 1 reconnect / lineage stale-event drop / stale-ack guard
Architect Batch #4 review 2026-04-27 ruled the four §2 invariants
(#4 / #11 / #12 / #13) belong at the engine layer, not core/replication/
— "single owner per invariant, don't double-assert in adapter and
engine". Batch 3 already covered the runtime concerns (lifecycle,
cooldown, lock ordering, peer-instance teardown); Batch #4 covers
the truth-layer translations engine performs from probe results
into recovery commands.

Tests (5 tests, 9 subcases, 9/9 PASS):

§2 #4 dispatch (catch-up vs rebuild) — TableDriven:
  - caught_up: R≥H → DecisionNone, no recovery cmd
  - gap_within_wal: R<H, R≥S → DecisionCatchUp + StartCatchUp
  - gap_exceeds_wal: R<S → DecisionRebuild + StartRebuild
  - rebuild_pinned: pin overrides catch-up → StartRebuild
  Mutual exclusion checked on each row (the OTHER cmd must NOT emit).
  No real retention/WAL logic dragged in; pure (R,S,H) input → cmd
  output table.

§2 #11 reconnect Case 1 (identity unchanged):
  Admit at (epoch=1, EV=1) → catch-up running → session fails →
  fresh ProbeSucceeded at SAME (epoch=1, EV=1) → engine still in
  CatchUp at the same lineage. Identity.{Epoch,EndpointVersion}
  pinned unchanged. No StartRebuild emitted (no master re-emit
  needed for Case 1 — pinned by §1.F).

§2 #12 lineage-bump during in-flight recovery:
  In-flight session 42 at epoch=1 → AssignmentObserved at epoch=2
  resets Session/Recovery/Reachability via identityChanged path →
  late SessionClosedCompleted carrying old SessionID=42 must be
  DROPPED. Asserts: Recovery.R does NOT advance, Session.Phase does
  NOT promote to Completed, no PublishHealthy emit. Distinct from
  batch 3's volume-layer Case 2 test (peer-instance replacement);
  this asserts the engine truth layer drops stale-SessionID events.

§2 #13 stale-ack guard (single owner = engine):
  StaleSessionAck_DoesNotPromoteHealth — SessionCompleted with
  AchievedLSN=50 < TargetLSN=100; Recovery.R advances to 50 but
  decide() leaves Decision in CatchUp (R<H), so Healthy gate
  refuses to flip. PublishHealthy NOT emitted.
  StaleSessionAck_FullAchievedDoesPromote — counterpart confirming
  AchievedLSN=H DOES promote (so prior test isn't trivially passing
  via "Healthy never promotes"). PublishHealthy emit confirmed.

Also addresses architect's lock-order reminder #1 from Batch 3 review:
volume.go ConfigureProbeLoop's peersFn comment now states explicitly
"HARD RULE: code on the probe path MUST NOT re-enter v.mu while
holding peer.mu" so any future "peer callback into volume" code is
blocked at review.

Full ./core/engine/ + ./core/replication/ regression: PASS.

Per architect ruling, §2 #14 backoff progression is mathematically
pinned at the peer layer (batch 2); no further integration-layer
re-assertion needed.

Next batch (G5-5C #5): cmd/blockvolume flag wiring + production
probeFn that calls executor.Probe + adapter.OnProbeResult.
2026-04-27 16:28:57 -07:00
Languages
Go 84.5%
Rust 7.9%
Shell 2.7%
templ 1.6%
Java 1%
Other 2%