mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
3234476a3a4bf4867348b0415073bd3d658c62ba
Spec-driven test-first work per architect 2026-04-29 ratification:
"先写完让 architect 看看然后写 code". This commit lands ONLY:
- core/transport/wal_shipper.go — initial implementation hypothesis
- core/transport/wal_shipper_test.go — 10 spec-§9 tests
The tests are NOT run; wal_shipper.go is NOT validated against them.
This is the spec→code BRIDGE: architect reviews tests against
v3-recovery-wal-shipper-spec.md §3 (INV) + §5 (R1) + §6 (R2) + §9
(min test names); after ratification, implementation gets fixed
under test pressure (NOT the other way around).
Test catalog (matching spec §9 exactly):
TestWalShipper_RegistrySingleton — INV-SINGLE
t.Skip — registry lives
in BlockExecutor (P1
mini-plan)
TestWalShipper_CursorMonotonic — INV-MONOTONIC-CURSOR
(cursor never regresses
outside session entry)
TestWalShipper_RewindOnceAtSessionEntry — INV-MONOTONIC-CURSOR
(one legal rewind path
via StartSession)
TestWalShipper_DeliveredEqualsCursor — INV-SUBSET (emitted set
= (fromLSN, cursor]
exactly, contiguous)
TestWalShipper_R1_NoGapAtTransition — INV-NO-GAP-R1 (concurrent
writer while drain →
R1 transitions; every
LSN ∈ [1, finalHead]
in emit log exactly
once)
TestWalShipper_R1_DoubleCheckRejectsRace — spec §5.1 (head moved
during check window;
R1 stays Backlog,
next scan picks up
missed LSN)
TestWalShipper_NoDoubleLive — INV-NO-DOUBLE-LIVE
(recordingEmit tracks
in-flight emits across
4 concurrent writers
+ drain; maxInFlight ≤ 1)
TestWalShipper_R2_LagSignalFires — spec §6.2 (Backlog mode
with lag > threshold
fires OnSaturation
exactly once per
session)
TestWalShipper_R2_NoSpuriousSignal — spec §6.3 (load-safe
scenario, OnSaturation
never fires)
TestWalShipper_BacklogToRealtime_Happy — spec §4 default priority
end-to-end happy path
(no race)
TestWalShipper_BacklogStaysBacklog_UnderLoad — spec §5.3 explicit
non-guarantee (writer
outpaces drain → mode
stays Backlog, not
fake-Realtime)
Implementation hypothesis (wal_shipper.go) covers spec §2 state +
§4 default priority + §5 R1 (assertCaughtUpAndEnableTailShipLocked
double-check inside shipMu) + §6 R2 (lag tracking + OnSaturation
hook). Hypothesis is what tests will VALIDATE OR INVALIDATE — not
authoritative.
Architect review prompt:
Q1: Are the 10 tests' assertions a faithful read of spec §3
invariants + §5 R1 + §6 R2? If a test allows behavior the
spec forbids (or rejects behavior the spec permits), flag.
Q2: Is the t.Skip on RegistrySingleton acceptable for this PR
scope (registry lands in P1 per mini-plan §3)?
Q3: TestWalShipper_R1_DoubleCheckRejectsRace uses heuristic timing
(sleep until cursor ≥ 8 then inject write) — do you want a
more deterministic harness (e.g., fixedHeadSource that lets
test inject head changes synchronously)? Acceptable as-is for
P0; if not, mini-plan §4 row needs sharpening.
Q4: TestWalShipper_R2_LagSignalFires asserts exact "fired == 1"
single-shot per session. Spec §6.2 says "exactly once when
synthetic load drives lag past threshold". If saturation
conditions briefly clear and re-fire later (same session),
should the hook re-fire? Spec implicit single-shot; please
confirm or sharpen.
After architect ratification: run tests against wal_shipper.go;
fix implementation where tests fail; iterate. Tests are
authoritative; impl bends to them.
Branch: g7-redo/wal-shipper-impl off phase-15. Does NOT touch
g7-redo/unified-wal-impl (archived per mini-plan §0). Does NOT
touch BlockExecutor / recovery.Sender / coord — those are P1+P2
in mini-plan §3.
Languages
Go
84.5%
Rust
7.9%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%