diff --git a/seaweed-block/core/frontend/chunkstore/layout/claim.go b/seaweed-block/core/frontend/chunkstore/layout/claim.go index d25869363b..b05662cb23 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/claim.go +++ b/seaweed-block/core/frontend/chunkstore/layout/claim.go @@ -28,7 +28,10 @@ func (h Head) Claim(me HolderID) (next Head, changed bool, err error) { if me.Epoch == 0 || me.Holder == "" || me.ClaimID == "" { return Head{}, false, errors.New("layout: Claim needs an epoch, a holder and a claim id") } - if h.State != StateLive { + if h.State == StateDetached && me.Epoch <= h.Epoch { + return Head{}, false, ErrDetached + } + if h.State != StateLive && h.State != StateDetached { return Head{}, false, fmt.Errorf("%w: HEAD is %s", ErrVolumeDeleting, h.State) } switch { @@ -42,6 +45,7 @@ func (h Head) Claim(me HolderID) (next Head, changed bool, err error) { next = h.clone() next.Epoch, next.Holder, next.ClaimID = me.Epoch, me.Holder, me.ClaimID next.Activity = Activity{Kind: ActIdle} + next.State = StateLive return next, true, nil } diff --git a/seaweed-block/core/frontend/chunkstore/layout/commit.go b/seaweed-block/core/frontend/chunkstore/layout/commit.go index 45fd2f02af..ca432b9d97 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/commit.go +++ b/seaweed-block/core/frontend/chunkstore/layout/commit.go @@ -26,12 +26,15 @@ var ( // the manifest of HEAD's current root that the session computed what is // new against: empty when HEAD has no current root, and empty also when // the current root is that of an empty image. +// StateDetached commits the final image of a stop: Position must be the local +// synced position taken after the caller closed its guest-write barrier. type CommitRequest struct { Session string Prev map[uint64]Ref Next map[uint64]Ref Position uint64 Snapshot string // "" = no named snapshot + State string // StateLive, or StateDetached for the final synced image } // rootOf names the root of a manifest. @@ -59,17 +62,22 @@ func newOwn(vol string, prev, next map[uint64]Ref) map[uint64]Ref { // Commit is transition 4 as a pure step on HEAD: for the holder at HEAD's // epoch with snap(session) open, current = root, position, the optional -// snapshot added, activity idle. A HEAD that already shows this commit +// snapshot added, activity idle, and state live or detached. Detached is the +// clean-stop proof and refuses every later holder operation at this epoch. +// A live HEAD that already shows this commit // applied (idle, current = root, position, the snapshot) is a replay: // unchanged, changed=false. -func (h Head) Commit(me HolderID, session string, root RootName, position uint64, snapshot string) (next Head, changed bool, err error) { +func (h Head) Commit(me HolderID, session string, root RootName, position uint64, snapshot, state string) (next Head, changed bool, err error) { if session == "" { return Head{}, false, errors.New("layout: Commit needs a session id") } if err := h.holderErr(me); err != nil { return Head{}, false, err } - if h.Activity.Kind == ActIdle && h.Current != nil && *h.Current == root && h.Position == position { + if state != StateLive && state != StateDetached { + return Head{}, false, fmt.Errorf("%w: invalid commit state %q", ErrMalformed, state) + } + if h.State == state && h.Activity.Kind == ActIdle && h.Current != nil && *h.Current == root && h.Position == position { if s, ok := h.Snapshots[snapshot]; snapshot == "" || ok && s.Root == root { return h, false, nil } @@ -97,6 +105,7 @@ func (h Head) Commit(me HolderID, session string, root RootName, position uint64 next.Current = &rn next.Position = position next.Activity = Activity{Kind: ActIdle} + next.State = state return next, true, nil } @@ -106,14 +115,16 @@ func (h Head) Commit(me HolderID, session string, root RootName, position uint64 // by one conditional update. An object present but written by another // session, or marked for removal, is not prepared: EnsureObject reuses it // first. Prev must build to HEAD's current root; a re-run after a lost -// reply finds the commit applied and writes nothing. +// reply finds a live commit applied and writes nothing. For a stop, the caller +// reads HEAD after an unknown outcome: detached at its claim means stopped; +// it never resumes serving without that read. func RunCommit(ctx context.Context, st HeadStore, os ObjectStore, vol string, me HolderID, req CommitRequest) (Head, error) { root, segs, err := rootOf(req.Next) if err != nil { return Head{}, err } return runTransition(ctx, st, func(h Head) (Head, bool, error) { - if next, changed, err := h.Commit(me, req.Session, root, req.Position, req.Snapshot); err != nil || !changed { + if next, changed, err := h.Commit(me, req.Session, root, req.Position, req.Snapshot, req.State); err != nil || !changed { return next, changed, err // refused, or already applied: no lookups } // The base is HEAD's current root. Before any commit there is none @@ -161,6 +172,6 @@ func RunCommit(ctx context.Context, st HeadStore, os ObjectStore, vol string, me return Head{}, false, fmt.Errorf("%w: %s (absent, written by another session, or marked)", ErrNotPrepared, rel) } } - return h.Commit(me, req.Session, root, req.Position, req.Snapshot) + return h.Commit(me, req.Session, root, req.Position, req.Snapshot, req.State) }) } diff --git a/seaweed-block/core/frontend/chunkstore/layout/commit_test.go b/seaweed-block/core/frontend/chunkstore/layout/commit_test.go index 8ca766435b..fdea6af3b6 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/commit_test.go +++ b/seaweed-block/core/frontend/chunkstore/layout/commit_test.go @@ -46,7 +46,7 @@ func manifest(entries ...Ref) map[uint64]Ref { func TestCommit_Closure(t *testing.T) { rn := RootName{Hash: Sum([]byte("new"))} h := snapHead("s1") - next, changed, err := h.Commit(me, "s1", rn, 50, "hourly") + next, changed, err := h.Commit(me, "s1", rn, 50, "hourly", StateLive) if err != nil || !changed || next.Activity.Kind != ActIdle || *next.Current != rn || next.Position != 50 || next.Snapshots["hourly"].Root != rn { t.Fatalf("Commit: %+v %t %v", next, changed, err) } @@ -56,10 +56,10 @@ func TestCommit_Closure(t *testing.T) { if h.Activity.Kind != ActSnap || h.Snapshots["hourly"].Root == rn { t.Fatal("Commit changed its receiver") } - if again, changed, err := next.Commit(me, "s1", rn, 50, "hourly"); err != nil || changed || again.Gen != next.Gen { + if again, changed, err := next.Commit(me, "s1", rn, 50, "hourly", StateLive); err != nil || changed || again.Gen != next.Gen { t.Fatalf("Commit over its applied HEAD: %+v %t %v; want a replay", again, changed, err) } - if n2, changed, err := h.Commit(me, "s1", rn, 50, ""); err != nil || !changed || len(n2.Snapshots) != 1 { + if n2, changed, err := h.Commit(me, "s1", rn, 50, "", StateLive); err != nil || !changed || len(n2.Snapshots) != 1 { t.Fatalf("Commit without a snapshot name: %+v %t %v", n2, changed, err) } full := snapHead("s1") @@ -80,7 +80,7 @@ func TestCommit_Closure(t *testing.T) { "name taken": {h, me, "daily", ErrSnapshotExists}, "snapshot limit": {full, me, "one-more", ErrTooManySnapshots}, } { - if _, _, err := tc.h.Commit(tc.me, "s1", rn, 50, tc.snapshot); !errors.Is(err, tc.want) { + if _, _, err := tc.h.Commit(tc.me, "s1", rn, 50, tc.snapshot, StateLive); !errors.Is(err, tc.want) { t.Errorf("%s: %v; want %v", name, err, tc.want) } } diff --git a/seaweed-block/core/frontend/chunkstore/layout/delete.go b/seaweed-block/core/frontend/chunkstore/layout/delete.go index 641e84e526..81639ee02e 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/delete.go +++ b/seaweed-block/core/frontend/chunkstore/layout/delete.go @@ -8,9 +8,10 @@ import ( "strings" ) -// HEAD states: a live volume, one being deleted, one deleted. +// HEAD states: a live volume, a cleanly stopped one, one being deleted, one deleted. const ( StateLive = "" + StateDetached = "detached" StateDeleting = "deleting" StateDeleted = "deleted" ) @@ -78,8 +79,8 @@ func (h Head) MarkDeleted() (next Head, changed bool, err error) { switch h.State { case StateDeleted: return h, false, nil - case StateLive: - return Head{}, false, fmt.Errorf("layout: HEAD is live; a delete marks it deleting first") + case StateLive, StateDetached: + return Head{}, false, fmt.Errorf("layout: HEAD is %q; a delete marks it deleting first", h.State) } next = h.clone() next.State = StateDeleted diff --git a/seaweed-block/core/frontend/chunkstore/layout/delete_test.go b/seaweed-block/core/frontend/chunkstore/layout/delete_test.go index 8a19b46860..62a77b54cc 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/delete_test.go +++ b/seaweed-block/core/frontend/chunkstore/layout/delete_test.go @@ -82,7 +82,7 @@ func TestDeleting_RefusesEveryHolderStep(t *testing.T) { for name, step := range map[string]func() error{ "Begin": func() error { _, _, err := h.Begin(me, "s"); return err }, "Abort": func() error { _, _, err := h.Abort(me, "s"); return err }, - "Commit": func() error { _, _, err := h.Commit(me, "s", rn, 1, ""); return err }, + "Commit": func() error { _, _, err := h.Commit(me, "s", rn, 1, "", StateLive); return err }, "BeginClean": func() error { _, _, err := h.BeginClean(me, "c"); return err }, "EndClean": func() error { _, _, err := h.EndClean(me, "c"); return err }, "Claim": func() error { _, _, err := h.Claim(newer); return err }, diff --git a/seaweed-block/core/frontend/chunkstore/layout/detached_test.go b/seaweed-block/core/frontend/chunkstore/layout/detached_test.go new file mode 100644 index 0000000000..b918a119f3 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/layout/detached_test.go @@ -0,0 +1,107 @@ +package layout + +import ( + "context" + "errors" + "reflect" + "strings" + "testing" +) + +// The final image is committed through the same single HEAD update as a +// snapshot. The caller supplies the position synced after closing guest writes. +func TestCommitDetached_ProofAndLostReply(t *testing.T) { + for _, applied := range []bool{false, true} { + t.Run(map[bool]string{false: "before apply", true: "reply lost"}[applied], func(t *testing.T) { + o, h, req := commitFixture(t) + req.State = StateDetached + st := &memHead{h: &h, killAt: 1, after: applied} + if _, err := RunCommit(context.Background(), st, o, "v1", me, req); !errors.Is(err, errKilled) { + t.Fatal("expected interrupted commit", err) + } + st.restart() + proof, found, err := st.ReadHead(context.Background()) + if err != nil || !found || !proof.heldBy(me) { + t.Fatal("stop cannot decide without reading its claim", proof, found, err) + } + if applied { + if proof.State != StateDetached || proof.Position != req.Position || proof.Activity.Kind != ActIdle { + t.Fatal("HEAD lacks the final synced image proof", proof) + } + if _, err := Start(context.Background(), st, &fakeLease{}, me, LocalRoot{ClaimID: me.ClaimID, Position: req.Position}); !errors.Is(err, ErrDetached) || !strings.Contains(err.Error(), "new grant") { + t.Fatal("same-epoch start did not refuse with the cure", err) + } + } else if proof.State != StateLive || proof.Position != h.Position { + t.Fatal("unapplied stop changed the published image", proof) + } + }) + } +} + +// Every holder method is enumerated: adding a transition requires a detached +// refusal probe too. Claim is the sole exception, only at a higher epoch. +func TestDetachedHEAD_RefusesEveryHolderTransition(t *testing.T) { + h := idleHead() + h.State = StateDetached + rn := RootName{Hash: Sum([]byte("image"))} + h.Current = &rn + steps := map[string]func() error{ + "Begin": func() error { _, _, e := h.Begin(me, "s"); return e }, + "Abort": func() error { _, _, e := h.Abort(me, "s"); return e }, + "Commit": func() error { _, _, e := h.Commit(me, "s", rn, h.Position, "", StateLive); return e }, + "BeginClean": func() error { _, _, e := h.BeginClean(me, "c"); return e }, + "EndClean": func() error { _, _, e := h.EndClean(me, "c"); return e }, + "Claim": func() error { _, _, e := h.Claim(me); return e }, + } + for name, step := range steps { + if err := step(); !errors.Is(err, ErrDetached) { + t.Errorf("%s did not refuse detached HEAD: %v", name, err) + } + } + ht, holderT := reflect.TypeOf(Head{}), reflect.TypeOf(HolderID{}) + for i := 0; i < ht.NumMethod(); i++ { + m := ht.Method(i) + if m.Type.NumIn() > 1 && m.Type.In(1) == holderT { + if _, ok := steps[m.Name]; !ok { + t.Errorf("holder transition %s has no detached probe", m.Name) + } + } + } + newHolder := me + newHolder.Epoch++ + next, changed, err := h.Claim(newHolder) + if err != nil || !changed || next.State != StateLive || next.Position != h.Position || *next.Current != rn { + t.Fatal("higher grant did not reopen the same published image", next, changed, err) + } + if next, changed, err := h.MarkDeleting(); err != nil || !changed || next.State != StateDeleting { + t.Fatal("detached volume could not enter deletion", next, changed, err) + } + if _, _, err := h.MarkDeleted(); err == nil { + t.Fatal("detached volume skipped the deleting transition") + } + if raw, err := h.Encode(); err != nil { + t.Fatal("detached proof not encodable", err) + } else if got, err := DecodeHead(raw, h.Gen, h.VolumeID); err != nil || got.State != h.State { + t.Fatal("detached proof not preserved", got, err) + } +} + +func TestDetachedHEAD_NewGrantStillWaitsForTheOldLease(t *testing.T) { + h := idleHead() + h.State = StateDetached + rn := RootName{Hash: Sum([]byte("image"))} + h.Current = &rn + st := &memHead{h: &h} + line := me + line.Epoch++ + lease := &fakeLease{} + local := LocalRoot{ClaimID: me.ClaimID, Position: h.Position} + if _, err := Start(context.Background(), st, lease, line, local); err == nil || st.updates != 0 || len(lease.calls) != 1 { + t.Fatal("higher epoch bypassed old lease", err, st.updates, lease.calls) + } + lease.ended = true + next, err := Start(context.Background(), st, lease, line, local) + if err != nil || next.State != StateLive || next.Epoch != line.Epoch || st.updates != 1 { + t.Fatal("higher grant could not reopen after lease end", next, err) + } +} diff --git a/seaweed-block/core/frontend/chunkstore/layout/head.go b/seaweed-block/core/frontend/chunkstore/layout/head.go index 48ab207aa9..5b392ff3d2 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/head.go +++ b/seaweed-block/core/frontend/chunkstore/layout/head.go @@ -63,7 +63,7 @@ type Head struct { Current *RootName // nil: no image committed yet Position uint64 Snapshots map[string]Snapshot - State string // StateLive, StateDeleting or StateDeleted + State string // StateLive, StateDetached, StateDeleting or StateDeleted } type headDoc struct { @@ -104,7 +104,7 @@ func (h Head) check() error { return fmt.Errorf("%w: HEAD without a volume id", ErrMalformed) } switch h.State { - case StateLive, StateDeleting, StateDeleted: + case StateLive, StateDetached, StateDeleting, StateDeleted: default: return fmt.Errorf("%w: HEAD state %q", ErrMalformed, h.State) } @@ -125,6 +125,9 @@ func (h Head) check() error { default: return fmt.Errorf("%w: activity %q", ErrMalformed, h.Activity.Kind) } + if h.State == StateDetached && (h.Activity.Kind != ActIdle || h.Current == nil) { + return fmt.Errorf("%w: detached HEAD needs an idle, committed image", ErrMalformed) + } // A deleted HEAD written as a tombstone for a restore target never // created has no holder; every other HEAD has an epoch, a holder and // the claim id of its claim. @@ -257,6 +260,7 @@ var ( ErrNotHolder = errors.New("layout: not the holder at HEAD's epoch") ErrBusy = errors.New("layout: another transaction is open") ErrNoSession = errors.New("layout: the session is not open") + ErrDetached = errors.New("layout: detached; a new grant is needed") ) // HolderID is the identity a transition acts as: the epoch of the line it @@ -277,6 +281,9 @@ func (h Head) heldBy(me HolderID) bool { // deleted or is deleted (ErrVolumeDeleting), or the caller is not the // holder at HEAD's epoch (ErrNotHolder); nil when it may act. func (h Head) holderErr(me HolderID) error { + if h.State == StateDetached { + return ErrDetached + } if h.State != StateLive { return fmt.Errorf("%w: HEAD is %s", ErrVolumeDeleting, h.State) } diff --git a/seaweed-block/core/frontend/chunkstore/layout/stale_test.go b/seaweed-block/core/frontend/chunkstore/layout/stale_test.go index 6548fff1f5..70e27297d9 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/stale_test.go +++ b/seaweed-block/core/frontend/chunkstore/layout/stale_test.go @@ -22,7 +22,7 @@ func TestTransitions_RefuseAStaleHolder(t *testing.T) { steps := map[string]func(Head, HolderID) error{ "Begin": func(h Head, c HolderID) error { _, _, err := h.Begin(c, "s"); return err }, "Abort": func(h Head, c HolderID) error { _, _, err := h.Abort(c, "s"); return err }, - "Commit": func(h Head, c HolderID) error { _, _, err := h.Commit(c, "s", rn, 1, ""); return err }, + "Commit": func(h Head, c HolderID) error { _, _, err := h.Commit(c, "s", rn, 1, "", StateLive); return err }, "BeginClean": func(h Head, c HolderID) error { _, _, err := h.BeginClean(c, "c"); return err }, "EndClean": func(h Head, c HolderID) error { _, _, err := h.EndClean(c, "c"); return err }, "Claim": func(h Head, c HolderID) error { _, _, err := h.Claim(c); return err }, diff --git a/seaweed-block/core/frontend/chunkstore/layout/start.go b/seaweed-block/core/frontend/chunkstore/layout/start.go index f56254a4c1..d312c5a67a 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/start.go +++ b/seaweed-block/core/frontend/chunkstore/layout/start.go @@ -76,6 +76,9 @@ func Start(ctx context.Context, st HeadStore, lease LeaseWait, line HolderID, lo // and server a root without HEAD's claim id, and above HEAD's epoch a // non-fresh root of another lineage. func startCheck(h Head, line HolderID, local LocalRoot) error { + if h.State == StateDetached && line.Epoch == h.Epoch { + return ErrDetached + } if !local.Fresh && local.ClaimID == h.ClaimID && local.Position < h.Position && line.Epoch >= h.Epoch { return fmt.Errorf("%w (%w): the local root holds position %d, HEAD published %d: an old copy of this lineage", ErrStaleLocalRoot, ErrNotHolder, local.Position, h.Position) } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 27b4a6ce17..f1d606acc7 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -525,6 +525,9 @@ stateDiagram-v2 idle --> snap: Begin(s) snap --> idle: Abort(s) snap --> idle: Commit(s, root) + snap --> detached: Commit(s, root, detached) + detached --> idle: Claim at higher epoch, old lease ended + detached --> deleting: MarkDeleting (no holder, no dependents) idle --> idle: Claim(e, claim id) snap --> idle: Claim(e, claim id), s void clean --> idle: Claim(e, claim id), c void @@ -542,11 +545,13 @@ stateDiagram-v2 | idle | snap(s) | caller is the holder at HEAD's epoch (epoch, server and claim id); HEAD present; snap(s) again is a replay, any other activity is refused | head.go `Head.Begin`, `runTransition` | `INV-SNAPK-HEAD-WRITE-001`, `INV-SNAPK-BEGIN-001` | | snap(s) | idle | holder at HEAD's epoch (epoch, server and claim id); activity is snap(s); over idle it succeeds without a write and means only that no activity remains | head.go `Head.Abort` | `INV-SNAPK-ABORT-001` | | snap(s) | idle, current = root | holder at HEAD's epoch (epoch, server and claim id); activity is snap(s); the previous manifest builds to HEAD's current root; the new own chunks, every segment and the root are present | commit.go `Head.Commit`, `RunCommit` | `INV-SNAPK-COMMIT-REACH-001`, `INV-SNAPK-TXN-INTERRUPT-001` | +| detached | idle at higher epoch | same-epoch holder operations and Start refused; Claim waits for the old lease | claim.go `Head.Claim`; head.go `holderErr`; start.go `Start` | `INV-SNAPK-DETACHED-001` | +| snap(s) | detached, current = root | ordinary Commit preparation checks; caller closed writes and captured its synced L; position = L | commit.go `Head.Commit`, `RunCommit` | `INV-SNAPK-DETACHED-001` | | any (Start) | idle at epoch e, claim id k | Start only: at HEAD's epoch it continues on the root carrying HEAD's claim id at or above HEAD's position, else refuses; above, a fresh root or the continuing lineage claims, validated against the HEAD the claim updates | start.go `Start`; claim.go `RunClaim` | `INV-SNAPK-START-ROOT-001`, `INV-SNAPK-START-LINEAGE-001`, `INV-SNAPK-START-POSITION-001` | | idle | clean(c) | holder at HEAD's epoch (epoch, server and claim id); activity idle (clean(c) again is a replay) | clean.go `Head.BeginClean` | `INV-SNAPK-CLEAN-EXCL-001` | | clean(c) | idle | holder at HEAD's epoch (epoch, server and claim id); activity clean(c); over idle it succeeds without a write | clean.go `Head.EndClean` | `INV-SNAPK-CLEAN-EXCL-001` | | clean(c) | clean(c), names removed | holder at HEAD's epoch (epoch, server and claim id) with clean(c) open (HEAD read once, after BeginClean); a name is deleted only if no root in HEAD (current or snapshot) names it in this volume's pool; each removal is a mark conditional on the plan's metadata, then a delete conditional on that mark | remove.go `RemoveUnreachable` | `INV-SNAPK-REMOVE-MARK-001` | -| idle (live) | deleting | the master reserved the volume for delete (no line granted after), then no line holds a live lease, checked between the HEAD read and the update; no open activity, no snapshot with dependents; deleting again is a replay | delete.go `Head.MarkDeleting`, `RunMarkDeleting` (`DeleteAuthority`) | `INV-SNAPK-DELETE-ORDER-001` | +| idle (live or detached) | deleting | the master reserved the volume for delete (no line granted after), then no line holds a live lease, checked between the HEAD read and the update; no open activity, no snapshot with dependents; deleting again is a replay | delete.go `Head.MarkDeleting`, `RunMarkDeleting` (`DeleteAuthority`) | `INV-SNAPK-DELETE-ORDER-001` | | absent | deleted (tombstone) | the operator's remove-dependent, for a restore target without HEAD (never created, or a restore died between its two creates); one exclusive create, so a later HEAD create of the restore fails; a HEAD appearing first refuses | delete.go `OperatorReleaseDependent` (`TargetStore.CreateDeletedHead`) | `INV-SNAPK-TOMBSTONE-001`, `INV-SNAPK-HEAD-WRITE-001` | | source: any live | source: target released | by the target's volume id, from every snapshot: from DeleteVolume once the target's HEAD is deleting, or from the operator's command once the target is deleted, of another id, no longer naming the source, or tombstoned; an absent target writes nothing | delete.go `Head.ReleaseDependent`, `RunReleaseDependent`, `OperatorReleaseDependent` | `INV-SNAPK-RELEASE-001`, `INV-SNAPK-RELEASE-CALLERS-001`, `INV-SNAPK-RELEASE-OPERATOR-001` | | deleting | deleted | after this volume is released from every source it names and its objects are deleted; deleted again is a replay; a live HEAD is refused | delete.go `Head.MarkDeleted`, `DeleteVolume` | `INV-SNAPK-DELETE-ORDER-001` | @@ -739,7 +744,7 @@ Notes: | `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease`; `core/lifecycle/node_inventory.go` `GetNodeSnapshot` (the holder host check) | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter`, `TestPlacementSnapshotFailedCommitStaysCommitted` (`core/lifecycle/placement_snapshot_test.go`); `TestNodeSnapshotDoesNotWaitForARegistrationWrite` (`core/lifecycle/node_snapshot_test.go`); `TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite` (`core/host/master/server_host_identity_test.go`) | — | ACTIVE | | `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | -| `INV-LIFECYCLE-STORE-DURABLE-001` | Node registration, volume record and placement-intent puts/replacements are atomic and durable: after a crash the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 lifecycle record publication | `core/lifecycle/record_file.go` `writeRecordDurably`; `node_inventory.go`, `store.go`, `placement_intent.go` `putLocked` | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`); `TestFileStoreCrashKeepsCompleteRecord`, `TestPlacementStoreCrashKeepsCompleteRecord`, `TestLifecyclePutSyncOrderAndFailure` (`core/lifecycle/store_crash_test.go`); `TestLifecycleStoreParentSync` (`core/lifecycle/store_parent_sync_test.go`) | — | ACTIVE | +| `INV-LIFECYCLE-STORE-DURABLE-001` | Node registration, volume record and placement-intent puts/replacements are atomic and durable: after a crash the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 lifecycle record publication | `core/lifecycle/record_file.go` `writeRecordDurably`; `node_inventory.go`, `store.go`, `placement_intent.go` `putLocked` | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`); `TestFileStoreCrashKeepsCompleteRecord`, `TestPlacementStoreCrashKeepsCompleteRecord`, `TestLifecyclePutSyncOrderAndFailure` (`core/lifecycle/store_crash_test.go`); `TestLifecycleStoreParentSync` (`core/lifecycle/store_parent_sync_test.go`) | � | ACTIVE | | `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE | | `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE | | `INV-SEC-CONTROL-BIND-001` | blockmaster's unauthenticated control listeners (--listen, and the runtime HTTP listener when enabled) bind only loopback unless --insecure-external-bind is given; a non-loopback address is refused at startup. | AUTHORITY: control API reachability | `core/host/master/journal_isolation.go` `ValidateControlListen`; `cmd/blockmaster/main.go` `parseFlags` | `TestParseFlags_ControlListenersNeedInsecureExternalBind`, `TestManifests_ExternalBlockmasterBindCarriesTheOptIn` (`cmd/blockmaster/external_bind_test.go`) | — (no state machine; the flag test is the proof form) | ACTIVE | @@ -1099,6 +1104,7 @@ Notes: | `INV-SNAPK-BEGIN-001` | Begin opens snap(s) only for the holder at HEAD's epoch and only from idle; a re-run of the open session writes nothing; killed at its write and re-run, it ends in snap(s) at one generation step. | M9 idle → snap | `core/frontend/chunkstore/layout` `head.go` `Head.Begin`, `RunBegin` | `TestBegin_Closure`, `TestRunBegin_InterruptAtEveryStep` | — (the snapshot kernel model is not in this repository) | ACTIVE | | `INV-SNAPK-ABORT-001` | Abort closes the holder's own snap(s) and changes nothing else; after its own crash a holder rolls the open session back before beginning another; over idle Abort writes nothing and its success never says whether the work was committed. | M9 snap → idle (Abort) | `core/frontend/chunkstore/layout` `head.go` `Head.Abort`, `RunAbort` | `TestAbort_Closure`, `TestAbort_IdleMeansNoActivityRemains`, `TestAbort_RollBackAfterOwnCrash`, `TestRunAbort_InterruptAtEveryStep` | — (the snapshot kernel model is not in this repository) | ACTIVE | | `INV-SNAPK-COMMIT-REACH-001` | A commit never names an object that is not written: before its one HEAD update it finds present the own chunks new against HEAD's current root (that root rebuilt from the previous manifest, an empty image included), every segment and the root; unchanged and foreign chunks are not looked up. | M9 snap → idle (Commit) | `core/frontend/chunkstore/layout` `commit.go` `RunCommit`, `Head.Commit` | `TestCommit_Closure`, `TestRunCommit_LooksUpOnlyWhatIsNew`, `TestRunCommit_RefusesUnwrittenObjects`, `TestRunCommit_StaleBaseAndLookupFailure`, `TestRunCommit_AfterAnEmptyPublishedRoot`, `TestRunCommit_InterruptAtEveryStep` | — (the snapshot kernel model is not in this repository) | ACTIVE | +| `INV-SNAPK-DETACHED-001` | A detached HEAD remains closed to its same-epoch holder; only a higher-epoch Claim returns it to live. | M9 snap → detached → higher-epoch idle | `core/frontend/chunkstore/layout` `commit.go`, `head.go`, `claim.go`, `start.go` | `TestCommitDetached_ProofAndLostReply`, `TestDetachedHEAD_RefusesEveryHolderTransition`, `TestDetachedHEAD_NewGrantStillWaitsForTheOldLease` | Caller write-barrier and synced-position join, master clean-proof reader and composed model review remain cutover gates. | ACTIVE | | `INV-SNAPK-TXN-INTERRUPT-001` | A snapshot transaction killed at any of its writes (Begin, each object, Commit), before the write or after it applied with its reply lost, never leaves HEAD reaching a missing object, and the restarted holder (roll back, new session, base recomputed from HEAD) ends at the committed image. | M9 idle → snap → idle | `core/frontend/chunkstore/layout` `head.go`, `commit.go` (the transitions above) | `TestSnapshotSession_InterruptAtEveryStep`, `TestReachableMissing_Controls`, `TestAbort_AfterCommitLeavesTheCommit` | — (the snapshot kernel model is not in this repository) | ACTIVE | | `INV-SNAPK-CLAIM-LEASE-001` | A claim takes HEAD only at a newer epoch and only after every older holder's lease has ended (checked after the read, before the update); it voids any open session or cleaning, so the old holder's commit, abort and begin are refused. | M9 any → idle (Claim) | `core/frontend/chunkstore/layout` `claim.go` `RunClaim`, `Head.Claim` | `TestClaim_Closure`, `TestRunClaim_WaitsForTheOldLease`, `TestRunClaim_VoidsTheOldSession`, `TestRunClaim_InterruptAtEveryStep` | — (the snapshot kernel model is not in this repository) | ACTIVE | | `INV-SNAPK-CLEAN-EXCL-001` | A cleaning and a snapshot exclude each other through HEAD's one activity field, so no name is removed while a snapshot is open; a claim voids an open cleaning. | M9 idle → clean → idle | `core/frontend/chunkstore/layout` `clean.go` `Head.BeginClean`, `Head.EndClean` | `TestBeginClean_Closure`, `TestEndClean_Closure`, `TestEndClean_IdleMeansNoActivityRemains`, `TestClean_ExcludesSnapshot`, `TestRunBeginClean_InterruptAtEveryStep`, `TestRunEndClean_InterruptAtEveryStep` | — (the snapshot kernel model is not in this repository) | ACTIVE |