* test(G1): red - a restarted replica applies a ship below its acknowledged epoch fencing-gaps-todo.md G1, red test first, as the doc describes it: a listener accepts a ship at epoch 2, is stopped and restarted on the same store, and a ship at epoch 1 arrives. Today it is applied: the floor was in memory only. Adds the seam the fix uses: NewReplicaListenerWithFloor(addr, store, floorPath), which cmd/blockvolume now uses with <durable-root>/<volume-id>.replica-floor (empty for memback). floorPath is ignored in this commit, so the test is red on behaviour. Stacked on the G2 branch (it reuses G2's epoch floor). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(G1): a durable replica epoch floor, and no mutation before the role is known fencing-gaps-todo.md G1, per the plan accepted on #83 (claude03; codex01 rounds 1-3). - core/transport/floor.go: a versioned, volume-bound floor record, strictly decoded (unknown/duplicate/missing fields, trailing data, wrong schema or volume, over 4 KiB refuse); persisted by temp write+fsync, rename, directory fsync, each checked; InitReplicaFloor creates the bootstrap record (epoch 0) before the volume and never replaces one. - Listener: NewReplicaListenerWithFloor(addr, store, volumeID, floorPath) loads the record (missing or invalid refuses) and starts unassigned: every mutating frame is refused until a role call succeeds. A frame whose epoch raises the floor persists it inside its G2-counted section before any effect or ACK (a barrier too); serialized under floorMu and monotonic; a refused frame leaves the lineage unchanged. FenceAsPrimary drains, persists, then returns; AdmitAsReplica persists first; both return the error. - Host: AdmitAsReplica errors fail the supporting path closed; any failed role call sets an admission latch that makes the projection unhealthy (writes refuse even on a prior-healthy host), reported in /status; a later successful role call clears it. SetSelfFence returns the replay error and cmd/blockvolume then does not serve. - cmd/blockvolume: the floor record is created before a new volume (DurableProvider.VolumeExists), and required on every later start. Tests: the red test, revised to the accepted 3-phase form (epoch-2 barrier ACK; restart refused before assignment; a stale epoch-1 admission still refuses epoch 1; current epoch accepted), barrier-only restart, fresh restart before assignment, record negatives and the existing-empty missing-record refusal, per-step persist failures on ship/barrier/rebuild, role-call persist failure incl. after a drain, fence-then-crash, concurrent monotonic raises, probes never persist, and the admission latch through the real StorageBackend. Each mechanism is load-bearing: without persistence 5 tests fail, without the startup gate 2, without the latch 1. Ledger: INV-FENCE-FLOOR-DURABLE-001. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(G1): stale role replays never reconcile a newer failure; the floor record's key set is closed codex01 review of 66446e0: - R1: a stale successful role call (e.g. an epoch-2 replay after the epoch-3 persist failed) cleared the admission latch and reopened writes. The host's desired role is now monotonic in epoch: a role call below the current desired epoch is refused as stale, without replacing the desired role or touching the latch; only the current (or a newer) epoch's success clears it, and install replay targets the retained current role. - R2: encoding/json struct decoding accepted case variants, so {"epoch":7,"EPOCH":0} loaded as floor 0. The key check now runs before decoding and accepts exactly schema, volume_id and epoch, case-sensitive, none repeated. Red (66446e0's floor.go and host.go) / green: codex01's two controls; the stale-replay cases on the primary, supporting and install-replay paths; uppercase keys, case-folded duplicates in both orders and a case-folded schema key refuse; canonical epoch 0 stays valid. All 23 G1/G2 tests pass 3/3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Protocol Design And Hardening
This directory is the working protocol-design entry point for Seaweed Block.
The goal is not to create a large abstract architecture library. The goal is to keep product behavior explainable and testable as the Kubernetes, CSI, host path, failover, repair, and dashboard surfaces grow.
Source Lineage
This directory distills the V3 design references under:
C:\work\seaweedfs\sw-block\design\v3-architecture.mdC:\work\seaweedfs\sw-block\design\v3-runtime-state-machines-overview.mdC:\work\seaweedfs\sw-block\design\v3-invariant-ledger.mdC:\work\seaweedfs\sw-block\design\protocol-anti-patterns.mdC:\work\seaweedfs\sw-block\design\v3-recovery-algorithm-consensus.md
Those documents remain the deeper historical source. The files here are the current-product operating copy for v0.3+ planning.
Design Thesis
Seaweed Block should use:
one product read model centered on ManagedVolume
+ many local projection controllers / small automata
+ invariant ledger
+ anti-pattern guardrails
+ cross-controller model tests
Do not build one giant state machine. Do not scatter unrelated local state machines. The product needs a shared volume-centered fact model and small engines that project from it.
Documents
control-model-principles.mddefines the truth-domain model and the rules for large context plus small automata.managed-volume-operations-model.mddefines the Phase 22 center of gravity: a PVC-backedManagedVolumeread model that composes K8s, CSI, authority, replica, host-path, workload, and evidence facts.engine-design-guidelines.mddefines the reusable engine/control-plane method: facts, context, multi-state projections, invariant checks, action contracts, executor boundaries, and evidence.invariant-ledger.mdstarts the current-project invariant ledger. Any new protocol claim should add or update a row here.protocol-anti-patterns.mdcopies the important anti-patterns into the current project vocabulary.phase22-control-context-plan.mdproposes the next hardening phase: ManagedVolume Operations Model.operations-state-dependency-review.mddefines the Phase 22 scope decision: operations v1 over a real product read model, not a pure dashboard pass or narrow protocol refactor.control-structure-effectiveness-review.mdreviews which parts of the control/model work have become real product capability, which remain too semantic, and what proof is required before approving more model work.fencing-gaps-todo.mdtracks open epoch / fencing gaps G1-G5 with the failure scenario, proposed fix, and red test for each.
Review Rule
Any behavior change that affects authority, recovery, CSI attach, host path, Kubernetes node behavior, or support evidence should answer:
- Which truth domain owns the new fact?
- Which invariant proves the behavior?
- Which anti-pattern did we check against?
- Is this a projection, or does it create authority?
- Does a cross-controller model test cover the composed state?
- Does the behavior update the
ManagedVolumestory for PVC, replica, frontend, CSI, host path, recovery, or evidence?
If the answers are unclear, update the protocol docs before shipping the behavior.