Compare commits

..
Author SHA1 Message Date
pingqiuandClaude Opus 5.5 205e40cf54 seaweed-block: the desired-ask retry keeps its DesiredAt to Stuck; contract rows
Review round 2 (both P2s):
- TestARepeatedlyLostReassignKeepsItsDesiredAtAndBecomesStuck runs four
  take -> ended-without-publication -> re-enqueue cycles across the retry
  window: DesiredAt stays the first desire and the Stuck evidence names it.
  A retry that re-anchors DesiredAt fails it.
- docs/design/invariants.md: M2 gains the controller-ask machine between
  the promotion gate and the publisher (queued, held, lost, re-enqueued,
  Stuck; the fenced-replace handoff), with its diagram, and the rows
  INV-AUTH-DESIRED-RETRY-001 and INV-PROMOTE-REPLACE-HANDOFF-001 naming the
  regression tests. No published specification models this handoff; the
  rows say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 01:05:20 -08:00
pingqiu 290049b1bf Merge branch 'block/controller-outcome-log' into block/controller-replace-reaches-reassign 2026-12-05 01:01:29 -08:00
pingqiuandClaude Opus 5.5 98b3104ad5 seaweed-block: a fenced replace always reaches the controller as a failover, and a lost Reassign is enqueued again
The gate marks the replaced primary's slot unacceptable in what it submits
on every fenced replace, not only when a loss is recorded. A primary only
the gate rejects (a node below the cluster's format level) was kept by the
controller's own acceptability predicate on every tick.

The same-ask dedupe holds a desired ask only while it is pending: queued,
or taken by the publisher and still being applied (the queue records the
ask the publisher holds until it asks for the next one). An identical ask
that is neither ended without a publication and is enqueued again, keeping
its DesiredAt so a repeatedly lost ask still reports Stuck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 00:13:55 -08:00
pingqiuandClaude Opus 5.5 860602beaa seaweed-block: red: a gate replace the controller keeps, and a lost Reassign held for ever
Two reds for the master's fenced replace that never publishes.

A primary only the gate rejects (its node reads an older format level,
its own flags still read reachable and ready, no loss recorded) is
replaced by a fencing round on every tick, and the controller answers
"no ask: the current primary is acceptable" on every tick.

A Reassign the publisher took and ended without publishing is lost, and
the same-ask dedupe answers "already desired" on every later intake, so
nothing enqueues it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 00:13:38 -08:00
7 changed files with 258 additions and 14 deletions

No files matched your search

+15 -5
View File
@@ -327,12 +327,22 @@ func (c *TopologyController) processSupportedVolumeLocked(
c.outcome[vol.VolumeID] = "no ask: " + reason
return
}
// Same-ask dedupe: if the identical ask is already the current
// desired, do not re-enqueue. Without this guard, repeated
// identical supported feeds would mint a new Reassign epoch
// each iteration — authority churn.
// Same-ask dedupe: while the identical ask is pending (queued, or
// taken by the publisher and still being applied), do not
// re-enqueue. Without this guard, repeated identical supported
// feeds would mint a new Reassign epoch each iteration —
// authority churn. An identical ask that is no longer pending
// ended without a publication (lost): enqueue it again, keeping
// its DesiredAt so a repeatedly lost ask still reports Stuck.
if prev, ok := c.desired[vol.VolumeID]; ok && sameAsk(prev.Ask, ask) {
c.outcome[vol.VolumeID] = fmt.Sprintf("already desired since %s: %s %s (%s)", prev.DesiredAt.UTC().Format(time.RFC3339Nano), ask.Intent, ask.ReplicaID, prev.Reason)
since := prev.DesiredAt.UTC().Format(time.RFC3339Nano)
if c.queue.pending(vol.VolumeID) {
c.outcome[vol.VolumeID] = fmt.Sprintf("already desired since %s: %s %s (%s)", since, ask.Intent, ask.ReplicaID, prev.Reason)
return
}
c.queue.enqueue(ask)
c.outcome[vol.VolumeID] = fmt.Sprintf("enqueued again %s %s (%s): desired since %s, its last ask ended without a publication", ask.Intent, ask.ReplicaID, prev.Reason, since)
applyProjectedMove(projectedLoad, vol, currentLine, hasLine, ask)
return
}
@@ -0,0 +1,126 @@
package authority
import (
"context"
"strings"
"testing"
"testing/synctest"
"time"
)
// The same-ask dedupe holds a desired Reassign only while that ask is
// pending: queued, or taken by the publisher and still being applied. An
// ask the publisher took and ended without publishing (its apply refused
// it) is lost, and the next intake of the same state enqueues it again.
// Holding the lost ask as "already desired" would keep the volume on its
// old primary for good.
func TestALostReassignIsEnqueuedAgainOnTheNextIntake(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
reader := newFakeBasisReader()
line := AuthorityBasis{Assigned: true, ReplicaID: "r1", Epoch: 1, EndpointVersion: 1, DataAddr: "d1", CtrlAddr: "c1"}
reader.Set("v1", "r1", line)
ctrl := NewTopologyController(TopologyControllerConfig{}, reader)
r1 := candidate("r1", "s1", "d1", "c1", 10)
r1.Reachable = false
snap := ClusterSnapshot{
CollectedRevision: 2,
Servers: []ServerObservation{
{ServerID: "s1", Reachable: true, Eligible: true},
{ServerID: "s2", Reachable: true, Eligible: true},
{ServerID: "s3", Reachable: true, Eligible: true},
},
Volumes: []VolumeTopologySnapshot{clusterVolume("v1", line, r1, candidate("r2", "s2", "d2", "c2", 20), candidate("r3", "s3", "d3", "c3", 10))},
}
submit := func() {
t.Helper()
if err := ctrl.SubmitClusterSnapshot(snap); err != nil {
t.Fatal(err)
}
}
submit()
if ask := nextAskOrFail(t, ctrl); ask.Intent != IntentReassign || ask.ReplicaID != "r2" {
t.Fatalf("first intake: %+v, want Reassign r2", ask)
}
// The publisher holds the ask (applying it): the same state again is
// deduplicated, nothing is queued twice.
submit()
if out := ctrl.LastOutcome("v1"); !strings.HasPrefix(out, "already desired since ") {
t.Fatalf("while the ask is being applied: outcome %q, want already desired", out)
}
// The apply ended without a publication (the line is still r1@1) and
// the publisher waits for its next ask: the ask is lost.
next := make(chan AssignmentAsk, 1)
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
go func() {
if ask, err := ctrl.Next(ctx); err == nil {
next <- ask
}
}()
synctest.Wait() // the publisher is back in Next, holding nothing
submit()
select {
case ask := <-next:
if ask.Intent != IntentReassign || ask.ReplicaID != "r2" {
t.Fatalf("after the loss: %+v, want Reassign r2 again", ask)
}
case <-ctx.Done():
t.Fatalf("a lost Reassign was never enqueued again; the controller's outcome: %q", ctrl.LastOutcome("v1"))
}
})
}
// A Reassign lost again and again keeps its first DesiredAt across every
// re-enqueue, so it still becomes Stuck once the retry window passes from
// that first desire: a retry that re-anchored DesiredAt would never report
// the volume stuck however long its asks keep failing.
func TestARepeatedlyLostReassignKeepsItsDesiredAtAndBecomesStuck(t *testing.T) {
const window = 10 * time.Second
reader := newFakeBasisReader()
line := AuthorityBasis{Assigned: true, ReplicaID: "r1", Epoch: 1, EndpointVersion: 1, DataAddr: "d1", CtrlAddr: "c1"}
reader.Set("v1", "r1", line)
ctrl := NewTopologyController(TopologyControllerConfig{RetryWindow: window}, reader)
clk := newFakeClock(time.Date(2026, 12, 5, 9, 0, 0, 0, time.UTC))
ctrl.SetNowForTest(clk.Now)
r1 := candidate("r1", "s1", "d1", "c1", 10)
r1.Reachable = false
snap := ClusterSnapshot{
CollectedRevision: 2,
Servers: []ServerObservation{
{ServerID: "s1", Reachable: true, Eligible: true},
{ServerID: "s2", Reachable: true, Eligible: true},
{ServerID: "s3", Reachable: true, Eligible: true},
},
Volumes: []VolumeTopologySnapshot{clusterVolume("v1", line, r1, candidate("r2", "s2", "d2", "c2", 20), candidate("r3", "s3", "d3", "c3", 10))},
}
first := clk.Now()
ended, cancel := context.WithCancel(context.Background())
cancel() // the publisher's next call after an apply that published nothing
for cycle := 0; cycle < 4; cycle++ {
if err := ctrl.SubmitClusterSnapshot(snap); err != nil {
t.Fatal(err)
}
if cycle > 0 && !strings.HasPrefix(ctrl.LastOutcome("v1"), "enqueued again Reassign r2") {
t.Fatalf("cycle %d: outcome %q, want the lost ask enqueued again", cycle, ctrl.LastOutcome("v1"))
}
if d, ok := ctrl.DesiredFor("v1"); !ok || !d.DesiredAt.Equal(first) {
t.Fatalf("cycle %d at +%v: desired %+v (ok=%v), want DesiredAt kept at the first desire %v", cycle, clk.Now().Sub(first), d, ok, first)
}
if ask := nextAskOrFail(t, ctrl); ask.Intent != IntentReassign || ask.ReplicaID != "r2" {
t.Fatalf("cycle %d: took %+v, want Reassign r2", cycle, ask)
}
_, _ = ctrl.Next(ended) // the apply ended without a publication: the ask is lost
clk.Advance(4 * time.Second)
}
// +16 s since the first desire, past the 10 s window: the latest intake
// (+12 s) found the desire unconfirmed past the window.
ev, stuck := ctrl.LastConvergenceStuck("v1")
if !stuck {
t.Fatalf("a Reassign lost on every apply for %v is not reported stuck (window %v)", clk.Now().Sub(first), window)
}
if !ev.DesiredAt.Equal(first) || ev.Ask.ReplicaID != "r2" {
t.Fatalf("stuck evidence %+v, want the first desire (%v) of Reassign r2", ev, first)
}
}
+17
View File
@@ -14,6 +14,10 @@ type assignmentQueue struct {
items map[string]AssignmentAsk
order []string
wake chan struct{}
// taken is the volume of the ask the publisher took last and is still
// applying: it is cleared when the publisher asks for its next one (the
// publisher applies one ask at a time, between two calls of next).
taken string
}
func newAssignmentQueue() *assignmentQueue {
@@ -42,7 +46,19 @@ func (q *assignmentQueue) discard(volumeID string) {
delete(q.items, volumeID)
}
// pending reports whether volumeID's ask is queued or still being applied.
// A desired ask that is neither ended without a publication (lost).
func (q *assignmentQueue) pending(volumeID string) bool {
q.mu.Lock()
defer q.mu.Unlock()
_, queued := q.items[volumeID]
return queued || q.taken == volumeID
}
func (q *assignmentQueue) next(ctx context.Context) (AssignmentAsk, error) {
q.mu.Lock()
q.taken = "" // the publisher is done with the ask it took last
q.mu.Unlock()
for {
q.mu.Lock()
if len(q.order) > 0 {
@@ -54,6 +70,7 @@ func (q *assignmentQueue) next(ctx context.Context) (AssignmentAsk, error) {
continue
}
delete(q.items, vid)
q.taken = vid
q.mu.Unlock()
return ask, nil
}
@@ -0,0 +1,60 @@
package master
import (
"regexp"
"strings"
"testing"
"time"
"github.com/seaweedfs/seaweed-block/core/authority"
"github.com/seaweedfs/seaweed-block/core/host/bootstrap"
)
// A fenced replace decided by the gate reaches the controller as a failover
// whatever the gate's reason. Here the gate replaces a primary only it reads
// as unacceptable: its node reads format level 0 on a level-1 cluster (not
// placement-eligible), while the primary's own slot flags still read
// reachable and ready, and it still reports (no loss is recorded). The
// controller judges acceptability by those flags alone, so unless the gate
// marks the replaced primary unacceptable in what it submits, the controller
// answers "the current primary is acceptable" on every tick and the fenced
// decision never publishes.
func TestAFencedReplaceOfAPrimaryOnlyTheGateRejectsReachesAReassign(t *testing.T) {
ctrl, pub, _ := lossCluster(t, authority.TopologyControllerConfig{})
h, buf := lossMaster(t, &fenceProbe{plain: lossPlain, fenced: lossFenced})
h.ctrl = ctrl
h.boot = &bootstrap.DurableAuthorityBootstrap{Publisher: pub}
h.reads = newReadsLevels(time.Hour)
h.reads.note("s1", "vol-rf3", "p-r1", 0) // the primary's node reads the old level
h.reads.note("s2", "vol-rf3", "p-r2", 1)
h.reads.note("s3", "vol-rf3", "p-r3", 1)
h.format.v.Store(1)
t0 := time.Date(2026, 12, 5, 8, 0, 0, 0, time.UTC)
for tick := range 3 {
now := t0.Add(time.Duration(tick) * time.Second)
snap := silentPrimary() // r1's flags read reachable and ready
snap.Volumes[0].Authority, _ = pub.VolumeAuthorityLine("vol-rf3")
if snap.Volumes[0].Authority.Epoch != 1 {
break // published
}
heard := map[string]time.Time{"r1": now, "r2": now, "r3": now} // r1 still reports: no loss
h.notePrimaryLosses(rx(heard, now), &snap)
h.takeGateReplaces()
h.applyPromotionEvidenceGate(&snap)
if l := gateLine(t, buf.String(), "vol-rf3"); !regexp.MustCompile(`primary_lost=false decision=replace\(fenced_at=2\)$`).MatchString(l) {
t.Fatalf("tick %d: gate line %q; want a fenced replace with no loss recorded", tick, l)
}
outcomes, err := ctrl.SubmitObservedStateOutcomes(snap, authority.SupportabilityReport{})
if err != nil {
t.Fatal(err)
}
h.reportReplaces("", nil, outcomes)
}
if strings.Contains(buf.String(), "controller: no ask: the current primary is acceptable") {
t.Fatalf("the controller kept a primary the gate replaced:\n%s", buf.String())
}
if !regexp.MustCompile(`decision=replace\(fenced_at=2\) controller: enqueued Reassign r[23] \(failover\)`).MatchString(buf.String()) {
t.Fatalf("the fenced replace was not enqueued as a failover:\n%s", buf.String())
}
waitLossLine(t, pub, "vol-rf3", func(l authority.AuthorityBasis) bool { return l.Epoch == 2 && l.ReplicaID != "r1" })
}
+1 -1
View File
@@ -147,7 +147,7 @@ type Host struct {
attest *storeAttestations // primaries' attested write-ACK stores
healthMu sync.Mutex // orders replica health events with their accepted heartbeats (#128 rule 6)
log *log.Logger
gateNoteMu sync.Mutex // guards gateNoteLast and gateReplaces
gateNoteMu sync.Mutex // guards gateNoteLast
gateNoteLast map[string]string // per kind, the last skip or drop a product-loop tick logged (noteGate)
gateReplaces []gateReplace // this tick's replace decisions, reported after the submit (reportReplaces)
primaryLossMu sync.Mutex // guards primaryLoss
@@ -500,12 +500,15 @@ func (h *Host) applyPromotionEvidenceGate(snap *authority.ClusterSnapshot) (int,
slot.PlannedMoveAllowed = false
}
}
// A fenced replacement of a lost primary reaches the controller as
// a failover: its slot no longer reads acceptable, so the controller
// publishes the fenced target with its fenced evidence (the line is
// minted only at the fenced epoch), never keeping the old line nor
// A fenced replacement reaches the controller as a failover,
// whatever the gate's reason (a recorded loss, or a primary only
// the gate reads as unacceptable, such as one on a node below the
// cluster's format level): its slot no longer reads acceptable, so
// the controller publishes the fenced target with its fenced
// evidence (the line is minted only at the fenced epoch), never
// keeping the old line by its own acceptability predicate nor
// routing the target as a planned rebalance without that epoch.
if lost && fencedReplace {
if fencedReplace {
current := &vol.Slots[currentIdx]
current.Reachable, current.ReadyForPrimary = false, false
}
+31 -3
View File
@@ -148,6 +148,34 @@ flowchart LR
| any authority line, stores still awaited (stage 1) | DeleteReserved without the holder's acknowledgement | the master's record is marked first, durably and in the lock that ends the store wait; the mark freezes the record in stage 1 (the wait never ends after it, so the primary, whose assignment keeps awaiting the stores, never serves); the reservation then skips the live-lease refusal. Deleting HEAD waits out the lease as above. Past stage 1, also while the end of creation is unrecorded (the volume may be serving), the live-lease refusal stays | `core/host/master/volume_delete_authority.go` `Reserve`; `core/host/master/store_attestation.go` `markDeleteWithoutAck`, `awaited`; `core/authority/workspace_delete_reservation.go` `ReserveNeverCreatedWorkspaceDeletion` | `INV-WS-DELETE-WITHOUT-ACK-001` |
| DeleteReserved, removed from the desired spec | Retired metadata (reservation permanent) | no live lease, then a fresh bounded HEAD read proves deleted or absent; unread/live/deleting keeps the records. Remove authority durably, then placement and bindings, then the volume record; a crash retries the remaining removals. A startup lease skip schedules one more pass after the latest observed barrier, also without the product loop; full passes log skips. The store and its resweep inputs are untouched | `core/host/master/spec_retirement.go` `ReconcileDeletedSpecVolumes`, `startPostFloorRetirement`; `core/authority/workspace_retirement.go` `RetireDeletedWorkspace` | `INV-SPEC-DELETE-RETIRE-001`, `INV-SPEC-DELETE-RETRY-001` |
**Controller ask, per volume (between the promotion gate and the publisher).**
The topology controller turns a supported snapshot into at most one ask per volume. The publisher drains the controller's queue one ask at a time (its `Run` loop, between two calls of `next`). A fenced replace decided by the supported gate is submitted with the replaced primary's slot unacceptable, whatever the gate's reason, so the controller's own acceptability predicate never keeps that primary. An ask is pending while it is queued or held by the publisher; an identical ask is deduplicated only while it is pending.
```mermaid
stateDiagram-v2
[*] --> Queued: intake decides an ask (desired, DesiredAt set)
Queued --> Held: publisher takes it (next)
Held --> Published: apply publishes (line moves)
Held --> Lost: apply ends without a publication (publisher calls next again)
Lost --> Queued: next intake decides the identical ask (DesiredAt kept)
Queued --> Queued: identical ask decided (already desired)
Held --> Held: identical ask decided (already desired)
Published --> [*]: snapshot observes the new line (desired confirmed)
```
| From | To | Event and guard | Enforced in | Protects |
|---|---|---|---|---|
| no desired ask | Queued | an intake of a supported snapshot decides an ask; the desired entry records DesiredAt. A fenced replace (with or without a recorded loss) reaches the controller with the replaced primary's slot unreachable and not ready, so its intake decides the failover to the fenced target | `core/authority/controller.go` `processSupportedVolumeLocked`, `decideVolume`; `core/host/master/product_loop.go` `applyPromotionEvidenceGate` | `INV-PROMOTE-REPLACE-HANDOFF-001` |
| Queued | Held | the publisher takes the ask; the queue records the volume it holds | `core/authority/queue.go` `next` | `INV-AUTH-DESIRED-RETRY-001` |
| Queued or Held | (no change) | an intake decides the identical ask while it is pending: deduplicated (`already desired since T`), nothing queued twice | `core/authority/controller.go` `processSupportedVolumeLocked`; `core/authority/queue.go` `pending` | `INV-AUTH-DESIRED-RETRY-001` |
| Held | Published | the apply publishes the line (epoch minted by the publisher) | `core/authority/authority.go` `applyWithWorkspaceMove` | `INV-AUTH-EPOCH-MINT-001` |
| Held | Lost | the apply ends without a publication (refused, or dropped); the publisher asks for its next ask, which clears the held volume | `core/authority/queue.go` `next` | `INV-AUTH-DESIRED-RETRY-001` |
| Lost | Queued (DesiredAt kept) | an intake decides the identical ask: enqueued again (`enqueued again ...`), the desired entry and its DesiredAt unchanged | `core/authority/controller.go` `processSupportedVolumeLocked` | `INV-AUTH-DESIRED-RETRY-001` |
| any desired (unconfirmed) | Stuck evidence | DesiredAt + retry window passed without the line observed; a repeatedly lost ask reaches it from its first desire | `core/authority/convergence.go` `evaluateStuckLocked` | `INV-AUTH-DESIRED-RETRY-001` |
Model scope: no published specification models this handoff; its liveness (a decided replace reaches a publication or names a blocker) is argued by the rows' tests, not a model.
**Volume creation phase, in blockmaster's store record** (`core/host/master/store_attestation.go`, decided by `inCreationPhase` in `core/host/master/product_loop.go`). Every replacement entry (both promotion gates, the operator's failover and planned move, the rebalance) acts only on Established.
```mermaid
@@ -956,6 +984,7 @@ Notes:
| `INV-CLI-TYPED-REFUSAL-001` | The chunk CLI reports a restore the master refused for a foreign source as `restore_source_not_own` (from the master's typed reason, never its text) and a volume the master does not know as `volume_not_found`. | M2 none → created (restore refusal); CLI volume resolve | `core/host/master/services.go` `CreateVolume`; `core/rpc/lifecycleclient/reason.go` `WithReason`, `Reason`; `cmd/sw-block/chunk_b.go` `chunkRestore`, `run` | `TestOpsChunkTypedRefusalCodes` (`cmd/sw-block/chunk_typed_codes_test.go`), `TestReasonRoundTrip` (`core/rpc/lifecycleclient/reason_test.go`), `TestARealCatalogRestoreOfARestoreTargetLeavesNothing` (`core/host/master/restore_refusal_catalog_test.go`) | — (reporting only; the refusal is `INV-CREATE-ONE-IDENTITY-001`'s). Limits: other FailedPrecondition refusals stay the generic `not_admitted` | ACTIVE |
| `INV-CLI-RESTORE-VERB-001` | `volume restore --abort` changes nothing unless the master records this command's source, snapshot and request id for the target and this host's settings name exactly it (volume, master, `--layout-id` alone in the extra arguments); a re-run counts only this replica's published line as placed. | client (no state machine): the CLI side of M2 restore create, placement and delete | `cmd/sw-block/volume_backup.go` `volumeRestoreAbort`, `volumeRestore`, `restorePlaced`; `core/host/master/services.go` `lifecycleVolumeResponse` | `TestVolumeRestoreAbortRefusesAForeignTarget`, `TestVolumeRestoreAbortRefusesAnotherLocalInstallation`, `TestVolumeRestoreAbortInterruptedAtEveryStepCompletes`, `TestVolumeRestoreCrashTableBothWays`, `TestVolumeRestorePublicationDuringThePlacement`, `TestVolumeRestorePlacementOfAnotherLineRefuses`, `TestVolumeRestoreCreatesPlacesAndStarts`, `TestVolumeBackupTakesOneSnapshotAndRerunReplays`, `TestVolumeBackupRefusals`, `TestVolumeBackupIncompleteAnswerIsUnknown` (`cmd/sw-block/volume_backup_test.go`), `TestGetVolumeAnswersTheRecordedRestoreTuple` (`core/host/master/volume_restore_tuple_test.go`) | — (the command's model is checked outside the repository; its trace is on the pull request) | ACTIVE |
| `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestLayoutGrantedEpochIssuerSites`, `TestLayoutEpochEnumerationRejectsANewIssuer`, `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`); also in `core/authority/layout_granted_epoch_guard_test.go` | `ControlPlane` `UniqueEpoch` | ACTIVE |
| `INV-AUTH-DESIRED-RETRY-001` | The controller deduplicates a desired ask only while it is pending: queued, or taken by the publisher and still being applied. An identical ask that ended without a publication is enqueued again on the next intake, keeping its first DesiredAt, so an ask lost on every apply still becomes Stuck once the retry window passes from that first desire. | M2 controller ask: Queued or Held (deduplicated); Held → Lost; Lost → Queued; Stuck evidence | `core/authority/controller.go` `processSupportedVolumeLocked`; `core/authority/queue.go` `pending`, `next`; `core/authority/convergence.go` `evaluateStuckLocked` | `TestALostReassignIsEnqueuedAgainOnTheNextIntake`, `TestARepeatedlyLostReassignKeepsItsDesiredAtAndBecomesStuck` (`core/authority/controller_lost_ask_test.go`) | — (no published specification models the controller's queue) | ACTIVE |
| `INV-AUTH-RESTART-REISSUE-001` | A line records the primary process it was issued for (durable); a current primary reporting another process is re-issued its line at a new endpoint version, and a primary adopts no line issued for another process, so a restarted process never reuses the dead one's sessions. | M2 authority (RefreshEndpoint); M3 primary adoption | `core/authority/authority.go` `applyWithWorkspaceMove` (records the ask's or the source's incarnation); `core/authority/controller.go` `endpointStale`, `sameAsk`, `refreshAsk` (conditional on the line it read); `core/host/master/product_loop.go` `RunLifecycleProductTick`, `restartedHolderRefresh` (the product loop's direct path for a workspace-bound RF1 volume, conditional on the line it read); `core/authority/workspace.go` `persistWorkspaceTimedLocked`; `core/authority/observation_store.go` `SlotFactAt`; `core/host/master/host.go` (the source); `core/host/volume/host.go` `applyFact` | `TestPublisher_RestartedPrimaryGetsANewEndpointVersion`, `TestPublisher_AskWithoutAProcessIsIssuedForTheReportedOne`, `TestTopologyController_RestartedPrimaryAtTheSameAddressIsReissued`, `TestTopologyController_QueuedRefreshIsReplacedForANewerProcess`, `TestTopologyController_UnnamedLineIsReissuedOnceForTheReportingProcess`, `TestWorkspaceLeaseWriteKeepsTheLinesIncarnationAcrossReload`, `TestObservationStore_SlotFactAtIsTheProcessAtThoseEndpoints` (`core/authority/restart_endpoint_version_test.go`); `TestLinesNameTheirPrimarysProcess`, `TestLineForTheTargetsEndpointsNamesTheTargetsProcess` (`core/host/master/line_incarnation_test.go`); `TestRF1RuntimeVolumeIsReissuedToARestartedHolder`, `TestRF1RuntimeLineNamingNoProcessIsReissued`, `TestRF1RefreshDecidedBeforeACrossHostMoveIsNotApplied` (`core/host/master/rf1_restart_reissue_test.go`); `TestRefreshIsConditionalOnTheLineItWasDecidedAgainst`, `TestControllerRefreshNamesTheLineItWasDecidedAgainst` (`core/authority/refresh_expected_line_test.go`); `TestHost_ApplyFact_LineIssuedForAnotherProcessIsNotAdopted`, `TestHost_ApplyFact_UnnamedLineIsNotAdoptedWhereLinesNameTheirProcess` (`core/host/volume/line_incarnation_test.go`); `TestHostConfigAdoptsOnlyLinesNamingThisProcess` (`cmd/blockvolume/lines_name_their_process_test.go`); `TestRestartedPrimaryAtTheSameEpochIsAdmitted` (`core/replication/primary_restart_session_test.go`) | — | ACTIVE |
| `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, a failed write does not publish it, and an unknown outcome (directory fsync after the rename failed) fail-stops blockmaster: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove`; `core/authority/authority_store_file.go` `Put` (`failStopDurabilityUnknown` after a failed directory open or fsync behind the rename, every record; a close error after a good fsync is reported written; Windows keeps its previous behaviour) | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`); `TestPutFailStopsWhenTheDirectoryFsyncFailsAfterRename`, `TestPutReportsWrittenWhenOnlyTheDirectoryCloseFails` (`core/authority/authority_store_dir_fsync_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE |
| `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE |
@@ -1323,8 +1352,8 @@ Notes:
| `INV-PROMOTE-FRONTIER-UNKNOWN-001` | With an unknown frontier under `sync_quorum` or `sync_all`, the gate allows the highest-durable ready candidate only if at least N_peers-K+1 of the N_peers peers are probed ready this tick and have a fresh heartbeat (K as in `waitForSyncAcks`); else none. | M3 Supporting → promotion candidate (RF=3 gate) | `core/host/master/product_loop.go` `promotionAllowedReplicas`, `unknownFrontierSurvivorsNeeded`, `freshPromotionPeers`; `core/replication/async_ack.go` `waitForSyncAcks` | `TestMountedFailover_ProductLoopRF3UnknownRequiredLSNFallsBackToHighestDurableLSN` (`core/host/master/product_loop_test.go`); `TestProductLoop_MissingRequiredFrontierRefusesRF3Promotion` (`core/host/master/promotion_missing_frontier_regression_test.go`); `TestUnknownFrontierSurvivorsNeeded`, `TestFreshPromotionPeers_UsesObservationFreshness`, `TestProductLoop_UnknownFrontierSurvivorReadyLastTickMissingNowRefused` (`core/host/master/promotion_frontier_coverage_test.go`) | — | ACTIVE |
| `INV-PROMOTE-FRONTIER-BEST-EFFORT-001` | The automatic path never replaces a lost primary of a `best_effort` volume (a write may be on the primary alone, as for the operator's move): both gates hold it before any fencing round and show `best_effort_no_automatic_failover`. | M3 Supporting → promotion candidate (both gates) | `core/host/master/product_loop.go` `automaticFailoverHold` (supported gate before `fencedDecision`; unsupported gate before its candidates); `promotionAllowedReplicas` | `TestTheAutomaticPathHoldsABestEffortVolume` (`core/host/master/best_effort_hold_test.go`); `TestMountedFailover_ProductLoopRF3BestEffortIsHeldDespiteAHighestDurableSurvivor`, `TestMountedFailover_ProductLoopRF3RejectsBestEffortProbeForHA` (`core/host/master/product_loop_test.go`); `TestPromotionAllowedReplicas_RequiredFrontierCoverage` (`core/host/master/promotion_frontier_coverage_test.go`) | — | ACTIVE |
| `INV-PROMOTE-ACK-PROFILE-MATCH-001` | The automatic path holds a lost primary's volume, before any fencing round and showing `ack_profile_mismatch`, when a probe answer names no ack profile or another than blockmaster's `--launcher-replication-ack`; blockmaster refuses to start with an unknown one. | M3 Supporting → promotion candidate (both gates) | `core/host/master/probe_round.go` `profileMismatch`; `core/host/master/product_loop.go` `automaticFailoverHold` (plain round), `fencedDecision` (fencing round); `core/host/volume/probe_round.go` `probeAnswer`; `cmd/blockvolume/main.go` `hostConfig`; `cmd/blockmaster/main.go` `parseFlags` | `TestTheAutomaticPathHoldsOnAnAckProfileMismatch`, `TestProbeRound_ReportsAnAckProfileMismatch`, `TestTheFencingRoundsAckProfileIsCheckedToo` (`core/host/master/ack_profile_mismatch_test.go`); `TestProbeAnswerNamesTheVolumesAckProfile` (`core/host/volume/probe_ack_profile_test.go`); `TestHostConfigAnswersTheVolumesOwnAckProfile` (`cmd/blockvolume/probe_ack_profile_test.go`); `TestBlockmasterRefusesAnUnknownLauncherReplicationAck` (`cmd/blockmaster/launcher_replication_ack_flag_test.go`) | — | ACTIVE |
| `INV-PROMOTE-DECISION-REPORTED-001` | Every replace decision of the supported promotion gate is logged once after its tick: with the controller's outcome from the same submission (read under its lock, so a later intake cannot change it), as not submitted and why, or as a failed submit. Diagnostics only: no decision changes. | M3 Supporting → promotion candidate (supported gate → controller → publisher) | `core/host/master/product_loop.go` `submitPlacementSnapshots`, `noteGateReplace`, `reportReplaces`; `core/authority/controller.go` `SubmitObservedStateOutcomes`, `LastOutcome` | `TestAReplaceDecisionLogsWhatTheControllerDidWithIt` (cases: enqueued, already desired, no ask with why, not submitted, an intake after the submission does not change its report, a submission that did not carry the volume, one report per decision), `TestAProductTickReplaceLogsTheControllerOutcomeAndThePublication`, `TestABindingReadFailureAfterTheProbeReportsTheDecisionNotSubmitted` (`core/host/master/gate_controller_outcome_test.go`, `core/host/master/gate_binding_read_failure_test.go`) | — (diagnostics; no published specification models the log) | ACTIVE |
| `INV-AUTHORITY-PUBLICATION-LOGGED-001` | Every authority publication is logged on the master's log with its volume, replica, epoch, endpoint version and intent, also when no event sink is set. Diagnostics only: no decision changes. | M3 controller → publisher (publication observer) | `core/host/master/product_loop.go` `recordAuthorityPublishedEvent` | `TestAPublicationIsLogged`, `TestAProductTickReplaceLogsTheControllerOutcomeAndThePublication` (`core/host/master/gate_controller_outcome_test.go`) | — (diagnostics; no published specification models the log) | ACTIVE |
| `INV-PROMOTE-DECISION-REPORTED-001` | Every replace decision of the supported promotion gate is reported on the master's log once, after its tick: with the controller's outcome for that volume from the same submission (read under the controller's lock, so a later intake cannot change it), as not submitted and why (placements changed, a binding appeared, endpoints bound elsewhere, or the workspace bindings could not be read after the probe), or as a failed submit; every publication is logged. Diagnostics only: no decision changes. | M3 Supporting → promotion candidate (supported gate → controller → publisher) | `core/host/master/product_loop.go` `submitPlacementSnapshots`, `noteGateReplace`, `reportReplaces`, `recordAuthorityPublishedEvent`; `core/authority/controller.go` `SubmitObservedStateOutcomes`, `LastOutcome` | `TestAReplaceDecisionLogsWhatTheControllerDidWithIt` (cases: enqueued, already desired, no ask with why, not submitted, an intake after the submission does not change its report, a submission that did not carry the volume, one report per decision), `TestAProductTickReplaceLogsTheControllerOutcomeAndThePublication`, `TestABindingReadFailureAfterTheProbeReportsTheDecisionNotSubmitted`, `TestAPublicationIsLogged` (`core/host/master/gate_controller_outcome_test.go`, `core/host/master/gate_binding_read_failure_test.go`) | — (diagnostics; no published specification models the log) | ACTIVE |
| `INV-PROMOTE-REPLACE-HANDOFF-001` | A fenced replace decided by the supported promotion gate reaches the controller as a failover whatever the gate's reason (a recorded loss, or a primary only the gate reads as unacceptable, such as one on a node below the cluster's format level): the replaced primary's slot reads unreachable and not ready in the submitted snapshot, so the controller never keeps it by its own acceptability predicate, and publishes the fenced target with its fenced evidence. | M2 controller ask: no desired ask → Queued (failover); M3 Primary → another replica Primary at e+1 | `core/host/master/product_loop.go` `applyPromotionEvidenceGate`; `core/authority/controller.go` `decideVolume` | `TestAFencedReplaceOfAPrimaryOnlyTheGateRejectsReachesAReassign` (`core/host/master/gate_controller_replace_test.go`); `TestALostPrimarysFencedReplacementIsPublished` (`core/host/master/primary_loss_publish_test.go`) | — (no published specification models the gate → controller handoff) | ACTIVE |
| `INV-PRIMARY-ACK-PROFILE-001` | A primary of a replicated line serves only when its own `--replication-ack` is the profile its assignment names (blockmaster's); otherwise its frontend is not Healthy and status names both profiles. So a lost primary, which does not answer, acknowledged under the master's profile. | M1 Primary → Serving (replicated line) | `core/host/master/services.go` `assignmentFact` (`ack_profile`); `core/host/volume/workspace_startup.go` `noteAckProfile`; `core/host/volume/projection_bridge.go` `projectionWithSupersede`; `core/host/volume/status_server.go` | `TestPrimaryOfAReplicatedLineServesOnlyUnderTheMastersAckProfile` (`core/host/volume/ack_profile_refusal_test.go`); `TestAssignmentNamesTheMastersAckProfile` (`core/host/master/ack_profile_mismatch_test.go`) | — | ACTIVE |
| `INV-CSI-CONSUMES-AUTHORITY-001` | CSI never imports authority code or builds assignment facts; it takes the publish target from blockmaster and refreshes it before a stage, and blockmaster mints the IDs of the events CSI reports. | M2 (read side) | `core/csi/master_backend.go` `LookupPublishTarget`; `core/csi/node.go` `refreshPublishContext`; `core/host/master/observation_service.go` `ReportClusterEvent` | `TestG15a_CSI_DoesNotImportAuthorityOrConstructAssignmentFacts` (`core/csi/boundary_guard_test.go`); `TestG15e_CSIReattachUsesFreshPublishTargetAfterUnstage` (`core/csi/node_test.go`); `TestObservationService_ReportClusterEventAppearsInVolumeTimeline` (`core/host/master/observation_service_test.go`) | — | ACTIVE |
| `INV-K8S-NONLOOPBACK-001` | Generated multi-node Helm values enable external iSCSI, external status and loopback rejection; with rejection enabled CSI never publishes a loopback target and fails closed when only loopback targets exist. | M2 (read side) | `cmd/sw-block/main.go` `runOpsGenerateHelmValues`; `core/csi/master_backend.go` `rejectFrontendAddr` | `TestOpsGenerateHelmValuesMultiNodeExternalISCSI` (`cmd/sw-block/main_test.go`); `TestNodeLoss_ControlStatusLookup_RejectsLoopbackPublishTargetsWhenEnabled`, `TestNodeLoss_ControlStatusLookup_FailClosedWhenOnlyLoopbackTargets` (`core/csi/master_backend_test.go`) | — | ACTIVE |
@@ -1346,7 +1375,6 @@ Notes:
- `INV-FENCE-STALE-PRIMARY-001`: Narrowed. A primary cut off from blockmaster that has not seen the newer line keeps admitting I/O, and under `best_effort` its local `fsync` still acknowledges (no primary lease on the Kubernetes path; see the Kubernetes known gaps). The lab counter `old_primary_stale_io_success_count=0` is lab evidence only.
- `INV-PROMOTE-FRONTIER-001`: Fixed for [#181](https://github.com/seaweedfs/seaweed-block/issues/181). `cmd/blockmaster` does not set `RequiredLSNByVolume`, so in a deployment the frontier is unknown and the survivor rule applies (an RF=3 `sync_quorum` volume with one peer unseen is not promoted automatically). Limits: blockmaster has no source for the required frontier ([#192](https://github.com/seaweedfs/seaweed-block/issues/192)); the rule covers only the acknowledgements represented by the frontiers sampled in one tick, because those probes are snapshots, not a fence, and a deposed primary can still acknowledge after a sample (no primary lease, [#195](https://github.com/seaweedfs/seaweed-block/issues/195)). See [Kubernetes design §6 and §12](kubernetes-block-design.md). RF=2 relies on `INV-REPL-PROMOTION-READY-001`.
- `INV-PROMOTE-FRONTIER-PROBE-001`, `INV-PROMOTE-FRONTIER-UNKNOWN-001`, `INV-PROMOTE-FRONTIER-BEST-EFFORT-001`: new rows split from `INV-PROMOTE-FRONTIER-001`, kept beside it. N_peers is the number of replicas other than the current primary; for RF=3 (two peers) both must be seen under `sync_quorum`, one under `sync_all`. An unknown frontier is never read as zero. Heartbeat freshness is the observation store's rule (`FreshSlotCandidate`). The gate runs for every volume with two or more slots (RF=2 included); a primary change is published only with its evidence.
- `INV-PROMOTE-DECISION-REPORTED-001`: a decision is not submitted when the placements changed during the probe, a volume got a workspace binding, a replica's endpoints are bound elsewhere, or the workspace bindings could not be read after the probe; the line names which. `INV-AUTHORITY-PUBLICATION-LOGGED-001` was split from it.
- `INV-K8S-NONLOOPBACK-001`: Rejection is opt-in: the chart default for `network.rejectLoopbackPublishTargets` is false; the generator sets it for multi-node values.
- `INV-OBS-PRODUCT-EVENTS-001`: Each event type has a unit test; all four together in one node-loss run is lab evidence only.
- `INV-HOSTPATH-TRANSPARENT-001`: Narrowed to the classifier. It does not compare the host path target with the promoted target, and only the missing-multipath case has a negative test. The mounted-failover run is lab evidence.