From 804bde1832f2d9d628ecad7055ba96802a7bb72c Mon Sep 17 00:00:00 2001 From: pingqiu Date: Tue, 24 Nov 2026 16:22:52 -0800 Subject: [PATCH] layout: the operator's remove-dependent checks the target first The release step alone does not look at the target, so as the operator's command it could release a live restore target and leave its foreign references unprotected. It is now used only by the target's own delete (its HEAD already deleting) and by OperatorReleaseDependent, which reads the target first and releases only if it exists and is deleted (HEAD deleting or deleted, or its name holding another volume id) or no root in its live HEAD names a chunk of the source. A live target still naming the source, one being created and one never created (the restore could still create it) are refused, and the source is not written. The package guard restricts the release's callers and requires the operator's read of the target; the HEAD reader enumeration classifies it. Co-Authored-By: Claude Opus 5.5 --- .../frontend/chunkstore/head_readers_test.go | 92 +++++++++++++----- .../core/frontend/chunkstore/layout/delete.go | 93 ++++++++++++++++++- .../frontend/chunkstore/layout/delete_test.go | 87 +++++++++++++++++ .../frontend/chunkstore/layout/guard_test.go | 15 +++ seaweed-block/docs/design/invariants.md | 2 +- 5 files changed, 259 insertions(+), 30 deletions(-) diff --git a/seaweed-block/core/frontend/chunkstore/head_readers_test.go b/seaweed-block/core/frontend/chunkstore/head_readers_test.go index 434da26d5c..dacb9c1b35 100644 --- a/seaweed-block/core/frontend/chunkstore/head_readers_test.go +++ b/seaweed-block/core/frontend/chunkstore/head_readers_test.go @@ -24,31 +24,32 @@ import ( // one; a change that treats an absent HEAD as unknown flips those probes. var headReaders = map[string]string{ // chunkstore: the two raw reads every other reader goes through - "core/frontend/chunkstore/catalog.go ReadHead -> LookupEntry": "ok=false, no error (probe ReadHead)", - "core/frontend/chunkstore/chunk_remote.go getHeadRoot -> LookupEntry": "zero HEAD, no error (probe GetHead)", - "core/frontend/chunkstore/catalog.go headExists -> LookupEntry": "false (probe EnsureVolume)", - "core/frontend/chunkstore/chunk_remote.go GetHead -> getHeadRoot": "zero HEAD, no error (probe GetHead)", - "core/frontend/chunkstore/chunk_remote.go GetHeadRoot -> getHeadRoot": "zero HEAD, no error (probe GetHeadRoot)", - "core/frontend/chunkstore/chunk_remote.go CASHead -> getHeadRoot": "GAP: expected gen 0 creates a HEAD over existing keys (probe CASHead)", - "core/frontend/chunkstore/catalog.go ensureInitialHead -> headExists": "GAP: creates an empty gen-1 HEAD over existing keys (probe EnsureVolume)", - "core/frontend/chunkstore/catalog.go EnsureVolume -> ReadHead": "GAP: attaches the recreated empty HEAD (probe EnsureVolume)", - "core/frontend/chunkstore/catalog.go fork -> ReadHead": "replay falls through and publishes the fork-time HEAD (probe ForkReplay)", - "core/frontend/chunkstore/catalog.go AbortFork -> ReadHead": "GAP: exclusive-creates an aborted HEAD (probe AbortFork)", - "core/frontend/chunkstore/gc.go run -> GetHead": "GAP: zero HEAD roots nothing; the volume's keys become candidates (probe GCMark)", - "core/frontend/chunkstore/gc_copy.go SweepCopies -> ReadHead": "after AbortFork: settles from the HEAD it created (probe AbortFork)", - "core/frontend/chunkstore/restore.go MarkIndependent -> ReadHead": "refuses (not a restore / no HEAD) (probe MarkIndependent)", - "core/frontend/chunkstore/share_guard.go beginShare -> ReadHead": "refuses outcome_unknown: the HEAD to share is no longer current", - "core/frontend/chunkstore/usage.go Usage -> ReadHead": "GAP: reports an empty image, no error (probe Usage)", - "core/frontend/chunkstore/verify.go readHead -> LookupEntry": "finding ROOT_INVALID (probe Verify)", - "core/frontend/chunkstore/layout/remove.go RemoveUnreachable -> ReadHead": "refuses ErrHeadAbsent and deletes nothing (probe LayoutRemoval)", - "core/frontend/chunkstore/layout/head.go runTransition -> ReadHead": "refuses ErrHeadAbsent and writes nothing; no layout transition creates a HEAD (probe LayoutTransition)", - "core/frontend/chunkstore/verify.go run -> LookupEntry": "finding ROOT_INVALID (probe Verify)", - "core/frontend/chunkstore/volume_delete.go DeleteVolume -> ReadHead": "operator delete writes a deleting HEAD from nothing and completes (probe DeleteVolume)", - "core/frontend/chunkstore/volume_delete.go markHeadDeleting -> ReadHead": "zero HEAD: creates the deleting HEAD (probe DeleteVolume)", - "core/frontend/chunkstore/volume_delete.go commitHeadPurging -> ReadHead": "reads the HEAD markHeadDeleting wrote (probe DeleteVolume)", - "core/frontend/chunkstore/volume_delete.go finishHeadDeleted -> ReadHead": "reads the HEAD markHeadDeleting wrote (probe DeleteVolume)", - "core/frontend/chunkstore/volume_delete.go revertHeadDeleting -> ReadHead": "reads the HEAD markHeadDeleting wrote (probe DeleteVolume)", - "core/frontend/chunkstore/volume_delete.go volumeGone -> ReadHead": "absent HEAD = not gone (probe DeleteVolume)", + "core/frontend/chunkstore/catalog.go ReadHead -> LookupEntry": "ok=false, no error (probe ReadHead)", + "core/frontend/chunkstore/chunk_remote.go getHeadRoot -> LookupEntry": "zero HEAD, no error (probe GetHead)", + "core/frontend/chunkstore/catalog.go headExists -> LookupEntry": "false (probe EnsureVolume)", + "core/frontend/chunkstore/chunk_remote.go GetHead -> getHeadRoot": "zero HEAD, no error (probe GetHead)", + "core/frontend/chunkstore/chunk_remote.go GetHeadRoot -> getHeadRoot": "zero HEAD, no error (probe GetHeadRoot)", + "core/frontend/chunkstore/chunk_remote.go CASHead -> getHeadRoot": "GAP: expected gen 0 creates a HEAD over existing keys (probe CASHead)", + "core/frontend/chunkstore/catalog.go ensureInitialHead -> headExists": "GAP: creates an empty gen-1 HEAD over existing keys (probe EnsureVolume)", + "core/frontend/chunkstore/catalog.go EnsureVolume -> ReadHead": "GAP: attaches the recreated empty HEAD (probe EnsureVolume)", + "core/frontend/chunkstore/catalog.go fork -> ReadHead": "replay falls through and publishes the fork-time HEAD (probe ForkReplay)", + "core/frontend/chunkstore/catalog.go AbortFork -> ReadHead": "GAP: exclusive-creates an aborted HEAD (probe AbortFork)", + "core/frontend/chunkstore/gc.go run -> GetHead": "GAP: zero HEAD roots nothing; the volume's keys become candidates (probe GCMark)", + "core/frontend/chunkstore/gc_copy.go SweepCopies -> ReadHead": "after AbortFork: settles from the HEAD it created (probe AbortFork)", + "core/frontend/chunkstore/restore.go MarkIndependent -> ReadHead": "refuses (not a restore / no HEAD) (probe MarkIndependent)", + "core/frontend/chunkstore/share_guard.go beginShare -> ReadHead": "refuses outcome_unknown: the HEAD to share is no longer current", + "core/frontend/chunkstore/usage.go Usage -> ReadHead": "GAP: reports an empty image, no error (probe Usage)", + "core/frontend/chunkstore/verify.go readHead -> LookupEntry": "finding ROOT_INVALID (probe Verify)", + "core/frontend/chunkstore/layout/delete.go OperatorReleaseDependent -> ReadHead": "reads the source's HEAD (absent: refuses ErrHeadAbsent) and the target's: a target with no HEAD and no VOLUME was never created and is refused, one with VOLUME and no HEAD is being created and is refused; nothing is written (probe LayoutOperatorRelease)", + "core/frontend/chunkstore/layout/remove.go RemoveUnreachable -> ReadHead": "refuses ErrHeadAbsent and deletes nothing (probe LayoutRemoval)", + "core/frontend/chunkstore/layout/head.go runTransition -> ReadHead": "refuses ErrHeadAbsent and writes nothing; no layout transition creates a HEAD (probe LayoutTransition)", + "core/frontend/chunkstore/verify.go run -> LookupEntry": "finding ROOT_INVALID (probe Verify)", + "core/frontend/chunkstore/volume_delete.go DeleteVolume -> ReadHead": "operator delete writes a deleting HEAD from nothing and completes (probe DeleteVolume)", + "core/frontend/chunkstore/volume_delete.go markHeadDeleting -> ReadHead": "zero HEAD: creates the deleting HEAD (probe DeleteVolume)", + "core/frontend/chunkstore/volume_delete.go commitHeadPurging -> ReadHead": "reads the HEAD markHeadDeleting wrote (probe DeleteVolume)", + "core/frontend/chunkstore/volume_delete.go finishHeadDeleted -> ReadHead": "reads the HEAD markHeadDeleting wrote (probe DeleteVolume)", + "core/frontend/chunkstore/volume_delete.go revertHeadDeleting -> ReadHead": "reads the HEAD markHeadDeleting wrote (probe DeleteVolume)", + "core/frontend/chunkstore/volume_delete.go volumeGone -> ReadHead": "absent HEAD = not gone (probe DeleteVolume)", // above the chunk store: they read through storage.ChunkRemote GetHead / // GetHeadRoot, so an absent HEAD reaches them as the zero HEAD (probe GetHead) "cmd/sw-block/chunk.go chunkShow -> ReadHead": "ok=false: reports no HEAD (probe ReadHead)", @@ -278,6 +279,33 @@ func TestHeadReaders_AbsentHeadProbes(t *testing.T) { t.Fatalf("layout removal over an absent HEAD deleted %d objects", pool.deletes) } }) + t.Run("LayoutOperatorRelease", func(t *testing.T) { + tid, err := layout.NewVolumeID() + if err != nil { + t.Fatal(err) + } + vb, err := layout.Volume{ID: tid, Name: "t", Format: layout.VolumeFormat}.Encode() + if err != nil { + t.Fatal(err) + } + withVolume := func(context.Context, string) ([]byte, bool, error) { return vb, true, nil } + r, err := layout.NewReader("/swblock/chunks", "t", withVolume) + if err != nil { + t.Fatal(err) + } + src := &presentLayoutHead{} + if _, err := layout.OperatorReleaseDependent(ctx, src, &absentLayoutHead{}, r, tid); !errors.Is(err, layout.ErrTargetLive) || src.updates != 0 { + t.Fatalf("operator release of a target with VOLUME and no HEAD: %v, %d writes; want ErrTargetLive and none", err, src.updates) + } + none, _ := layout.NewReader("/swblock/chunks", "t", func(context.Context, string) ([]byte, bool, error) { return nil, false, nil }) + if _, err := layout.OperatorReleaseDependent(ctx, src, &absentLayoutHead{}, none, tid); !errors.Is(err, layout.ErrTargetNeverCreated) || src.updates != 0 { + t.Fatalf("operator release of a target never created: %v, %d writes; want ErrTargetNeverCreated and none", err, src.updates) + } + absent := &absentLayoutHead{} + if _, err := layout.OperatorReleaseDependent(ctx, absent, &absentLayoutHead{}, r, tid); !errors.Is(err, layout.ErrHeadAbsent) || absent.updates != 0 { + t.Fatalf("operator release with the source HEAD absent: %v; want ErrHeadAbsent", err) + } + }) t.Run("ForkReplay", func(t *testing.T) { f, b := headReaderForkFixture(t) c, err := NewCatalog(manifestFilerBlobs{f, gcBlobs{b}}, catBase) @@ -319,3 +347,17 @@ func (p *countingPool) DeleteObject(context.Context, string) error { p.deletes++ type okLease struct{} func (okLease) StillHeld(context.Context) error { return nil } + +// presentLayoutHead is a layout HEAD store whose HEAD is present (a live, +// idle volume); it counts updates. +type presentLayoutHead struct{ updates int } + +func (p *presentLayoutHead) ReadHead(context.Context) (layout.Head, bool, error) { + id, _ := layout.NewVolumeID() + return layout.Head{Gen: 1, VolumeID: id, Epoch: 1, Holder: "h", Activity: layout.Activity{Kind: layout.ActIdle}}, true, nil +} + +func (p *presentLayoutHead) UpdateHead(context.Context, uint64, layout.Head) error { + p.updates++ + return nil +} diff --git a/seaweed-block/core/frontend/chunkstore/layout/delete.go b/seaweed-block/core/frontend/chunkstore/layout/delete.go index 9f7ac1a43f..a0fb1e9a7e 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/delete.go +++ b/seaweed-block/core/frontend/chunkstore/layout/delete.go @@ -23,6 +23,12 @@ var ( ErrHasDependents = errors.New("layout: a snapshot has dependents") // ErrHolderActive: a transaction is open on the volume. ErrHolderActive = errors.New("layout: a holder is acting on the volume") + // ErrTargetLive: the operator asked to release a dependent whose + // target still exists and may still name the source's chunks. + ErrTargetLive = errors.New("layout: the dependent's target is live") + // ErrTargetNeverCreated: the dependent's target has neither VOLUME nor + // HEAD; the restore that registered it could still create it. + ErrTargetNeverCreated = errors.New("layout: the dependent's target was never created") ) // HolderGone is the deletion's premise: it returns nil only when no block @@ -68,9 +74,10 @@ func (h Head) MarkDeleted() (next Head, changed bool, err error) { } // ReleaseDependent removes the target volume id from the dependents of -// every snapshot of this (source) HEAD: the step a deleted target makes on -// each source, and the operator's remove-dependent command. A HEAD with no -// such dependent is a replay. +// every snapshot of this (source) HEAD: the step a target being deleted +// makes on each source. It does not look at the target; the operator's +// command goes through OperatorReleaseDependent, which does. A HEAD with +// no such dependent is a replay. func (h Head) ReleaseDependent(target VolumeID) (next Head, changed bool, err error) { if target.IsZero() { return Head{}, false, errors.New("layout: ReleaseDependent needs a target volume id") @@ -106,7 +113,8 @@ func RunMarkDeleted(ctx context.Context, st HeadStore) (Head, error) { } // RunReleaseDependent applies ReleaseDependent to a source's HEAD by one -// conditional update. +// conditional update. Its callers know the target is gone: DeleteVolume +// (the target's HEAD is deleting) and OperatorReleaseDependent (checked). func RunReleaseDependent(ctx context.Context, source HeadStore, target VolumeID) (Head, error) { return runTransition(ctx, source, func(h Head) (Head, bool, error) { return h.ReleaseDependent(target) }) } @@ -141,3 +149,80 @@ func DeleteVolume(ctx context.Context, st HeadStore, gone HolderGone, id VolumeI _, err := RunMarkDeleted(ctx, st) return err } + +// OperatorReleaseDependent is the operator's remove-dependent command: it +// releases the target from the source's dependents only when the target +// exists and is deleted or no longer names the source, read first: its +// HEAD is deleting or deleted; its name now holds another volume (another +// VOLUME id); or its HEAD is live and no root in it (current or snapshot) +// names a chunk of the source. A live target that still names the source, +// or one being created (VOLUME without HEAD), is refused (ErrTargetLive). +// A target never created (no VOLUME, no HEAD) is refused too +// (ErrTargetNeverCreated): the restore could still create it after the +// release. The source is not written when refused. +func OperatorReleaseDependent(ctx context.Context, source, target HeadStore, r *Reader, targetID VolumeID) (Head, error) { + sh, found, err := source.ReadHead(ctx) + if err != nil { + return Head{}, err + } + if !found { + return Head{}, ErrHeadAbsent + } + id, err := r.VolumeID(ctx, r.vol) + hasVolume := err == nil + if err != nil && !errors.Is(err, ErrMissing) { + return Head{}, err + } + th, hasHead, err := target.ReadHead(ctx) + if err != nil { + return Head{}, err + } + switch { + case hasHead && (th.State == StateDeleting || th.State == StateDeleted): + case hasVolume && id != targetID: + case !hasVolume && !hasHead: + return Head{}, fmt.Errorf("%w: %s", ErrTargetNeverCreated, r.vol) + case hasVolume && hasHead: + names, err := namesVolume(ctx, r, th, sh.VolumeID) + if err != nil { + return Head{}, err + } + if names { + return Head{}, fmt.Errorf("%w: %s still names chunks of the source", ErrTargetLive, r.vol) + } + default: + return Head{}, fmt.Errorf("%w: %s is being created", ErrTargetLive, r.vol) + } + return RunReleaseDependent(ctx, source, targetID) +} + +// namesVolume reports whether any root in h names a chunk owned by owner. +// Every shard of every root is read; an unreadable one is an error, never +// "names nothing". +func namesVolume(ctx context.Context, r *Reader, h Head, owner VolumeID) (bool, error) { + roots := map[RootName]bool{} + if h.Current != nil { + roots[*h.Current] = true + } + for _, s := range h.Snapshots { + roots[s.Root] = true + } + for rn := range roots { + img, err := r.Open(ctx, rn) + if err != nil { + return false, err + } + for shard := range img.root.Segments { + seg, _, err := img.Segment(ctx, shard) + if err != nil { + return false, err + } + for _, ref := range seg.Chunks { + if ref.OwnerID == owner { + return true, nil + } + } + } + } + return false, nil +} diff --git a/seaweed-block/core/frontend/chunkstore/layout/delete_test.go b/seaweed-block/core/frontend/chunkstore/layout/delete_test.go index d2a237b606..bab3d06fd0 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/delete_test.go +++ b/seaweed-block/core/frontend/chunkstore/layout/delete_test.go @@ -232,3 +232,90 @@ func TestDeleteVolume_InterruptAtEveryStep(t *testing.T) { } } } + +// operatorCase: source src (id of "src") lists target t as a dependent; +// t's VOLUME, HEAD and root objects are as the case sets them. When the +// target names chunks, namesSource decides whether one of them is src's. +func operatorCase(t *testing.T, tgtHead *Head, tgtVolume *VolumeID, namesSource bool) (*memHead, *memHead, *Reader) { + t.Helper() + w := newDeleteWorld() + objs := map[string][]byte{} + put := func(rel string, b []byte) { objs[path.Join(removeBase, "t", rel)] = b } + if tgtVolume != nil { + b, err := Volume{ID: *tgtVolume, Name: "t", Format: VolumeFormat}.Encode() + if err != nil { + t.Fatal(err) + } + put(VolumeName, b) + } + if tgtHead != nil { + m := manifest(Ref{Owner: "t", OwnerID: idFor("t"), Chunk: NameChunk(1, []byte("own"))}) + if namesSource { + m[2] = Ref{Owner: "src", OwnerID: idFor("src"), Chunk: NameChunk(2, []byte("from src"))} + } + root, segs, err := Build(m) + if err != nil { + t.Fatal(err) + } + for n, b := range segs { + put(n.Path(), b) + } + rn, rb, err := NameRoot(root) + if err != nil { + t.Fatal(err) + } + put(rn.Path(), rb) + h := *tgtHead + h.Current = &rn + tgtHead = &h + } + r, err := NewReader(removeBase, "t", func(_ context.Context, p string) ([]byte, bool, error) { + b, ok := objs[p] + return b, ok, nil + }) + if err != nil { + t.Fatal(err) + } + return w.src, &memHead{h: tgtHead}, r +} + +// The operator's remove-dependent releases a target only when the target +// exists and is deleted or no longer names the source: its HEAD deleting +// or deleted, its name holding another volume (another VOLUME id), or a +// live HEAD none of whose roots names a chunk of the source. A live target +// that still names the source, one being created (VOLUME without HEAD) and +// one never created (no VOLUME, no HEAD: the restore could still create +// it) are refused and the source is unchanged. +func TestOperatorReleaseDependent(t *testing.T) { + ctx := context.Background() + live := idleHead() + live.VolumeID = idFor("t") + deleting := live + deleting.State = StateDeleting + tid, other := idFor("t"), idFor("t again") + for name, tc := range map[string]struct { + head *Head + volume *VolumeID + namesSource bool + release bool + want error + }{ + "live target naming the source": {&live, &tid, true, false, ErrTargetLive}, + "live target no longer naming it": {&live, &tid, false, true, nil}, + "target being created": {nil, &tid, false, false, ErrTargetLive}, + "target never created": {nil, nil, false, false, ErrTargetNeverCreated}, + "target deleting": {&deleting, &tid, true, true, nil}, + "name holds another volume": {nil, &other, false, true, nil}, + } { + src, tgt, r := operatorCase(t, tc.head, tc.volume, tc.namesSource) + before := src.updates + _, err := OperatorReleaseDependent(ctx, src, tgt, r, tid) + released := len(src.h.Snapshots["daily"].Dependents) == 0 + if tc.release && (err != nil || !released) { + t.Errorf("%s: %v, released %t; want released", name, err, released) + } + if !tc.release && (!errors.Is(err, tc.want) || released || src.updates != before) { + t.Errorf("%s: %v, released %t; want %v and the source unchanged", name, err, released, tc.want) + } + } +} diff --git a/seaweed-block/core/frontend/chunkstore/layout/guard_test.go b/seaweed-block/core/frontend/chunkstore/layout/guard_test.go index 89ae70c43b..6ef1f3bf84 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/guard_test.go +++ b/seaweed-block/core/frontend/chunkstore/layout/guard_test.go @@ -123,6 +123,9 @@ func owners(m map[string]bool) []string { // - Lease, claim half: OldLeaseEnded is used only in RunClaim, and // RunClaim, when it is declared, uses it. // - Every declared exported Run function goes through runTransition. +// - Release of a dependent: RunReleaseDependent is used only by +// DeleteVolume (its own HEAD is deleting) and OperatorReleaseDependent, +// which reads the target's HEAD before it releases. // - Pool: a name starting with Delete or Remove is used only in // RemoveUnreachable, where every delete is preceded, in the same loop // body, by the remover's own lease check (StillHeld), and in @@ -168,6 +171,14 @@ func guardFindings(code map[string]map[string]bool, decl, tests map[string]bool) bad = append(bad, fn+" is declared and does not go through runTransition") } } + for _, fn := range owners(code["RunReleaseDependent"]) { + if fn != "DeleteVolume" && fn != "OperatorReleaseDependent" { + bad = append(bad, fn+" uses RunReleaseDependent: only DeleteVolume (target deleting) and OperatorReleaseDependent (target checked) release") + } + } + if decl["OperatorReleaseDependent"] && !code["ReadHead"]["OperatorReleaseDependent"] { + bad = append(bad, "OperatorReleaseDependent does not read the target's HEAD before releasing") + } for name, by := range code { if strings.HasPrefix(name, "Delete") || strings.HasPrefix(name, "Remove") { for _, fn := range owners(by) { @@ -428,6 +439,10 @@ func DeleteVolume(ctx context.Context, st HeadStore, id VolumeID, srcs []HeadSto _, _ = RunMarkDeleted(ctx, st) return nil }`, want: "DeleteVolume has no NoHolder"}, + "release outside delete and the operator's check": {src: `func w(ctx context.Context, st HeadStore, id VolumeID) { _, _ = RunReleaseDependent(ctx, st, id) }`, want: "only DeleteVolume (target deleting) and OperatorReleaseDependent"}, + "operator release without reading the target": {file: "delete.go", src: `func OperatorReleaseDependent(ctx context.Context, source HeadStore, id VolumeID) (Head, error) { + return RunReleaseDependent(ctx, source, id) +}`, want: "does not read the target's HEAD"}, "remover method value": {src: `type p interface{ RemoveName(string) } func w(x p) { f := x.RemoveName; f("o") }`, want: "only RemoveUnreachable (after its lease re-check) and DeleteVolume"}, } { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index d246579b4b..8adfdcabfd 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -1101,7 +1101,7 @@ Notes: | `INV-SNAPK-REMOVE-LEASE-001` | A pool name is removed only inside the holder's own cleaning, only when no root in HEAD names it, and only after the remover's own lease is checked immediately before that delete; a lapsed lease stops the pass, an unreadable root or segment stops it before any delete, and a snapshot open on the volume refuses it. A source scan requires the lease check before every delete in the same block and refuses any other remover. | M9 clean → clean (RemoveUnreachable) | `core/frontend/chunkstore/layout` `remove.go` `RemoveUnreachable` | `TestRemoveUnreachable_RemovesOnlyWhatNoRootNames`, `TestRemoveUnreachable_RefusedOutsideItsCleaning`, `TestRemoveUnreachable_StopsWhenTheLeaseLapses`, `TestRemoveUnreachable_NothingRemovedOnAPartialView`, `TestCleaningPass_InterruptAtEveryStep`, `TestGuard_Controls` | — (the snapshot kernel model is not in this repository) | ACTIVE | | `INV-SNAPK-IDENTITY-001` | A volume is identified by the random id in its VOLUME record, never by its name alone: HEAD carries the volume id; every chunk reference in a segment carries its owner's volume id, and a read checks it against the owner's VOLUME before fetching (a volume created again under the name is ErrIdentity); every dependent records the target's volume id and the snapshot's root hash; a holder is the epoch, the server and the claim id its claim wrote into HEAD, so the same server with another claim id is refused by every transition. | M9 every transition; content-named layout | `core/frontend/chunkstore/layout` `volume.go` `Volume`, `VolumeID`; `head.go` `Head.check`, `heldBy`; `claim.go` `Head.Claim`; `read.go` `Image.Chunk`; `layout.go` `Segment.Encode` | `TestVolumeID_RandomAndParsed`, `TestVolume_GoldenEncodingRoundTrip`, `TestHead_GoldenEncodingRoundTrip`, `TestHead_Refusals`, `TestSegment_EncodeRefusals`, `TestRead_ForeignChunkNeedsTheOwnersVolumeID`, `TestClaim_WritesItsClaimID`, `TestTransitions_RefuseAStaleHolder`, `TestRemoveUnreachable_NeedsItsOwnVolumeID` | — (the snapshot kernel model is not in this repository) | ACTIVE | | `INV-SNAPK-DELETE-ORDER-001` | A volume delete runs in its order, each prefix safe and the whole re-runnable: HEAD deleting (only with no holder, no open activity and no snapshot with dependents), then this volume released from every source, then its objects deleted, then HEAD deleted; from deleting on, no holder transition, claim or removal applies. A source scan requires that order in DeleteVolume and refuses any other remover. | M9 idle → deleting → deleted | `core/frontend/chunkstore/layout` `delete.go` `DeleteVolume`, `Head.MarkDeleting`, `Head.MarkDeleted`; `head.go` `holderErr` | `TestMarkDeleting_Closure`, `TestMarkDeleted_Closure`, `TestDeleting_RefusesEveryHolderStep`, `TestDeleteVolume`, `TestDeleteVolume_InterruptAtEveryStep`, `TestRunMarkDeleting_InterruptAtEveryStep`, `TestRunMarkDeleted_InterruptAtEveryStep`, `TestGuard_Controls` | — (the snapshot kernel model is not in this repository) | ACTIVE | -| `INV-SNAPK-RELEASE-001` | A target is released from a source's dependents by its volume id, from every snapshot of that source, by one conditional update (the delete's release step and the operator's remove-dependent command); a volume created again under the target's name releases nothing; releasing an absent target writes nothing. | M9 source HEAD, dependents (no activity change) | `core/frontend/chunkstore/layout` `delete.go` `Head.ReleaseDependent`, `RunReleaseDependent` | `TestReleaseDependent_Closure`, `TestRunReleaseDependent_InterruptAtEveryStep` | — (the snapshot kernel model is not in this repository) | ACTIVE | +| `INV-SNAPK-RELEASE-001` | A target is released from a source's dependents by its volume id, from every snapshot of that source, by one conditional update; a volume created again under the target's name releases nothing; releasing an absent target writes nothing. Only two callers release: the delete of the target itself (its HEAD already deleting) and the operator's command, which first reads the target and releases only if it exists and is deleted (HEAD deleting or deleted, or its name holding another volume id) or no root in its live HEAD names a chunk of the source; a live target still naming the source, one being created and one never created are refused. A source scan restricts the callers and requires the operator's read of the target. | M9 source HEAD, dependents (no activity change) | `core/frontend/chunkstore/layout` `delete.go` `Head.ReleaseDependent`, `RunReleaseDependent`, `OperatorReleaseDependent` | `TestReleaseDependent_Closure`, `TestRunReleaseDependent_InterruptAtEveryStep`, `TestOperatorReleaseDependent`, `TestGuard_Controls` | — (the snapshot kernel model is not in this repository) | ACTIVE | | `INV-SNAPK-STALE-HOLDER-001` | Every transition refuses an older epoch of the same server, the same epoch held by another server, and the same epoch and server with another claim id, in idle, snap and clean; a new transition must be added to the table. | M9 every transition | `core/frontend/chunkstore/layout` `Head.heldBy` and each transition | `TestTransitions_RefuseAStaleHolder` | — (the snapshot kernel model is not in this repository) | ACTIVE | Notes: