From e9c8e464f4d8515a62f46e090941994d93f57fdb Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 15:30:00 -0800 Subject: [PATCH 1/2] ci(spec): a published spec states its exhausted bounds docs/spec/README.md gains an Exhausted bounds table: one row per spec with a configuration TLC explored completely, its bounds, its distinct state count and what the model leaves out. internal/invcheck checks every row (the spec and configuration exist, no cell is empty) and that every spec has a row or is in a list that only shrinks (21 today). Eight rows are added from results the README already states; nothing was re-run. Co-Authored-By: Claude Fable 5.2 --- seaweed-block/docs/spec/README.md | 23 ++++ .../internal/invcheck/spec_bounds_test.go | 117 ++++++++++++++++++ .../testdata/specs-without-bounds.txt | 23 ++++ 3 files changed, 163 insertions(+) create mode 100644 seaweed-block/internal/invcheck/spec_bounds_test.go create mode 100644 seaweed-block/internal/invcheck/testdata/specs-without-bounds.txt diff --git a/seaweed-block/docs/spec/README.md b/seaweed-block/docs/spec/README.md index d0060fb545..51b0f6aa19 100644 --- a/seaweed-block/docs/spec/README.md +++ b/seaweed-block/docs/spec/README.md @@ -103,6 +103,29 @@ Two kinds of config are **expected to violate**: Each `.cfg` names its spec on its first line. +## Exhausted bounds + +One row per spec: a configuration that TLC explored completely (breadth-first, +no error, queue empty), the bounds of that configuration, its distinct state +count, and what the model leaves out. A pass means "no violation exists within +these bounds", nothing more. A spec is added to this directory together with +its row; `internal/invcheck` checks that each row names an existing spec and +configuration and fills every cell. Specs that predate this table are listed +in `internal/invcheck/testdata/specs-without-bounds.txt`; the list only +shrinks. The sections below hold the full results, the negative +configurations and the counterexamples. + +| Spec | Configuration | Bounds | Distinct states | Not modelled | +|---|---|---|---|---| +| `ForkDelete.tla` | `cfg/ForkDelete_safe_na_P2_D1E2G5.cfg` | deadline D=1, skew E=2, apply bound P=2, grace G=5 (the boundary G = D + E + P), check-then-publish fork, three clocks | 15,730,209 | guest I/O; GC as more than one atomic step; more than one fork per parent read | +| `FrozenDetachBudget.tla` | `cfg/FrozenDetachBudget.cfg` | one externally frozen attempt; time in tenths of a second | 439 | physical latency; the external controller's re-freeze limit; fencing and CAS races during the cut | +| `GCClockSkew.tla` | `GCClockSkew_safe.cfg` | G=3, S=1, Q=1, Born=10, MaxT=17 | 96 | the root scan, copy settlement and higher-epoch guards; clocks outside the configured skew | +| `GCDeleteProgress.tla` | `GCDeleteProgress_safe.cfg` | three ordered candidates, the first DELETE rejected | 4 | root and epoch admission; elapsed coverage; persistence | +| `PlainDetach.tla` | `cfg/PlainDetach.cfg` | up to two I/O readers, frontend close | 10 | HEAD publication; authority; physical I/O; wall-clock bounds; failure settlement | +| `RestoreIndependence.tla` | `cfg/RestoreIndependence_nc_safe_n4.cfg` | no-claim design, the largest of the safe configurations (`n4`) | 2,752,518 | guest writes to the target while it takes ownership; GC that takes time; more than one restore per snapshot | +| `ScopedMaintenanceGC.tla` | `ScopedMaintenanceGC_safe.cfg` | three keys across two volumes, one foreign-only root | 10 | the complete mark and the grace timing (in `RetentionGCTiming`); density and metadata-RPC cost | +| `WorkspaceMoveOutcome.tla` | `cfg/WorkspaceMoveOutcome.cfg` | one volume, seven error causes, one failed write, one reply | 135 | authority changes; journal durability; lease safety; RPC delivery; reload | + ## Specs at a glance State counts are distinct states for exhaustive passes. "N-step trace" is the diff --git a/seaweed-block/internal/invcheck/spec_bounds_test.go b/seaweed-block/internal/invcheck/spec_bounds_test.go new file mode 100644 index 0000000000..58c9a06bd5 --- /dev/null +++ b/seaweed-block/internal/invcheck/spec_bounds_test.go @@ -0,0 +1,117 @@ +package invcheck + +import ( + "os" + "path/filepath" + "regexp" + "sort" + "strings" + "testing" +) + +// specsWithoutBoundsLeft is the number of specs in docs/spec that have no +// row yet in the "Exhausted bounds" table of docs/spec/README.md. It only +// goes down: a new spec arrives with its row. +const specsWithoutBoundsLeft = 21 + +var stateCount = regexp.MustCompile(`\d`) + +// A published spec says what was checked: docs/spec/README.md has an +// "Exhausted bounds" table with, for each spec, one configuration that TLC +// explored completely, the bounds of that configuration, its distinct state +// count, and what the model leaves out. Specs that predate the table are +// listed in testdata/specs-without-bounds.txt, and that list only shrinks. +func TestPublicSpecsStateTheirBounds(t *testing.T) { + root := repoRoot(t) + specDir := filepath.Join(root, "docs", "spec") + + entries, err := os.ReadDir(specDir) + if err != nil { + t.Fatal(err) + } + specs := map[string]bool{} + for _, e := range entries { + if !e.IsDir() && strings.HasSuffix(e.Name(), ".tla") { + specs[e.Name()] = true + } + } + + raw, err := os.ReadFile(filepath.Join(specDir, "README.md")) + if err != nil { + t.Fatal(err) + } + doc := strings.ReplaceAll(string(raw), "\r\n", "\n") + start := strings.Index(doc, "\n## Exhausted bounds\n") + if start < 0 { + t.Fatal("docs/spec/README.md: heading \"## Exhausted bounds\" not found") + } + section := doc[start+1:] + if end := strings.Index(section[1:], "\n## "); end >= 0 { + section = section[:end+1] + } + + withRow := map[string]bool{} + for _, line := range strings.Split(section, "\n") { + if !strings.HasPrefix(line, "| `") { + continue + } + cells := strings.Split(strings.Trim(line, "|"), "|") + if len(cells) != 5 { + t.Errorf("Exhausted bounds: a row has %d cells, want 5 (spec, configuration, bounds, distinct states, not modelled): %s", len(cells), line) + continue + } + for i := range cells { + cells[i] = strings.TrimSpace(cells[i]) + } + spec := strings.Trim(cells[0], "`") + cfg := strings.Trim(cells[1], "`") + if !specs[spec] { + t.Errorf("Exhausted bounds: %s is not a file in docs/spec", spec) + continue + } + if withRow[spec] { + t.Errorf("Exhausted bounds: %s has two rows; keep the one configuration that best states the claim", spec) + } + withRow[spec] = true + if _, err := os.Stat(filepath.Join(specDir, filepath.FromSlash(cfg))); err != nil { + t.Errorf("Exhausted bounds: %s names configuration %q, which is not a file under docs/spec", spec, cfg) + } + if cells[2] == "" { + t.Errorf("Exhausted bounds: %s states no bounds", spec) + } + if !stateCount.MatchString(cells[3]) { + t.Errorf("Exhausted bounds: %s states no distinct state count", spec) + } + if cells[4] == "" { + t.Errorf("Exhausted bounds: %s does not say what is not modelled", spec) + } + } + + var missing []string + for s := range specs { + if !withRow[s] { + missing = append(missing, s) + } + } + sort.Strings(missing) + + listRaw, err := os.ReadFile(filepath.Join("testdata", "specs-without-bounds.txt")) + if err != nil { + t.Fatal(err) + } + var listed []string + for _, l := range strings.Split(strings.ReplaceAll(string(listRaw), "\r\n", "\n"), "\n") { + if l = strings.TrimSpace(l); l != "" && !strings.HasPrefix(l, "#") { + listed = append(listed, l) + } + } + sort.Strings(listed) + + if strings.Join(missing, "\n") != strings.Join(listed, "\n") { + t.Errorf("specs with no Exhausted bounds row:\n %s\ntestdata/specs-without-bounds.txt lists:\n %s\nA new spec needs a row in docs/spec/README.md; a spec that gained a row leaves the list.", + strings.Join(missing, "\n "), strings.Join(listed, "\n ")) + } + if len(listed) != specsWithoutBoundsLeft { + t.Errorf("testdata/specs-without-bounds.txt has %d specs, specsWithoutBoundsLeft is %d: lower the constant when a spec leaves the list; it never goes up", len(listed), specsWithoutBoundsLeft) + } +} diff --git a/seaweed-block/internal/invcheck/testdata/specs-without-bounds.txt b/seaweed-block/internal/invcheck/testdata/specs-without-bounds.txt new file mode 100644 index 0000000000..280604d094 --- /dev/null +++ b/seaweed-block/internal/invcheck/testdata/specs-without-bounds.txt @@ -0,0 +1,23 @@ +# Specs in docs/spec with no row yet in the "Exhausted bounds" table of docs/spec/README.md. +# This list only shrinks: add the row, then remove the line and lower specsWithoutBoundsLeft. +ChunkLifecycle.tla +ChunkLifecycleFixed.tla +ControlPlane.tla +CutCOW.tla +CutCOW2.tla +CutCapture.tla +CutPipeline.tla +HostBudget.tla +MaintenanceOwner.tla +PrecopyFixedAdmission.tla +ReplicaApplyOrder.tla +ReplicaPrefixFloor.tla +ReplicaReviewGuards.tla +ReplicationFailover.tla +RetentionGCMulti.tla +RetentionGCTiming.tla +SmartWALRecovery.tla +WALReclaim.tla +WALRecovery.tla +WALReplica.tla +WorkspaceTakeover.tla From f6b3b3e34dba99e9d4ff96e3061aef1592beaccd Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 16:48:29 -0800 Subject: [PATCH 2/2] docs(spec): bounds rows for the three reopen and seal specs HeadReopenBelt, PlainSealReplay and SealedReopen arrived on main with their results in the README; each gets its Exhausted bounds row from those figures. Nothing re-run. Co-Authored-By: Claude Fable 5.2 --- seaweed-block/docs/spec/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/seaweed-block/docs/spec/README.md b/seaweed-block/docs/spec/README.md index 217df27cf9..78a1b3d446 100644 --- a/seaweed-block/docs/spec/README.md +++ b/seaweed-block/docs/spec/README.md @@ -121,9 +121,12 @@ configurations and the counterexamples. | `FrozenDetachBudget.tla` | `cfg/FrozenDetachBudget.cfg` | one externally frozen attempt; time in tenths of a second | 439 | physical latency; the external controller's re-freeze limit; fencing and CAS races during the cut | | `GCClockSkew.tla` | `GCClockSkew_safe.cfg` | G=3, S=1, Q=1, Born=10, MaxT=17 | 96 | the root scan, copy settlement and higher-epoch guards; clocks outside the configured skew | | `GCDeleteProgress.tla` | `GCDeleteProgress_safe.cfg` | three ordered candidates, the first DELETE rejected | 4 | root and epoch admission; elapsed coverage; persistence | +| `HeadReopenBelt.tla` | `cfg/HeadReopenBelt.cfg` | one HEAD, one old server-held CAS, one reopen, one new acknowledged image, one nonempty base | 12 | storage I/O and durability; WAL recovery; an empty root with a delayed first exclusive create | | `PlainDetach.tla` | `cfg/PlainDetach.cfg` | up to two I/O readers, frontend close | 10 | HEAD publication; authority; physical I/O; wall-clock bounds; failure settlement | +| `PlainSealReplay.tla` | `cfg/PlainSealReplay.cfg` | one seal request, process memory kept or lost, seven read observations of HEAD | 42 | the controller's pending record and its boot refusal; the hand-over; RPC delivery | | `RestoreIndependence.tla` | `cfg/RestoreIndependence_nc_safe_n4.cfg` | no-claim design, the largest of the safe configurations (`n4`) | 2,752,518 | guest writes to the target while it takes ownership; GC that takes time; more than one restore per snapshot | | `ScopedMaintenanceGC.tla` | `ScopedMaintenanceGC_safe.cfg` | three keys across two volumes, one foreign-only root | 10 | the complete mark and the grace timing (in `RetentionGCTiming`); density and metadata-RPC cost | +| `SealedReopen.tla` | `cfg/SealedReopen.cfg` | one sealed HEAD of the same holder and epoch, one reopen | 2 | the hand-over and its liveness; RPC delivery; any other holder or epoch | | `WorkspaceMoveOutcome.tla` | `cfg/WorkspaceMoveOutcome.cfg` | one volume, seven error causes, one failed write, one reply | 135 | authority changes; journal durability; lease safety; RPC delivery; reload | ## Specs at a glance