diff --git a/seaweed-block/cmd/sw-block/chunk_verify_test.go b/seaweed-block/cmd/sw-block/chunk_verify_test.go index 551563eec8..4ac1cd30f0 100644 --- a/seaweed-block/cmd/sw-block/chunk_verify_test.go +++ b/seaweed-block/cmd/sw-block/chunk_verify_test.go @@ -43,7 +43,7 @@ func verifyCLIFixture(t *testing.T) (*manifestFixtureFiler, string) { oldResolve := resolveVolumeID resolveVolumeID = func(context.Context, string, string) (layout.VolumeID, error) { return id, nil } t.Cleanup(func() { resolveVolumeID = oldResolve }) - vb, err := layout.Volume{ID: id, Name: "v1", Geometry: layout.Geometry{SizeBytes: 64 * 4096, BlockSize: 4096, ChunkBytes: 4 * 4096}, Format: layout.VolumeFormat}.Encode() + vb, err := layout.Volume{ID: id, Name: "v1", Geometry: layout.Geometry{SizeBytes: 64 * 4096, BlockSize: 4096, ChunkBytes: 4096}, Format: layout.VolumeFormat}.Encode() if err != nil { t.Fatal(err) } diff --git a/seaweed-block/core/frontend/chunkstore/layout/verify.go b/seaweed-block/core/frontend/chunkstore/layout/verify.go index cbec6337c7..7433730f67 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/verify.go +++ b/seaweed-block/core/frontend/chunkstore/layout/verify.go @@ -42,7 +42,7 @@ type VerifyOptions struct { List List // Stat checks a chunk's presence and size without reading its body. // In-memory callers may omit it and supply those bytes through Fetch. - Stat func(ctx context.Context, p string) (found bool, err error) + Stat func(ctx context.Context, p string, expectedSize uint64) (found bool, err error) } // Finding is one problem found at Path (relative to ). @@ -71,6 +71,7 @@ type verifier struct { ownMeta map[string]bool owners map[string]ownerID // VOLUME id per chunk owner, read once checked map[string]bool // chunk paths checked across all roots + geometry map[string]Geometry ownID VolumeID } @@ -97,7 +98,7 @@ func Verify(ctx context.Context, base, vol string, fetch Fetch, opts VerifyOptio if opts.Orphans && opts.List == nil { return VerifyResult{}, errors.New("layout: verify orphans needs a list") } - v := &verifier{base: base, vol: vol, fetch: fetch, opts: opts, ownPool: map[string]bool{}, ownMeta: map[string]bool{}, owners: map[string]ownerID{}, checked: map[string]bool{}} + v := &verifier{base: base, vol: vol, fetch: fetch, opts: opts, ownPool: map[string]bool{}, ownMeta: map[string]bool{}, owners: map[string]ownerID{}, checked: map[string]bool{}, geometry: map[string]Geometry{}} v.res.Complete = true head, ok, err := v.head(ctx, vol) if err != nil { @@ -200,6 +201,7 @@ func (v *verifier) volumeID(ctx context.Context, vol string, report bool) (Volum v.incomplete("VOLUME identity mismatch") return VolumeID{}, false, nil } + v.geometry[vol] = rec.Geometry return rec.ID, true, nil } @@ -312,10 +314,6 @@ func (v *verifier) chunks(ctx context.Context, r *Reader, seg Segment, count boo v.res.Chunks++ dir := VolumeDir(ref.Owner, ref.OwnerID) p := path.Join(dir, ref.Chunk.Path()) - if v.checked[p] { - continue - } - v.checked[p] = true o, seen := v.owners[dir] if !seen { id, ok, err := v.volumeID(ctx, dir, false) @@ -329,6 +327,10 @@ func (v *verifier) chunks(ctx context.Context, r *Reader, seg Segment, count boo v.find(FindIdentity, p, fmt.Sprintf("names owner %s id %s; its VOLUME has %s", ref.Owner, ref.OwnerID, map[bool]string{true: o.id.String(), false: "none"}[o.ok])) continue } + if v.checked[p] { + continue + } + v.checked[p] = true if v.opts.Depth == DepthFull { if _, err := r.get(ctx, dir, ref.Chunk.Path(), ref.Chunk.Hash); err != nil { if err := v.classify(p, err); err != nil { @@ -337,10 +339,19 @@ func (v *verifier) chunks(ctx context.Context, r *Reader, seg Segment, count boo } continue } + var expectedSize uint64 + if v.opts.Stat != nil { + g := v.geometry[dir] + if ref.Chunk.Index > (g.SizeBytes-1)/g.ChunkBytes { + v.find(FindCorrupt, p, "chunk index is outside its owner's VOLUME geometry") + continue + } + expectedSize = min(g.ChunkBytes, g.SizeBytes-ref.Chunk.Index*g.ChunkBytes) + } var ok bool var err error if v.opts.Stat != nil { - ok, err = v.opts.Stat(ctx, path.Join(v.base, p)) + ok, err = v.opts.Stat(ctx, path.Join(v.base, p), expectedSize) } else { _, ok, err = v.fetch(ctx, path.Join(v.base, p)) } diff --git a/seaweed-block/core/frontend/chunkstore/layout/volume_writer_repository_guard_test.go b/seaweed-block/core/frontend/chunkstore/layout/volume_writer_repository_guard_test.go index 30eb2b8f84..4dce73c726 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/volume_writer_repository_guard_test.go +++ b/seaweed-block/core/frontend/chunkstore/layout/volume_writer_repository_guard_test.go @@ -87,6 +87,9 @@ func TestVolumeWriterRepositorySites(t *testing.T) { "core/frontend/chunkstore/layout/verify.go volumeID VolumeName": 1, "core/frontend/chunkstore/layout_create.go ReadVolumeRecord VolumeName": 1, "core/frontend/chunkstore/layout_create.go CreateVolumeRecord VolumeName": 1, + // Read-only cache discriminator; the distinct-object verifier control + // proves VOLUME is observed once while HEAD is confirmed separately. + "core/frontend/chunkstore/layout_verify.go VerifyLayout VolumeName": 1, } got := map[string]int{} root := filepath.Clean("../../../..") diff --git a/seaweed-block/core/frontend/chunkstore/layout_verify.go b/seaweed-block/core/frontend/chunkstore/layout_verify.go index 47609cb7db..7977d946e2 100644 --- a/seaweed-block/core/frontend/chunkstore/layout_verify.go +++ b/seaweed-block/core/frontend/chunkstore/layout_verify.go @@ -122,7 +122,7 @@ func VerifyLayout(ctx context.Context, f Filer, base, vol string, opts layout.Ve // verifyStat checks the filer's binding and size, not the needle's bytes. // Reading and hashing those bytes belongs to data depth. -func (s *LayoutStore) verifyStat(ctx context.Context, p string) (bool, error) { +func (s *LayoutStore) verifyStat(ctx context.Context, p string, expectedSize uint64) (bool, error) { if !path.IsAbs(p) || path.Clean(p) != p || !strings.HasPrefix(p, path.Dir(s.root)+"/") { return false, errors.New("chunkstore: object path outside the store base") } @@ -137,12 +137,15 @@ func (s *LayoutStore) verifyStat(ctx context.Context, p string) (bool, error) { return false, fmt.Errorf("%w: %s is not a file", layout.ErrCorrupt, p) } if len(e.Chunks) == 0 { + if uint64(len(e.Content)) != expectedSize { + return false, fmt.Errorf("%w: inline size differs from VOLUME geometry for %s", layout.ErrCorrupt, p) + } if e.Attributes != nil && e.Attributes.FileSize != uint64(len(e.Content)) { return false, fmt.Errorf("%w: inline size mismatch for %s", layout.ErrCorrupt, p) } return true, nil } - if len(e.Content) != 0 || len(e.Chunks) != 1 || e.Chunks[0] == nil || e.Chunks[0].Offset != 0 || e.Chunks[0].FileId == "" || e.Attributes == nil || e.Attributes.FileSize != e.Chunks[0].Size { + if len(e.Content) != 0 || len(e.Chunks) != 1 || e.Chunks[0] == nil || e.Chunks[0].Offset != 0 || e.Chunks[0].FileId == "" || e.Attributes == nil || e.Attributes.FileSize != e.Chunks[0].Size || e.Attributes.FileSize != expectedSize { return false, fmt.Errorf("%w: invalid file binding or size for %s", layout.ErrCorrupt, p) } return true, nil diff --git a/seaweed-block/core/frontend/chunkstore/layout_verify_test.go b/seaweed-block/core/frontend/chunkstore/layout_verify_test.go index f0a421695b..4fd80da01c 100644 --- a/seaweed-block/core/frontend/chunkstore/layout_verify_test.go +++ b/seaweed-block/core/frontend/chunkstore/layout_verify_test.go @@ -48,7 +48,7 @@ func verifyFixtureVolume(t *testing.T) (filerBlobs, layout.VolumeID) { manifest := map[uint64]layout.Ref{} putDir(t, f, path.Join("/blocks", layout.VolumeDir("v", id), "pool/0")) for _, i := range []uint64{0, 5} { - d := []byte(strings.Repeat(string(rune('a'+i)), 64)) + d := []byte(strings.Repeat(string(rune('a'+i)), 4*4096)) c := layout.NameChunk(i, d) putFile(t, f, path.Join(path.Join("/blocks", layout.VolumeDir("v", id)), c.Path()), d) manifest[i] = layout.Ref{Owner: "v", OwnerID: id, Chunk: c} @@ -87,7 +87,7 @@ func TestVerifyLayoutThroughTheAdapter(t *testing.T) { } extra := layout.NameChunk(9, []byte("zz")) putFile(t, fb.fakeFiler, path.Join(path.Join("/blocks", layout.VolumeDir("v", id)), extra.Path()), []byte("zz")) - c0 := layout.NameChunk(0, []byte(strings.Repeat("a", 64))) + c0 := layout.NameChunk(0, []byte(strings.Repeat("a", 4*4096))) delete(fb.fakeFiler.entries, path.Join(path.Join("/blocks", layout.VolumeDir("v", id)), c0.Path())) before = snapshotStore(fb) r, err = VerifyLayout(ctx, fb, "/blocks", layout.VolumeDir("v", id), layout.VerifyOptions{Orphans: true}) @@ -190,7 +190,7 @@ func TestVerifyLayoutRequiresStableHeadForMissingAndOrphans(t *testing.T) { fb, id := verifyFixtureVolume(t) hp := path.Join("/blocks", layout.VolumeDir("v", id), layout.HeadName) fb.fakeFiler.entries[hp].Extended = map[string][]byte{layoutKind: []byte("head"), layoutVolume: []byte(id.String()), layoutGen: []byte("1")} - c := layout.NameChunk(0, []byte(strings.Repeat("a", 64))) + c := layout.NameChunk(0, []byte(strings.Repeat("a", 4*4096))) delete(fb.fakeFiler.entries, path.Join("/blocks", layout.VolumeDir("v", id), c.Path())) extra := layout.NameChunk(9, []byte("orphan")) putFile(t, fb.fakeFiler, path.Join("/blocks", layout.VolumeDir("v", id), extra.Path()), []byte("orphan")) diff --git a/seaweed-block/core/frontend/chunkstore/verify_bindings_stat_test.go b/seaweed-block/core/frontend/chunkstore/verify_bindings_stat_test.go index 2ee3a6d56b..37da50da03 100644 --- a/seaweed-block/core/frontend/chunkstore/verify_bindings_stat_test.go +++ b/seaweed-block/core/frontend/chunkstore/verify_bindings_stat_test.go @@ -47,8 +47,8 @@ func TestVerifyBindingsNeverReadsChunkBodies(t *testing.T) { t.Fatalf("data: %+v, %v, body reads=%d", res, err, full-after) } // Same-size damage is invisible to bindings, but must be caught by data depth. - e := fb.fakeFiler.entries[path.Join("/blocks", layout.VolumeDir("v", id), layout.NameChunk(0, []byte(strings.Repeat("a", 64))).Path())] - fb.fakeBlobs.data[e.Chunks[0].FileId] = []byte(strings.Repeat("z", 64)) + e := fb.fakeFiler.entries[path.Join("/blocks", layout.VolumeDir("v", id), layout.NameChunk(0, []byte(strings.Repeat("a", 4*4096))).Path())] + fb.fakeBlobs.data[e.Chunks[0].FileId] = []byte(strings.Repeat("z", 4*4096)) res, err = VerifyLayout(context.Background(), fb, "/blocks", layout.VolumeDir("v", id), layout.VerifyOptions{Depth: layout.DepthFull}) if err != nil || len(res.Findings) != 1 || res.Findings[0].Class != layout.FindCorrupt { t.Fatalf("damaged data: %+v, %v", res, err) @@ -70,11 +70,22 @@ func TestVerifyBindingsChecksEachDistinctObjectOnce(t *testing.T) { dir := path.Join("/blocks", layout.VolumeDir("v", id)) refs := map[uint64]layout.Ref{} for _, i := range []uint64{0, 5} { - refs[i] = layout.Ref{Owner: "v", OwnerID: id, Chunk: layout.NameChunk(i, []byte(strings.Repeat(string(rune('a'+i)), 64)))} + refs[i] = layout.Ref{Owner: "v", OwnerID: id, Chunk: layout.NameChunk(i, []byte(strings.Repeat(string(rune('a'+i)), 4*4096)))} + } + // This snapshot deliberately reaches the next shard; its volume covers it. + vp := path.Join(dir, layout.VolumeName) + volume, err := layout.DecodeVolume(fb.fakeFiler.entries[vp].Content) + if err != nil { + t.Fatal(err) + } + volume.SizeBytes = uint64(layout.ShardSize+2) * volume.ChunkBytes + fb.fakeFiler.entries[vp].Content, err = volume.Encode() + if err != nil { + t.Fatal(err) } index := uint64(layout.ShardSize + 1) - n := layout.NameChunk(index, []byte("snapshot-only")) - putFile(t, fb.fakeFiler, path.Join(dir, n.Path()), []byte("snapshot-only")) + n := layout.NameChunk(index, []byte(strings.Repeat("s", 4*4096))) + putFile(t, fb.fakeFiler, path.Join(dir, n.Path()), []byte(strings.Repeat("s", 4*4096))) refs[index] = layout.Ref{Owner: "v", OwnerID: id, Chunk: n} root, segs, err := layout.Build(refs) if err != nil { @@ -126,7 +137,7 @@ func TestVerifyBindingsChecksDeclaredSizesAndRefusals(t *testing.T) { for _, mode := range []string{"size", "no-attributes", "offset", "empty-fid", "nil-chunk", "multiple-chunks", "directory", "mixed-content", "inline-size", "missing"} { t.Run(mode, func(t *testing.T) { fb, id := verifyBlobFixture(t) - p := path.Join("/blocks", layout.VolumeDir("v", id), layout.NameChunk(0, []byte(strings.Repeat("a", 64))).Path()) + p := path.Join("/blocks", layout.VolumeDir("v", id), layout.NameChunk(0, []byte(strings.Repeat("a", 4*4096))).Path()) e := fb.fakeFiler.entries[p] switch mode { case "size": @@ -204,7 +215,7 @@ func (f *verifyPayloadCounter) Get(ctx context.Context, fid string) ([]byte, err } func TestVerifyBindingsProductionMetadataStillDecodes(t *testing.T) { ctx := context.Background() - c, source, _, _ := cleanFixture(t) + c, source := verifyProductionFixture(t) target := newRef(t, "restored") if _, err := c.Restore(ctx, source, "s", target); err != nil { t.Fatal(err) @@ -236,3 +247,100 @@ func TestVerifyBindingsProductionMetadataStillDecodes(t *testing.T) { t.Fatalf("restore data: %+v, %v, payload reads=%d", res, err, f.payloadReads) } } + +func TestVerifyBindingsRejectsSelfConsistentTruncationAgainstGeometry(t *testing.T) { + fb, id := verifyBlobFixture(t) + p := path.Join("/blocks", layout.VolumeDir("v", id), layout.NameChunk(0, []byte(strings.Repeat("a", 4*4096))).Path()) + e := fb.fakeFiler.entries[p] + e.Attributes.FileSize = 32 + e.Chunks[0].Size = 32 + res, err := VerifyLayout(context.Background(), fb, "/blocks", layout.VolumeDir("v", id), layout.VerifyOptions{Depth: layout.DepthNames}) + if err != nil || !res.Complete || len(res.Findings) != 1 || res.Findings[0].Class != layout.FindCorrupt || res.Findings[0].Path != strings.TrimPrefix(p, "/blocks/") { + t.Fatalf("self-consistent truncation: %+v, %v", res, err) + } +} + +func TestVerifyBindingsUsesTailGeometryAndRejectsOutsideVolume(t *testing.T) { + for _, mode := range []string{"tail", "short-tail", "outside"} { + t.Run(mode, func(t *testing.T) { + fb, id := verifyBlobFixture(t) + dir := path.Join("/blocks", layout.VolumeDir("v", id)) + vp := path.Join(dir, layout.VolumeName) + volume, err := layout.DecodeVolume(fb.fakeFiler.entries[vp].Content) + if err != nil { + t.Fatal(err) + } + volume.SizeBytes = 5*volume.ChunkBytes + 4096 + if mode == "outside" { + volume.SizeBytes = 5 * volume.ChunkBytes + } + fb.fakeFiler.entries[vp].Content, err = volume.Encode() + if err != nil { + t.Fatal(err) + } + p := path.Join(dir, layout.NameChunk(5, []byte(strings.Repeat("f", 4*4096))).Path()) + // Names depth observes declared metadata only; it must not read this body. + e := fb.fakeFiler.entries[p] + e.Attributes.FileSize, e.Chunks[0].Size = 4096, 4096 + if mode == "short-tail" { + e.Attributes.FileSize, e.Chunks[0].Size = 2048, 2048 + } + res, err := VerifyLayout(context.Background(), fb, "/blocks", layout.VolumeDir("v", id), layout.VerifyOptions{Depth: layout.DepthNames}) + if err != nil || !res.Complete { + t.Fatalf("%s: %+v, %v", mode, res, err) + } + if mode == "tail" { + if len(res.Findings) != 0 { + t.Fatalf("valid tail: %+v", res.Findings) + } + } else if len(res.Findings) != 1 || res.Findings[0].Class != layout.FindCorrupt || res.Findings[0].Path != strings.TrimPrefix(p, "/blocks/") { + t.Fatalf("%s: %+v", mode, res.Findings) + } + _, gets, _ := fb.fakeBlobs.counts() + if gets != 0 { + t.Fatalf("bindings read %d bodies", gets) + } + }) + } +} + +func TestVerifyDeduplicationNeverSkipsFullOwnerIdentity(t *testing.T) { + for _, depth := range []string{layout.DepthNames, layout.DepthFull} { + t.Run(depth, func(t *testing.T) { + fb, id := verifyBlobFixture(t) + wrong := id + wrong[15] ^= 1 + if layout.VolumeDir("v", wrong) != layout.VolumeDir("v", id) { + t.Fatal("fixture needs an id8 collision") + } + ref := layout.Ref{Owner: "v", OwnerID: wrong, Chunk: layout.NameChunk(0, []byte(strings.Repeat("a", 4*4096)))} + root, segs, err := layout.Build(map[uint64]layout.Ref{0: ref}) + if err != nil { + t.Fatal(err) + } + dir := path.Join("/blocks", layout.VolumeDir("v", id)) + for n, b := range segs { + putFile(t, fb.fakeFiler, path.Join(dir, n.Path()), b) + } + rn, raw, err := layout.NameRoot(root) + if err != nil { + t.Fatal(err) + } + putFile(t, fb.fakeFiler, path.Join(dir, rn.Path()), raw) + e := fb.fakeFiler.entries[path.Join(dir, layout.HeadName)] + h, err := layout.DecodeHead(e.Content, 0, id) + if err != nil { + t.Fatal(err) + } + h.Snapshots = map[string]layout.Snapshot{"different-owner": {Root: rn}} + e.Content, err = h.Encode() + if err != nil { + t.Fatal(err) + } + res, err := VerifyLayout(context.Background(), fb, "/blocks", layout.VolumeDir("v", id), layout.VerifyOptions{Depth: depth}) + if err != nil || !res.Complete || len(res.Findings) != 1 || res.Findings[0].Class != layout.FindIdentity { + t.Fatalf("id8 collision after a valid reference: %+v, %v", res, err) + } + }) + } +} diff --git a/seaweed-block/core/frontend/chunkstore/verify_production_layout_test.go b/seaweed-block/core/frontend/chunkstore/verify_production_layout_test.go index 5ed3d073f6..cd435c590d 100644 --- a/seaweed-block/core/frontend/chunkstore/verify_production_layout_test.go +++ b/seaweed-block/core/frontend/chunkstore/verify_production_layout_test.go @@ -1,6 +1,7 @@ package chunkstore import ( + "bytes" "context" "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/filerpb" "google.golang.org/protobuf/proto" @@ -19,7 +20,7 @@ type verifyProductionStore struct { // restored image borrows the source's chunks while owning copied metadata. func TestVerifyProductionLayoutCurrentAndRestored(t *testing.T) { ctx := context.Background() - c, source, _, _ := cleanFixture(t) + c, source := verifyProductionFixture(t) target := newRef(t, "restored") if _, err := c.Restore(ctx, source, "s", target); err != nil { t.Fatal(err) @@ -58,7 +59,7 @@ func (f *verifyMovingDependent) LookupEntry(ctx context.Context, dir, name strin } func TestVerifyConfirmsDependentHeadBeforeReportingOrphans(t *testing.T) { ctx := context.Background() - c, source, _, _ := cleanFixture(t) + c, source := verifyProductionFixture(t) target := newRef(t, "restored") if _, err := c.Restore(ctx, source, "s", target); err != nil { t.Fatal(err) @@ -80,3 +81,21 @@ func TestVerifyConfirmsDependentHeadBeforeReportingOrphans(t *testing.T) { t.Fatalf("moving dependent: %+v %v reads=%d", r, err, f.reads) } } + +// Unlike catalog-only fixtures, a verifier fixture stores full geometry-sized chunks. +func verifyProductionFixture(t *testing.T) (*BCatalog, VolumeRef) { + t.Helper() + c, err := NewBCatalog(NewMemFiler(), newFakeBlobs(), "/blocks") + if err != nil { + t.Fatal(err) + } + source := newRef(t, "source") + if _, err := c.CreateVolume(context.Background(), source, layout.Geometry{SizeBytes: 64 * 4096, BlockSize: 4096, ChunkBytes: 4 * 4096}); err != nil { + t.Fatal(err) + } + commitSnapshot(t, c, source, bytes.Repeat([]byte{7}, 4*4096), "s") + if err := c.f.CreateEntry(context.Background(), path.Join(c.base, source.Dir(), layout.PoolDir), &filerpb.Entry{Name: "0", IsDirectory: true}, false); err != nil { + t.Fatal(err) + } + return c, source +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index abd653fdde..f76ca2fcd9 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -1060,14 +1060,14 @@ Notes: | `INV-SNAP-SCHEDULE-RESTART-001` | A new snapshot worker seeds its last success from HEAD's newest scheduled creation time (future clamped to now), then the next stable per-volume grid slot; absent history is due now. Restarts preserve overdue age; manual snapshots do not seed it. | M8 scheduled worker Armed → Due | `core/frontend/durable/chunk_snapshot_schedule.go` `snapshotScheduleFromHead`; `provider_chunk.go` `newChunkLayer` | `TestScheduledSnapshotRestartsStillTakeTheDueSnapshot`, `TestScheduledSnapshotRestartPreservesOverdueFromHEAD`, `TestScheduledSnapshotWithoutHistoryIsImmediatelyDue`, `TestScheduledSnapshotProvidersSpreadAfterImmediateFirstAttempt`, `TestSnapshotScheduleHeadSeedKeepsPerVolumeGrid`, `TestSnapshotScheduleHeadSeedClampsFutureCreationTime` | — (read-only timer initialization from existing HEAD metadata) | ACTIVE | | `INV-SNAP-SCHEDULED-KEEP-001` | Retention keeps the newest K scheduled snapshots, K being the newest one's swb.schedule.keep (default 7); scheduled snapshots never count against KeepNewest or get age keeps, so other snapshots are planned as if they were absent. | M6 snapshot: Published → Deleting (retention, class `scheduled`) | `core/frontend/chunkstore/retain/retain.go` `Plan`, `scheduleKeepOf` | `TestPlanRetention_ScheduledClassKeepsItsOwnNewest`, `TestPlanRetention_PinnedScheduledStaysInItsClass` (`core/frontend/chunkstore/retain/retain_test.go`) | — | ACTIVE | | `INV-VERIFY-READONLY-001` | Verify writes nothing at any depth: it reaches the store only through Fetch, Stat and List, and a full pass with orphans leaves every filer entry and blob unchanged. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyLayoutThroughTheAdapter` (`core/frontend/chunkstore/layout_verify_test.go`) | — | ACTIVE | -| `INV-VERIFY-BINDINGS-001` | Bindings depth checks each chunk's filer binding and declared size without reading its blob body; data depth retains byte/hash validation. | M6 reader (no transition) | `core/frontend/chunkstore/layout_verify.go` `verifyStat`; `layout/verify.go` `chunks` | `TestVerifyBindingsNeverReadsChunkBodies`, `TestVerifyBindingsChecksDeclaredSizesAndRefusals`, `TestVerifyBindingsLookupFailureIsNotAMissingObject` | — (read-only inspection) | ACTIVE | -| `INV-VERIFY-DISTINCT-001` | A verify pass looks up each immutable metadata object and chunk binding once across roots; HEAD remains independently confirmed, and chunk bodies are never retained in the metadata cache. | M6 reader (no transition) | `core/frontend/chunkstore/layout_verify.go` `VerifyLayout`; `layout/verify.go` `chunks` | `TestVerifyBindingsChecksEachDistinctObjectOnce` | — (pass-local reuse) | ACTIVE | +| `INV-VERIFY-BINDINGS-001` | Bindings depth checks each chunk's filer binding and size against its owner's VOLUME geometry (tail excepted), without reading the blob body. | M6 reader (no transition) | `core/frontend/chunkstore/layout_verify.go` `verifyStat`; `core/frontend/chunkstore/layout/verify.go` `chunks` | `TestVerifyBindingsNeverReadsChunkBodies`, `TestVerifyBindingsChecksDeclaredSizesAndRefusals`, `TestVerifyBindingsLookupFailureIsNotAMissingObject`, `TestVerifyBindingsRejectsSelfConsistentTruncationAgainstGeometry`, `TestVerifyBindingsUsesTailGeometryAndRejectsOutsideVolume` | — (read-only inspection) | ACTIVE | +| `INV-VERIFY-DISTINCT-001` | A verify pass looks up each immutable metadata object and chunk binding once across roots; HEAD remains independently confirmed, and chunk bodies are never retained in the metadata cache. | M6 reader (no transition) | `core/frontend/chunkstore/layout_verify.go` `VerifyLayout`; `core/frontend/chunkstore/layout/verify.go` `chunks` | `TestVerifyBindingsChecksEachDistinctObjectOnce` | — (pass-local reuse) | ACTIVE | | `INV-VERIFY-STABLE-HEAD-001` | Filer verify publishes MISSING or ORPHAN only after two HEAD observations agree on a nonzero generation and volume identity. An unavailable or changed own/dependent HEAD makes the pass incomplete and suppresses those findings. Unsupported verify options refuse before dialing. | M6 (reader; no transition) | `core/frontend/chunkstore/layout_verify.go` `VerifyLayout`; `cmd/sw-block/chunk_verify.go` `chunkVerify` | `TestVerifyLayoutRequiresStableHeadForMissingAndOrphans`; `TestVerifyConfirmsDependentHeadBeforeReportingOrphans`; `TestOpsChunkVerifyRefusesUnsupportedFlagsBeforeDial` | — | ACTIVE | | `INV-VERIFY-NOTFOUND-001` | Verify reports `MISSING` only when the store answers that the object does not exist; any other read failure ends the pass as incomplete with that error, and is never a finding. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyReadErrorIsReturned`, `TestVerifyFindsMissingAndCorrupt` (`core/frontend/chunkstore/layout/verify_test.go`); `TestOpsChunk_VerifyReadErrorIsIncomplete` (`cmd/sw-block/chunk_verify_test.go`) | — | ACTIVE | | `INV-VERIFY-REACH-001` | A complete pass checks every object the current root and every snapshot root name (roots, segments, chunks): an absent one is `MISSING`; one whose bytes do not hash to its name, at depth full, is `CORRUPT`. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyCleanVolume`, `TestVerifyFindsMissingAndCorrupt`, `TestVerifyWalksSnapshotRoots` (`core/frontend/chunkstore/layout/verify_test.go`) | — | ACTIVE | | `INV-VERIFY-INCOMPLETE-001` | A volume whose VOLUME or HEAD is absent or does not decode is never reported clean: the pass is incomplete and says which object. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyHeadMissingOrMalformedIsIncomplete` (`core/frontend/chunkstore/layout/verify_test.go`) | — | ACTIVE | | `INV-VERIFY-ORPHAN-001` | With orphans on, only this volume's own full-id names that no root or live restore target names are ORPHAN. Owner/target paths use VolumeDir(name,id); an unreadable live target suppresses orphan findings. Verify deletes nothing. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyOrphans`, `TestVerifyDependentReachIsNotOrphanAndUnreadableDependentSuppresses` (`core/frontend/chunkstore/layout/verify_test.go`) ; `TestVerifyProductionLayoutCurrentAndRestored` (`core/frontend/chunkstore/verify_production_layout_test.go`) | — | ACTIVE | -| `INV-VERIFY-IDENTITY-001` | Verify reads canonical VolumeDir(name,id) directories. VOLUME must match its directory, HEAD must match VOLUME, and a master-resolved id must match in full. A mismatched chunk-owner VOLUME is IDENTITY, never clean. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyVolumeRecordAndHeadID`, `TestVerifyChunkOwnerIdentity` (`core/frontend/chunkstore/layout/verify_test.go`) ; `TestVerifyProductionLayoutCurrentAndRestored` (`core/frontend/chunkstore/verify_production_layout_test.go`); `TestOpsChunk_VerifyProductionLayoutNameAndDirectory`, `TestOpsChunk_VerifyBindsMasterFullIDDespiteDirectoryPrefixCollision` (`cmd/sw-block/chunk_verify_production_test.go`) | — | ACTIVE | +| `INV-VERIFY-IDENTITY-001` | Verify reads canonical VolumeDir(name,id) directories. VOLUME must match its directory, HEAD must match VOLUME, and a master-resolved id must match in full. A mismatched chunk-owner VOLUME is IDENTITY, never clean. | M6 (reader; no transition) | `core/frontend/chunkstore/layout/verify.go` `Verify`; `core/frontend/chunkstore/layout_verify.go` `VerifyLayout` | `TestVerifyVolumeRecordAndHeadID`, `TestVerifyChunkOwnerIdentity` (`core/frontend/chunkstore/layout/verify_test.go`), `TestVerifyDeduplicationNeverSkipsFullOwnerIdentity` (`core/frontend/chunkstore/verify_bindings_stat_test.go`) ; `TestVerifyProductionLayoutCurrentAndRestored` (`core/frontend/chunkstore/verify_production_layout_test.go`); `TestOpsChunk_VerifyProductionLayoutNameAndDirectory`, `TestOpsChunk_VerifyBindsMasterFullIDDespiteDirectoryPrefixCollision` (`cmd/sw-block/chunk_verify_production_test.go`) | — | ACTIVE | | `INV-RESTORE-HYDRATE-001` | The background hydrate walker fetches a chunk only through that chunk's shared fill flight: at most one fetch per chunk absence, and a fetched block is never installed over a block written locally. | M4 Holder (background hydrate) | `core/storage/chunk_hydrate_all.go` `HydrateAll`, `HydrateAllAt`, `startWalkerFill`, `nextHydrateTarget`, `admitFill`; `core/storage/chunk_hydration.go` `hydrationFlightLocked`; `core/storage/chunk_layer.go` `fillOnce` | `TestHydrateAll_FillsEveryChunkOnceAndReadsTheHeadImage`, `TestHydrateAll_YieldsToGuestReadsAndNeverFetchesTwice`, `TestHydrateAll_NeverOverwritesALocalWrite`, `TestHydrateAll_AdmitsEachFillThroughTheLimiterWithTheCallersClass`, `TestHydrateAll_RealBackgroundFillLimiterAdmitsEveryFill`, `TestHydrateAll_PermitIsHeldUntilTheOwnedFetchSettles`, `TestHydrateAll_RevocationStopsTheWalker`, `TestHydrateAll_CancelReturnsWhileTheFetchIsHeld`, `TestHydrateAll_PacedByByteRate` (`core/storage/chunk_hydrate_all_test.go`) | — | DORMANT | | `INV-RESTORE-OWN-BATCH-001` | A batch cut re-uploads at most N local chunks whose HEAD keys name another volume under new own keys, even when their bytes equal HEAD's, in one ordinary cut (one intent, one HEAD CAS); it never fetches an absent chunk. | M6.Restore.Owning>Owning | `core/storage/chunk_own.go` `OwnBatch`; `core/storage/chunk_cut_payload.go` `streamCutPayloads` | `TestOwnBatch_BoundedBatchesReplaceEveryForeignKey`, `TestOwnBatch_SkipsChunksNotLocal`, `TestOwnBatch_CarriesGuestWrites` (`core/storage/chunk_own_test.go`) | `RestoreIndependence` `NoGap` | DORMANT | | `INV-RESTORE-READ-REF-001` | A restore target reads each chunk its HEAD names from the pool of the reference's owner, by the reference alone (no other copy, no name-built path); a chunk missing there is an error on a fresh host, never zeros. | M6 restore target read (no transition) | `core/frontend/chunkstore/layout/read.go` `Reader.ReadRef`; `core/frontend/chunkstore/layout_remote.go` `LayoutRemote.Get` | `TestLayoutRemote_RestoreTargetReadsItsSource` (`core/frontend/chunkstore/layout_restore_read_test.go`) | — | ACTIVE | diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index 35f2dd1eaf..e489e42760 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -870,7 +870,8 @@ check. Source and restore-target chunks are checked in their owners' canonical directories using each reference's full owner id. The default `--depth bindings` (also named `meta`) checks each distinct chunk's -filer entry and the consistency of its declared size without fetching the chunk +filer entry and its declared size against its owner's VOLUME geometry (including +the final partial chunk) without fetching the chunk body. It does not detect content damage or a missing backing needle behind a present entry; use `--depth data` for those checks. Roots and segments are still read and decoded, and shared immutable objects are checked once per pass.