mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
82fb2a8a34eceba2b7c124c54517543cb7f1eabc
17
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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>
|
||
|
|
2347ccb72d |
G5-5A round 54 follow-ups: freshness gate + lineage rule + comment
Architect review round 54 findings (3 items, all addressed):
HIGH 1 — SlotFact ignores freshness:
ObservationStore explicitly says expired observations stay
visible but are 'semantically ineligible for supported snapshot
synthesis'. SlotFact was scanning the full observation map
without checking ExpiresAt. For peer-set construction this is
wrong: a stale heartbeat addr is unsafe to dial.
Fix: SlotFact now skips observations where now > obs.ExpiresAt.
New test TestObservationStore_SlotFact_ExpiredObservation_FailsClosed
verifies the boundary (ok=true within FreshnessWindow,
ok=false past expiry).
HIGH 2 — path 1 mis-stamps live-ship lineage:
resolvePeers path 1 was using the peer's OWN LastPublished
Epoch/EV. If LastPublished(v1, r2) returns r2's retained
historical authority line (e.g., r2 was previously bound at
Epoch=N before reassignment to r1 at Epoch=N+1), primary r1
would stamp live-ship frames under r2's old N — breaks the
apply gate at the replica which expects current authority.
Fix: BOTH paths now stamp peer.Epoch/EV with subscriber's
lineage. Authority/observation supplies addresses only;
subscriber stamps lineage. Updated TestResolvePeers_BothBound
to pin this (peer's old 4/1 must NOT win over subscriber's
5/2). path-1-preferred test still passes — it's about which
ADDR wins, not lineage.
LOW 3 — stale comment:
collectPeers godoc still claimed observation-derived peers
'carry Epoch=0 + EndpointVersion=0 to mark observation-derived'.
Out of date since round-54 inheritance fix. Rewrote comment
block to reflect current rule: both paths stamp subscriber's
lineage; authority/observation supplies addresses only.
All G5-5A tests still pass (10/10); cmd/blockvolume G5-4
integration test PASS; full V3 suite green.
Refs: architect round 54 review of
|
||
|
|
61f5ff62a8 |
G5-5A: master peer-set from observed supporting replicas
Architect ratification round 54 (2026-04-27): collectPeers may
synthesize peer descriptors for topology slot members observed by
heartbeat even when they don't have a bound authority publication.
Root cause from QA round 54: V3 controller only mints
AssignmentInfo for the BOUND replica (Publisher.apply path).
Supporting replicas have no published authority line, so
master.collectPeers' pub.LastPublished returns false for them,
peers list is empty, primary's ReplicationVolume has no peers,
fan-out/Sync barrier has no acks → iSCSI fsync I/O error.
Architect Option A (chosen): collectPeers falls back to
ObservationStore for slot members without published lines.
Topology membership is the allow-list (option R / arbitrary
observed nodes still rejected). Authority state stays clean —
Option B (mint presence records into pub.state) was rejected.
Implementation:
core/authority/observation_store.go:
+ SlotFact(volumeID, replicaID) — returns latest-observation
SlotFact across all servers; fail-closed on empty DataAddr.
core/host/master/services.go:
collectPeers signature changes from (volumeID, selfReplicaID
string) to (volumeID string, selfInfo adapter.AssignmentInfo)
so observation-derived peers can inherit subscriber's Epoch/EV.
Body extracted to pure helper resolvePeers() for testability.
Peer construction policy:
Path 1: pub.LastPublished hits → use authority Epoch/EV/addrs
Path 2: SlotFact hits → use heartbeat addrs + INHERIT
SUBSCRIBER'S Epoch/EV (live ships carry primary's
lineage; replica validates against it)
Else: skip fail-closed
Inheriting subscriber's Epoch/EV is required because
ReplicaPeer constructor (replication/peer.go:130) rejects
zero values — the lineage stamps every outgoing live-ship
frame, and primary's authority is what the supporting replica
validates against.
Tests:
core/authority/observation_store_slotfact_test.go: 5 tests
(round trip, empty store, fail-closed empty addr,
latest-wins across servers, vol/replica mismatch)
core/host/master/services_g5_5a_test.go: 5 tests
(headline r1-bound + r2-observed-only, both bound,
neither bound nor observed, nil obs store, path-1 wins
over path-2)
All 10 G5-5A tests pass; full V3 suite green (23/23 packages
incl. cmd/blockvolume G5-4 integration test still green).
No engine/adapter behavior change — touches master/observation
peer-set construction only.
Refs: QA round 54 finding (cross-host fsync I/O error);
architect Option A ratification 2026-04-27.
|
||
|
|
3351a66ff2 |
T4d-3: R+1 threading + import-discipline fence (G-1 v0.2 PORT items 1-5; CARRY-T4D-LANE-CONTEXT-001 Option B)
Per T4d mini-plan v0.3 §2.3 + G-1 v0.2 (architect+QA-signed
2026-04-25). Refs G-1 sign: pending hash (G-1 doc lives in
seaweedfs sw-block/design/v3-phase-15-t4d-3-g1-v2-read.md v0.2);
QA approval round-46 cleared T4d-3 start.
PORT items landed (G-1 v0.2 §3, items 1-5):
Item 1 — start boundary: engine.StartCatchUp gains FromLSN field;
engine emits Recovery.R + 1 (decide path + retry-loop re-emit).
Pinned by INV-REPL-CATCHUP-FROMLSN-IS-REPLICA-FLUSHED-PLUS-1 +
INV-REPL-CATCHUP-FROMLSN-FROM-ENGINE-STATE-NOT-PROBE.
Item 2 — per-call deadline: preserved unchanged (T4c-2 INV-REPL-
CATCHUP-DEADLINE-PER-CALL-SCOPE forward-carries).
Item 3 — last-sent monotonic + completion: preserved unchanged
(T4c-2 invariants forward-carry; barrier ack remains completion
truth).
Item 4 — retry budget: engine retry-loop reuses ORIGINAL Recovery.R
+ 1 on re-emit per G-1 §6.2 architect Option A (no inter-attempt
re-probe; apply gate handles over-ship). Pinned by
TestT4d3_CatchUp_RetryReusesOriginalRPlus1.
Item 5 — retention-miss escalation: T4d-1 typed-kind contract
already in place; engine branches on FailureKind. Forward-carry.
V3-NATIVE items (no V2 source per G-1 v0.2 §4):
- Engine-owned retry loop (Q1) — already in place at T4c-3
- Unified recovery command model — T4c-pre-B
- Lane-aware apply gate integration — T4d-2
- BarrierResponse.AchievedLSN as completion truth — T4c-2
- Package-boundary discipline — pinned by new
TestT4d3_Catchup_TransportNeverImportsSubstrateInternals
(parses transport .go files via go/parser; fails if any
substrate-internal package import surfaces)
Signature ripple (10 files):
- engine.StartCatchUp{FromLSN uint64} added (no removals)
- adapter.CommandExecutor.StartCatchUp interface +1 param
- transport.BlockExecutor.StartCatchUp + doCatchUp +1 param
- 4 test executor stubs (mockExecutor, closureExecutor,
policyClosureExecutor, restartExecutor) + production
HealthyPathExecutor + noopExecutor + ops nopExecutor
- transport.recovery_session.go bridge passes fromLSN=1 (legacy
StartRecoverySession path; forward-carry to T4e for explicit
fromLSN field on StartRecovery)
- adapter.adapter_test.go bridge passes fromLSN=1
- 5 transport test call sites + 3 component integration test sites
- component framework CatchUpReplica helper passes fromLSN=1
(transitional shim; tests needing explicit R+1 use direct
executor invocation per G-1 §7)
NEW TESTS (G-1 §7 test parity matrix):
- core/engine/t4d3_rplus1_test.go (3 tests):
- TestT4d3_CatchUp_Engine_RPlus1_FromOwnState_NotProbeDirectly
(pins INV-REPL-CATCHUP-FROMLSN-FROM-ENGINE-STATE-NOT-PROBE)
- TestT4d3_CatchUp_RetryReusesOriginalRPlus1 (G-1 §6.2 Option A)
- TestT4d3_StartCatchUpStruct_HasFromLSNField (compile fence)
- core/transport/t4d3_rplus1_test.go (3 tests):
- TestT4d3_CatchUp_ScansFromReplicaR_NotGenesis (substrate
receives caller-supplied fromLSN; sender does NOT add +1)
- TestT4d3_CatchUp_StartCatchUpSignature_FromLSNRequired
- TestT4d3_CatchUp_NonEmptyReplica_BlockStoreOverShipsExpected
(round-46 ADDITION 2 substrate-bound naming — opposing-
assertion regression fence per §9 caveat)
- core/transport/import_discipline_test.go (1 test):
- TestT4d3_Catchup_TransportNeverImportsSubstrateInternals
(Q3 INV-REPL-TRANSPORT-STORAGE-CONTRACT-ONLY; parses transport
sources, fails on substrate-internal imports)
- core/replication/component/t4d3_scenarios_test.go (4 tests):
- TestT4d3_CatchUp_NonEmptyReplica_ShortGap_BandwidthBounded_
Walstore (substrate-bound bandwidth observation)
- TestT4d3_CatchUp_NonEmptyReplica_ShortGap_BandwidthBounded_
Smartwal (mirror)
- TestT4d3_RetryAfterReplicaAdvanced_OverScansHandledByApplyGate
(round-46 ADDITION 1 — pins §6.2 Option A safety claim:
over-scan + apply gate per-LBA stale-skip; assertions cover
byte-exact convergence + no per-LBA regression + coverage
union completeness)
- TestT4d3_RecoveryTargetLSN1_KnownGap (CARRY-T4D-LANE-CONTEXT-
001 Option B close — SKIPPED with explicit forward-binding
for the T4e or beyond fix; gate API itself is already
lane-pure, only caller's signal source needs upgrading)
CARRY-T4D-LANE-CONTEXT-001 close (round-46 architect HARD CLOSE
CONDITION): Option B chosen (NOT Option A) because true handler/
session-context lane signal is a much larger refactor (separate
listener ports OR per-connection lane tag via session-registration
handshake OR new MessageType — all wire/transport-architectural
changes). Architect listed Option B as acceptable. The skip-marked
test documents the H=1 known gap; godoc cites
CARRY-T4D-LANE-CONTEXT-001 explicitly for catalogue cross-reference.
NOT in T4d-3 scope (deferred):
- Engine-driven recovery wiring through ReplicationVolume↔adapter
(G-1 §4 Item A integration scope) — engine retry-loop is
unit-tested; full ReplicationVolume↔adapter binding is a
follow-up task. Rationale: this commit is large enough; landing
the R+1 threading + import discipline as one piece + adding
end-to-end engine-driven recovery wiring as another keeps
reviewability tractable. T4d-4 owns the lifecycle integration;
the engine-driven-recovery wiring fits naturally there OR as a
T4d-3-followup.
Forward-carry status:
- T4d-1 typed-kind contract: forward-carries unchanged
- T4d-2 lane-pure apply gate: forward-carries; round-46 lane
discipline still honored (gate doesn't sniff lineage)
- All round-43/44 stale-skip invariants: forward-carry green
- T4c-2 6 catch-up invariants: forward-carry under R+1 threading
(verified via T4c muscle tests still passing)
- 22 packages green; 0 failures
Tests added: 11 (per G-1 §7 matrix).
Refs: T4d mini-plan v0.3 §2.3 (architect-ratified); G-1 v0.2
QA-signed (CARRY-T4D-LANE-CONTEXT-001 close condition Option B);
round-46 architect ruling (lane-pure gate); kickoff §9 (Q1/Q2/Q3).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
71e2e082c0 |
T4c-1: ProbeReq + ProbeResponse symmetric full-lineage wire + validation
Per architect round-26 Item C.3 (symmetric pair) + round-21 uniform rule
(every authority-bearing wire surface carries full RecoveryLineage).
Probe lineage source per architect Option D (post-QA-sign clarification):
adapter mints transient probe sessionID; executor reads primaryStore
boundary for TargetLSN; engine stays pure semantic reducer; probe
lineage NOT registered in executor.sessions; no SessionPrepared /
Started / Closed lifecycle for probe.
Wire (T4c-1):
- ProbeReq: 32B body — [SessionID][Epoch][EndpointVersion][TargetLSN]
- ProbeResp: 56B body — [32B echoed lineage][8B R][8B S][8B H]
- Both directions: strict decode (short / zeroed lineage / field-order
drift rejected) mirrored from BarrierResp (T4b-1)
Replica side (replica.go MsgProbeReq):
- decodes lineage; validates via new validateProbeLineage (rejects
zeros + strictly older epoch/endpointVersion); does NOT advance
activeLineage (probe is non-mutating; advancing would race ahead of
in-flight catch-up/rebuild sessionIDs and stale-reject their frames)
- echoes lineage in 32B prefix of response
Primary side (executor.go BlockExecutor.Probe):
- new sessionID parameter (adapter-minted); reads primaryStore.Boundaries()
for TargetLSN floor (max(1, primaryH)); builds full RecoveryLineage
- sends EncodeProbeReq; validates echoed lineage on response;
ErrProbeLineageMismatch surfaces in FailReason on mismatch (mirrors
T4b-2 ErrBarrierLineageMismatch)
Adapter (adapter.go):
- prepareQueuedCommands mints transient probe sessionID for ProbeReplica
(parallel to FenceAtEpoch); executeCommand passes sessionID through
- CommandExecutor.Probe interface gains sessionID parameter; all test
executor stubs updated (mockExecutor, closureExecutor, policyClosure,
restartExecutor, HealthyPath, noop, ops nopExecutor)
INV-REPL-LINEAGE-BORNE-ON-PROBE-PAIR inscribed at catalogue §3.3 close
(both directions carry full lineage; both fail-closed on
short/zeroed/malformed; primary-side filters by full-lineage match).
Tests (21 new across 3 files):
- core/transport/probe_wire_test.go (12 wire pins)
- core/transport/probe_validation_test.go (7 replica + primary contract)
- core/adapter/probe_session_test.go (2 transient sessionID)
Existing test fix:
- TestFailClosed_ProbeDuringRebuild_DoesNotDisturbActiveLineage rewritten
as TestFailClosed_StaleProbeDuringRebuild_RejectedAndRebuildContinues —
pre-T4c-1 premise ("probe is observation only, no lineage") is
invalidated; new contract: stale probe rejected without echo,
fresh probe authority-bearing
- protocol_test envelope round-trip uses new probe shapes
- transport_test.go probe call passes sessionID
go test ./... -count=1 → all 21 packages green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
eadc113697 |
T4c-pre-B: unified StartRecovery command + per-kind runtime policy
Per design memo §7a (architect rounds 29-30): introduce semantic unification at the command boundary — one StartRecovery covers catch-up / rebuild / partial-LBA — without unifying runtime behavior. RecoveryRuntimePolicy carries per-content-kind envelope (timeout / progress cadence / cancellation mode); engine populates via DefaultRuntimePolicyFor at emit time. - core/engine: StartRecovery + RecoveryContentKind (wal_delta / full_extent / partial_lba) + DurationClass + CancellationMode + RecoveryRuntimePolicy + DefaultRuntimePolicyFor. - core/adapter: CommandExecutor.StartRecoverySession; adapter dispatch wired (queue + execute + start watchdog). - core/transport: BlockExecutor.StartRecoverySession bridges wal_delta → catch-up sender, full_extent → rebuild sender; partial_lba returns explicit Stage-2 error; validateRecoveryPolicy enforces non-empty envelope + wal_delta+CancelOnTimeout requires Timeout > 0. - Test executors (authority, host/volume, ops) updated with stub StartRecoverySession. - 10 new engine tests (command shape, per-kind defaults, label strings, cadence/timeout consistency); 8 new transport tests (policy validation, dispatch contract — partial_lba rejected, unknown kind rejected, policy-validates-before-dispatch). Legacy StartCatchUp / StartRebuild retained as engine emit shape; T4c-3 muscle port migrates engine emission to StartRecovery. go test ./... -count=1 → all 21 packages green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
55793d49bc |
T0 closure: blockmaster/blockvolume hosting + D1-D5 tests
Product binaries (cmd/blockmaster, cmd/blockvolume) and core/host wiring for volume-scoped assignment delivery, durable authority with Windows rename retry, and the T0 closure test set (D1 L2 subprocess, D2 G1 adversarial, D3 concurrent write-reload regression, D4 hosting-smoke scenario + Go-native replay, D5 --topology flag). Diagnostic surfaces: ObservationStore.SupersededCount (PCDD-DELAYED-HB-001 evidence, not authority input) and SetNowForTest clock seam on Store/Host, guarded by grep test ensuring the identifier stays out of production files. |
||
|
|
c699d358b0 |
P14 cleanup: CodeRabbit nits on the S5-S8 PR
Three review follow-ups from PR #10 CodeRabbit feedback. All style/robustness; no correctness changes. 1. core/authority/authority.go — drop dead-scaffolding locals (prevForRollback / hadPrev) around the durable-write path. State mutation is deliberately sequenced after store.Put, so there is nothing to roll back on Put failure. Replace the phantom locals with a comment stating the invariant. 2. cmd/sparrow/s7_restart_smoke_test.go — use exec.CommandContext with a 60s test-level deadline for both the go build and the two subprocess runs, so a hung child dies when go test times out instead of lingering. 3. cmd/sparrow/s7_bootstrap_test.go — replace `dir + string(os.PathSeparator) + ...` with filepath.Join for cross-platform correctness. Not addressed (explicitly CodeRabbit-flagged "recommended not essential"): double-reload at boot (bootstrap.go). Would require a new Publisher WithPreloaded option; skipped to keep this commit tight and not reopen S5 surfaces. go test ./core/authority ./cmd/sparrow -count=1 green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
5a902c15f4 |
P14 S8: IntentRefreshEndpoint L1 route test (evidence-matrix Claim 6)
Closes the S8 evidence-matrix gap for Claim 6 (controller-driven bind / reassign / refresh over accepted topology). Prior state had Bind / Reassign with dedicated L1 routes but refresh was only exercised at L0 via controller_test.go, covered implicitly by placement/rebalance/failover. This adds the explicit route. Scenario: heartbeats report slot DataAddr/CtrlAddr changing for the current authority while publisher still holds old addrs → decideVolume emits IntentRefreshEndpoint → publisher bumps EndpointVersion on the same Epoch → bridge delivers refreshed AssignmentInfo to the consumer → next rebuild confirms via the full contract (including addr match) and clears desired. Test file: core/authority/convergence_route_test.go - TestConvergenceRoute_RefreshEndpoint_ConfirmsAndClearsDesired - buildV1HeartbeatsWithAddrs helper (per-replica addr override for heartbeat construction) Publisher's directive is the real TopologyController (not a static ask list) so the route goes through decideVolume. go test ./core/authority -count=1 green (4.8s). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
0562aeb878 |
P14 S7: real-route restart closure (L1 component + L2 subprocess smoke)
Proves the S4-S6 control loop composes under restart and real-route pressure: durable authority reload -> observation replay -> controller recompute -> VolumeBridge delivery -> VolumeReplicaAdapter. Restart sequence pinned (sketch §5, adapter-BEFORE-bridge per round-3): lock -> store -> pub(reload) -> ctrl(reloaded reader) -> host(same reader) -> adapter -> VolumeBridge -> pub.Run + host.Start. Desired state is recomputed, not persisted (sketch §6). No DesiredStore, no StuckStore, no bootstrap-mint shortcut. Stale pre-restart observation rejected via existing basisMatchesLine, not a new bootstrap predicate. L1 (core/authority/restart_route_test.go, 8 tests + 4 stale sub-cases): row 1 reloaded authority via bridge to adapter; row 2 recompute (hard precondition + same-observation replay); row 3 stale observation (4 sub-cases via snapshottingReader host-reader freeze — test simulation shape per sketch §9, not a heartbeat-wire claim); row 4a old slot NOT revived from durable (S5 one-record-per-volume contract); row 4b live-route monotonic guard rejects bridge-delivered old slot from in-memory publisher; row 5 unsupported evidence via ConflictingPrimaryClaim; row 6 fence path bounded (Fence command reaches executor via real route; withheld callback does not produce spurious Healthy); row 7 per-volume isolation on restart. L2 component (cmd/sparrow/s7_bootstrap_test.go): rows 8/9/10a via in-process Bootstrap two-run, asserting directly on ReloadedRecords, ReloadSkips, VolumeAuthorityLine. No backward mint across restart. L2 subprocess (cmd/sparrow/s7_restart_smoke_test.go): row 10b via real sparrow binary spawn twice against the same store dir. Asserts exit 0 on both runs, lock released between runs, second-run structured stdout reports the durable line the first run wrote, backwardMint=false. cmd/sparrow additions: - --s7-restart-smoke flag (test-only, undocumented in --help) - runS7RestartSmoke entry with pinned JSON pass-line schema - parseFlags rules: requires --authority-store, mutually exclusive with --s5-bootstrap Helpers: restartRoute / simulateRestart (single pinned construction seam; no direct adapter.OnAssignment anywhere; uses VolumeBridge, not hand-rolled Bridge goroutines); restartExecutor (fence-mode configurable pre-loop); snapshottingReader.forceSet for stale-basis simulation. Engine/adapter/transport: no changes. Row 4 honesty split (round-5c): durable restart discards old-slot state by S5 design, so "old-slot rejected on restart" is proved by ABSENCE; the monotonic-guard proof belongs to a pre-restart live-route test where in-memory per-replica keys legitimately exist. Row 6 explicitly defers the full timeout- expiry quantitative bound to the adapter's own tests (sketch §10.1 Path B forbids S7 from reconfiguring the fence path). Residual: Windows TempDir teardown can race with lock-file release; logged as residual per sketch §8.5 scope — durable-store write/reload errors remain hard failures. go test ./core/authority ./cmd/sparrow ./core/adapter -count=1 green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
a837a67ec6 |
P14 S6: convergence institution (bounded wait + stuck evidence)
Turns controller desired assignments into a bounded-fate closure: confirmed, retried (passively), superseded, or surfaced as stuck evidence — without minting new authority. - DesiredAssignment: +ProposedBasis/DesiredAt/LastRetryAt/Stuck. - TopologyControllerConfig: +RetryWindow (default 5s). - convergence.go: ConvergenceStuckEvidence (distinct map from UnsupportedEvidence), supersedeDesiredLocked (case 1 only: publisher epoch > ProposedBasis AND different target — case 2 dropped because it misclassified every in-flight Reassign), evaluateStuckLocked (passive; does NOT re-emit). - controller.go: unified processSupportedVolumeLocked; confirm routes through clearDesiredLocked so late post-Stuck confirmations drop stuck evidence; supported-recovery clears prior UnsupportedEvidence. L0 (convergence_test.go): 15 targeted proofs — confirmation (both-sources, stale-observation guard), stuck (after window, no Reassign churn, clears on late confirm), supersede (publisher moved elsewhere, normal-lag is NOT supersede, decision-table differs), pending/unsupported clearing, per-volume isolation, supported-recovery evidence cleanup. L1 (convergence_route_test.go): 3 component-route proofs through ObservationHost -> TopologyController -> Publisher -> VolumeBridge -> Consumer: observation-fed failover confirms, publish-but-not-observed reaches Stuck with no duplicate bridge delivery, supersede drops stale desired. No engine/adapter/transport changes. S2 non-forgeability and S5 store-write guards still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
47eb1f6f8d |
P14 S5: durable authority institution + live sparrow bootstrap
Introduces the P14 S5 durable-authority layer: Publisher state
survives control-plane restart via an atomic-rename file-per-
volume store, guarded by a cross-platform OS-level single-owner
lock, with startup wiring in cmd/sparrow that acquires the lock
and reloads durable truth before live publication begins.
Load-bearing boundaries held (sketch §3):
* durable authority store may preserve and reload truth, but
it may NEVER mint truth. Publisher is the sole minter of
Epoch / EndpointVersion; the store persists values already
minted and reloads them verbatim at boot.
* AST boundary guards (from S5 sketch §12) enforced at test
scope: no non-authority code constructs a DurableRecord with
non-zero Epoch/EndpointVersion, no non-authority code calls
store.Put.
Core store and interface (core/authority/):
* authority_store.go — DurableRecord shape (per-volume current
line; no per-slot history, no append log, no wall-clock
freshness field); AuthorityStore interface with Load /
LoadWithSkips / Put / Close; SHA-256-checksummed JSON
envelope; per-record ErrCorruptRecord; index-level failure
distinguished from per-record skip.
* authority_store_file.go — file-per-volume FileAuthorityStore
with fsync + atomic rename on write; stale-tempfile cleanup
on Load; INJECTIVE filename encoding (every non-[a-zA-Z0-9-]
byte including '_' escapes as "_XX" — closes the earlier
"_002f" vs "/" aliasing gap).
* authority_bootstrap.go — AcquireStoreLock returning a
StoreLock whose OS-level file lock is dropped on handle
close, cross-platform crash-safe.
* authority_bootstrap_unix.go (build !windows) — syscall.Flock
with LOCK_EX|LOCK_NB.
* authority_bootstrap_windows.go (build windows) —
syscall.CreateFile with dwShareMode=0 exclusive share;
ERROR_SHARING_VIOLATION / ERROR_ACCESS_DENIED map to
ErrStoreLockHeld. Purely stdlib; no x/sys dependency.
Publisher integration (core/authority/authority.go):
* WithStore(store) functional option on NewPublisher. Nil /
omitted keeps existing in-memory behavior.
* Synchronous reload at construction: verifies records,
populates p.state, seeds p.writeSeqByVolume from max stored
WriteSeq. Per-record corrupt skips surface via LoadErrors()
(per-volume fail-closed; process continues).
* Synchronous write-through in apply(): DurableRecord built
under pub.mu, store.Put invoked before in-memory commit. On
Put failure the in-memory state is NOT mutated, subscribers
are NOT notified, and the caller gets a wrapped error — on-
disk and in-memory stay lock-step.
* Index-level load failure panics at construction (honors the
sketch §10 fail-the-whole-boot rule); the Bootstrap helper
converts this to a clean error return via a pre-check.
Live sparrow entry point (cmd/sparrow/):
* bootstrap.go — Bootstrap(storeDir, directive) helper that
performs the full startup sequence (lock → store → index
pre-check → NewPublisher with reload → log outcomes). Also
exposes BootstrapFromStore seam so tests can inject a mock
store to exercise the pre-check cleanup branch portably.
* s5_bootstrap.go — runS5Bootstrap mode invoked via
"sparrow --authority-store <dir> --s5-bootstrap". Acquires
lock, reloads, runs Publisher briefly, emits report, exits
cleanly. This is the one real non-test caller of the
durable route. The default demo path stays in-memory by
design (the Bind/Reassign smoke sequence is not restart-
clean, and forcing it to be would smuggle durability-aware
branches into SMOKE test code).
* main.go — --authority-store and --s5-bootstrap flags
rejected at parseFlags unless paired; --s5-bootstrap
dispatches to runS5Bootstrap. Default modes unchanged.
Proof (core/authority/ + cmd/sparrow/):
* authority_store_test.go — round-trip, latest-wins per-volume,
corrupt-record per-volume fail-closed, atomic-write-no-torn
(orphan tempfile cleanup), process lock exclusivity +
idempotent release + survives stale lockfile on disk,
unreadable-index boot fails closed, wall-clock-NOT-consulted
on reload, AST boundary guards (store never mints, only
core/authority calls store.Put), filename encoding
injectivity + no-filesystem-unsafe-output, envelope shape.
* authority_restart_test.go — reload reproduces current line,
stale pre-failover record rejected, Publisher advances from
reloaded truth (not zero), Controller sees reloaded line at
boot, Put-failure rolls in-memory back, empty-store reload
yields fresh state, store-backed Publisher runs normal
Bridge route.
* cmd/sparrow/bootstrap_test.go — live Bootstrap tests: fresh
dir acquires lock + reloads, existing-record reloads into
Publisher state, corrupt record logged at startup (not
stranded in LoadErrors), lock contention refuses second
bootstrap, empty dir errors, Close idempotent,
ParseFlags_AuthorityStoreRequiresS5Bootstrap flag validation,
RepeatedRunsAreRestartClean (two runS5Bootstrap invocations
on same dir with seeded record between — architect round-7
regression), PreCheckFailure_ReleasesLockAndClosesStore
(mock-injected index failure → lock released, store closed,
error returned — architect round-8/9 regression).
* observation_test.go — E2E SystemFedSnapshotReachesController
poll-loop fixed: was racing on first non-empty submission
(initial pending) instead of waiting for supported; now
polls until supported-v1 with 3 slots is observed.
No changes to engine, adapter, transport, ops, storage.
Authority package: 112 tests. cmd/sparrow: 19 tests. Full module:
12 packages pass.
Design docs in sw-block/design/ external repo:
* v3-phase-14-s5-assignment.md
* v3-phase-14-s5-durable-authority-institution.md
* v3-phase-14-s5-sketch.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
60c5ff5db4 |
P14 S4: observation institution + multi-volume topology controller
Lands two related pieces that make late-Phase-14 observation-to-
authority truth system-owned:
1. Multi-volume TopologyController (accepted P14 topology set:
per-volume three-slot on distinct servers). This was the
"consumer baseline" staged earlier as full-topology
scaffolding and is committed here as the foundation S4 feeds.
2. Observation institution: heartbeat / inventory -> stable
ClusterSnapshot producer, per the S4 assignment
(sw-block/design/v3-phase-14-s4-assignment.md and
v3-phase-14-s4-sketch.md).
Load-bearing boundary held across both pieces:
* observation institution may withhold supportability, but it
may NOT mint authority (sketch §3)
* Publisher stays the sole minter of Epoch/EndpointVersion
* adapter.OnAssignment stays the one and only consumer ingress
* no new engine event, command, or projection field
Observation-side deliverables (core/authority/):
* observation_types.go — Observation, ServerFact, SlotFact,
LocalRoleClaim, FreshnessConfig, Supportability enum
(pending / supported / unsupported kept VISIBLY distinct per
architect execution note), AcceptedTopology, six reason
constants.
* observation_store.go — push-ingest latest-wins per ServerID,
derived ServerFreshness (never-observed / bootstrapping /
missing / fresh / expired), immutable storeSnapshot for
builder input, configurable GC.
* observation_wire.go — V2 heartbeat wire shape port
(block_heartbeat / block_heartbeat_proto /
block_heartbeat_loop analogues) as mechanism only.
HeartbeatToObservation is a pure field-shape copy.
* unsupported_evidence.go — per-volume VolumeUnsupportedEvidence
(latest-wins per VolumeID), separate VolumePendingStatus,
SupportabilityReport with Pending + Unsupported as distinct
maps, BuildResult.
* snapshot_builder.go — pure BuildSnapshot(store, topology,
reader) -> BuildResult. Reads publisher's current per-volume
line via the read-only AuthorityBasisReader and stamps it in
VolumeTopologySnapshot.Authority for supported volumes, so
the controller's stale-resistance check can match on
subsequent feeds. Observation never mints authority.
* observation_host.go — owns store lifecycle, push-ingest
entry points, reactive rebuild (build-on-change + coalescing
wake), GC sweep honoring configured retain window,
ControllerSink atomic submission (snapshot + report
together so supportability transitions propagate even when
supported volumes drop to zero).
Controller-side intake (core/authority/controller.go):
* SubmitClusterSnapshot kept as the test-scaffolding entry.
* NEW SubmitObservedState(snap, report) — the observation-fed
intake. Mirrors SubmitClusterSnapshot's convergence
discipline line-for-line (stale-basis preserves desired,
no-emit clears desired, same-ask dedupe prevents authority
churn) and adds pending/unsupported transition handling.
Under this intake, the controller hears every supportability
transition, including "zero supported volumes now", which
clears stale desired state.
V2 muscles ported (mechanism only):
* block_heartbeat / block_heartbeat_proto field layout
(observation_wire.go)
* block_heartbeat_loop shape concept (host owns the loop)
Explicitly NOT ported (per assignment denylist):
* weed/storage/blockvol/promotion.go
* old HandleAssignment / promote / demote ownership
* master_block_plan / master_block_failover / master_block_registry /
master_block_assignment_queue (reference only for S5/S6)
* any V2 path where heartbeat timing or local status becomes
failover truth
Proof matrix (observation_test.go — 35 tests covering all sketch
§16 rows + architect-round regressions):
Authoring:
- PartialInventory_PendingThenUnsupported
- MissingServerObservation_NeverOrdinaryIneligible
- EndToEnd_SystemFedSnapshotReachesController
- ConflictingPrimaryClaim_Unsupported
- ConflictingPrimaryClaim_NoWinnerEverChosen
- ExpiredFact_SemanticallyIneligible
- ExpiredDoesNotReachController
- BadVolumeDoesNotBlockHealthyVolume_Isolation
- VolumeUnsupportedEvidence_IsolatedPerVolume
- DuplicateServerTopology_UnsupportedAndEvidenceRecorded
- DuplicateServerTopology_NotControllerInput
Host-level:
- IngestMutation_TriggersSnapshotRebuild
- FreshnessWindowHonored_NotTickMultiples
- GCRetainWindow_Honored
Boundary (AST-based, sketch §16a):
- NeverMintsAuthority_BoundaryGuard
- SupportabilityDoesNotReadClusterSnapshotOutput
Architect round-2 regressions:
- BuilderStampsAuthorityFromReader
- SupportabilityCollapsePropagatesToController
- SupportabilityCollapseClearsControllerDesired
- UnknownObservedVolume_ProducesUnsupportedEvidence
Architect round-3 regressions:
- IdenticalSupportedSnapshots_NoDuplicateAsks
- VolumeRecovers_ClearsStaleDesired
No changes to engine, adapter, transport, ops, storage, or
sparrow. 91 authority tests pass. Full module: 12 packages pass.
Design docs in sw-block/design/ external repo:
* v3-phase-14-s4-assignment.md
* v3-phase-14-s4-observation-institution.md
* v3-phase-14-s4-sketch.md
* v3-phase-14-s4-closure-gaps.md (architect-round boundary notes)
* v3-phase-14-full-topology-design.md
* v3-phase-14-placement-rebalance-policy.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
0fc367f3a3 |
P14 S3: bounded policy owner + system-owned failover (two-slot topology)
Introduces the first accepted S3 slice: one explicit policy owner
behind the S2 Directive seam, with cross-slot failover proven
end-to-end through the existing authority publication route. The
accepted topology set for this slice is one volume, two replica
slots on distinct servers, one current primary, one failover
candidate.
Load-bearing boundaries preserved from S2:
* policy emits AssignmentAsk, never AssignmentInfo
* authority.Publisher remains the sole minter of Epoch /
EndpointVersion (enforced by the repo-wide AST
non-forgeability test)
* engine and adapter remain consumers; adapter.OnAssignment
stays the one and only consumer ingress
* Remove / retirement deferred
S2 boundary change absorbed via the reassign-semantic note
(sw-block/design/v3-phase-14-s3-reassign-semantic.md):
* IntentReassign is now a per-volume authority advance, not a
per-slot Epoch bump. Target ReplicaID may differ from the
currently-published replica. New Epoch is minted from the
max across (VolumeID, *) + 1. EV resets to 1 on the target.
Still requires SOME prior publish for the volume; first-time
establishment remains IntentBind.
* Per-slot EV monotonicity unchanged for IntentRefreshEndpoint.
Implementation (core/authority/):
* policy.go — PolicyOwner (Directive impl), AssignmentAsk input
model (AuthorityBasis, SlotObservation, PolicySnapshot),
PolicyConfig, AuthorityBasisReader (LastAuthorityBasis +
VolumeAuthorityLine), decision table (Bind /
RefreshEndpoint / Reassign), unsupported-topology evidence
with structured offending-basis artifact.
* authority.go — widened IntentReassign; new
VolumeAuthorityLine method on Publisher; new VolumeBridge
helper for system-owned retarget without test choreography;
new maxPublishedEpochForVolume helper.
Four ordered guards on every snapshot in PolicyOwner.Next:
1. distinct-servers invariant (empty ServerID or matching
non-empty ServerID -> unsupported evidence)
2. snapshot-side authority-in-topology (snap.Authority outside
the two slots -> unsupported evidence)
3. publisher-side out-of-topology authority (publisher's
current per-volume line on a replica not in the two slots
-> unsupported evidence carrying the offending Basis)
4. per-volume stale-resistance (snap.Authority must match the
current per-volume authority line on VolumeID, ReplicaID,
Epoch, EndpointVersion)
Closure proofs (core/authority/policy_test.go — 26 new tests):
Authoring (§13.1 of sketch):
- TestPolicy_NoAuth_OneAcceptable_EmitsBind
- TestPolicy_NoAuth_BothAcceptable_EmitsBindForPreferred
- TestPolicy_NoAuth_NeitherAcceptable_NoAsk
- TestPolicy_CurrentHealthy_Unchanged_NoAsk
- TestPolicy_CurrentHealthy_DataAddrChanged_EmitsRefresh
- TestPolicy_CurrentHealthy_CtrlAddrChanged_EmitsRefresh
- TestPolicy_CurrentUnacceptable_OtherAcceptable_EmitsReassign
- TestPolicy_CurrentUnacceptable_OtherUnacceptable_NoAsk
- TestPolicy_AuthOutsideTopology_NoAskPlusUnsupportedEvidence
- TestPolicy_UnsupportedTopology_AlwaysEmitsEvidence
- TestPolicy_OnlyThreeIntentsProduced
Stale-resistance (§13.2 + architect round 2 + round 3):
- TestPolicy_StaleDecision_DroppedWhenAuthorityAdvances
- TestPolicy_StaleRefresh_DroppedWhenNewerEndpointVersion
- TestPolicy_NewerSnapshotOverwritesOlder_OnlyLatestValidEmits
- TestPolicy_StaleSnapshotAfterCrossSlotFailover_Dropped
Topology honesty (architect round 3 + round 4):
- TestPolicy_EmptyServerID_NoAskPlusUnsupportedEvidence
- TestPolicy_BothSlotsSameServer_NoAskPlusUnsupportedEvidence
- TestPolicy_OutOfTopologyPublisherAuthority_NoAskPlusUnsupportedEvidence
(structured Basis assertions — evidence carries the
offending publisher line, not just a reason string)
Boundary:
- TestPolicy_NoDirectAssignmentInfoConstruction
- TestPolicy_DoesNotAddAdapterIngress
Reassign semantic regressions:
- TestReassign_CrossSlotMintsEpochPlusOne
- TestReassign_NoPriorVolumePublish_StillRejects
- TestReassign_PerSlotOpsOnOldSlotDoNotAdvanceVolumeLine
- TestReassign_PerSlotEndpointVersionMonotonicityPreserved
End-to-end closure (VolumeBridge-based, no test choreography):
- TestPolicyToAdapter_E2E_Bind
- TestPolicyToAdapter_E2E_Failover
- TestPolicyToAdapter_E2E_EndpointRefresh
- TestVolumeBridge_FollowsFailoverWithoutTestChoreography
- TestVolumeBridge_PostFailoverOldSlotRefreshRejectedByAdapter
(adapter rejects stale-identity input delivered through
VolumeBridge after cross-slot move)
- TestPolicyToAdapter_E2E_Failover_PublicationHonestyDuringTransition
(ack-gated window: adapter is non-Healthy at Epoch=2 until
FenceCompleted; observed deterministically via fence-hold
hook on the test executor)
No changes to engine, adapter, transport, ops, storage, or
sparrow. The S3 package is additive.
Authority package tests: 56 pass (30 from S1+S2; 26 new from S3).
Full module: 12 packages pass.
Design docs (in sw-block/design/ external repo):
* v3-phase-14-s3-audit.md
* v3-phase-14-s3-sketch.md
* v3-phase-14-s3-design.md
* v3-phase-14-s3-closure.md
* v3-phase-14-s3-reassign-semantic.md (boundary note)
* v3-phase-14-s3-closure-gaps.md (round 3 boundary note)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
63ea717a75 |
P14 S2 fix²: close-safe delivery, catch-up ordering, pointer-form bypass
Addresses five architect findings across two review rounds, all on
the authority package introduced in
|
||
|
|
3d53563ca9 |
P14 S2 fix: per-subscription cancel, lossless-latest delivery, AST non-forgeability
Addresses three architect findings on the first S2 drop:
1. High: Unsubscribe(vid, rid) was key-wide — one Bridge exiting
silently closed channels for all other peers on the same
(VolumeID, ReplicaID). Replaced with per-subscription cancel:
Subscribe now returns (ch, cancel func). Each cancel closes only
its own subscription. Publisher owns a nextSubID counter and
tracks subscriptions as []*subscription per key. Cancel is
idempotent and safe against concurrent Run-exit teardown via a
"whoever finds it closes it" protocol.
Regression test: TestPublisher_IndependentUnsubscribe_OtherPeersUnaffected.
2. High: silent drop on full subscriber buffer could leave the
adapter on stale authority truth until an unrelated later ask
happened — unacceptable for an authority route. Per-subscription
channels are capacity 1 with overwrite-latest semantics: on full,
the publisher drains the stale pending value and retries send,
so the subscriber always reads the LATEST authoritative state
next. Intermediate states may be coalesced (correct for authority
truth; the engine cares about current identity, not interstitial
history).
Regression test: TestPublisher_DeliveryConvergesToLatestOnSlowConsumer.
3. Medium: the non-forgeability structural test was a regex-based
grep over core/ only, and caught only composite-literal Epoch
assignments. Rewritten as an AST-based walker that (a) covers
the whole repo (cmd/ and future production packages included,
not just core/) and (b) catches both composite-literal mints
with non-zero Epoch/EndpointVersion AND local variable
declarations of type AssignmentInfo — the classic bypass shape
for deferred mutation: `var x AssignmentInfo; x.Epoch = input`.
The stronger check surfaced three pre-existing hidden operator
paths in cmd/sparrow/main.go that minted AssignmentInfo with
hard-coded epochs 1/2/3 directly. All three demo sites are now
routed through a shared authority.Publisher: healthy demo issues
IntentBind, catch_up and rebuild demos issue IntentReassign.
No sparrow demo code constructs AssignmentInfo directly anymore.
Other:
* Run now closes every live subscription channel on exit, so
Bridges observe end-of-stream cleanly. Tested by
TestPublisher_RunClosesLiveSubscriptionsOnExit.
* Publisher.apply() releases the publisher lock before fan-out,
preventing a slow consumer from stalling the authoring loop.
Docs updated:
* docs/p14-s2-design.md — Publication API now documents
per-subscription cancel, removes the stale Unsubscribe(vid,rid)
verb, adds the "lossless for current fact" delivery semantic.
* docs/p14-s2-closure.md — test list updated (20 tests), Changed
section records the sparrow migration.
No changes to engine, adapter, transport, ops, storage.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
5c663b8c83 |
P14 S2: bounded authority publication route for assignment truth
Introduces the core/authority/ package — the system-owned publication
route where Epoch and EndpointVersion are authored, not relayed. The
publisher is the only production code that constructs an
adapter.AssignmentInfo with a non-zero Epoch.
Contract boundaries (load-bearing):
* S2 owns publication of authority truth.
* S2 does NOT own failover policy.
* Engine and adapter remain consumers, not producers.
Design:
* Publisher.Run consumes AssignmentAsk values from an injected
Directive and fans out AssignmentInfo to subscribers keyed by
(VolumeID, ReplicaID) — not by ReplicaID alone, which would
multiplex different volumes that share a replica name.
* AssignmentAsk carries no Epoch and no EndpointVersion. The
publisher mints both from the intent enum (Bind | RefreshEndpoint
| Reassign). Retirement (Remove) is deliberately deferred.
* No public verb accepts a preformed AssignmentInfo. The former
PublishAssignment relay verb was removed from the design before
code — the publisher is a minter, not a pass-through.
* Directive is the seam where P14 S3's failover policy will later
plug in without reaching into the publisher. S2 ships only
StaticDirective.
* Bridge forwards publisher output to adapter.OnAssignment — the
adapter remains the one and only consumer entry point; no second
mutation ingress was added.
Tests (core/authority/authority_test.go):
* Intent semantics: Bind mints epoch=1 ev=1; RefreshEndpoint keeps
epoch and bumps ev (no-op on unchanged addrs); Reassign bumps
epoch and resets ev=1; each invalid precondition is rejected.
* Fan-out keyed by (VolumeID, ReplicaID): two subs on the same key
both receive; a sub on a different volume for the same replica
name does NOT receive — regression for the narrow-key bug.
* Late-subscriber catch-up via LastPublished.
* Run loop drives Directive until ctx cancel; rejected asks are
logged and loop continues.
* Bridge forwards to AssignmentConsumer.
* Closure target integration test: Publisher -> Bridge -> real
VolumeReplicaAdapter reaches Mode == ModeHealthy without any
harness.assign call.
* Non-forgeability structural test walks core/ and fails if any
production file outside an explicit allowlist (authority /
calibration / conformance / schema) constructs an AssignmentInfo
with a non-zero Epoch.
Docs:
* docs/p14-s2-audit.md — scoped audit of existing producers /
publishers / consumers / hidden-operator-path smells / V2 port
candidates.
* docs/p14-s2-design.md — bounded design: load-bearing boundaries,
closure target, package layout, AssignmentAsk shape, authoring
rules table, publication API, Bridge model, V2 port plan,
explicit non-goals and acceptance criteria.
* docs/p14-s2-closure.md — what S2 closed, what stayed out, S2/S3
boundary table, verification recipe.
No changes to engine, adapter, transport, ops, storage, or sparrow
wiring. The authority route is additive.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|