From 63dcb49a5401b7dbbab478a0b387e3d107a9350f Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 16 Nov 2026 16:16:02 -0800 Subject: [PATCH] docs: delete outdated docs, simplify the rest, and split the design reference with diagrams - Delete the stale roadmap and eight wiki planning pages (git history keeps them); move the only unique content (Phase 166-170 write-path experiment results) into docs/releases/nvme-tcp-supported-lab.md. - Simplify the remaining user docs; duplicated non-claim lists link to docs/kubernetes-status.md; lab host names and local paths are removed. - Split docs/design/block-design.md into core, agent-workspace-design.md and kubernetes-block-design.md; add four SVG diagrams of the on-disk and remote structures and new mermaid diagrams. - mkdocs.yml nav and README links follow the new layout; the two gate scripts drop the one check each that read a deleted file. Docs only; no product code changes. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/README.md | 16 +- seaweed-block/docs/assets/smartwal-layout.svg | 93 ++ seaweed-block/docs/assets/walstore-layout.svg | 177 +++ .../docs/assets/walstore-lsn-watermarks.svg | 72 ++ .../docs/assets/workspace-cut-manifest.svg | 171 +++ .../docs/design/agent-workspace-design.md | 325 +++++ seaweed-block/docs/design/block-design.md | 263 +--- .../docs/design/kubernetes-block-design.md | 315 +++++ seaweed-block/docs/developer-architecture.md | 2 +- seaweed-block/docs/fsync-latency.md | 11 +- seaweed-block/docs/kubernetes-app-demo.md | 9 +- seaweed-block/docs/kubernetes-status.md | 3 - seaweed-block/docs/overview.md | 54 +- seaweed-block/docs/quickstart-kubernetes.md | 36 +- seaweed-block/docs/releases/README.md | 5 + .../releases/nvme-rdma-capability-boundary.md | 12 +- .../docs/releases/nvme-tcp-supported-lab.md | 29 +- seaweed-block/docs/roadmap.md | 1148 ----------------- seaweed-block/docs/user-capabilities.md | 60 +- seaweed-block/docs/wiki/code-map.md | 29 +- seaweed-block/docs/wiki/coverage-matrix.md | 81 -- .../deep-dives/gpudirect-cufile-cuobject.md | 281 ---- seaweed-block/docs/wiki/developer-guide.md | 186 --- seaweed-block/docs/wiki/historical-sources.md | 90 -- seaweed-block/docs/wiki/index.md | 113 +- seaweed-block/docs/wiki/phase-map.md | 116 -- seaweed-block/docs/wiki/phase-recap.md | 144 --- seaweed-block/docs/wiki/protocol-catalog.md | 77 -- seaweed-block/docs/wiki/state-machines.md | 7 +- seaweed-block/docs/wiki/topic-inventory.md | 142 -- seaweed-block/docs/workspace-measurements.md | 5 +- seaweed-block/mkdocs.yml | 31 +- ...e157-nvme-rdma-capability-boundary-gate.sh | 1 - ...un-phase87-failback-docs-alignment-gate.sh | 1 - 34 files changed, 1434 insertions(+), 2671 deletions(-) create mode 100644 seaweed-block/docs/assets/smartwal-layout.svg create mode 100644 seaweed-block/docs/assets/walstore-layout.svg create mode 100644 seaweed-block/docs/assets/walstore-lsn-watermarks.svg create mode 100644 seaweed-block/docs/assets/workspace-cut-manifest.svg create mode 100644 seaweed-block/docs/design/agent-workspace-design.md create mode 100644 seaweed-block/docs/design/kubernetes-block-design.md delete mode 100644 seaweed-block/docs/roadmap.md delete mode 100644 seaweed-block/docs/wiki/coverage-matrix.md delete mode 100644 seaweed-block/docs/wiki/deep-dives/gpudirect-cufile-cuobject.md delete mode 100644 seaweed-block/docs/wiki/developer-guide.md delete mode 100644 seaweed-block/docs/wiki/historical-sources.md delete mode 100644 seaweed-block/docs/wiki/phase-map.md delete mode 100644 seaweed-block/docs/wiki/phase-recap.md delete mode 100644 seaweed-block/docs/wiki/protocol-catalog.md delete mode 100644 seaweed-block/docs/wiki/topic-inventory.md diff --git a/seaweed-block/README.md b/seaweed-block/README.md index fd94cb34b8..17b80fd8b3 100644 --- a/seaweed-block/README.md +++ b/seaweed-block/README.md @@ -31,9 +31,11 @@ current: a deposed primary refuses I/O once it observes the new assignment or a fence, or once its workspace lease expires. That is a local admission rule, not an instant global revocation. Separately, every remote HEAD publish is a conditional update on `{gen, epoch}`, so the store refuses a stale holder's -publish even before that holder notices it was replaced. The [design -reference](docs/design/block-design.md) covers each part, its invariants, the -tests behind them and the known issues. +publish even before that holder notices it was replaced. The design is in +three documents: the [core design](docs/design/block-design.md), the [agent +workspace design](docs/design/agent-workspace-design.md) and the [Kubernetes +block design](docs/design/kubernetes-block-design.md). Each covers its parts, +their invariants, the tests behind them and the known issues. ## Highlights @@ -195,7 +197,7 @@ run evidence: [release notes](docs/releases/README.md). - **CI** runs `go build`, `go vet` and `go test -short` on every pull request and push to `main` ([workflow](.github/workflows/test.yml)). Crash, mutation, real-SeaweedFS and binary tests are described in the - [design reference, Part 3](docs/design/block-design.md#part-3-verification-lessons-known-issues), + [core design, Part 2](docs/design/block-design.md#part-2-verification-lessons-known-issues), with the known issues. - **Formal models**: [TLA+ specifications](docs/spec/README.md) of the protocols where a bug would lose data. Counterexamples became fixes and @@ -206,12 +208,14 @@ run evidence: [release notes](docs/releases/README.md). ## Documentation -- Design: [design reference](docs/design/block-design.md), [TLA+ specifications](docs/spec/README.md), +- Design: [core](docs/design/block-design.md), [agent workspace](docs/design/agent-workspace-design.md), + [Kubernetes block](docs/design/kubernetes-block-design.md), [TLA+ specifications](docs/spec/README.md), [workspace measurements](docs/workspace-measurements.md) - Operations: [standalone deployment](docs/standalone-deployment.md), [Kubernetes quickstart](docs/quickstart-kubernetes.md), [user capabilities](docs/user-capabilities.md) - Claims: [Kubernetes status](docs/kubernetes-status.md), [release notes](docs/releases/README.md), - [NVMe/TCP supported-lab claim](docs/releases/nvme-tcp-supported-lab.md), [roadmap](docs/roadmap.md) + [NVMe/TCP supported-lab claim](docs/releases/nvme-tcp-supported-lab.md), + [known issues and work in progress](docs/design/block-design.md#24-known-issues-and-work-in-progress) - Engineering references, not release-claim sources: [architecture](docs/architecture.md), [developer architecture](docs/developer-architecture.md), [runtime state machines](docs/runtime-state-machines.md) diff --git a/seaweed-block/docs/assets/smartwal-layout.svg b/seaweed-block/docs/assets/smartwal-layout.svg new file mode 100644 index 0000000000..65abf6b8f6 --- /dev/null +++ b/seaweed-block/docs/assets/smartwal-layout.svg @@ -0,0 +1,93 @@ + + smartwal (experimental) layout: data written in place in the extent, plus a ring of 32-byte metadata records indexed by LSN modulo capacity + + + + + + + + + + + + smartwal · in-place data plus a metadata record ring + + EXPERIMENTAL + Not a default and no chunk snapshots · core/storage/smartwal/store.go (Store), record.go, ring.go, recovery.go + + + File regions (not to scale) + + header + 4 KiB · offset 0 + + record ring + slots × 32 bytes (65,536 slots = 2 MiB default) + + extent: the data, written in place + numBlocks × BlockSize · reads always come from here + + + + One ring slot: a 32-byte record (record.go encode) + + + + + + + + + mg + fl + rsv + LBA u32 + LSN u64 + reserved2 (zero) + dataCRC32 + recCRC32 + 0 + 1 + 2 + 4 + 8 + 16 + 24 + 28 + 32 + mg = magic 0xAC (anything else is an empty slot) · fl = flags (write 0x01, trim 0x02, barrier 0x04) · rsv = reserved · little-endian + dataCRC32 = CRC32 of the data block in the extent · recCRC32 = CRC32 of bytes 0..27 · slot index = LSN mod capacity (ring.go appendAt) + + + Write order (Store.writeAt) and Sync + + 1 · read the old block + kept in memory for rollback + + 2 · pwrite data in place + the extent slot of the LBA + + 3 · append the record + slot = LSN mod capacity; on failure + the old block is written back + + 4 · Sync: one fsync + covers data and record together + (same file) + + + + + + + + Known crash window between 2 and 3 + extent newer than the ring: CRC check fails, volume does not open + + + + Recovery (runRecoveryCounting): + scan every slot (a bad recCRC is skipped and counted as a warning) → highest LSN per LBA → + check the extent block against dataCRC32; a mismatch fails closed as a WAL integrity failure → frontier = highest verified LSN + diff --git a/seaweed-block/docs/assets/walstore-layout.svg b/seaweed-block/docs/assets/walstore-layout.svg new file mode 100644 index 0000000000..abb4167c3e --- /dev/null +++ b/seaweed-block/docs/assets/walstore-layout.svg @@ -0,0 +1,177 @@ + + walstore on-disk layout: a 4 KiB superblock, a circular WAL and a block-indexed extent in one file, the WAL record format, and the write, Sync, flush, checkpoint and recovery path + + + + + + + + + + + + + + + + walstore · on-disk layout and write path + One preallocated file per volume replica · core/storage/walstore.go (WALStore), superblock.go, wal_entry.go, wal_writer.go + + + File regions (not to scale) + + superblock + 4 KiB · offset 0 + + circular WAL + WALSize bytes (64 MiB default) · offset 4096 + + extent + VolumeSize bytes · offset 4096 + WALSize · one slot per block (LBA × BlockSize) + + + + Superblock fields + Magic "SWBK" · Version 2 · Flags · UUID + VolumeSize · ExtentSize · BlockSize (4096) + WALOffset (must be 4096) · WALSize + WALHead · WALTail + monotonic logical byte cursors; position = cursor mod WALSize + WALCheckpointLSN + highest LSN durably in the extent; replay skips LSN ≤ it + CreatedAt · ImplKind (1 = walstore) · ImplVersion + + 96 bytes encoded, rest of the 4 KiB is zero (writeTo). + Wrong magic, version or ImplKind refuses to open. + No checksum over the superblock (known issue). + + + + WAL region, physical view [0, WALSize) + + + + r9 + + r10 + + reusable (released) + + r4 + + r5 + + r6 + + r7 + + r8 + + padding + + + + head + + durable tail + + + wrap: a record that does not fit at the end is preceded by padding and starts at 0 + + Retained window [tail, head): records recovery may still need. Space used = head − durable tail. + Bytes are reused only after an fsynced superblock releases them (walWriter.spaceUsed, tailPersisted). + + + One WAL record (wal_entry.go) + + LSN 8 + + Reserved 8 + + Type 1 + + Flags 1 + + LBA 8 + + Length 4 + + data (Length bytes) + + CRC32 4 + + EntrySize 4 + prefix: 30 bytes + trailer: 8 bytes + Fixed overhead 38 bytes; CRC32 covers prefix and data; a one-block (4 KiB) write is a 4,134-byte record. + + + Write path (Sync is the only durability point) + + + 1 · Write + assign the next LSN + pwrite the record at head + dirty map: LBA → record, LSN + not durable yet + WALStore.Write + + + 2 · Sync (FLUSH / FUA) + group commit: one fsync + for many callers (wait ≤ 1 ms + or 64 waiters); no extent copy + returns the synced frontier + WALStore.Sync, group_commit.go + + + 3 · Flusher (100 ms) + snapshot the whole dirty map + copy each still-current record + to its extent slot; one fsync + extent now holds the batch + flusher.flushOnceInternal + + + 4 · Checkpoint + bitmap / metadata hooks first + superblock: CheckpointLSN, + head, released tail; fsync + replay now starts later + persistCheckpointReleasing + + + 5 · Reuse + writer may overwrite the + released WAL bytes; flushed + entries compare-and-deleted + a newer write survives + tailPersisted, compareAndDelete + + + + + + + Read: a dirty-map hit reads the WAL record, otherwise the extent slot (WALStore.Read). A failed fsync is sticky: no later Sync, write or checkpoint until reopen. + + + + Recovery after a crash (recovery.go recoverWAL, WALStore.Recover) + + read the superblock + persisted tail, head, checkpoint + + scan [tail, head) + stop at a bad CRC or a truncated record + + skip LSN ≤ checkpoint + replay the rest by LSN (last writer wins) + + persist rebuilt bounds + before the first append; bad bounds fail closed + + + + diff --git a/seaweed-block/docs/assets/walstore-lsn-watermarks.svg b/seaweed-block/docs/assets/walstore-lsn-watermarks.svg new file mode 100644 index 0000000000..a57212ebe6 --- /dev/null +++ b/seaweed-block/docs/assets/walstore-lsn-watermarks.svg @@ -0,0 +1,72 @@ + + walstore LSN watermarks on a timeline: checkpoint, synced frontier and newest written LSN, and which writes survive a crash + + + + + + + + + + + + + walstore · LSN watermarks and what survives a crash + Frontiers kept by WALStore (core/storage/walstore.go); on disk are only the WAL bytes and the superblock's WALCheckpointLSN + + + + checkpointLSN + + syncedLSN + + walHead (newest written) + + + + 1 … checkpoint + in the extent + + checkpoint … synced + in the WAL, fsynced + + synced … head + pwrite only + + LSN + nextLSN → + + + + flush in progress + extent written and fsynced, + checkpoint not yet persisted + + + + HEAD RemoteLSN (workspace only) + the last cut H: always a synced LSN, + independent of the checkpoint + + + + After a crash (process kill or power cut without media corruption) + + + ≤ checkpoint: survives. + Read from the extent; recovery skips these records; their WAL bytes are released once that superblock is fsynced. + + + ≤ synced: survives. + Acknowledged by Sync. Recovery replays them from the WAL into the dirty map by LSN (last writer wins). + + + > synced: may be lost. + Never acknowledged. A record that reached the disk intact is replayed; a torn one ends the scan of its range. + + + A crash during a flush replays the same records again from the WAL: the tail was not released, so nothing is lost and replay is idempotent. + The checkpoint is not ordered against syncedLSN: the flusher's own fsync also makes the records it copies durable (flusher.flushOnceInternal). + After recovery, the synced frontier is the higher of the checkpoint and the highest valid record LSN; new writes continue above it (WALStore.Recover). + diff --git a/seaweed-block/docs/assets/workspace-cut-manifest.svg b/seaweed-block/docs/assets/workspace-cut-manifest.svg new file mode 100644 index 0000000000..add9ee2986 --- /dev/null +++ b/seaweed-block/docs/assets/workspace-cut-manifest.svg @@ -0,0 +1,171 @@ + + Agent workspace cut: the dirty chunk bitmap over 4 MiB chunk slots, the quiesced cut, immutable chunk uploads, the two-level manifest and the HEAD conditional update; a snapshot or fork copies only the HEAD root + + + + + + + + + + + + + + + Agent workspace · dirty bitmap → cut → chunks → HEAD + core/storage/chunk_layer.go (captureLocked), chunk_seam.go · core/frontend/chunkstore/manifest.go, chunk_remote.go, catalog.go + + + + Local volume (walstore), split into chunk slots + chunk = 1024 blocks × 4 KiB = 4 MiB (defaultChunkBlocks × BlockSize) · chunk i holds blocks [1024·i, 1024·i + 1024) + + + c0 + c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + … + c256 + … + + + 010 + 011 + 001 + 0 + + chunk slots + dirty bitmap + An extent write marks its chunk in memory, O(1), no I/O (OnExtentWrite). Dirty set = persisted bitmap ∪ chunks of WAL entries above the checkpoint. + The bitmap is made durable before the checkpoint passes those WAL entries (BeforeCheckpointAdvance). It may over-report, never under-report. + + + The cut (captureLocked) + + + 1 · quiesce + capture barrier (exclusive), + Sync: H = synced LSN + large dirty sets pre-copy first + + + 2 · copy + read dirty chunks into + buffers, SHA-256; release + pause = Sync + this copy + + + 3 · upload changed + intent first, then new keys + (8 parallel by default) + same hash or all-zero: no upload + + + 4 · segments + rewrite only segments with + changed chunks (intent first) + unchanged segments keep keys + + + 5 · CAS HEAD + on {gen, epoch}; then drop + intents, reset the bitmap + post-cut dirt stays set + + + + + + + + + + SeaweedFS: filer entries and immutable chunk objects + + + + v1/HEAD (root, format 2) + Gen g+1 · Epoch e · Holder A + RemoteLSN H · State active + ChunkBytes 4 MiB · ManifestChunkCount + Segments: + 0 → @v1/seg/n2 (new) + 1 → @v1/seg/n1 (unchanged) + {gen, epoch, holder} mirrored in + extended attributes for the CAS + + + + segment 0: @v1/seg/n2 (new) + chunks 0–255 (1 GiB = 256 chunks) + 1 → k1', 4 → k4', 5 → k5', 8 → k8' (new keys) + others → previous keys · absent index = zeros + + + segment 1: @v1/seg/n1 (unchanged) + chunks 256–511 + each entry: chunk key + SHA-256 + same object, same key as before the cut + + + + + + Chunk objects (write-once) + + k1' + k4' + k5' + k8' + k1 + k4 + k2 + … + + this cut + earlier cuts + key: chunks/e<epoch>/c<idx>/<nonce>-<seq> (newKey) + keys/<key> binds it to a needle; never rebound + old versions stay while a snapshot or fork + reaches them; GC reclaims the rest + + + + + + Snapshot: v1/snaps/s1/<attempt> + an exclusive create holding a copy + of the HEAD root; name claimed in + snapnames/s1 first + no segment or chunk is copied + + + Fork: v2/VOLUME + v2/HEAD + VOLUME: origin fork, parent v1@s1 + HEAD: Gen 1 · Epoch 0 · no holder + RemoteLSN and Segments copied from s1: + 0 → @v1/seg/n2 · 1 → @v1/seg/n1 + owner-qualified keys: v2 shares v1's objects + + + fork + + + copy of root + + + Other filer entries per volume + intents/<id>: keys about to be published; + GC roots until the CAS outcome is known + VOLUME: identity, geometry, lineage; + write-once + snapnames/<name>: name records + diff --git a/seaweed-block/docs/design/agent-workspace-design.md b/seaweed-block/docs/design/agent-workspace-design.md new file mode 100644 index 0000000000..ca073faaa3 --- /dev/null +++ b/seaweed-block/docs/design/agent-workspace-design.md @@ -0,0 +1,325 @@ +# Agent workspace disks: design + +This document describes the Agent Block line: a local-speed block device for an agent sandbox or microVM, whose durability comes from snapshots in SeaweedFS. It covers how the code works, the invariants, where each is enforced, the tests, and what is not done yet. + +**Status: proof of concept.** The chunk path (`blockvolume --durable-impl=walstore-chunk`) is not yet a default, a release claim or a production path. + +The three design documents: + +| Document | Covers | +|---|---| +| [Core design](block-design.md) | The shared core: frontends and the Backend contract, walstore, smartwal (experimental), durability and `Sync`, authority and epochs, the replication engine, recovery; verification, lessons and known issues across the codebase | +| Agent workspace design (this document) | Agent workspace disks: one local replica per workspace, cuts to SeaweedFS, snapshots, forks, GC, host moves | +| [Kubernetes block design](kubernetes-block-design.md) | Kubernetes block volumes (alpha): CSI, Helm, RF=2/3 replication and failover, multipath, readiness | + +Conventions are those of the core document: code references name a file and a function, not a line number; test references name the test function and its file; "Model-checked" means the protocol was specified in TLA+ and checked exhaustively with TLC at small scale (the specifications are in [`docs/spec/`](../spec/README.md)). + +## Contents + +- [1. Composition](#1-composition) +- [2. One replica; durability from cuts](#2-one-replica-durability-from-cuts) +- [3. Remote layout](#3-remote-layout) +- [4. Dirty tracking](#4-dirty-tracking) +- [5. The cut](#5-the-cut) +- [6. Snapshots, forks, retention, GC, volume delete](#6-snapshots-forks-retention-gc-volume-delete) +- [7. Lease, takeover and host moves](#7-lease-takeover-and-host-moves) +- [8. Security model](#8-security-model) +- [9. Invariants](#9-invariants) +- [10. Tests](#10-tests) +- [11. Review directions](#11-review-directions) +- [12. Lessons](#12-lessons) +- [13. Measured results](#13-measured-results) +- [14. Known gaps](#14-known-gaps) + +--- + +## 1. Composition + +

+ Agent workspace disks: an agent microVM on host A writes to a blockvolume with a local WAL; cuts upload changed chunks to SeaweedFS, where a HEAD root, snapshots and forks share immutable chunks; another host can take over the HEAD +

+ +An agent workspace disk is a composition of core parts plus a SeaweedFS chunk backend: + +```mermaid +flowchart LR + G["guest microVM"] -->|"virtio-blk"| F["frontend: ublk or NVMe/TCP loopback"] + F -->|"Read / Write / Sync"| W["local engine: walstore"] + W -->|"dirty chunk bitmap"| C["chunk layer: quiesced cut"] + C -->|"upload changed 4 MiB chunks, intents first"| S[("SeaweedFS: immutable chunks + segment manifests")] + C -->|"CAS HEAD on {gen, epoch}"| H["HEAD root (about 2 KB)"] + H -->|"snapshot / fork = copy the root"| H2["snapshot or forked volume"] + M["blockmaster: epoch + lease"] -->|"higher epoch"| T["another host: claim HEAD, lazy-load chunks"] + T --> H +``` + +- **Frontend:** the same ublk and NVMe/TCP code as the Kubernetes line ([core §1.1](block-design.md#11-frontends-and-the-backend-contract)). NVMe/TCP binds to loopback (`cmd/blockvolume/main.go` `enforceFrontendLoopbackBind`); ublk serves `/dev/ublkbN` on the same host (`--ublk-device`). The guest sees a plain virtio block device that the hypervisor attaches. +- **Local engine:** walstore only (`--durable-impl=walstore-chunk`, [core §1.2](block-design.md#12-walstore-wal-plus-extent)). `Sync` still means local durability; nothing on the write path waits for the network. smartwal does not support the chunk layer. +- **Chunk layer:** `core/storage/chunk_layer.go` (`chunkLayerImpl`), attached under the walstore flusher; the contract is the header of `core/storage/chunk_seam.go`. +- **Backend:** SeaweedFS. Chunk bytes live in volume servers; HEAD, key bindings, intents, volume records and snapshot records live in the filer (`core/frontend/chunkstore`). +- **Authority:** blockmaster mints the epoch and grants a workspace lease ([core §1.5](block-design.md#15-authority-blockmaster-assignments-epochs-leases); §7 below). + +## 2. One replica; durability from cuts + +A workspace runs one replica (RF=1). It does not use the replication engine of the Kubernetes line; durability against host loss comes from cuts published to SeaweedFS. + +| Event | What survives | +|---|---| +| Guest `fsync` returns | the write is in the local WAL (a covering `Sync`) | +| Process crash or host restart | every synced write; local recovery replays the WAL ([core §1.2](block-design.md#12-walstore-wal-plus-extent)) | +| Permanent host loss | the image at the last successful cut (HEAD `RemoteLSN`); writes after it are lost | +| Clean move (Detach) | everything written before Detach: guest I/O is stopped, then Detach publishes a final cut before the host releases the volume | + +- **When cuts happen.** At semantic points chosen by the integrator (after an agent step, before a risky command, on detach) and on explicit request (`sw-block ops chunk cut`). The periodic timer is off by default (`cmd/blockvolume/chunk_remote.go` `defaultChunkCaptureInterval = 0`); an operator may set one as a host-loss safety net. `--chunk-dirty-threshold` (default 512 chunks, 2 GiB) only bounds how much one cut copies under its barrier; it never triggers a cut. +- **So the default RPO is unbounded** until the integrator cuts. This is a design choice for workspaces, where a cut at a semantic point is more useful than a timer. +- Multi-replica workspaces combined with chunk snapshots are not supported. + +## 3. Remote layout + +

+ Dirty bitmap over 4 MiB chunk slots; the five steps of a cut; in SeaweedFS the HEAD root lists segment references, each segment lists chunk keys with SHA-256, chunk objects are write-once; a snapshot copies the root and a fork writes a new VOLUME and a HEAD at gen 1, epoch 0 with the same segment references +

+ +Per volume, under the chunk base directory in the filer (`core/frontend/chunkstore/catalog.go` header, `chunk_remote.go` header): + +| Entry | Content | Written | +|---|---|---| +| `HEAD` | the published state as JSON; `{gen, epoch, holder}` mirrored in extended attributes (`swb.gen`, `swb.epoch`, `swb.holder`) | conditional update on `{gen, epoch}`; the first HEAD is an exclusive create | +| `keys/` | one entry per chunk key, naming the needle (fid) that holds the bytes | exclusive create; never rebound | +| `intents/` | the keys a holder is about to publish (GC roots); id `-<16 hex>` | created before the first upload, removed after the outcome is known | +| `VOLUME` | identity, geometry (`NumBlocks`, `BlockSize`, `ChunkBlocks`), origin (create or fork) and parent | write-once | +| `snapnames/`, `snaps//` | snapshot name records and snapshots | exclusive create | + +**HEAD** (`core/storage/chunk_seam.go` `chunkHead`): `Gen`, `Epoch`, `Holder`, `RemoteLSN`, `Segments` (or a flat `Chunks` map in format 1), `ChunkBytes`, `ManifestChunkCount`, `State` (`active`, `detached`, `deleting`, `purging`, `deleted`, `aborted`), `DetachedBy`. A chunk index missing from the manifest reads as zeros. + +**Chunks.** A chunk is `ChunkBlocks × BlockSize` = 1024 × 4 KiB = 4 MiB (`core/frontend/durable/provider.go` `defaultChunkBlocks`; `core/storage/store.go` `DefaultBlockSize`). Chunk keys are `chunks/e/c/-` (`chunk_layer.go` `newKey`) and are never reused. `ChunkRemote.Put` refuses a key that exists or once existed, and refuses an owner-qualified key: a volume only writes its own keys (`chunk_remote.go` `putObject`). + +**Two-level manifest** (format 2, `core/frontend/chunkstore/manifest.go`): +- The HEAD root lists segment references `{Key, SHA256, Owner, Count}` keyed by segment number (`core/storage/chunk_manifest.go` `ChunkSegment`). +- Each segment covers a fixed 1 GiB of logical range (`manifestSegmentBytes`, a format constant), so 256 chunks of 4 MiB. It holds a sparse map of chunk index to `{Key, SHA256}`. +- Segment keys are owner-qualified, `@/seg/` (`ChunkRemote.PrepareManifest`). A cut rewrites only segments whose chunks changed; unchanged segments keep their exact keys. +- Each HEAD is logically full: restore never chains deltas. +- A flat (format 1) HEAD is upgraded at its next cut ([chunk manifests](../chunk-manifests.md)). In a host-side proxy, the root of a 10 GiB volume shrank from 261,531 bytes (flat) to 2,172 bytes (two-level) (§13). + +## 4. Dirty tracking + +- **In memory:** every extent write marks its chunk dirty, in O(1), with no I/O and no remote call (`chunk_layer.go` `OnExtentWrite`; the set is `chunkLayerImpl.dirty`). A rebuild BASE write sets a constant-time all-dirty flag instead. +- **Off the write path:** WAL entries carry their LBA, so the dirty set is the persisted bitmap plus the chunks of WAL entries above the checkpoint (`walChunks`). The bitmap is made durable before the checkpoint advances past those entries (`BeforeCheckpointAdvance`, called from walstore `persistCheckpointReleasing`); an error refuses the advance and the WAL keeps the entries. +- **On disk:** `FileChunkBitmapStore` (`core/storage/chunk_bitmap_file.go`) is one state file (a header `{BaseLSN, HeadGen, Epoch, Base}` and the dirty chunk indices, with a SHA-256 over the body) replaced atomically on every change, plus an append-only delta log with one record per closed HEAD period. +- **Reset:** only after a successful HEAD CAS at cut H. The new header is `{BaseLSN: H, HeadGen, Epoch}`; chunks dirtied after the cut stay set (`chunkBitmapStore.Reset`, stillDirty). +- **Over-report, never under-report.** A lost bitmap, or a header that does not match HEAD `{RemoteLSN, Gen, Epoch}`, falls back to a background per-chunk SHA-256 comparison against HEAD; cuts are refused until it finishes (`startReconcile`, `errChunkReconciling`). + +## 5. The cut + +`chunkLayerImpl.captureLocked` (`core/storage/chunk_layer.go`; contract in the `chunk_seam.go` header). A checkpoint is not a prefix image (the extent can already hold blocks newer than the checkpoint), so a cut is a quiesced point, not a checkpoint boundary. + +1. **Admit:** refuse when closed, fenced, detached, during a base install, or when `CaptureAllowed` fails (healthy primary, unchanged lineage, valid lease). +2. **Pre-copy:** while more than `BarrierBound` chunks would be copied under the barrier (`--chunk-dirty-threshold`, default 512), stage up to that many per round outside the barrier, for at most `chunkStageRounds` (3) rounds (`stage`). A staged chunk with new bytes is uploaded under a fresh key named by an intent written first. +3. **Quiesce:** take the capture barrier (walstore `captureMu`) exclusively, then `Sync`. H is the synced LSN; no data newer than H exists in the WAL or the extent. +4. **Copy:** read every candidate chunk through the normal read path into immutable buffers and hash them; release the barrier. The pause is `Sync` plus this copy. A staged copy is reused only if its chunk was not written since and HEAD is unchanged. +5. **LSN guard:** if H is below HEAD's `RemoteLSN`, refuse (`lsn_behind`). +6. **Diff:** upload only chunks whose SHA-256 differs from HEAD; drop all-zero chunks from the map. +7. **Intent first:** write an intent naming every key, then upload in parallel (`UploadConcurrency`, `--chunk-upload-concurrency`, default 8, 1 to 64). +8. **Manifest:** build segments; new segments are also covered by an intent before upload (`PrepareManifest`). +9. **Re-admit** right before the CAS; fence if a superseding holder owns HEAD (`supersededBy`). +10. **CAS** HEAD on `{gen, epoch}` with `RemoteLSN = H`. On success, drop the intents and reset the bitmap, keeping post-cut dirt. +11. **Unknown outcome:** re-read HEAD; never retry blindly. If unresolved, keep the proposal pending and keep the intents. + +`ChunkRemote.CASHead` (`core/frontend/chunkstore/chunk_remote.go`) refuses a lower epoch, any move of a `deleting`, `purging` or `deleted` HEAD, a `{gen, epoch}` mismatch and a lower `RemoteLSN`, then issues the filer's conditional `UpdateEntry` with `expected_extended = {swb.gen, swb.epoch}`. Only a definite refusal is a precondition failure; any other error is an unknown outcome. + +**Reads after a move.** A block absent locally is fetched from the chunk named in HEAD, bounded by `ReadMissTimeout` (default 30 s), and installed only if no newer local version exists; the dirty map is consulted again after the fetch, so a newer local write always wins (`OnReadMiss`; walstore `readFromExtent`). + +## 6. Snapshots, forks, retention, GC, volume delete + +- **Snapshot** (`Catalog.CreateSnapshot`): claim the name with an exclusive name record `{request, attempt}` (a retry gets its own attempt back); check the volume is not being deleted; write an intent with a deadline; re-check the deadline; exclusively create `snaps//` holding a copy of the HEAD root. An unknown outcome keeps the intent; the caller retries with the same request id. +- **Fork** (`Catalog.Fork`): claim the parent snapshot, check the source is not being deleted, write the target `VOLUME` (origin fork), then a HEAD at gen 1, epoch 0, no holder, with the parent's `RemoteLSN` and references. No segment or chunk is copied: the fork's references are owner-qualified, so it reads the parent's objects, and its root alone keeps them live after the parent snapshot is deleted. +- **Retention** (`retention.go`): classes `semantic` and `pinned`; newest N, recent window and log-spaced keeps; a snapshot with a live fork claim is always kept; deletion uses the same conditional mark as `DeleteSnapshot`. +- **GC** (`gc.go` `Collector.run`, operator-driven through `sw-block ops chunk gc`, preview by default; see also `core/frontend/chunkstore/GC.md`): + - roots: every HEAD, every snapshot (including deleting ones), snapshot attempts, live intents, and segment objects; an unreadable segment aborts the mark; + - a capture intent expires only if it is older than the TTL, blockmaster has issued a higher epoch, and the remote HEAD has moved to a higher epoch; copy intents are settled only by a permanent tombstone at their publication target; + - the whole mark must finish within the grace period minus the operation deadline, and the collector requires grace greater than the deadline; + - a binding is deleted only if it is older than the grace period and was unrooted in two marks at least one grace period apart with unchanged binding bytes; + - deletion tombstones the binding (`swb.gc.deleted=1`), deletes the needle, then marks it `done`; bindings are never removed, so a key is never rebound. +- **Volume delete** (`volume_delete.go` `DeleteVolume`): (a) a blockmaster deletion reservation; (b) one HEAD write to `deleting` (refused while HEAD is held); (c) refuse and revert if any snapshot name record exists; (c') commit `deleting → purging` bound to the same incarnation; (e) HEAD becomes `deleted` with no chunks and `VOLUME` is marked deleted. A deleted id is never attached or created again. + +HEAD states: + +```mermaid +stateDiagram-v2 + [*] --> active: initial HEAD (gen 1, epoch 0) or fork HEAD + active --> active: holder's cut CAS (gen+1) + active --> detached: Detach final cut + detached --> active: takeover CAS (higher epoch, new holder) + active --> active: forced takeover (higher epoch) + active --> deleting: delete mark (HEAD not held) + detached --> deleting: delete mark + deleting --> active: snapshots exist, delete reverts + deleting --> detached: snapshots exist, delete reverts + deleting --> purging: commit point (same incarnation) + purging --> deleted: chunks dropped, VOLUME marked deleted + deleted --> [*] + [*] --> aborted: GC tombstones a dead fork's HEAD +``` + +Snapshot name lifecycle: + +```mermaid +stateDiagram-v2 + [*] --> NameHeld: exclusive name record {request, attempt} + NameHeld --> Published: exclusive create snaps/name/attempt + NameHeld --> Aborted: DeleteSnapshot or GC tombstones the attempt path + Published --> Deleting: DeleteSnapshot or retention (no live fork claim) + Deleting --> NameFreed: name record removed + Aborted --> NameFreed: name record removed + NameFreed --> [*] +``` + +The attempt path is never removed, so a late create can never land after a delete. + +## 7. Lease, takeover and host moves + +**Host guard** (`core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard`, enabled with `blockvolume --workspace-lease`; see [workspace lease](../workspace-lease.md)): frontend I/O and cuts are admitted only with a granted, unexpired lease for the exact `{volume, replica, epoch}`. Validity is anchored to the renewal request's start time, and blockmaster's `ValidForNs` already subtracts half the clock-skew bound (`core/host/master/workspace_service.go` `leaseFact`). A late reply cannot extend admission. A fenced guard never reopens. The lease is 30 s (`core/authority/authority.go`, `workspaceTTL`); the skew bound defaults to 20 s (`blockmaster --workspace-max-clock-skew`). + +**CLEAN move:** Detach publishes the final cut with `State = detached` in one CAS → revoke → the host drains frontend, replication and provider and acknowledges the stored detached HEAD generation → blockmaster checks the detached HEAD and the matching acknowledgement → new epoch → the new host claims HEAD. + +**FORCED move:** blockmaster waits until both the stored expiry and its conservative restart deadline plus the full skew bound have passed (`core/authority/workspace.go` `prepareWorkspaceMoveLocked`). The old host's late CAS fails on the epoch; its uploads become orphans for GC. Writes since the old host's last cut are lost. + +**Takeover** (`core/storage/chunk_restore.go` `ClaimChunkHead`, called before the chunk layer attaches in `core/frontend/durable/provider_chunk.go`): read HEAD; fence if HEAD has a higher epoch or another holder at the same epoch; seed the local LSN frontier from HEAD (`PrepareRestore`); CAS HEAD to the new epoch and holder with `State = active`; on an unknown outcome, succeed only if a re-read shows the exact proposal. I/O opens afterwards; blocks load lazily on first read. + +```mermaid +sequenceDiagram + autonumber + participant A as Old holder (host A) + participant M as blockmaster + participant B as New holder (host B) + participant F as Filer HEAD + Note over A,F: HEAD {gen g, epoch e, holder A} + alt CLEAN move + A->>F: Detach: final cut, CAS on {g, e}, State detached + M->>A: revoke + A->>A: drain frontend, replication and provider + A->>M: ack the detached HEAD gen (lease still valid) + M->>M: check detached HEAD and ack, then mint epoch e+1 + else FORCED move (host A lost or partitioned) + A--xM: renewals stop + A->>A: self-fence when ValidForNs runs out + M->>M: wait for expiry, restart deadline and skew bound, then mint epoch e+1 + end + M->>B: assignment at epoch e+1 and a lease + B->>F: GetHead + B->>B: refuse if HEAD epoch is higher, else seed the local frontier from HEAD + B->>F: CASHead expected {current gen, e}, next {epoch e+1, holder B, active} + F-->>B: installed (gen + 1) + B->>B: serve I/O, chunks load lazily on first read + opt late publish from the old holder + A->>F: CASHead expected {g, e} + F-->>A: precondition failed (gen and epoch moved) + A->>A: fence, its uploads are orphans for GC + end +``` + +Lease states: + +```mermaid +stateDiagram-v2 + state "Lease (blockmaster)" as L { + [*] --> Granted: Renew + Granted --> Granted: Renew before expiry + Granted --> Revoking: BeginWorkspaceRevocation + Revoking --> Acked: host acks detached HEAD gen while the lease is valid + Acked --> Moved: CLEAN move + Granted --> Expired: expiry + Expired --> Moved: FORCED move after expiry + skew bound + } +``` + +**Moving back to a host with a surviving local file.** A fresh volume claims HEAD before serving. A non-fresh attach reads HEAD first; if another holder published it, the attach fails closed with `ErrChunkStaleLocalRoot` (`core/frontend/durable/provider_chunk.go`): the volume is not served, and one log line and the status evidence name the local root to remove or quarantine, after which the next attach starts fresh from HEAD (#167). + +## 8. Security model + +What isolates one workspace from another today: + +- **One process per workspace volume.** Each `blockvolume` serves one volume replica from its own local file. +- **Loopback frontends.** NVMe/TCP and iSCSI refuse non-loopback binds unless an explicit `--allow-external-*-bind` flag is set; external iSCSI also requires CHAP (`cmd/blockvolume/main.go` `enforceFrontendLoopbackBind`, `enforceISCSIBindPolicy`). The status endpoint and the `/chunk/*` control routes are loopback-only by default. ublk serves a device node on the same host and needs root. +- **Orchestrator, hypervisor and jailer (outside this repository).** The guest sees only the virtio block device its hypervisor attaches; which device each microVM gets, and the sandboxing of the hypervisor process (for example a jailer with chroot, cgroups and an unprivileged user) are the integrator's configuration. This repository does not ship that integration. +- **Ownership on the remote is a correctness rule, not access control.** A volume writes only its own keys (`ChunkRemote.putObject` refuses owner-qualified keys); a fork reads its parent's objects through owner-qualified keys; every HEAD publish is a CAS on `{gen, epoch}`. These rules stop a stale holder, not a malicious client. + +Not done yet: + +- No authentication on the control plane (blockmaster), the status and chunk control endpoints, the replication channel or the filer client. Anyone who can reach the filer can read or change any volume's entries. **Planned:** mTLS and role checks for destructive operations ([core known issues](block-design.md#24-known-issues-and-work-in-progress)). +- No encryption of chunks in SeaweedFS or of traffic to it. +- The NVMe/TCP H2CData bound check can wrap and panic the process on one malformed PDU; it is reachable from loopback ([core known issues](block-design.md#24-known-issues-and-work-in-progress)). +- ublk at high density: unprivileged per-volume servers need a privileged control broker, which is not done. + +## 9. Invariants + +| Invariant | Enforced in | Test | Model-checked | +|---|---|---|---| +| Only one holder can publish HEAD: every publish is a CAS on `{gen, epoch}`; a superseded holder fences itself | `chunk_remote.go` `CASHead`; `chunk_layer.go` `supersededBy` | `TestChunkRemote_TakeoverRefusesOldHolder` (`core/frontend/chunkstore/chunk_remote_test.go`); `TestChunkLayer_C6_FencedOnTakeover` (`core/storage/chunk_layer_contract_test.go`) | yes | +| HEAD epoch and `RemoteLSN` never decrease | `CASHead`; `captureLocked` LSN guard | `TestChunkRemote_EpochNeverLowers` (`core/frontend/chunkstore/chunk_remote_test.go`); `TestChunkCut_RemoteLSNNeverDecreases` (`core/storage/chunk_layer_lsn_order_test.go`); `TestHEADRefusesLSNRegressionAcrossMove` (`core/frontend/chunkstore/restore_lsn_test.go`) | yes | +| HEAD is exactly the image at a quiesced cut H, and H is a synced LSN | `captureLocked` | `TestChunkLayer_C1_HeadIsQuiescedCutImage`, `TestChunkLayer_C3_EveryHeadIsExactUnderConcurrentWrites` (`core/storage/chunk_layer_contract_test.go`) | yes | +| The dirty bitmap never under-reports; it is durable before the checkpoint passes its entries and reset only after a successful CAS | `BeforeCheckpointAdvance`; `finishCut` | `TestChunkLayer_C11_BitmapPersistedBeforeWALRecycle`, `TestChunkLayer_C11_RolloverKeepsPostCutDirt` (`core/storage/chunk_layer_c11_test.go`) | yes | +| Chunks and segments are write-once; keys are never rebound | `chunk_remote.go` `putObject`; `gc.go` tombstones | `TestChunkRemote_KeysAreWriteOnce` (`core/frontend/chunkstore/chunk_remote_test.go`); `TestChunkLayer_C5_ChunksAreImmutable` (`core/storage/chunk_layer_contract_test.go`) | yes | +| Intents are durable before the first upload and removed only after the CAS outcome is known | `captureLocked` | `TestChunkIntent_WrittenBeforeFirstUploadAndDeletedAfterCAS`, `TestChunkIntent_UncertainCASKeepsIntentUntilSettled` (`core/storage/chunk_layer_intent_test.go`) | yes | +| GC never deletes a chunk reachable from a HEAD, snapshot, attempt or intent, and deletes only after two graced marks | `gc.go` `Collector.run` | `TestGC_UnreachableRequiresTwoMarksAndUploadAge`, `TestGC_StalledCutRemainsReadableAfterTwoMarks`, `TestGC_IntentExpiryNeedsTTLAuthorityAndRemoteFence` (`core/frontend/chunkstore/gc_test.go`) | yes | +| A published snapshot is removed only by `DeleteSnapshot` or retention for the planned attempt, never while a fork claim is live | `catalog.go` `DeleteSnapshot`; `retention.go` `markDeleting` | `TestCatalog_DeleteMarksThenIdempotent` (`core/frontend/chunkstore/catalog_test.go`); `TestCatalog_ClaimBetweenCheckAndMarkWins` (`core/frontend/chunkstore/retention_review_test.go`) | yes | +| Volume delete commits only with no snapshot name records; past the commit point it is irreversible | `volume_delete.go` | `TestCatalog_DeleteVolumeRefusesWhileSnapshotsExist`, `TestCatalog_ConcurrentDeleteCannotRollBackACommittedOne`, `TestCatalog_DeletedHeadCannotBeRevivedByAClaim` (`core/frontend/chunkstore/volume_delete_test.go`) | yes | +| Volume ids are never reused | `core/host/master/services.go`; `catalog.go` `EnsureVolume` | `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | yes | +| A host serves and cuts only under a valid lease; a fenced guard never reopens | `workspace_lease.go` | `TestWorkspaceLeaseExpiryFencesWithoutTimerAndCannotReopen`, `TestWorkspaceDelayedRenewalCannotUndoExpiry` (`core/host/volume/workspace_lease_test.go`); `TestWorkspaceHostRequiresLeaseBeforeFrontendAndCut` (`core/host/volume/workspace_runtime_test.go`) | yes | +| A forced move waits for expiry plus the skew bound; a clean move needs a detached HEAD and a matching acknowledgement; a new host claims HEAD before serving | `workspace.go` `prepareWorkspaceMoveLocked`; `provider_chunk.go` | `TestWorkspaceSkewSeparatesOldServingFromForcedGrant` (`core/host/master/workspace_skew_test.go`); `TestWorkspaceCleanMoveNeedsDetachedHEADAndRevocationAck` (`core/authority/workspace_test.go`); `TestWorkspaceMoveRestoresLazilyAndFencesOldHost` (`core/host/master/workspace_restore_test.go`) | yes | + +## 10. Tests + +- Contract tests C1–C11 for the chunk layer (`core/storage/chunk_layer_contract_test.go`, `chunk_layer_c11_test.go`), with a fake remote that can hold a CAS or create and complete it after the caller gave up. +- Real SeaweedFS (build tag `chunkstore_integration`, real master, volume and filer processes): `TestIntegration_ChunkRemoteContract` (`core/frontend/chunkstore/chunk_remote_integration_test.go`), `TestIntegration_DeleteVolumeThenGC` (`core/frontend/chunkstore/volume_delete_integration_test.go`), `TestIntegration_RetainAndUsage` (`core/frontend/chunkstore/retention_integration_test.go`), `TestIntegration_OpsChunkGC_RealMasterAndStore` (`cmd/sw-block/chunk_gc_integration_test.go`), and `TestIntegration_ConcurrentHEADCASRealFiler` (`core/frontend/chunkstore/concurrent_cas_integration_test.go`), which holds concurrent HEAD updates until every client has read, then lets the real filer's `expected_extended` check decide. +- Binary tests with real `blockvolume` and `blockmaster`, for example `TestBinaryWorkspaceLeaseOptInOwnsCLEANShutdown` (`cmd/blockvolume/workspace_lease_binary_test.go`). +- Two-host lab lifecycle with Firecracker microVMs (§13). +- Not covered: several filers sharing a store, a filer that predates `expected_extended`, and power loss on the local host (see [core §2.2](block-design.md#22-what-is-not-covered)). + +## 11. Review directions + +- **Every remote write must be either write-once or a CAS.** Name the precondition and say what happens on an unknown outcome. +- **Every new publication must be covered by an intent** before its first object is written, and the intent must survive an unknown outcome. +- **Nothing may move a HEAD in `deleting`, `purging` or `deleted`** except the delete's own transitions. +- **Anything that changes GC roots must also change `Collector.run`.** That includes a new manifest level or a new kind of reference. +- **Attach paths must decide** whether the local file or HEAD is authoritative, and claim HEAD when it is not this holder's. +- **Cut cost:** check barrier pause, RAM held, and amplification for any change to chunk size, staging or copy. + +## 12. Lessons + +- **#152, found before merge.** Model checking reproduced four concurrency issues from a review round, each in seconds: + - a snapshot back-out marked another caller's published snapshot as deleting; + - a claim check suffered an ABA across delete incarnations; + - a lost CLI token left a reservation held; + - CreateVolume released a lock before the create. + - **Fix:** incarnation-bound commit, no snapshot cascade, request ids, and lock scope. + - **Guards:** `TestCatalog_ConcurrentDeleteCannotRollBackACommittedOne` and `TestCatalog_DeleteVolumeLosesToAnAttachAtTheMark`. +- **#157, clock skew (fixed in #158).** A forced move had no clock-skew margin, so with a slow host clock the old and new hosts could serve together. HEAD stayed safe. + - **Fix:** blockmaster waits for expiry plus the skew bound; hosts fence half a bound early. + - **Guard:** `TestWorkspaceSkewSeparatesOldServingFromForcedGrant`. +- **#102 review, read-miss race.** A read miss that waited on a remote fetch could return a stale zero block while a WAL write landed. + - **Fix:** re-resolve through the dirty map after the fetch. + - **Guard:** `TestChunkLayer_WALOnlyOverlapReadNeverReturnsUntouchedZero` (`core/storage/chunk_layer_races_test.go`). +- **#118 review, Recover and the barrier.** Recover must take the capture barrier. Otherwise a record at H+1 could be copied into a HEAD labelled H. + - **Guard:** `TestChunkCut_RecoverWaitsForTheCaptureBarrier` (`core/storage/chunk_layer_precopy_test.go`). + +## 13. Measured results + +Measurements, not SLOs; each is the median of 3 runs. [Workspace measurements](../workspace-measurements.md) has every number and how it was measured. + +- **Workloads** (Firecracker microVMs, 4 vCPU, 4 GiB, one bare-metal host, NVMe/TCP loopback): metadata-heavy agent workloads (`npm ci`, `git clone`, untar, `find` + `stat`) ran at local-disk speed. The cost is `fsync` latency: 2,000 × create + write + `fsync` took 14.33 s against 6.09 s on a local disk, about 7 ms against 3 ms per `fsync`. Reducing it is in progress; the per-stage histograms are described in [fsync latency](../fsync-latency.md). +- **Snapshot and fork** (host-side proxy, a 10 GiB volume of 2,560 chunks, no network latency, guest `fsync` or block frontend): HEAD root 2,172 bytes; snapshot 0.18 ms; fork 0.29 ms (flat manifest: 261,531 bytes, 5.79 ms, 10.67 ms). +- **Cut upload** (same proxy): 64 dirty chunks (256 MiB) in 624 ms with one upload at a time, 434 ms with 8 in parallel. +- **Two-host lifecycle** (Firecracker VMs, SeaweedFS chunk backend): create, write, two snapshots, fork, clean move, stale-holder replay refused, delete, GC; 35 of 35 checks passed, GC reclaimed 38 of 38 candidates and every reclaimed chunk returned 404. + +## 14. Known gaps + +These are tracked for fixes. Gaps that apply to the whole codebase (authentication, formats, power-loss testing) are in the [core known issues](block-design.md#24-known-issues-and-work-in-progress). + +- **Moving back to a host with a surviving local file** fails closed with `ErrChunkStaleLocalRoot` (§7). **Follow-up:** recreate the local root from HEAD automatically instead of refusing. +- **Default RPO is unbounded.** No automatic cut is enabled by default (§2). +- **The master is a single point of failure.** A master outage longer than the lease stops I/O on every workspace, and recovery is a forced move. +- **Cut cost.** The barrier pause includes copying every non-staged candidate chunk (up to the dirty threshold, 512 chunks by default), held in RAM until upload. A 4 KiB write re-uploads its 4 MiB chunk, and a read miss after a move fetches the whole chunk with no request coalescing. +- **GC is manual.** Needles uploaded without a persisted key binding are never reclaimed. An intent stamped by a host clock running ahead of the GC runner fails the whole pass (liveness, not safety). +- **Filer conditional update: multi-filer and old-filer cases.** Reading the open-source SeaweedFS filer: `UpdateEntry` takes an exclusive lock on the path before it validates `expected_extended`. The concurrent case against one pinned filer is tested (#163). Not tested: several filers sharing a store, and a filer that predates the field (there is no capability probe). **Planned:** a multi-filer test and a probe. +- **No multi-replica workspaces with chunk snapshots**, and no crash-restart recovery of a ublk server (a crashed server fails closed). diff --git a/seaweed-block/docs/design/block-design.md b/seaweed-block/docs/design/block-design.md index 75d0f5cb89..21912bbebc 100644 --- a/seaweed-block/docs/design/block-design.md +++ b/seaweed-block/docs/design/block-design.md @@ -1,10 +1,14 @@ -# Seaweed Block design +# Seaweed Block design: core -This is the design reference for Seaweed Block. It describes how the code works, which invariants it maintains, where each invariant is enforced, which tests cover it, and what is not covered yet. +This is the design reference for the core of Seaweed Block. It describes how the code works, which invariants it maintains, where each invariant is enforced, which tests cover it, and what is not covered yet. -- **Part 1** describes the core block service: frontends, storage engines, durability, the authority model, replication for the Kubernetes line, and recovery. -- **Part 2** describes agent workspace disks. They are a composition of core parts plus a SeaweedFS chunk backend. -- **Part 3** covers verification across the codebase, lessons learned, and known issues. +The design is split into three documents: this shared core and one document per product line. + +| Document | Covers | +|---|---| +| Core design (this document) | **Part 1**, the core block service: frontends and the Backend contract, walstore, smartwal (experimental), durability and `Sync`, the authority model, the replication engine, recovery. **Part 2**, verification, lessons and known issues across the codebase. | +| [Agent workspace design](agent-workspace-design.md) | Agent workspace disks (proof of concept): a frontend, local walstore and a SeaweedFS chunk backend; one replica per workspace with durability from snapshots; the cut, the two-level manifest, snapshots, forks, GC, leases and host moves; the security model. | +| [Kubernetes block design](kubernetes-block-design.md) | Kubernetes block volumes (alpha): the CSI driver, Helm and the operator controllers, RF=2/3 replication and failover from the product view, iSCSI ALUA, multipath and NVMe/TCP ANA, authority promotion, readiness, the operation layer. | Code references name a file and a function, not a line number, so they stay valid as the code changes. Test references name the test function and its file. "Model-checked" means the protocol was specified in TLA+ and checked exhaustively with TLC at small scale. The specifications are in [`docs/spec/`](../spec/README.md); Go regression tests are the in-repo evidence for every counterexample found that way. @@ -16,10 +20,13 @@ Code references name a file and a function, not a line number, so they stay vali - [1.3 smartwal: in-place writes plus a metadata ring](#13-smartwal-in-place-writes-plus-a-metadata-ring) - [1.4 Durability and Sync](#14-durability-and-sync) - [1.5 Authority: blockmaster, assignments, epochs, leases](#15-authority-blockmaster-assignments-epochs-leases) - - [1.6 Replication and failover (Kubernetes line)](#16-replication-and-failover-kubernetes-line) + - [1.6 Replication and failover](#16-replication-and-failover) - [1.7 Recovery and typed fail-closed reasons](#17-recovery-and-typed-fail-closed-reasons) -- [Part 2. Agent workspace disks](#part-2-agent-workspace-disks) -- [Part 3. Verification, lessons, known issues](#part-3-verification-lessons-known-issues) +- [Part 2. Verification, lessons, known issues](#part-2-verification-lessons-known-issues) + - [2.1 Test methods](#21-test-methods) + - [2.2 What is not covered](#22-what-is-not-covered) + - [2.3 Lessons learned](#23-lessons-learned) + - [2.4 Known issues and work in progress](#24-known-issues-and-work-in-progress) --- @@ -91,6 +98,12 @@ stateDiagram-v2 - A WAL record is a 30-byte header (LSN, reserved, type, flags, LBA, length), the data, and an 8-byte trailer (CRC32, record size) (`core/storage/wal_entry.go`). A record that does not fit at the end of the region is preceded by a padding record and starts at offset 0 (`core/storage/wal_writer.go` `walWriter.append`). - An in-memory dirty map maps each LBA to its newest WAL record and LSN (`core/storage/dirty_map.go`). +

+ walstore file: a 4 KiB superblock, a circular WAL of 64 MiB by default, and the extent; the superblock fields; the WAL ring with head, durable tail and a padding record before the wrap; the record format with a 30-byte prefix and an 8-byte trailer; the five steps Write, Sync, flusher, checkpoint and reuse; and recovery from the superblock +

+ +Numbers in the figure, all from the code: the superblock is 4096 bytes and the WAL starts at offset 4096 (`superblock.go` `superblockSize`, `newSuperblock`, `validate`), and 96 bytes of it are encoded (`superblock.writeTo`); the WAL region is 64 MiB (the `newSuperblock` default, which walstore does not override), and the extent starts at `WALOffset + WALSize` with one slot per block (`walstore.go` `CreateWALStoreWithOptions`, `openInitializedWithMetadata`); a record has a 30-byte prefix and an 8-byte trailer (`wal_entry.go` `walEntryPrefixSize`, `walEntryHeaderSize`); the group committer waits up to 1 ms or 64 waiters (`openInitializedWithMetadata`, `NewGroupCommitter`); the flusher runs every 100 ms (`flusher.go` `newFlusher`). A store may also bind an optional metadata region after the extent through a metadata factory (`block_metadata.go` `bindBlockMetadata`); it is not shown. + **Write.** `WALStore.Write` takes the capture barrier (shared), the lifecycle lock and WAL admission (back-pressure when the WAL is full), assigns the next LSN under `mu`, appends the record with `pwrite` only, updates the dirty map and notifies an attached chunk layer. The write is not durable until a covering `Sync` returns. **Sync.** `WALStore.Sync` records the current head, runs a group-committed `fsync` (`core/storage/group_commit.go`), and returns the new durable frontier. A request whose writes are already covered by a completed physical sync reuses it (`walSyncCovered`, `syncWALBatch`); reuse is disabled when a chunk layer is attached or after replica apply and direct extent writes. @@ -108,9 +121,15 @@ stateDiagram-v2 1. Derive scan ranges from the persisted `[tail, head)`. An empty window (head == tail) is scanned from its own position, not from offset 0. 2. Decode each range until a record fails CRC or is truncated. If a valid record with a higher LSN follows a bad one, record a `wal_hole_suspected` warning (detection only). 3. Skip records at or below the checkpoint. Replay the rest by last writer wins on LSN (`dirtyMap.putAtIfNewer`), not by physical order. -4. Rebuild and validate the retained bounds; an inconsistent order or size is a `WALIntegrityFailure` and the store does not open. +4. Rebuild and validate the retained bounds; an inconsistent order or size is a WAL integrity failure (`NewWALIntegrityFailure`) and the store does not open. 5. `Recover` persists rebuilt bounds before any append. +

+ LSN timeline with the checkpoint, the synced frontier and the newest written LSN: writes at or below the checkpoint are in the extent, writes up to the synced frontier are fsynced in the WAL and replayed after a crash, writes above it were never acknowledged and may be lost +

+ +The watermarks are `WALStore.checkpointLSN` (persisted as the superblock's `WALCheckpointLSN`), `syncedLSN` (returned by `Sync`) and `walHead` (the newest written LSN; `nextLSN` is one above it). Only the checkpoint and the WAL bytes are on disk. After a crash, `Recover` sets the synced frontier to the higher of the checkpoint and the highest valid record it replays. + ```mermaid stateDiagram-v2 [*] --> Appended: Write (pwrite, LSN assigned, dirty map) @@ -134,7 +153,7 @@ stateDiagram-v2 | Synced entries above an intentional LSN gap (a rebuild's frontier jump) are kept | `recovery.go` (replay keyed on the checkpoint, not on a contiguous prefix) | `TestWALStoreRecoverKeepsSyncedEntriesAboveAnUnpersistedFrontierJump` (`core/storage/walstore_recovery_frontier_gap_test.go`) | yes | | A failed checkpoint metadata write neither publishes nor recycles | `persistCheckpointReleasing` | `TestFlusherCheckpointMetadataFailureDoesNotPublishOrRecycle` (`core/storage/walstore_checkpoint_safety_test.go`) | — | -**Tests and coverage.** Unit tests with hand-built torn and corrupted bytes; fault seams for append and metadata writes; a Linux SIGKILL crash test over checkpoint windows. Not covered: real power loss (dropped or reordered page-cache writes) at the device level, fuzzing of the recovery scan as a whole (the WAL record decoder is fuzzed, see 3.2), and crash-point enumeration. +**Tests and coverage.** Unit tests with hand-built torn and corrupted bytes; fault seams for append and metadata writes; a Linux SIGKILL crash test over checkpoint windows. Not covered: real power loss (dropped or reordered page-cache writes) at the device level, fuzzing of the recovery scan as a whole (the WAL record decoder is fuzzed, see 2.2), and crash-point enumeration. **Review directions.** - Any change to recovery must say what it does for: a torn tail, a torn record inside the retained window, a wrapped log, an empty window, and a corrupted synced record. @@ -158,9 +177,15 @@ stateDiagram-v2 **Layout.** A 4 KB header, a ring of 32-byte records, and the extent (`core/storage/smartwal/store.go`). A record holds magic, flags, LBA, LSN, the CRC32 of the 4 KB data block, and a record CRC (`core/storage/smartwal/record.go`). Slot = LSN mod capacity (`ring.go` `appendAt`). +

+ smartwal file: a 4 KiB header, a ring of 32-byte records and the extent; the byte layout of one record; the write order read old block, write in place, append record, Sync; the crash window between the in-place write and the append; recovery +

+ +Numbers in the figure: the header is 4096 bytes (`smartwal/superblock.go` `headerSize`); a record is 32 bytes with the byte offsets of `record.go` `encode` (magic 0xAC; flags write 0x01, trim 0x02, barrier 0x04); the default ring has 65,536 slots, 2 MiB (`store.go` `defaultWALSlots`). On a data CRC mismatch, recovery fails closed (`recovery.go` `runRecoveryCounting`); the comment on the `Store` type still says such a record is skipped, which the code no longer does. + **Write, read, Sync.** `Store.writeAt` reads the old block (kept for rollback), writes the new data in place, then appends the record; if the append fails, the old block is written back. Reads always come from the extent. `Sync` is one `fsync` of the file. -**Recovery.** `runRecoveryCounting` (`core/storage/smartwal/recovery.go`): scan slots (record-CRC failures are skipped and counted as a warning), keep the highest-LSN record per LBA, check the extent block against its data CRC, and fail closed with `WALIntegrityFailure` on a mismatch. The frontier is the highest verified LSN. +**Recovery.** `runRecoveryCounting` (`core/storage/smartwal/recovery.go`): scan slots (record-CRC failures are skipped and counted as a warning), keep the highest-LSN record per LBA, check the extent block against its data CRC, and fail closed with a WAL integrity failure (`NewWALIntegrityFailure`) on a mismatch. The frontier is the highest verified LSN. ```mermaid stateDiagram-v2 @@ -184,18 +209,19 @@ stateDiagram-v2 **Review directions.** Any fix must define the order between the record and the data and say how a torn pair is classified (torn and unsynced, versus corrupted and synced). A synced watermark persisted outside the ring is the planned way to tell them apart. -**Lessons.** #51 (open): a CRC-failed committed record is skipped and the volume reports ready. #155 made this visible as a warning; the fix needs the format change described in Part 3. +**Lessons.** #51 (open): a CRC-failed committed record is skipped and the volume reports ready. #155 made this visible as a warning; the fix needs the format change described in Part 2. ## 1.4 Durability and Sync - **One durability point.** A write is durable only when a `Sync` covering its LSN returns nil. `Sync` returns the durable frontier. - **Group commit.** Concurrent `Sync` callers share one `fsync`. The committer waits up to `MaxDelay` (1 ms) or until 64 waiters are queued (`core/storage/group_commit.go` `NewGroupCommitter`, `Run`). - **Deduplication.** A sync that started after the last mutation covers later `Sync` requests with no new writes (`walstore.go` `walSyncCovered`). +- **A failed `fsync` is sticky.** The first failed `fsync` of the store's file (WAL, extent or superblock), or a failed WAL append, latches a typed `io_error` fault; the open store then refuses every later `Sync`, write and checkpoint until it is reopened and recovered (`walstore.go` `noteFsyncFailure`, `noteAppendFailure`, `syncFile`, `stickyIOFault`). Every `fsync` of the file is serialized with that latch, so no publication can pass the check and complete after another path's `fsync` failed (#172). - **With replication.** `ReplicationVolume.Sync` queues a barrier behind every shipped write, runs the local `fsync` in parallel, and applies the volume's durability mode (§1.6). - **Observability.** Per-stage power-of-two histograms (frontend receive, WAL append, group-commit wait, physical sync, return) are exposed under `/status/durable` (`docs/fsync-latency.md`). **Review directions.** -- `fsync` failure semantics: after a failed `fsync`, the kernel may have dropped the dirty pages. A later successful `fsync` does not prove the earlier data is durable (see Known issues). +- `fsync` failure semantics: after a failed `fsync`, the kernel may have dropped the dirty pages, so a later successful `fsync` proves nothing about them. Any new path that `fsync`s the store's file must go through `syncFile`, so the fault latches. - Do not add a stage's p99 to another's; the populations differ. ## 1.5 Authority: blockmaster, assignments, epochs, leases @@ -204,7 +230,7 @@ stateDiagram-v2 - blockmaster is the only component that mints epochs. A reassignment takes the maximum epoch published for the volume plus one (`core/authority/authority.go` `applyWithWorkspaceMove`, `IntentReassign` case). A workspace move reserves its epoch the same way and journals the move before the epoch is published (`core/authority/workspace.go` `prepareWorkspaceMoveLocked`). - If a durable authority write fails, the publisher marks the volume uncertain and refuses further writes for it, so a later write cannot go backwards (`workspace.go` `persistWorkspaceLocked`). - blockvolume never elects itself; it serves under the assignment it was given, and every I/O re-checks that assignment (§1.1). -- Workspace volumes add a lease (§2.5). +- Workspace volumes add a lease ([agent workspace design §7](agent-workspace-design.md#7-lease-takeover-and-host-moves)). ```mermaid stateDiagram-v2 @@ -228,9 +254,9 @@ stateDiagram-v2 **Review directions.** Any new way to publish an assignment must go through the publisher's epoch rule; nothing else may construct an epoch. The control plane has no authentication today (see Known issues), so every destructive RPC is reachable by anyone who can reach the port. -## 1.6 Replication and failover (Kubernetes line) +## 1.6 Replication and failover -Agent workspaces do not use this path (they run RF=1); Kubernetes volumes use RF=2 or RF=3. +This section is the replication engine as a core component. Kubernetes volumes use it when their StorageClass sets `replicationFactor` to 2 or 3 (the default is 1); agent workspaces do not use it (they run RF=1). The product view (StorageClass and Helm settings, failure detection, the promotion gate, multipath, readiness) is in the [Kubernetes block design](kubernetes-block-design.md). **Shipping.** The primary writes locally first, then ships each write to every replica in LSN order (`core/replication/volume.go` `OnLocalWrite`), through a per-peer FIFO. @@ -254,12 +280,14 @@ stateDiagram-v2 Healthy --> Degraded: barrier or ship failure Degraded --> CatchingUp: gap within the primary's WAL CatchingUp --> Healthy: caught up to the target + CatchingUp --> Degraded: catch-up fails + Degraded --> Healthy: recovers Degraded --> NeedsRebuild: gap beyond WAL retention or retries exhausted CatchingUp --> NeedsRebuild: WAL recycled - NeedsRebuild --> Healthy: dual-lane rebuild completes and acks durably + NeedsRebuild --> [*]: terminal for this peer ``` -(Peer states are in `core/replication/peer.go` `ReplicaState`.) +(Peer states and allowed transitions are in `core/replication/peer.go` `ReplicaState`, `replicaStateTransitionAllowed`. `NeedsRebuild` is terminal in this state machine; the rebuild itself runs as a separate dual-lane session, and the Kubernetes line drives it through an opt-in operator path, see the [Kubernetes block design](kubernetes-block-design.md#4-replication-and-failover).) **Invariants.** @@ -302,185 +330,9 @@ The reason is an unhealthy, not-eligible fact; blockmaster does not promote or s --- -# Part 2. Agent workspace disks +# Part 2. Verification, lessons, known issues -An agent workspace disk is a composition of core parts: - -```mermaid -flowchart LR - G["guest microVM"] -->|"virtio-blk"| F["frontend: NVMe/TCP loopback or ublk (1.1)"] - F -->|"Read / Write / Sync"| W["local engine: walstore (1.2)"] - W -->|"dirty chunk bitmap"| C["chunk layer: quiesced cut"] - C -->|"upload changed 4 MiB chunks, intents first"| S[("SeaweedFS: immutable chunks + segment manifests")] - C -->|"CAS HEAD on {gen, epoch}"| H["HEAD root (about 2 KB)"] - H -->|"snapshot / fork = copy the root"| H2["snapshot or forked volume"] - M["blockmaster: epoch + lease (1.5)"] -->|"higher epoch"| T["another host: claim HEAD, lazy-load chunks"] - T --> H -``` - -- **Frontend:** the same NVMe/TCP and ublk code as the Kubernetes line, bound to loopback. -- **Local engine:** walstore only (`--durable-impl=walstore-chunk`). `Sync` still means local durability; nothing on the write path waits for the network. -- **Backend:** SeaweedFS. Chunks live in volume servers; HEAD, key bindings, intents and snapshot records live in the filer. -- **Single replica by design.** Durability against host loss comes from cuts to SeaweedFS. A host restart loses nothing (local WAL); a permanent host loss loses the writes since the last cut. -- **Host moves** reuse the epoch from §1.5: the new host claims HEAD with a higher epoch. - -## 2.1 Remote layout - -Per volume, in the filer (`core/frontend/chunkstore/catalog.go` header, `chunk_remote.go` header): -- `HEAD`: the published state as JSON, with `{gen, epoch, holder}` mirrored in extended attributes for the conditional update. -- `keys/`: one write-once entry per chunk key, naming the needle that holds the bytes. -- `intents/`: live publication intents (GC roots). -- `VOLUME`: identity, geometry, origin (create or fork) and parent; write-once. -- `snapnames/`: name records; `snaps//`: snapshots. - -HEAD fields: `Gen`, `Epoch`, `Holder`, `RemoteLSN`, chunk or segment references, `State`, `DetachedBy` (`core/storage/chunk_seam.go` `chunkHead`). A chunk index missing from HEAD reads as zeros. A chunk is 4 MiB (1024 blocks of 4 KiB). Chunk keys are `chunks/e/c/-` and are never reused (`chunk_layer.go` `newKey`). - -**Two-level manifest.** The HEAD root lists segment references, not chunks. Each segment covers 1 GiB of logical range and lists that range's chunk references with SHA-256 (`core/frontend/chunkstore/manifest.go`). Unchanged segments keep their keys. A flat (format 1) HEAD is upgraded at its next cut (`docs/chunk-manifests.md`). - -## 2.2 Dirty tracking (bitmap) - -- Every extent write marks its chunk dirty in memory, in O(1), with no I/O (`chunk_layer.go` `OnExtentWrite`). -- The dirty set is the persisted bitmap plus the chunks of WAL entries above the checkpoint, so the bitmap is off the write path. It is made durable before the checkpoint advances (`BeforeCheckpointAdvance`, called from `persistCheckpointReleasing`). -- The bitmap may over-report, never under-report. A lost bitmap, or a header that does not match HEAD, falls back to a background per-chunk SHA-256 comparison; cuts are refused until it finishes (`startReconcile`, `errChunkReconciling`). - -## 2.3 The cut - -`chunkLayerImpl.captureLocked` (`core/storage/chunk_layer.go`; contract in the `chunk_seam.go` header): -1. **Admit:** refuse when closed, fenced, detached, during a base install, or when `CaptureAllowed` fails (healthy primary, unchanged lineage, valid lease). -2. **Pre-copy:** if many chunks are dirty, stage them outside the barrier in rounds. -3. **Quiesce:** take the capture barrier exclusively, `Sync`; H is the synced LSN. -4. **Copy:** read every candidate chunk through the normal read path into immutable buffers and hash them; release the barrier. A staged copy is reused only if its chunk was not written since and HEAD is unchanged. -5. **LSN guard:** if H is below HEAD's `RemoteLSN`, refuse (`lsn_behind`). -6. **Diff:** upload only chunks whose SHA-256 differs from HEAD; drop all-zero chunks from the map. -7. **Intent first:** write an intent naming every key, then upload in parallel (default 8). -8. **Manifest:** build segments; new segments are also covered by an intent before upload. -9. **Re-admit** right before the CAS; fence if a superseding holder owns HEAD. -10. **CAS** HEAD on `{gen, epoch}`. On success, drop the intents and reset the bitmap, keeping post-cut dirt. -11. **Unknown outcome:** re-read HEAD; never retry blindly. If unresolved, keep the proposal pending and keep the intents. - -`ChunkRemote.CASHead` (`core/frontend/chunkstore/chunk_remote.go`) refuses a lower epoch, any move of a deleting, purging or deleted HEAD, a `{gen, epoch}` mismatch and a lower `RemoteLSN`, then issues the filer's conditional `UpdateEntry` with `expected_extended = {swb.gen, swb.epoch}` (the first HEAD is an exclusive create). Only a definite refusal is a precondition failure; any other error is an unknown outcome. - -## 2.4 Snapshots, forks, retention, GC, volume delete - -- **Snapshot** (`Catalog.CreateSnapshot`): claim the name with an exclusive name record `{request, attempt}` (a retry gets its own attempt back); check the volume is not being deleted; write an intent with a deadline; re-check the deadline; exclusively create `snaps//` holding a copy of the HEAD root. An unknown outcome keeps the intent; the caller retries with the same request id. -- **Fork** (`Catalog.Fork`): claim the parent snapshot, check the source is not being deleted, write the target `VOLUME` (origin fork), then a HEAD at gen 1, epoch 0, no holder, with the parent's `RemoteLSN` and references. No chunk is copied. -- **Retention** (`retention.go`): classes `semantic` and `pinned`; newest N, recent window and log-spaced keeps; a snapshot with a live fork claim is always kept; deletion uses the same conditional mark as `DeleteSnapshot`. -- **GC** (`gc.go` `Collector.run`, operator-driven through `sw-block ops chunk gc`, preview by default): - - roots: every HEAD, every snapshot (including deleting ones), snapshot attempts, live intents, and segment objects; an unreadable segment aborts the mark; - - a capture intent expires only if it is older than the TTL, blockmaster has issued a higher epoch, and the remote HEAD has moved to a higher epoch; copy intents are settled only by a permanent tombstone at their publication target; - - the whole mark must finish within the grace period minus the operation deadline, and the collector requires grace greater than the deadline; - - a binding is deleted only if it is older than the grace period and was unrooted in two marks at least one grace period apart with unchanged binding bytes; - - deletion tombstones the binding (`swb.gc.deleted=1`), deletes the needle, then marks it `done`; bindings are never removed, so a key is never rebound. -- **Volume delete** (`volume_delete.go` `DeleteVolume`): (a) a blockmaster deletion reservation; (b) one HEAD write to `deleting` (refused while HEAD is held); (c) refuse and revert if any snapshot name record exists; (c') commit `deleting → purging` bound to the same incarnation; (e) HEAD becomes `deleted` with no chunks and `VOLUME` is marked deleted. A deleted id is never attached or created again. - -## 2.5 Lease, takeover and host moves - -**Host guard** (`core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard`): frontend I/O and cuts are admitted only with a granted, unexpired lease for the exact `{volume, replica, epoch}`. Validity is anchored to the renewal request's start time, and blockmaster's `ValidForNs` already subtracts half the clock-skew bound (`core/host/master/workspace_service.go` `leaseFact`). A late reply cannot extend admission. A fenced guard never reopens. - -**CLEAN move:** Detach publishes the final cut with `State = detached` in one CAS → revoke → the host drains frontend, replication and provider and acknowledges the stored detached HEAD generation → blockmaster checks the detached HEAD and the matching acknowledgement → new epoch → the new host claims HEAD. - -**FORCED move:** blockmaster waits until both the stored expiry and its conservative restart deadline plus the full skew bound have passed (`core/authority/workspace.go` `prepareWorkspaceMoveLocked`); the default bound is 20 s against a 30 s lease. The old host's late CAS fails on the epoch; its uploads become orphans for GC. Writes since the old host's last cut are lost. - -**Takeover** (`core/storage/chunk_restore.go` `ClaimChunkHead`, called before the chunk layer attaches in `core/frontend/durable/provider_chunk.go`): read HEAD; fence if HEAD has a higher epoch or another holder at the same epoch; seed the local LSN frontier from HEAD; CAS HEAD to the new epoch and holder; on an unknown outcome, succeed only if a re-read shows the exact proposal. I/O opens afterwards; blocks load lazily on first read. - -```mermaid -stateDiagram-v2 - [*] --> active: initial HEAD (gen 1, epoch 0) or fork HEAD - active --> active: holder's cut CAS (gen+1) - active --> detached: Detach final cut - detached --> active: takeover CAS (higher epoch, new holder) - active --> active: forced takeover (higher epoch) - active --> deleting: delete mark (HEAD not held) - detached --> deleting: delete mark - deleting --> active: snapshots exist, delete reverts - deleting --> detached: snapshots exist, delete reverts - deleting --> purging: commit point (same incarnation) - purging --> deleted: chunks dropped, VOLUME marked deleted - deleted --> [*] - [*] --> aborted: GC tombstones a dead fork's HEAD -``` - -```mermaid -stateDiagram-v2 - state "Lease (blockmaster)" as L { - [*] --> Granted: Renew - Granted --> Granted: Renew before expiry - Granted --> Revoking: BeginWorkspaceRevocation - Revoking --> Acked: host acks detached HEAD gen while the lease is valid - Acked --> Moved: CLEAN move - Granted --> Expired: expiry - Expired --> Moved: FORCED move after expiry + skew bound - } -``` - -```mermaid -stateDiagram-v2 - [*] --> NameHeld: exclusive name record {request, attempt} - NameHeld --> Published: exclusive create snaps/name/attempt - NameHeld --> Aborted: DeleteSnapshot or GC tombstones the attempt path - Published --> Deleting: DeleteSnapshot or retention (no live fork claim) - Deleting --> NameFreed: name record removed - Aborted --> NameFreed: name record removed - NameFreed --> [*] -``` - -The attempt path is never removed, so a late create can never land after a delete. - -## 2.6 Workspace invariants - -| Invariant | Enforced in | Test | Model-checked | -|---|---|---|---| -| Only one holder can publish HEAD: every publish is a CAS on `{gen, epoch}`; a superseded holder fences itself | `chunk_remote.go` `CASHead`; `chunk_layer.go` `supersededBy` | `TestChunkRemote_TakeoverRefusesOldHolder` (`core/frontend/chunkstore/chunk_remote_test.go`); `TestChunkLayer_C6_FencedOnTakeover` (`core/storage/chunk_layer_contract_test.go`) | yes | -| HEAD epoch and `RemoteLSN` never decrease | `CASHead`; `captureLocked` LSN guard | `TestChunkRemote_EpochNeverLowers` (`core/frontend/chunkstore/chunk_remote_test.go`); `TestChunkCut_RemoteLSNNeverDecreases` (`core/storage/chunk_layer_lsn_order_test.go`); `TestHEADRefusesLSNRegressionAcrossMove` (`core/frontend/chunkstore/restore_lsn_test.go`) | yes | -| HEAD is exactly the image at a quiesced cut H, and H is a synced LSN | `captureLocked` | `TestChunkLayer_C1_HeadIsQuiescedCutImage`, `TestChunkLayer_C3_EveryHeadIsExactUnderConcurrentWrites` (`core/storage/chunk_layer_contract_test.go`) | yes | -| The dirty bitmap never under-reports; it is durable before the checkpoint passes its entries and reset only after a successful CAS | `BeforeCheckpointAdvance`; `finishCut` | `TestChunkLayer_C11_BitmapPersistedBeforeWALRecycle`, `TestChunkLayer_C11_RolloverKeepsPostCutDirt` (`core/storage/chunk_layer_c11_test.go`) | yes | -| Chunks and segments are write-once; keys are never rebound | `chunk_remote.go` `putObject`; `gc.go` tombstones | `TestChunkRemote_KeysAreWriteOnce` (`core/frontend/chunkstore/chunk_remote_test.go`); `TestChunkLayer_C5_ChunksAreImmutable` (`core/storage/chunk_layer_contract_test.go`) | yes | -| Intents are durable before the first upload and removed only after the CAS outcome is known | `captureLocked` | `TestChunkIntent_WrittenBeforeFirstUploadAndDeletedAfterCAS`, `TestChunkIntent_UncertainCASKeepsIntentUntilSettled` (`core/storage/chunk_layer_intent_test.go`) | yes | -| GC never deletes a chunk reachable from a HEAD, snapshot, attempt or intent, and deletes only after two graced marks | `gc.go` `Collector.run` | `TestGC_UnreachableRequiresTwoMarksAndUploadAge`, `TestGC_StalledCutRemainsReadableAfterTwoMarks`, `TestGC_IntentExpiryNeedsTTLAuthorityAndRemoteFence` (`core/frontend/chunkstore/gc_test.go`) | yes | -| A published snapshot is removed only by `DeleteSnapshot` or retention for the planned attempt, never while a fork claim is live | `catalog.go` `DeleteSnapshot`; `retention.go` `markDeleting` | `TestCatalog_DeleteMarksThenIdempotent` (`core/frontend/chunkstore/catalog_test.go`); `TestCatalog_ClaimBetweenCheckAndMarkWins` (`core/frontend/chunkstore/retention_review_test.go`) | yes | -| Volume delete commits only with no snapshot name records; past the commit point it is irreversible | `volume_delete.go` | `TestCatalog_DeleteVolumeRefusesWhileSnapshotsExist`, `TestCatalog_ConcurrentDeleteCannotRollBackACommittedOne`, `TestCatalog_DeletedHeadCannotBeRevivedByAClaim` (`core/frontend/chunkstore/volume_delete_test.go`) | yes | -| Volume ids are never reused | `services.go`; `catalog.go` `EnsureVolume` | `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | yes | -| A host serves and cuts only under a valid lease; a fenced guard never reopens | `workspace_lease.go` | `TestWorkspaceLeaseExpiryFencesWithoutTimerAndCannotReopen`, `TestWorkspaceDelayedRenewalCannotUndoExpiry` (`core/host/volume/workspace_lease_test.go`); `TestWorkspaceHostRequiresLeaseBeforeFrontendAndCut` (`core/host/volume/workspace_runtime_test.go`) | yes | -| A forced move waits for expiry plus the skew bound; a clean move needs a detached HEAD and a matching acknowledgement; a new host claims HEAD before serving | `workspace.go` `prepareWorkspaceMoveLocked`; `provider_chunk.go` | `TestWorkspaceSkewSeparatesOldServingFromForcedGrant` (`core/host/master/workspace_skew_test.go`); `TestWorkspaceCleanMoveNeedsDetachedHEADAndRevocationAck` (`core/authority/workspace_test.go`); `TestWorkspaceMoveRestoresLazilyAndFencesOldHost` (`core/host/master/workspace_restore_test.go`) | yes | - -## 2.7 Workspace tests - -- Contract tests C1–C11 for the chunk layer (`core/storage/chunk_layer_contract_test.go`, `chunk_layer_c11_test.go`), with a fake remote that can hold a CAS or create and complete it after the caller gave up. -- Real SeaweedFS (build tag `chunkstore_integration`, real master, volume and filer processes): `TestIntegration_ChunkRemoteContract` (`core/frontend/chunkstore/chunk_remote_integration_test.go`), `TestIntegration_DeleteVolumeThenGC` (`core/frontend/chunkstore/volume_delete_integration_test.go`), `TestIntegration_RetainAndUsage` (`core/frontend/chunkstore/retention_integration_test.go`), and `TestIntegration_OpsChunkGC_RealMasterAndStore` (`cmd/sw-block/chunk_gc_integration_test.go`). -- Two-host lab lifecycle with Firecracker microVMs: create, write, snapshots, fork, clean move, stale-holder replay refused, delete, GC; 35 of 35 checks passed, GC reclaimed 38 of 38 candidates and every reclaimed chunk returned 404 ([workspace measurements](../workspace-measurements.md), "Workspace lifecycle on two hosts"). - -## 2.8 Workspace review directions - -- **Every remote write must be either write-once or a CAS.** Name the precondition and say what happens on an unknown outcome. -- **Every new publication must be covered by an intent** before its first object is written, and the intent must survive an unknown outcome. -- **Nothing may move a HEAD in `deleting`, `purging` or `deleted`** except the delete's own transitions. -- **Anything that changes GC roots must also change `Collector.run`.** That includes a new manifest level or a new kind of reference. -- **Attach paths must decide** whether the local file or HEAD is authoritative, and claim HEAD when it is not this holder's. -- **Cut cost:** check barrier pause, RAM held, and amplification for any change to chunk size, staging or copy. - -## 2.9 Workspace lessons - -- **#152, found before merge.** Model checking reproduced four concurrency issues from a review round, each in seconds: - - a snapshot back-out marked another caller's published snapshot as deleting; - - a claim check suffered an ABA across delete incarnations; - - a lost CLI token left a reservation held; - - CreateVolume released a lock before the create. - - **Fix:** incarnation-bound commit, no snapshot cascade, request ids, and lock scope. - - **Guards:** `TestCatalog_ConcurrentDeleteCannotRollBackACommittedOne` and `TestCatalog_DeleteVolumeLosesToAnAttachAtTheMark`. -- **#157, clock skew (fixed in #158).** A forced move had no clock-skew margin, so with a slow host clock the old and new hosts could serve together. HEAD stayed safe. - - **Fix:** blockmaster waits for expiry plus the skew bound; hosts fence half a bound early. - - **Guard:** `TestWorkspaceSkewSeparatesOldServingFromForcedGrant`. -- **#102 review, read-miss race.** A read miss that waited on a remote fetch could return a stale zero block while a WAL write landed. - - **Fix:** re-resolve through the dirty map after the fetch. - - **Guard:** `TestChunkLayer_WALOnlyOverlapReadNeverReturnsUntouchedZero` (`core/storage/chunk_layer_races_test.go`). -- **#118 review, Recover and the barrier.** Recover must take the capture barrier. Otherwise a record at H+1 could be copied into a HEAD labelled H. - - **Guard:** `TestChunkCut_RecoverWaitsForTheCaptureBarrier` (`core/storage/chunk_layer_precopy_test.go`). - ---- - -# Part 3. Verification, lessons, known issues - -## 3.1 Test methods +## 2.1 Test methods | Layer | Method | Example | |---|---|---| @@ -490,12 +342,12 @@ The attempt path is never removed, so a late create can never land after a delet | Crash tests | Real process SIGKILL, then reopen and compare | `TestWALStoreCheckpointSIGKILLCrashWindows` | | Real-service integration | Build tag `chunkstore_integration`; real SeaweedFS processes | `TestIntegration_DeleteVolumeThenGC` | | Binary tests | Real `blockvolume` and `blockmaster` binaries | `TestBinaryWorkspaceLeaseOptInOwnsCLEANShutdown` (`cmd/blockvolume/workspace_lease_binary_test.go`) | -| Lab packets | Sealed scripts and expected results, run on lab hosts, with automatic teardown that reports a run as not clean if anything is left behind | the two-host lifecycle run (Part 2.7) | +| Lab packets | Sealed scripts and expected results, run on lab hosts, with automatic teardown that reports a run as not clean if anything is left behind | the two-host lifecycle run ([agent workspace design §10](agent-workspace-design.md#10-tests)) | | Scenario runner (soak, chaos) | Test intent lives in YAML in this repo (`testops/`); the open-source `sw-test-runner` handles orchestration, cleanup and artifacts | `testops/README.md`, `testops/scenarios/` | | Model checking | TLA+ specifications for the chunk lifecycle, host takeover, WAL crash recovery, cut capture, the authority store, RF=2 failover and GC timing (the specifications in [`docs/spec/`](../spec/README.md)); each guard has a "remove it and get a counterexample" check | found the #152 issues, the torn-wrap loss (#159/#156) and the clock-skew gap (#158) | | Review | Independent review rounds per PR, each finding turned into a failing test first; an independent repository-wide review | see Known issues | -## 3.2 What is not covered +## 2.2 What is not covered - **CI runs the short suite only.** The test workflow (`.github/workflows/test.yml`) runs `go build`, `go vet` and `go test -short` on pull requests and on `main`. Integration (`chunkstore_integration`), kernel (ublk, NVMe initiator) and lab tests run on development and Linux test hosts. - **Fuzzing covers the on-disk and remote decoders, not the wire parsers.** #175 added Go fuzz targets: `FuzzDecodeWALEntry`, `FuzzWALEntryRoundTrip`, `FuzzDecodeWALEntryFields` (`core/storage/wal_entry_fuzz_test.go`); `FuzzSmartWALDecode`, `FuzzSmartWALRecordFields`, `FuzzSmartWALRoundTrip` (`core/storage/smartwal/record_fuzz_test.go`); `FuzzParallelWALDecodeRecord`, `FuzzParallelWALRecordRoundTrip`, `FuzzParallelWALDecodeHeader` (`core/storage/parallelwal/codec_fuzz_test.go`); `FuzzDecodeManifestJSON`, `FuzzDecodeHeadDocument` (`core/frontend/chunkstore/decode_fuzz_test.go`). Their seed corpora run as ordinary tests; open-ended runs use `go test -fuzz`. The NVMe/TCP and iSCSI PDU parsers are not fuzzed. @@ -504,7 +356,7 @@ The attempt path is never removed, so a late create can never land after a delet - **Environment-sensitive tests:** Linux-only tests, tests that need a SeaweedFS binary, and tests that need the kernel ublk driver. Two frontend process tests are flaky on `main`. - **Model checking is small-scale and design-level:** 2–3 volumes or hosts, 4–6 LSNs, bounded clocks. The specifications are mapped to code by reading, so every counterexample must also become a Go test. -## 3.3 Lessons learned +## 2.3 Lessons learned | Issue | Symptom | Root cause | Fix | Guard test | |---|---|---|---|---| @@ -517,16 +369,14 @@ The attempt path is never removed, so a late create can never land after a delet | torn wrap | Synced writes lost after a plain power cut | the WAL writer reused bytes the persisted superblock still retained, and replay used physical order | #159 (reuse only persisted-released bytes) and #156 (replay by LSN) | `TestWALStoreAppendDuringFlushThenTornWrapKeepsSyncedRecords`, `TestWALStoreRecoverLastWriterWinsAcrossScanOrder` | | #152 | Four concurrency bugs in volume delete, caught before merge | rollback and claim checks not bound to one delete incarnation; a lost token; a lock released early | incarnation-bound commit, no cascade, request ids | `TestCatalog_ConcurrentDeleteCannotRollBackACommittedOne` | | #157 | Old and new hosts could serve together after a forced move | no clock-skew margin between the master's grant and the host's self-fence | #158: skew bound on both sides | `TestWorkspaceSkewSeparatesOldServingFromForcedGrant` | +| #172 | After a failed `fsync`, the next `Sync` retried and acknowledged on success, although the kernel may have dropped the pages | `fsync` errors were not sticky | #172: the first failure latches a terminal fault for the open store | `TestWALStoreWALFsyncFailureIsSticky`, `TestWALStoreQueuedSyncAfterAFailedFsyncIsRefused` | -## 3.4 Known issues and work in progress +## 2.4 Known issues and work in progress -These are tracked for fixes. Most were raised by an independent review of this repository. +These are tracked for fixes. Most were raised by an independent review of this repository. Gaps specific to one product line are in that line's document: [agent workspace known gaps](agent-workspace-design.md#14-known-gaps) and [Kubernetes known gaps](kubernetes-block-design.md#12-known-gaps). -- **Moving a workspace back to a host with a surviving local file.** A fresh volume claims HEAD before serving. Since #167, a non-fresh attach reads HEAD first; if another holder published it, the attach fails closed with `ErrChunkStaleLocalRoot` (`core/frontend/durable/provider_chunk.go`): the volume is not served, and one log line and the status evidence name the local root to remove or quarantine, after which the next attach starts fresh from HEAD. **Follow-up:** recreate the local root from HEAD automatically instead of refusing. -- **`fsync` errors are not sticky.** After a failed physical sync, the next `Sync` retries `fsync` and acknowledges on success (`walstore.go` `syncWALBatch`). On Linux the dirty pages may already be gone. **Planned fix:** a failed `fsync` puts the store into a terminal error state. - **NVMe/TCP H2CData offset overflow.** The `DATAO + length` bound check is done in 32-bit arithmetic and can wrap, so one malformed PDU can panic the process (`core/frontend/nvme/session.go` `recvH2CData`). Reachable from loopback by default. **Planned fix:** 64-bit arithmetic, offset and R2T consistency checks, and bounds on wire-supplied allocations. - **Process notes in source comments.** #162 removed reviewer names and decision timestamps from code comments. A few comments still cite internal review labels (for example "ruling F1") where a neutral design rationale would be clearer. -- **Filer conditional update: multi-filer and old-filer cases.** Reading the open-source SeaweedFS filer: `UpdateEntry` takes an exclusive lock on the path before it validates `expected_extended`. The concurrent case against one pinned filer is tested (#163, see 3.2). Not tested: several filers sharing a store, and a filer that predates the field (there is no capability probe). **Planned:** a multi-filer test and a probe. - **fsync latency (about 7 ms against 3 ms local).** Leads to measure with the `/status/durable` histograms: - the group committer waits a full 1 ms unless 64 waiters are queued, so at queue depth 1 every `fsync` pays at least 1 ms; - the checkpoint superblock `fsync` runs under the exclusive store lock, stalling reads and writes each flush cycle. @@ -534,8 +384,5 @@ These are tracked for fixes. Most were raised by an independent review of this r - **Forged records in user data.** WAL records are not bound to a store incarnation or lap, so bytes inside user data that happen to decode as a valid record could be replayed by the defensive scan. **Planned:** an incarnation nonce and lap in the next format, plus a clean-shutdown marker in the meantime. - **Mid-history WAL corruption only warns** (§1.2 step 2). Fixing it needs the synced watermark in the next format. - **No authentication** on the control plane, the replication channel or the filer client. Frontends bind to loopback by default. **Planned:** mTLS and role checks for destructive operations. -- **Default RPO is unbounded.** No automatic cut is enabled by default; the integrator cuts at semantic points (after an agent step, before a risky command, on detach). -- **The master is a single point of failure.** A master outage longer than the lease stops I/O on every workspace, and recovery is a forced move. -- **Cut cost.** The barrier pause includes copying every non-staged candidate chunk (up to the dirty threshold, 512 chunks by default), held in RAM until upload. A 4 KiB write re-uploads its 4 MiB chunk, and a read miss after a move fetches the whole chunk with no request coalescing. -- **GC is manual.** Needles uploaded without a persisted key binding are never reclaimed. An intent stamped by a host clock running ahead of the GC runner fails the whole pass (liveness, not safety). +- **blockmaster is a single instance.** There is no master high availability. A master outage longer than the lease stops I/O on every workspace, and recovery is then a forced move; Kubernetes volumes cannot fail over while it is down. - **Formats are exact-version.** The superblock, HEAD and segment formats are checked exactly and fail closed; the walstore superblock has no CRC. A format change needs a dual-reader release. diff --git a/seaweed-block/docs/design/kubernetes-block-design.md b/seaweed-block/docs/design/kubernetes-block-design.md new file mode 100644 index 0000000000..da6027ef69 --- /dev/null +++ b/seaweed-block/docs/design/kubernetes-block-design.md @@ -0,0 +1,315 @@ +# Kubernetes block volumes: design + +This document describes the Kubernetes block line: block volumes for app pods through a PVC and the CSI driver, with optional synchronous RF=2 or RF=3 replication. It covers how the code works, the invariants, where each is enforced, the tests, and what is not done yet. + +**Status: alpha.** Supported lab clusters only, not production. What is available, gated, source-gated or planned, and which images go with which path, is maintained in [Kubernetes status](../kubernetes-status.md); this document does not repeat that table. + +The three design documents: + +| Document | Covers | +|---|---| +| [Core design](block-design.md) | The shared core: frontends and the Backend contract, walstore, smartwal (experimental), durability and `Sync`, authority and epochs, the replication engine, recovery; verification, lessons and known issues across the codebase | +| [Agent workspace design](agent-workspace-design.md) | Agent workspace disks (proof of concept): one local replica per workspace, cuts to SeaweedFS, snapshots, forks, GC, host moves | +| Kubernetes block design (this document) | The product view of Kubernetes volumes: CSI, Helm and the operator controllers, replication and failover, multipath, promotion, readiness, the operation layer | + +The replication engine itself (shipping by LSN, barriers, durability modes, replica fencing, catch-up and rebuild decisions) is a core component and is described in [core §1.6](block-design.md#16-replication-and-failover). Conventions are those of the core document: code references name a file and a function; test references name the test function and its file. + +## Contents + +- [1. Topology](#1-topology) +- [2. CSI driver lifecycle](#2-csi-driver-lifecycle) +- [3. Helm chart and operator controllers](#3-helm-chart-and-operator-controllers) +- [4. Replication and failover](#4-replication-and-failover) +- [5. iSCSI ALUA, multipath and NVMe/TCP ANA](#5-iscsi-alua-multipath-and-nvmetcp-ana) +- [6. Authority promotion](#6-authority-promotion) +- [7. Readiness](#7-readiness) +- [8. Operation layer](#8-operation-layer) +- [9. Alpha scope and what is not supported](#9-alpha-scope-and-what-is-not-supported) +- [10. Invariants and tests](#10-invariants-and-tests) +- [11. Review directions](#11-review-directions) +- [12. Known gaps](#12-known-gaps) + +--- + +## 1. Topology + +```mermaid +flowchart TB + subgraph API["Kubernetes API"] + PVC["PVC + StorageClass"] + CRD["SwBlock* custom resources"] + end + subgraph CTRL["CSI controller Deployment"] + CC["csi-provisioner, csi-attacher, blockcsi controller"] + end + OPS["operator controllers: sw-block ops (opt-in)"] + BM["blockmaster, 1 replica: authority, launcher, evidence"] + subgraph VOL["blockvolume Deployments, one per replica, applied by the launcher"] + P["r1: primary"] + R2["r2: replica"] + R3["r3: replica"] + P -->|"ship by LSN, barrier"| R2 + P -->|"ship by LSN, barrier"| R3 + end + subgraph NODE["app node: CSI node DaemonSet"] + CN["kubelet, blockcsi node"] --> INI["iscsiadm + dm-multipath, or nvme connect"] + end + PVC --> CC + CC -->|"gRPC: LifecycleService, EvidenceService"| BM + CC -->|"create SwBlockVolume"| CRD + OPS -->|"gRPC: ClusterEvidenceService"| BM + OPS -->|"status, Events, finalizer"| CRD + BM -->|"apply Deployments, stream AssignmentFact"| VOL + VOL -->|"gRPC: ReportHeartbeat"| BM + CN -->|"gRPC: EvidenceService, current target"| BM + INI -->|"iSCSI or NVMe/TCP: active path"| P + INI -.->|"standby path, multipath opt-in"| R2 +``` + +| Component | What it is | Code | +|---|---|---| +| blockmaster | one Deployment (`replicas: 1`, host network). The only component that mints epochs; it records volume intent, places replicas, publishes assignments, collects heartbeats and serves evidence. All its gRPC services share one listener (Helm port 9333). | `cmd/blockmaster`; `core/host/master/host.go`; services in `core/rpc/proto/control.proto` | +| blockvolume | one Deployment per volume replica, created by blockmaster's launcher, pinned to a node by `kubernetes.io/hostname`. Not a chart workload. | `core/launcher/k8s_renderer.go` `RenderBlockVolumeDeployments`; `k8s_reconciler.go` `ReconcileBlockVolumeDeployments` | +| CSI controller | Deployment: `blockcsi` with csi-provisioner and csi-attacher | `cmd/blockcsi/main.go` `run`; `core/csi/controller.go` | +| CSI node | privileged DaemonSet with node-driver-registrar; loads `iscsi_tcp`, `nvme_tcp`, `dm_multipath`, `scsi_dh_alua` | `core/csi/node.go` | +| Custom resources | group `block.seaweedfs.com`, version `v1alpha1`: `SwBlockCluster`, `SwBlockVolume`, `SwBlockReplicaEligibility`, `SwBlockReplicaRebuild`, `SwBlockReplicaFailback`, `SwBlockFrontendPublication` | `charts/seaweed-block` | +| Operator controllers | opt-in Deployments running `sw-block ops ` (§3) | `cmd/sw-block/main.go`; `core/ops` | + +Wire protocols: blockvolume heartbeats are unary `ObservationService.ReportHeartbeat` calls; assignments arrive on the server stream `AssignmentService.SubscribeAssignments` as `AssignmentFact` (volume, replica, epoch, endpoint version, data and control addresses, peers). Primary to replica traffic is the replication protocol of `core/transport/protocol.go`. Node initiators reach blockvolume over iSCSI (Helm base port 3260) or NVMe/TCP (base port 4420). Every gRPC client dials with insecure credentials (§12). + +## 2. CSI driver lifecycle + +Driver `block.csi.seaweedfs.com`. Identity advertises `CONTROLLER_SERVICE` only (`core/csi/identity.go`). With `--master`, `blockcsi` builds three blockmaster clients: `ControlLifecycleProvisioner` (`LifecycleService`), `ControlStatusLookup` (`EvidenceService`) and `ControlEventReporter` (`ObservationService`) (`core/csi/master_backend.go`). + +```mermaid +sequenceDiagram + autonumber + participant K as kubelet / CSI sidecars + participant C as blockcsi controller + participant N as blockcsi node + participant M as blockmaster + participant V as blockvolume (primary) + K->>C: CreateVolume (StorageClass parameters) + C->>M: LifecycleService.CreateVolume (desired intent only) + C->>C: optional: create or patch the SwBlockVolume object + M->>V: launcher applies Deployments, assignment at epoch 1 + K->>C: ControllerPublishVolume + C->>M: EvidenceService.QueryVolumeStatus + M-->>C: current target: iSCSI portals and IQN, or NVMe addresses and NQN + K->>N: NodeStageVolume (publish context) + N->>M: refresh the target before trusting the context + N->>V: iSCSI login on every portal, or nvme connect per address + N->>N: format if needed, mount, write .transport .volume .target + K->>N: NodePublishVolume (bind mount into the pod) +``` + +- **CreateVolume** (`ControllerServer.CreateVolume`): needs a name and a capacity; accepts Mount or Block access types with `SINGLE_NODE_WRITER` only. StorageClass parameters: `replicationFactor` (default 1), `sw-block.seaweedfs.com/protocol` (`iscsi` by default, or `nvme`; also accepted as `protocol` or `frontendProtocol`, and conflicting values are refused), `sw-block.seaweedfs.com/nvme-transport` (with nvme only, default `tcp`), and `stage2_multipath`. blockmaster records desired intent only; it does not mint an assignment or epoch on this call. The CR is created through `InClusterSwBlockVolumeRegistrar.EnsureVolumeObject`, with a merge-patch on conflict. +- **DeleteVolume** calls `LifecycleService.DeleteVolume`. +- **ControllerPublishVolume** looks up the current target (`LookupPublishTarget`) and returns a publish context with `protocol`, `iscsiAddr(s)`, `iqn`, `nvmeAddr(s)`, `nqn`, `nvmeTransport`, `stage2_multipath` (`backend.go` `publishContext`). With multipath on, it waits up to 90 s for at least two paths. No target is `NotFound`; no frontend fact is `FailedPrecondition`. `ControllerUnpublishVolume` does nothing. +- **NodeStageVolume** (`NodeServer.NodeStageVolume`): `refreshPublishContext` asks blockmaster for the current target first, so a re-stage after failover finds the new primary. iSCSI (`stageISCSI`): discovery, optional CHAP from the node-stage secret, login on every portal, with multipath the dm device by IQN (`linux_util.go` `GetMultipathDeviceByIQN`), then `FormatAndMount` (ext4 by default). NVMe (`stageNVMe`): `nvme connect` per address, wait up to 60 s, mount; NVMe uses kernel native multipath, no dm layer. After a successful stage the node reports `csi_reattach_observed` (`reportCSIReattachObserved`). +- **NodeUnstageVolume** unmounts, then logs out or disconnects; after a plugin restart it uses the files written into the staging directory. +- **NodePublishVolume** bind-mounts the staged path. Capabilities: `STAGE_UNSTAGE_VOLUME` only; `NodeGetInfo` reports topology key `topology.block.csi.seaweedfs.com/node` and 256 volumes per node. + +**Idempotency.** A repeated create with the same spec is a no-op; a different size, RF, protocol or transport is a conflict (`lifecycle.FileStore.CreateVolume`, `ErrVolumeConflict`). Stage onto a mounted path succeeds only for the same volume identity (`validateMountedStagingVolume`); a logged-in session with no staged identity fails closed; a failed mount or device lookup rolls back the login or connect; unstage with nothing mounted still succeeds. + +## 3. Helm chart and operator controllers + +The chart is `charts/seaweed-block`. It deploys blockmaster (with `--launcher-kubernetes-apply`), the CSI controller and node, the `CSIDriver` (`attachRequired: true`), the CRDs, RBAC, a StorageClass (default name `sw-block-dynamic`, `allowVolumeExpansion: false`), and the operator controllers below. `sw-block ops generate-helm-values` writes a values file for a cluster. + +Key values: `blockNodes[]`; `ports.iscsiBase`, `ports.nvmeBase`, `ports.statusBase`; `network.externalISCSI` (requires `chap.enabled`), `network.externalNVMe`, `network.externalStatus`; `stage2Multipath.enabled` (false); `restartPersistence.mode` (ephemeral by default) and `blockmaster.stateHostPath`; `replication.expectedSlotsPerVolume`, `replication.ackProfile`, `compat.launcherReplicationAckFlag` (false); `blockmaster.launcherStatus`. + +**Operator controllers.** Each is a Deployment running `sw-block ops `; every one is off by default (`create: false`), and the executors also default to dry run. + +| Controller | Reconciler | Writes | +|---|---|---| +| operator-status | `OperatorStatusReconciler` | `SwBlockCluster` and `SwBlockVolume` status and Events, from blockmaster `ClusterEvidenceService`. Read, status and events RBAC only. | +| lifecycle-owner | `LifecycleOwnerReconciler` | the protection finalizer on `SwBlockVolume` (§8), boxed in by a ValidatingAdmissionPolicy | +| authority-executor | `AuthorityExecutorReconciler` | eligibility and rebuild status; mutation classes `ack_eligibility` and `rebuild_traffic` | +| rebuild, failback and frontend-publication target owners | (one per kind) | create their own CR kind | +| failback-executor | `FailbackExecutorReconciler` | calls `FailbackService.ExecuteFailback` (gRPC or HTTP) | +| frontend-publication-executor | (executor) | posts to blockmaster `/runtime/frontend-publication`, which checks the authority line and reports the result; it does not change a frontend | + +## 4. Replication and failover + +**Replication factor.** Per volume, from the StorageClass `replicationFactor` (default 1), passed to `LifecycleService.CreateVolume`. On the failover path one RF applies to the whole cluster: blockmaster `--expected-slots-per-volume` (default 3; Helm sets it from `replication.expectedSlotsPerVolume`, falling back to RF), and `core/authority/topology.go` `validateVolumeTopology` rejects a whole observation snapshot if any volume has a different slot count or two slots share a replica or server id (the anti-affinity rule). + +**Durability mode.** Cluster-wide, not per StorageClass. `blockvolume --replication-ack best-effort|sync-quorum|sync-all` selects `replication.DurabilityBestEffort`, `DurabilitySyncQuorum` (a majority, the primary counts) or `DurabilitySyncAll` (`cmd/blockvolume/main.go` `parseReplicationAckProfile`; semantics in [core §1.6](block-design.md#16-replication-and-failover)). The launcher renders it from blockmaster `--launcher-replication-ack`, which the chart passes from `replication.ackProfile` only when `compat.launcherReplicationAckFlag: true`. A default install therefore runs best-effort. + +**Detection.** +- blockvolume heartbeats every 2 s (`--heartbeat-interval`; `core/host/volume/host.go` `buildReport`). Each slot carries reachable, `ready_for_primary`, eligible, withdrawn, incarnation, `unhealthy_reason` and its frontends. +- blockmaster expires an observation after `--freshness-window` (30 s). +- The volume reports `recovery_timeout` after `--recover-timeout` (30 s) and `wal_corrupt`, `io_error` or `role_admission_failed` at once (`core/host/volume/recovery_watchdog.go`; [core §1.7](block-design.md#17-recovery-and-typed-fail-closed-reasons)). +- A restarted primary keeps its authority for one boot-grace period per incarnation, but not after 3 restarts in 10 minutes or an explicit unhealthy report (`core/authority/primary_boot_grace.go`; `topology.go` `PrimaryBootFlapRestarts`, `PrimaryBootFlapWindow`). + +**Who decides.** blockmaster's product loop (`core/host/master/product_loop.go` `RunLifecycleProductTick`) builds a snapshot and submits it to the topology controller. +- RF=2: `TopologyController.decideVolume` (`core/authority/controller.go`) keeps an acceptable primary; otherwise, unless boot grace holds, `chooseFailoverCandidate` picks a ready, eligible, reachable replica and asks for `IntentReassign`. +- RF=3: in addition, `applyPromotionEvidenceGate` probes `/status` and `/status/durable` on every replica (`core/host/master/promotion_probe.go`) and picks a ready candidate with the highest durable LSN, ties broken by the lowest replica id (§6). The probe needs the status endpoints rendered (`--launcher-status`, Helm `blockmaster.launcherStatus`); without it RF=3 promotion is blocked with `no_promotion_ready_candidate`. + +**Epoch and delivery.** `Publisher.applyWithWorkspaceMove` (`core/authority/authority.go`) mints the per-volume maximum epoch plus one for a reassignment, persists it (`AuthorityStore.Put` writes before the in-memory change), then pushes a new `AssignmentFact` to subscribers. The new primary fences its own listener and persists its epoch floor before it serves; replicas raise their floor, so frames from the old primary are refused (`fenceSelfWithPeers`, `ReplicaListener.FenceAsPrimary`, `raiseFloor`; [core §1.6](block-design.md#16-replication-and-failover)). + +```mermaid +sequenceDiagram + autonumber + participant P1 as blockvolume r1 (primary, epoch N) + participant M as blockmaster + participant R2 as blockvolume r2 + participant R3 as blockvolume r3 + participant H as node initiator (multipath) + P1--xM: heartbeats stop, or report unhealthy_reason + Note over M: observation expires after the freshness window + M->>R2: probe /status and /status/durable (RF=3 gate) + M->>R3: probe /status and /status/durable + M->>M: pick the ready candidate with the highest durable LSN + M->>M: Publisher mints epoch N+1 and persists it + M->>R2: AssignmentFact: primary at epoch N+1, peers + R2->>R2: fence own listener, persist epoch floor, open frontend + M->>R3: AssignmentFact: replica at epoch N+1 + R3->>R3: raise epoch floor to N+1 + opt old primary still running + P1->>R3: ship frame at epoch N + R3-->>P1: refused: below the floor + end + H->>R2: path state query: ALUA Active/Optimized or ANA Optimized + H->>R2: I/O moves to the new active path +``` + +**Returned replica.** When an old primary sees a fact that names another primary, it re-admits itself as a supporting replica if it is listed in the peers, with its frontend gated; otherwise it closes ingress (`core/host/volume/subscribe.go` `decodeSelfPeerAssignment`; `fenceSelfWithPeers`). Moving the primary back (failback) and rebuilding a returned replica are explicit, opt-in operator paths: +- **Failback:** a `SwBlockReplicaFailback` CR → `FailbackExecutorReconciler` → `FailbackService.ExecuteFailback` → `core/authority/failback_runtime.go` `FailbackAuthorityRuntime.ExecuteFailback`, which checks the expected current replica and epoch, then reassigns through the publisher. blockmaster serves it only with `--failback-runtime-rpc`. +- **Rebuild:** a `SwBlockReplicaRebuild` CR → `AuthorityExecutorReconciler` → `POST /runtime/rebuild` on the primary's status server (`core/host/volume/status_server.go` `handleRuntimeRebuild`) → a dual-lane rebuild ([core §1.6](block-design.md#16-replication-and-failover)) → eligibility after the rebuild is caught up. The blockvolume flag `--runtime-rebuild-endpoint` is not rendered by the launcher or the chart. + +## 5. iSCSI ALUA, multipath and NVMe/TCP ANA + +The frontends only report path state; they never decide it. The state is a projection of the volume's local view of its assignment (`volume.AdapterProjectionView`). + +| Local view | iSCSI ALUA (`cmd/blockvolume/iscsi_alua_provider.go`) | NVMe ANA (`cmd/blockvolume/nvme_ana_provider.go`) | Data commands | +|---|---|---|---| +| frontend healthy (serving primary) | Active/Optimized | Optimized | served | +| engine recovering | Transitioning | Change | rejected | +| engine healthy or idle, frontend not primary | Standby | Non-optimized | rejected | +| engine degraded | Unavailable | Inaccessible | rejected | +| no view, or volume or replica mismatch | Unavailable | Inaccessible | rejected | + +- **iSCSI** (`core/frontend/iscsi/alua.go`, `scsi.go`): with a provider, standard INQUIRY advertises implicit ALUA (TPGS = 01b); VPD page 0x83 adds target-port-group and relative-port designators; REPORT TARGET PORT GROUPS returns one descriptor. Every path shows the same device identifier (hashed from IQN and volume), and each replica has its own target port group. On a non-active path, READ, WRITE and SYNCHRONIZE CACHE return NOT READY with ASCQ 0x0B, target port in standby (`aluaDataReject`). A standby path can still log in through a probe backend (`cmd/blockvolume/iscsi_probe_provider.go`). Active/Non-optimized is never reported, and explicit ALUA (SET TARGET PORT GROUPS) is not implemented. +- **NVMe/TCP** (`core/frontend/nvme/ana.go`, `admin_log.go` `handleANALogPage`, `admin_features.go` `watchANAChangeNotice`): the ANA log page 0x0c, one ANA group, and an asynchronous event when the state changes (the change count follows epoch and endpoint version). A path that is not Optimized rejects data commands with a path-related status (`io.go` `metadataOnlyReject`). +- **Node multipath:** opt-in with `stage2Multipath.enabled` (`blockcsi --stage2-multipath`). The controller then groups the frontends of all replicas by IQN into one multi-path publish context (`ControlStatusLookup`, `WithMultipathPublishTargets`), and `stageISCSI` logs into every portal and mounts the dm-multipath device. The chart does not ship a `multipath.conf`; the node's multipath configuration is the operator's. + +## 6. Authority promotion + +The volume computes whether it may become primary; blockmaster decides; only the publisher mints the epoch. + +**Promotion-ready fact** (`core/engine/promotion_ready.go` `BuildPromotionReadyFact`), reported in heartbeats as `ready_for_primary`. The first failing check wins: + +| Order | Reason | Condition | +|---|---|---| +| 1 | `not_member` | the replica is not a member of the current assignment | +| 2 | `not_reachable` | the reachability probe has not succeeded | +| 3 | `not_caught_up` | the recovery decision is not "none" (catch-up or rebuild pending) | +| 4 | `fence_pending` | its fence has not completed at the current epoch | +| 5 | `post_close_durable_ack_needed` | a recovered replica has not delivered its post-rebuild durable acknowledgement | +| 6 | `promotion_ready` | all checks pass | + +**RF=3 gate** (`core/host/master/promotion_probe.go`, `promotionAllowedReplicas`, `chooseAllowedPromotionTarget`): no promotion when the probe failed or is not installed, or the ack profile is unknown; a candidate is skipped when it is not `replica_ready` with a known frontier, or its durable LSN is below the required frontier. The decision is recorded as an ops event (`candidate_covers_required_frontier`, `candidate_frontier_behind`, `no_promotion_ready_candidate`). The required frontier per volume (`RequiredLSNByVolume`) is not set by `cmd/blockmaster` today, so the effective rule is "ready, highest durable LSN" (§12). + +**What blocks a promotion:** any engine reason above; `unhealthy_reason` set or withdrawn; an unreachable or ineligible server; boot grace still holding; a current primary whose probe is ready; a snapshot rejected for slot count; slots that changed while the probe ran. + +```mermaid +stateDiagram-v2 + [*] --> Serving: assignment at epoch N + Serving --> Suspect: heartbeat expired or unhealthy_reason + Suspect --> Serving: boot grace holds, or current primary probes ready + Suspect --> Blocked: no promotion-ready candidate + Blocked --> Suspect: next product tick + Suspect --> Reassigned: candidate chosen, IntentReassign + Reassigned --> Serving: publisher persists epoch N+1, new primary fences and serves +``` + +(The states in this diagram are descriptive names for the decision in `RunLifecycleProductTick` and `decideVolume`; they are not code types.) + +## 7. Readiness + +**blockvolume process readiness.** At start, blockvolume blocks local readiness ("awaiting durable recovery") and opens and recovers its store (`cmd/blockvolume/durable_startup.go` `openAndRecoverDurable`). Three outcomes: ready (the block clears), faulted (the process stays up and reports a typed reason: `wal_corrupt`, `io_error`, or `recovery_timeout` from the watchdog) or fatal (the process exits). While blocked, `applyFact` admits nothing, primary or supporting, and stores the assignment to replay once readiness clears. The status server (`core/host/volume/status_server.go`) exposes `/status`, `/status/peers`, `/status/durable`, `/status/nvme`, `/status/frontend-capabilities`; its projection carries `Healthy`, `FrontendPrimaryReady`, `AuthorityRole` (primary, superseded, unknown), `ReplicationRole` (none, recovering, not_ready, replica_ready, unknown), `UnhealthyReason` and catch-up lag. + +**Managed volume readiness** (`core/ops/managed_volume_model.go` `classifyManagedVolume`): one status per volume (invalid, unsafe, blocked, recovering, recovered, degraded, ready, unknown) over sub-states for Kubernetes, authority, CSI, host path, recovery and workload. Known blockers win before staleness, and stale evidence is never ready: + +```mermaid +flowchart TD + A["evidence for one volume"] --> B{"multiple primaries observed?"} + B -->|yes| INV["invalid"] + B -->|no| C{"known blocker?"} + C -->|yes| BLK["unsafe or blocked"] + C -->|no| D{"evidence stale or status unreachable?"} + D -->|yes| UNK["unknown (Ready=Unknown)"] + D -->|no| E{"recovered transparently or by reattach?"} + E -->|yes| REC["recovered"] + E -->|no| F{"primary available?"} + F -->|no| BLK2["blocked"] + F -->|yes| G{"first volume verified?"} + G -->|yes| RDY["ready"] + G -->|no| RCV["recovering or unknown"] +``` + +Known blockers, in priority order: a returned replica serving its frontend (unsafe), a publish target on loopback across nodes, a CSI image pull failure, a WAL integrity fault, an NVMe or multipath identity problem, a blocked CSI node, a failed writer mount, a host path not multipathed after failover, an unbound PVC. + +Conditions (`Ready`, `Blocked`, `Recovered`, `Invalid`, `Recovering`, evidence stale) are written to the CR status by operator-status (`managedVolumeConditionsForProjection`). + +## 8. Operation layer + +The operation layer is read-only except for one mutation: the finalizer `block.seaweedfs.com/swblockvolume-protection` on `SwBlockVolume` (`core/ops/delete_safety_contract.go`). + +- **Decision:** `EvaluateSwBlockVolumeDeleteSafety` returns not requested; requested with unknown safety (cleanup evidence missing or stale); blocked (residue left); or releasable, which allows the finalizer release. Evidence older than 15 minutes is stale (`MaxEvidenceAge`). +- **Flow:** operator-status writes `status.deleteSafety`; `LifecycleOwnerReconciler.Reconcile` adds the finalizer, and releases it only when the release is allowed (`PatchSwBlockVolumeFinalizers`); otherwise it holds and emits a Warning Event. +- **Idempotency:** reconciliation is level-based (it re-reads every pass and skips objects that already carry the finalizer); there is no operation journal. Dry run is the default. +- **Admission:** a ValidatingAdmissionPolicy (fail closed) lets the lifecycle-owner service account change nothing on a `SwBlockVolume` except adding or removing its own finalizer. +- **Action vocabulary** (`managed_volume_model.go`, evaluated by `managed_volume_action_evaluator.go` `EvaluateManagedVolumeAction`): `observe.*`, `safe_k8s.*`, and `authority.*` actions (request promotion, reintegrate, rebuild or fail back a returned replica), in read-only, dry-run or scripted mode; unknown, disabled or under-specified actions fail closed. The executors added later (§3) are off by default and guard their CRs with the expected current replica and epoch. + +## 9. Alpha scope and what is not supported + +Status per feature is in [Kubernetes status](../kubernetes-status.md) and [what you should not expect yet](../kubernetes-status.md#what-you-should-not-expect-yet). Confirmed in the code at this revision: + +- **Not implemented:** snapshots, clones and restore (`VolumeContentSource` is not read), expansion (no `EXPAND_VOLUME`; the StorageClass sets `allowVolumeExpansion: false`), `ListVolumes`, `GetCapacity`, `NodeGetVolumeStats`. They fall through to the CSI "unimplemented" stubs. +- **Access modes:** `ReadWriteOnce` only (`SINGLE_NODE_WRITER`); RWX and ROX are refused. +- **Raw block volumes** are accepted at create, but stage always formats and mounts, and publish is a bind mount (code reading; no test covers raw block). +- **No topology-aware provisioning**, one RF per cluster on the failover path, and a single blockmaster (no master high availability). +- **Security:** iSCSI CHAP is the only authentication. CSI, blockvolume and the controllers talk to blockmaster over plaintext, unauthenticated gRPC; NVMe/TCP has no authentication; there is no encryption. + +## 10. Invariants and tests + +| Invariant | Enforced in | Test | +|---|---|---| +| Only the publisher mints epochs; a reassignment is the per-volume maximum plus one | `core/authority/authority.go` `Publisher.applyWithWorkspaceMove` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | +| CSI never constructs authority facts; create records intent only | import boundary; `ControlLifecycleProvisioner` | `TestG15a_CSI_DoesNotImportAuthorityOrConstructAssignmentFacts` (`core/csi/boundary_guard_test.go`); `TestG15c_ControllerCreateVolume_RecordsDesiredIntentOnly` (`core/csi/controller_test.go`) | +| An epoch is persisted before it is published | `AuthorityStore.Put` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | +| Failover only to a ready, eligible, reachable candidate; no candidate mints nothing | `candidateAcceptable`, `chooseFailoverCandidate` | `TestG8_0_TopologyController_FailoverRequiresReadyEligibleReachableCandidate` (`core/authority/g8_0_authority_failover_test.go`) | +| RF=3 promotes only with a fresh probe, to a candidate covering the frontier | `applyPromotionEvidenceGate` | `TestMountedFailover_ProductLoopRF3PromotesCandidateCoveringSyncAckProbe`, `TestMountedFailover_ProductLoopRF3BlocksFailoverWithoutFreshPromotionProbe` (`core/host/master/product_loop_test.go`) | +| A superseded replica never feeds the adapter and reports not ready | `applyFact` | `TestHost_ApplyFact_Supersede_NeverCallsAdapterOrReplication` (`core/host/volume/apply_fact_test.go`); `TestHost_BuildReport_SupersededReplicaNotReadyForPrimary` (`core/host/volume/frontend_targets_test.go`) | +| A new primary fences its listener before it serves; replicas refuse frames below their floor | `ReplicaListener.FenceAsPrimary`; `raiseFloor` | `TestG2_PromotedHostRefusesShipFromDeposedPrimary` (`core/host/volume/g2_self_fence_test.go`); `TestG1_RestartedReplicaRefusesShipBelowItsAcknowledgedEpoch` (`core/transport/g1_durable_floor_test.go`) | +| A killed primary's acknowledged write is readable from the new primary | failover path end to end | `TestG8B_L2PrimaryKill_ReassignsAuthorityToReplica`, `TestG8B_L2PrimaryKill_NewPrimaryReadsAcknowledgedISCSIWrite` (`cmd/blockvolume/g8_l2_failover_test.go`) | +| Path state only reports; a mismatch fails closed; a non-active path never completes data I/O | ALUA and ANA providers; `aluaDataReject`; `metadataOnlyReject` | `TestP6ALUA_NonActiveStatesRejectDataPath` (`core/frontend/iscsi/p6_alua_test.go`); `TestProjectionALUAProvider_FailsClosedOnIdentityMismatch` (`cmd/blockvolume/iscsi_alua_provider_test.go`); `TestP4NVMe_StandbyProbePathRejectsDataCommands` (`core/frontend/nvme/p4_probe_backend_test.go`) | +| A re-stage after failover uses the fresh target, not the stale context | `refreshPublishContext` | `TestG15e_CSIReattachUsesFreshPublishTargetAfterUnstage`, `TestNodeStage_UsesPortalSpecificISCSISessionAfterFailover` (`core/csi/node_test.go`) | +| Stale evidence is never ready; dual primaries are invalid | `classifyManagedVolume` | `TestManagedVolumeProjection_InvalidDualPrimaryBeatsReady` (`core/ops/managed_volume_model_test.go`); `TestManagedVolumeProjection_EvidenceStaleIsNotReady` (`core/ops/managed_volume_conditions_test.go`) | +| The lifecycle owner touches only its finalizer, and releases it only when allowed | reconciler; admission policy | `TestLifecycleOwnerReconcilerReleasesOnlyProtectionFinalizerWhenAllowed` (`core/ops/lifecycle_owner_controller_test.go`); the admission policy is covered by TestOps scenarios only | + +**Test methods.** Unit and component tests per package; binary tests with real `blockvolume` and `blockmaster` (`cmd/blockvolume`); manifest tests that render the chart's templates and check RBAC and packaging (`core/ops/kubernetes_crd_manifests_test.go`, `cmd/blockcsi/g15d_manifest_test.go`); and scenario runs in supported lab clusters, whose intent lives in `testops/` and whose results are in the [release notes](../releases/README.md). Mounted failover, multipath and restart persistence are lab-gated, not CI. + +## 11. Review directions + +- Nothing outside the publisher may construct an epoch or an assignment; CSI and the operator controllers only record intent or read evidence. +- A new path-state or readiness source must fail closed on an identity mismatch and on stale evidence. +- Any new data command on a frontend must pass the same path-state gate. +- An opt-in executor must check the expected current replica and epoch, and must stay off by default. +- A chart change that affects durability or promotion must say which flags reach blockvolume and blockmaster. + +## 12. Known gaps + +These are found by reading the code at this revision; most are tracked for fixes. Gaps that apply to the whole codebase are in the [core known issues](block-design.md#24-known-issues-and-work-in-progress). + +- **No primary lease on the Kubernetes path.** A primary cut off from blockmaster keeps admitting I/O under its last assignment until it observes a newer one. The replicas' epoch floors refuse its shipped frames, which fails its `Sync` under `sync_quorum` or `sync_all`; under best-effort, the chart default, its local `fsync` still acknowledges. Its frontend also keeps reporting Active/Optimized, so a node that still reaches it may keep using that path. The workspace lease (`--workspace-lease`) requires `walstore-chunk` and is not rendered for Kubernetes volumes. +- **Synchronous durability needs two settings.** `replication.ackProfile` reaches blockvolume only with `compat.launcherReplicationAckFlag: true`. +- **The RF=3 required frontier is not wired.** `RequiredLSNByVolume` is never set by `cmd/blockmaster`, so promotion picks the ready candidate with the highest durable LSN without checking it against the last acknowledged sync. +- **Returned-replica rebuild is not deployable through Helm.** The executor exists, but `--runtime-rebuild-endpoint` is not rendered. +- **CSI publish is not fenced per node.** `ControlStatusLookup` ignores the node id. +- **The CSI node uses the controller's service account**, with write access to PVs, PVCs and `SwBlockVolume` objects. +- **A create conflict surfaces as `Internal`.** blockmaster returns gRPC `AlreadyExists`, which `ControllerServer.CreateVolume` does not map to its conflict error. +- **Nothing in Go code deletes the `SwBlockVolume` CR**; the gate scripts do. +- **No authentication or encryption** on the control plane (see §9). +- **Single blockmaster.** Volumes cannot fail over while it is down. diff --git a/seaweed-block/docs/developer-architecture.md b/seaweed-block/docs/developer-architecture.md index 6cb55dff93..8ccc4a9302 100644 --- a/seaweed-block/docs/developer-architecture.md +++ b/seaweed-block/docs/developer-architecture.md @@ -288,7 +288,7 @@ For a new contributor: 2. `deploy/k8s/alpha/README.md` 3. `docs/architecture.md` 4. this document -5. `docs/roadmap.md` +5. `docs/design/block-design.md`, `docs/design/kubernetes-block-design.md` For implementation work: diff --git a/seaweed-block/docs/fsync-latency.md b/seaweed-block/docs/fsync-latency.md index aebf20b10a..ac18e596d8 100644 --- a/seaweed-block/docs/fsync-latency.md +++ b/seaweed-block/docs/fsync-latency.md @@ -1,6 +1,9 @@ # Fsync latency breakdown -For walstore and walstore-chunk, read the existing volume-host endpoint: +**Use this when:** you need to find where `fsync` time goes on a walstore or +walstore-chunk volume, stage by stage, from the volume host's status endpoint. + +Read the volume-host endpoint: ```sh curl -fsS 'http://127.0.0.1:PORT/status/durable?volume=VOLUME' @@ -22,12 +25,12 @@ Each distribution exposes `Count`, `SumNanos`, 64 non-cumulative `Buckets`, `P50 `Frontend.Writes` includes FUA, `FUAWrites` is its subset, `Flushes` counts Flush commands and `Failed` counts unsuccessful handler results. Invalid ublk range/buffer requests are rejected before the timing hook or provider lookup: they remain counted by the device-level error/request counters, but add no backend-owned frontend sample. NVMe handler refusal counts retain their existing instrumentation. Non-durable backends retain their existing dispatch behavior. ublk and NVMe/TCP use the same optional backend timing seam; no guest filesystem or hardware is required for accounting tests. -A guest fsync may produce two Flush commands; compare command counts and physical Sync samples before attributing two disk syncs. Shared physical Sync and per-request queue samples have different populations. Do not add p50/p99 values, or subtract one stage's p99 from another's. Large queue time suggests batching/scheduling; large FileSync suggests local file/disk latency; large BackendSync with small local stages can include replication or metadata work. This diagnostic does not separately time each replication/checkpoint operation. Kernel transport completion and guest scheduling require the M5 external measurement. No frontend tuning or durability-policy change is included. +A guest fsync may produce two Flush commands; compare command counts and physical Sync samples before attributing two disk syncs. Shared physical Sync and per-request queue samples have different populations. Do not add p50/p99 values, or subtract one stage's p99 from another's. Large queue time suggests batching/scheduling; large FileSync suggests local file/disk latency; large BackendSync with small local stages can include replication or metadata work. This diagnostic does not separately time each replication/checkpoint operation. Kernel transport completion and guest scheduling are outside these histograms and need an external measurement. ## Verification and overhead scope -Unit controls cover known histogram quantiles, concurrent counters, failed/refused requests, both frontend dispatchers, batch waiter-versus-physical counts and dedup. The initial status contract test fails on unmodified main because the existing JSON has no durability histograms. +Unit tests cover known histogram quantiles, concurrent counters, failed/refused requests, both frontend dispatchers, batch waiter-versus-physical counts and dedup. -The PR records an interleaved main-versus-instrumented comparison of the existing file-backed TCP paired-Flush proxy (`SW_BLOCK_SYNC_PERF=1`, `TestNVMePairedFlushLatency`), using prebuilt binaries on tp04. It measures request-path default-on overhead; it is not mounted fio, a guest fsync result, or a device-specific latency promise. M5 may proceed independently if this PR has not landed. +Default-on overhead was checked with an interleaved before-versus-after comparison of the file-backed TCP paired-Flush proxy (`SW_BLOCK_SYNC_PERF=1`, `TestNVMePairedFlushLatency`). That measures request-path overhead only; it is not mounted fio, a guest fsync result, or a device-specific latency promise. The ublk Target forwards the optional timing hook through its lazy providerBackend to the actual durable backend. Initial provider lookup is included in ReceiveToBackend. If provider open fails before a durable backend is available, the request returns that error without a second open attempt, and no backend-owned frontend histogram exists for that failure. The device-level error counters remain the source for such failures. A later request may retry normally. Caller tests start the real Target with only the kernel device constructor replaced; NVMe uses a real TCP target and FUA capsule. diff --git a/seaweed-block/docs/kubernetes-app-demo.md b/seaweed-block/docs/kubernetes-app-demo.md index bb5682aa11..d120edf78a 100644 --- a/seaweed-block/docs/kubernetes-app-demo.md +++ b/seaweed-block/docs/kubernetes-app-demo.md @@ -1,5 +1,10 @@ # Kubernetes App Demo +**Use this when:** you present Seaweed Block on Kubernetes with local images +and want viewers to see an ordinary app pod write a PVC and a replacement pod +read it back. For the supported install path, use the +[Kubernetes quickstart](quickstart-kubernetes.md). + This demo shows `seaweed-block` from the application's point of view. The app is a normal Kubernetes pod using a normal PVC. The storage stack is the @@ -109,6 +114,8 @@ This demo does not claim: - multi-node production readiness, - failover while the app remains mounted, -- durable state across blockvolume pod restart, +- durable state across blockvolume pod restart (restart persistence with a + hostPath state root is a separate gated path, see + [Kubernetes status](kubernetes-status.md)), - real operator reconciliation, - performance or soak readiness. diff --git a/seaweed-block/docs/kubernetes-status.md b/seaweed-block/docs/kubernetes-status.md index 65e36086b1..2ba34dbb81 100644 --- a/seaweed-block/docs/kubernetes-status.md +++ b/seaweed-block/docs/kubernetes-status.md @@ -8,9 +8,6 @@ matches which release line. evidence for every claim below. [User capabilities](user-capabilities.md) describes current behavior and the read-only operations commands. -This page holds the detailed Kubernetes claim lists that used to be in the -top-level README. The text is unchanged. - The Kubernetes path is focused on one user-visible loop: ```text diff --git a/seaweed-block/docs/overview.md b/seaweed-block/docs/overview.md index 64cc6ae6eb..920fc890d8 100644 --- a/seaweed-block/docs/overview.md +++ b/seaweed-block/docs/overview.md @@ -1,27 +1,47 @@ -# `docs/` Overview +# `docs/` overview -This directory contains public and technical documentation. +An index of this directory. Internal planning and historical design notes +belong under `internal/docs/`, not here. -## Public / Contributor Docs +## Design and evidence | File | Purpose | |---|---| -| `architecture.md` | Short product architecture overview. | -| `developer-architecture.md` | Deeper module-by-module architecture for contributors. | -| `runtime-state-machines.md` | Mermaid state-machine and loop overview. | -| `roadmap.md` | Alpha roadmap and non-claims. | -| `quickstart-kubernetes.md` | First-volume Kubernetes quickstart. | -| `user-capabilities.md` | User-facing current capabilities, operations commands, status vocabulary, and non-claims. | -| `operations-v1.md` | Legacy V1 alpha operations manual; use quickstart and release notes for current claims. | -| `kubernetes-app-demo.md` | Presentation-friendly Kubernetes app + PVC demo. | +| `design/block-design.md` | Core design: frontends, walstore and smartwal, durability, authority, replication engine, recovery; verification and known issues | +| `design/agent-workspace-design.md` | Agent workspace disks: chunk backend, cuts, snapshots, forks, GC, host moves, security model | +| `design/kubernetes-block-design.md` | Kubernetes block volumes: CSI, Helm and operator, replication and failover, multipath, readiness | +| `spec/` | TLA+ specifications of the protocols where a bug would lose data | +| `workspace-measurements.md` | Measured workspace results and how each was measured | +| `kubernetes-status.md` | Kubernetes feature status, claims, non-claims and release images | +| `releases/` | Release notes: what each release claimed and the run evidence behind it | -## Calibration Evidence +## Operations -`calibration/` contains evidence documents still referenced by calibration code. -Keep them here until those references move to the shared design archive. +| File | Purpose | +|---|---| +| `standalone-deployment.md` | Run `blockmaster` and `blockvolume` with systemd, outside Kubernetes | +| `quickstart-kubernetes.md` | Kubernetes first-volume path with Helm | +| `user-capabilities.md` | Kubernetes capabilities, read-only operations commands, status vocabulary | +| `kubernetes-app-demo.md` | Presentation demo: an app pod writes and a replacement pod reads one PVC | +| `chunk-manifests.md` | Chunk upload settings and the HEAD/segment manifest format | +| `workspace-lease.md` | Workspace host lease, clean and forced moves, clock skew | +| `fsync-latency.md` | Reading the per-stage `fsync` histograms under `/status/durable` | -## Documentation Rule +## Engineering references (Kubernetes line) + +| File | Purpose | +|---|---| +| `architecture.md` | Short Kubernetes product architecture | +| `developer-architecture.md` | Module-by-module boundaries for contributors | +| `runtime-state-machines.md` | Control-plane, CSI and frontend loops | +| `operations-v1.md` | Legacy V1 alpha operations manual; use the quickstart and release notes for current claims | +| `wiki/` | Engineering wiki (MkDocs): code map, state machines, deep dives | + +## Calibration evidence + +`calibration/` contains evidence documents still referenced by calibration +code (`core/calibration`, `cmd/sparrow`). + +## Documentation rule If a document is meant for external users, avoid internal phase or gate labels. -Internal planning, readiness tracking, audits, and historical design notes -belong under `internal/docs/`, not in this public docs entry path. diff --git a/seaweed-block/docs/quickstart-kubernetes.md b/seaweed-block/docs/quickstart-kubernetes.md index 8ee0f36d83..7b459eb230 100644 --- a/seaweed-block/docs/quickstart-kubernetes.md +++ b/seaweed-block/docs/quickstart-kubernetes.md @@ -1,6 +1,7 @@ # Kubernetes Quick Start -This guide is the current alpha path for Seaweed Block on Kubernetes. +**Use this when:** you install the Kubernetes alpha with Helm on a supported +test cluster and want to create, verify and clean up a first PVC-backed volume. It shows the user loop: @@ -37,10 +38,8 @@ The quickstart proves: - The example resources and host-side residue are cleaned up. It does not prove production HA, backup/restore, broad upgrade safety, broad -platform compatibility, broad mutating operator lifecycle, mutating admin -workflows, or production UI. The separate v0.5 beta-candidate lifecycle-owner -path is limited to the Seaweed Block `SwBlockVolume` protection finalizer and -requires matching release images. +platform compatibility, a mutating operator, or a production UI; see +[what you should not expect yet](kubernetes-status.md#what-you-should-not-expect-yet). ## Prerequisites @@ -140,12 +139,8 @@ sw-block ops generate-helm-values \ ``` Current validated published quickstart image tag: -`sha-dc2972d0059b`. - -This tag covers the v0.4 read-only/status foundation path. The v0.5 -bounded lifecycle-owner path requires matching `sw-block` and `sw-block-csi` -images published from the Phase 44 release commit; do not use the older -quickstart tag to validate lifecycle-owner behavior. +`sha-dc2972d0059b`. It covers the v0.4 read-only/status path; later paths +need matching images, see [release images](kubernetes-status.md#release-images). Published image digests: @@ -351,8 +346,7 @@ bash scripts/run-basic-app-example.sh "$PWD" The `"$PWD"` argument is the repository root for both helper scripts. -Use Helm for the v0.3 alpha release path unless you are specifically testing -local script activation. +Use Helm unless you are specifically testing local script activation. ## Troubleshooting @@ -425,14 +419,8 @@ other run owns the resources. ## Current Alpha Limitations -- This is an alpha Helm path, not a production installer or operator. -- The dashboard is local and read-only, not a production hosted UI. -- Mutating admin workflows are not exposed: no promote, repair, rebuild, - failback, delete, backup, restore, or cleanup button. -- Broad upgrade and rollback safety are not claimed beyond the gated alpha - smoke path. -- Backup, snapshot, and restore are not claimed. -- Broad distro/kernel/initiator compatibility is not claimed. -- Performance, RTO, and SLO numbers are not claimed. -- Transparent Kubernetes node-loss without pod recreate is not claimed by this - quickstart. +This is an alpha Helm path, not a production installer or operator. The +dashboard is local and read-only. Broad upgrade and rollback safety are not +claimed beyond the gated alpha smoke path, and performance, RTO and SLO numbers +are not claimed. The full list is in +[what you should not expect yet](kubernetes-status.md#what-you-should-not-expect-yet). diff --git a/seaweed-block/docs/releases/README.md b/seaweed-block/docs/releases/README.md index 3f7a7826c7..df3295b868 100644 --- a/seaweed-block/docs/releases/README.md +++ b/seaweed-block/docs/releases/README.md @@ -20,6 +20,11 @@ is still outside the supported boundary. - [NVMe/RDMA Capability Boundary](nvme-rdma-capability-boundary.md) - [WAL Multi-Block Record Opt-In Boundary](wal-multiblock-opt-in.md) +Agent workspace disks (`walstore-chunk`) are not part of any release yet; they +are a proof of concept. Their measurements are in +[workspace measurements](../workspace-measurements.md) and their design in the +[agent workspace design](../design/agent-workspace-design.md). + ## Version Boundary - `v0.1-alpha` is the engineering alpha foundation: CSI/PVC plumbing, diff --git a/seaweed-block/docs/releases/nvme-rdma-capability-boundary.md b/seaweed-block/docs/releases/nvme-rdma-capability-boundary.md index 0a11f6fcbe..11589c7ffb 100644 --- a/seaweed-block/docs/releases/nvme-rdma-capability-boundary.md +++ b/seaweed-block/docs/releases/nvme-rdma-capability-boundary.md @@ -19,8 +19,8 @@ compatibility, performance improvement, and production SLOs remain non-claims. ## Implemented Standalone Path ```text -Linux nvme-rdma initiator on m01 --> RoCE data-plane address 10.0.0.3 on m02 +Linux nvme-rdma initiator on lab host A +-> RoCE data-plane address 10.0.0.3 on lab host B -> Linux kernel nvmet-rdma target -> configfs namespace backed by /dev/nbdX -> Seaweed Block NBD request bridge @@ -130,7 +130,7 @@ cleanup_status=ok TestOps run `20260718-025048-9d6a` passed 14/14 actions with fresh matching product and CSI images. A dynamic PVC selected `nvmeTransport: rdma`, the target -published `10.0.0.3:4420`, CSI mounted it on m01, and writer/reader verification +published `10.0.0.3:4420`, CSI mounted it on lab host A, and writer/reader verification passed. ```text @@ -178,6 +178,6 @@ must not be described as an acceleration path or used for an SLO claim. ## Related External RDMA Work -`C:\work\rdma\seaweed-mono-rdma-refresh` and `C:\work\rdma\sra-next` provide -useful VFS/object/RustVolume/RDMA/NIXL evidence. They do not implement the -standard Linux NVMe/RDMA target used here and remain separate product surfaces. +Other SeaweedFS RDMA work (file, object and volume-server data paths) is +separate. It does not implement the standard Linux NVMe/RDMA target used here +and remains a separate product surface. diff --git a/seaweed-block/docs/releases/nvme-tcp-supported-lab.md b/seaweed-block/docs/releases/nvme-tcp-supported-lab.md index 86c33a1683..7b7487966b 100644 --- a/seaweed-block/docs/releases/nvme-tcp-supported-lab.md +++ b/seaweed-block/docs/releases/nvme-tcp-supported-lab.md @@ -763,6 +763,31 @@ report_dashboard_agree=true cleanup_status=ok ``` +## Later Write-Path Experiments (Not Adopted) + +Results of the experiments that followed Phase 165. +None of them changes a claim on this page. + +- Phase 166 implements the RF2 NVMe/RDMA reconnect and exact path-replacement + contract, but its live close gate is blocked by lab topology: a third remote + RoCE-capable Kubernetes initiator is required before mounted RDMA multipath + survival or reconnect can be claimed. +- Phase 167 (`parallel-walstore`, a parallel write engine) preserves its tested + global LSN/frontier, crash recovery and catch-up/rebuild semantics, but + remains explicit and opt-in because its 4 KiB throughput/scaling gate failed. +- Phase 168 tested a bounded Linux `io_uring` submission/completion owner. + Correctness passed, but native execution reached only 0.96x the legacy + single-writer path and 0.96x four-writer scaling, so the candidate was + removed. +- Phase 169 changed the persistence unit to checksummed multi-entry segments. + Format, recovery, Sync and failure semantics passed, but the optimistic gate + measured four-writer scaling of only `0.772x` its one-writer rate and + `0.990x` the positioned control, so the candidate was removed before + checkpoint/rebuild integration. +- Phase 170 moved performance work back to the default `walstore` path and its + existing-format `appendBatch` seam. Direct I/O, fixed buffers, FUA and device + atomic-write support remain evidence-gated follow-ups. + ## Representative Release Smoke When matching release images exist, the smoke should use the exact image pair: @@ -824,8 +849,8 @@ This evidence does not claim: - Performance, throughput, latency, or production SLO. - Broad Linux distro, kernel, initiator, or cloud compatibility. - Production HA, node-loss survival, or arbitrary unbounded path churn. -- Broad Linux host AER/ANA notification compatibility beyond the m02 supported - lab gate. +- Broad Linux host AER/ANA notification compatibility beyond the supported + lab host gate. - Published-image Kubernetes dynamic NVMe reconnect after control-plane desired path-set replacement/failover until matching release images pass a release smoke. The current evidence is source-gated. diff --git a/seaweed-block/docs/roadmap.md b/seaweed-block/docs/roadmap.md deleted file mode 100644 index 2b6f61bbf5..0000000000 --- a/seaweed-block/docs/roadmap.md +++ /dev/null @@ -1,1148 +0,0 @@ -# Seaweed Block Roadmap - -> Document status: public roadmap summary. It is intentionally high level and -> may trail the internal execution plan between releases. For current -> user-facing claims, use [`quickstart-kubernetes.md`](quickstart-kubernetes.md) -> and [`releases/README.md`](releases/README.md). - -This roadmap is intentionally practical. The goal is to make a Kubernetes block -service that is easy to try, review, and improve without hiding unfinished -storage semantics. - -## Current Alpha MVP - -Already demonstrated: - -- CSI static PV path on Kubernetes. -- CSI dynamic PVC create path. -- CSI dynamic PVC delete/cleanup path. -- iSCSI mount into a real pod. -- Pod write/read checksum through the mounted volume. -- TestOps registry and CLI MVP. -- Deeper recovery/failover components tested below the K8s surface. - -Current alpha constraints: - -- single-node Kubernetes lab evidence -- iSCSI and NVMe-oF frontends are release-gated on a single-node lab -- `walstore` backend only -- launcher-generated blockvolume state uses `emptyDir` -- harness applies generated blockvolume manifests -- generated blockvolume Deployments can use PVC owner references for cleanup -- no production operator yet; only the bounded v0.5 beta-candidate - lifecycle-owner mutates `SwBlockVolume.metadata.finalizers` - -## Near-Term MVP Hardening - -1. Package a clean Kubernetes install surface. - - - v0.2 alpha: script-based Day-1 activation path - - v0.3 alpha: Helm chart for the same supported path - - document image names, immutable release tags, prerequisites, and cleanup - - remove gate-specific naming from user paths where possible - -2. Replace `emptyDir` for blockvolume state. - - - add durable root configuration - - support hostPath/local-path style lab persistence - - keep `emptyDir` only for explicit throwaway smoke tests - -3. Add a minimal operator/controller loop after Helm. - - - do not jump directly from scripts to an operator - - first stabilize install values, chart ownership, and uninstall behavior - - read-only CRDs, Conditions, Events, node readiness, support evidence refs, - cleanup visibility, and safe next-step status are now gated as the first - operator foundation - - mutating lifecycle ownership, finalizers, upgrade execution, repair, - rebuild, failback, and automatic cleanup remain separate future phases - -4. Improve TestOps usability. - - - remote shell execution for K8s scenarios - - stable result bundles - - scenario registry index - - stronger negative-path gates for blocked, stale, unreachable, corrupt - evidence, and cleanup-residue cases - -## Current Capability Snapshot - -Seaweed Block can already demonstrate a narrow Kubernetes block-storage loop: - -- Helm install on supported lab clusters. -- Dynamic PVC provisioning through CSI. -- App pod mount, write, read, and replacement-reader verification. -- iSCSI frontend with gated ALUA/dm-multipath failover evidence. -- RF=3 multi-volume lab path with independent volume identity and publish - target. -- Restart persistence for supported hostPath gates. -- Read-only CLI/report/dashboard/support-bundle flows. -- Read-only CRD status and Events for `SwBlockCluster` and `SwBlockVolume`. -- Live node evidence for Kubernetes Ready/SchedulingDisabled, CSI registration, - CSI image-pull blockers, host-prereq evidence replay, and loopback - cross-node attach blockers. -- Negative-first status: blocked, stale, unreachable, or corrupt evidence must - not become false `Ready=True`. -- Cleanup verification for Kubernetes, iSCSI, multipath, process, and hostPath - residue. -- Executable lifecycle action contracts: dry-run actions can be allowed with - evidence, unsafe/future-mutating actions are rejected with stable reasons, and - CRD/report/dashboard/operator-snapshot surfaces agree on the decision. -- Delete-safety status and cleanup-required visibility without finalizer or - cleanup mutation. -- Bounded `SwBlockVolume` finalizer lifecycle in the v0.5 beta-candidate path: - CSI-created identity CRs, lifecycle-owner protection finalizer, evidence-driven - hold/release, Events, and multi-volume isolation. -- NVMe/TCP CSI multipath attach is gated for the supported lab path; RoCE and - NVMe/RDMA remain explicit non-claims until host preflight plus live I/O gates - prove them. -- Cross-node loopback NVMe/TCP topology is explicitly blocked. The - non-loopback NVMe/TCP publish path is wired through blockvolume, - blockmaster, Helm, and generated values, and the supported lab path now has a - live cross-node writer/reader gate against a routable NVMe/TCP target. This - is still not a RoCE, performance/SLO, broad compatibility, or production HA - claim. -- NVMe/TCP write-path profiling is source-gated through target/backend/WAL - counters. The current 32KiB request shape is traced to the target-advertised - `MaxH2CDataLength`, not to WAL coalescing or a RoCE/RDMA path. A 64KiB - `MaxH2CDataLength` candidate is gated as explicit opt-in lab evidence. Under - that opt-in the target/backend request max stays at 64KiB and the next named - bottleneck is WAL append, not frontend request size. The append bucket is - paired with near-equal WAL encode cost; Phase 144 names - `wal_record_materialization_reduction` as the next narrow backend target. - Phase 145 removes one local batch-allocation seam without changing WAL format - or recovery semantics. Phase 146 measured that change as visible in the lab - profile, but it is still not a default or performance/SLO claim. The next - backend step selected by Phase 147 is a disabled-by-default multi-block WAL - record prototype. The current WAL format remains unchanged until local - encode/decode, dirty-read, recovery-split, and flusher-split tests pass. - Phase 148 closes that local correctness gate; the next step is profiling - record-count reduction before any runtime or Kubernetes opt-in. Phase 149 - proves that reduction locally (`2048` encode ops to `128`) and keeps the next - step bounded to a disabled-by-default runtime opt-in. Phase 150 wires that - opt-in without changing defaults. Phase 151 proves the opt-in runs through the - mounted NVMe/TCP path and observes the multi-block record shape. Phase 152 - proves mounted restart/recovery compatibility with hostPath persistence, - force-delete restart, and `recovered_lsn_after_restart=14545`. The opt-in - remains default-off and is not a performance/SLO, RoCE, or NVMe/RDMA claim. - Phase 153 documents the release boundary and lab-only opt-in shape without - changing the default WAL format. Phase 154 fixes the local diagnostic - `HeadLSN` bug where walstore's WAL byte-position metadata could leak into the - LSN boundary after recovery. Phase 155 confirms that same `/status/durable` - boundary in the mounted K8s path: after force-delete restart/recovery, - `DurableLSN`, `HeadLSN`, and recovery evidence all match the recovered LSN. - Phase 156 keeps the opt-in source-gated: a future public release-image claim - requires a matching-image smoke of the explicit opt-in recovery/status path. -- Phase 157 keeps RoCE/NVMe-RDMA as a product non-claim until the product owns a - real RDMA transport path and passes standalone live I/O, Kubernetes - publish/attach, status-surface, fallback/refusal, and cleanup gates. Host RDMA - capability and external VFS/object RDMA evidence remain useful inputs but are - not a Seaweed Block NVMe/RDMA claim. -- Phase 158 adds a product-owned read-only capability probe: - `/status/frontend-capabilities` reports NVMe/TCP supported and NVMe/RDMA - unsupported with a stable reason. It still does not start an RDMA listener or - claim RoCE/NVMe-RDMA attach. -- Phase 159 defines the standalone NVMe/RDMA listener design gate. It explicitly - rejects a fake "RDMA listener" that still speaks the NVMe/TCP PDU stream, and - selects a transport adapter seam as the next implementation step before any - Kubernetes publish/attach or performance claim. -- Phase 160 adds that code seam: NVMe sessions now use a transport adapter - interface, with TCP still backed by the existing NVMe/TCP PDU Reader/Writer. - RDMA remains unsupported and the capability endpoint still reports the stable - unsupported reason. -- Phase 161 adds read-only RDMA preflight facts for module, RDMA device, and - bind-address evidence while preserving `supported=false` and no RDMA listener. -- Phase 162 adds a disabled-by-default RDMA listener start decision skeleton: - the product can report why start is not allowed, but still does not start an - RDMA listener or claim live I/O. -- Phase 163 implements and live-gates the first source-gated standalone - NVMe/RDMA path. Linux `nvme connect -t rdma` reaches the real Seaweed backend - through kernel `nvmet-rdma` plus a product-owned NBD bridge; write/read/flush - and cleanup pass on the 10.0.0.x RoCE lab network. Kubernetes publication, - failover, broad compatibility, and performance remain non-claims. -- Phase 164 hardens that standalone path with startup rollback, 4 KiB and - larger I/O, FUA/flush, durable restart/reconnect, two-target isolation, - bounded churn, stable refusal, and zero-residue cleanup. -- Phase 165 closes the separate opt-in Kubernetes NVMe/RDMA publish/attach - gate. StorageClass intent is carried explicitly through lifecycle and - frontend facts into CSI; a dynamic PVC mounts on m01 through the m02 RoCE - address, CRD status and host sysfs both report RDMA, writer/reader pass, and - exact controller/configfs/NBD/Kubernetes cleanup returns to zero. NVMe/TCP - remains the default. RDMA reconnect/failover, multipath, performance, broad - compatibility, and SLOs remain separate future gates. -- Phase 166 implements the RF2 NVMe/RDMA reconnect and exact path-replacement - contract, but the live close gate remains blocked by lab topology. A third - remote RoCE-capable Kubernetes initiator is required before the project can - claim mounted RDMA multipath survival or reconnect. -- Phase 167 closed as an opt-in Parallel Write Engine research result. Its - correctness model and batch path passed, but ordinary 4 KiB scaling did not. -- Phase 168 rejected a Linux `io_uring` WAL execution candidate, and Phase 169 - rejected a segmented group-commit format after its four-writer optimistic - upper bound reached only `0.772x` its one-writer rate and `0.990x` the - positioned control. Both candidates were removed. -- Phase 170 moves performance work back to the default `walstore` product path: - profile its staged costs, then use the existing-format `appendBatch` seam - only if CRC/copy/lock evidence justifies a bounded commit pipeline. -- Kubernetes NVMe/TCP mounted reconnect is source-gated through changed - desired path-set evidence: CSI-node can connect a newly published desired - NVMe path, prune the stale old host path for the same NQN, preserve pod - identity, and keep mounted I/O working. -- Install drift status for current versus desired chart/app/image identity - without upgrade execution. -- CRD/RBAC status-writer conformance coverage for the failures that previously - escaped mock tests and only failed in live QA. - -The product model is converging around one read-only control-plane pattern: -truth owners publish facts, the status layer aggregates judgment, executors stay -bounded, and evidence explains why the status is allowed. The next work should -preserve that model rather than add isolated scripts or separate status systems. - -Recommended order from here: - -1. Operator-status foundation release: complete in v0.4 beta. It claims - status/events-only visibility, not lifecycle mutation. -2. Operation Layer v0.5 beta candidate: code and QA complete through Phase 44; - release images still need publish/pinned-image smoke before marking it - shipped. The team is intentionally skipping that release step for the next - development slice, so v0.5 must not be marked released from roadmap wording. - It claims a bounded `SwBlockVolume` protection-finalizer lifecycle, not - automatic cleanup or broad operator automation. - - Phase 41: lifecycle-owner foundation. **Closed 2026-06-14, QA PASS** - (`internal/docs/finished-plans/phase41_finishedplan_lifecycle_owner_foundation.md`). - Observer/lifecycle-owner/executor roles defined; delete-safety preconditions - and a dry-run finalizer-release action shipped. - - Phase 42: real API/admission proof. **Closed 2026-06-15, QA PASS** - (`internal/docs/finished-plans/phase42_finishedplan_lifecycle_owner_admission_gate.md`). - The lifecycle-owner patch boundary is proven with real Kubernetes - ValidatingAdmissionPolicy. - - Phase 43: first bounded lifecycle mutation. **Closed 2026-06-15, QA PASS** - (`internal/docs/finished-plans/phase43_finishedplan_bounded_finalizer_lifecycle.md`). - Finalizer add/release works as isolated gates. - - Phase 44: delete lifecycle close gate. **Closed 2026-06-17, QA PASS** - (`internal/docs/finished-plans/phase44_finishedplan_delete_lifecycle_close_gate.md`). - The integrated PVC -> protected CR -> hold/release -> zero-residue path is - validated end-to-end. -3. Phase 46: productize returned-replica rebuild/reintegration status and - decisioning. **Closed 2026-06-19, QA PASS** - (`internal/docs/finished-plans/phase46_finishedplan_returned_replica_reintegration_productization.md`). - Returned replicas are now Kubernetes/product-surface visible, fenced from - frontend/ACK eligibility until evidence supports reintegration, and - volume-scoped across multi-volume reports. Automatic failback or broad - rebuild execution remains a later executor phase. -4. Phase 47: returned-replica executor admission. **Closed 2026-06-20, QA PASS** - (`internal/docs/finished-plans/phase47_finishedplan_returned_replica_executor_admission.md`). - `authority.reintegrate_returned_replica` is allowed only as a dry-run, - non-mutating action when exact fencing and frontier evidence is present. - This is not automatic failback or rebuild execution. -5. Phase 48: returned-replica live evidence close. **Closed 2026-06-20, QA PASS** - (`internal/docs/finished-plans/phase48_finishedplan_returned_replica_live_evidence.md`). - The live iSCSI returned-replica scenario now emits same-run managed-volume - evidence proving r1 remains fenced, r2 remains the primary, and the returned - replica covers the required frontier before any future executor mutates - authority or storage state. -6. Phase 49: returned-replica executor preflight. **Closed 2026-06-20, local PASS** - (`internal/docs/finished-plans/phase49_finishedplan_returned_replica_executor_preflight.md`). - The returned-replica dry-run action now has a typed preflight that is ready - only when the target is unique, frontend/ACK fenced, and durable frontier - evidence covers the required frontier. It remains non-mutating and does not - claim automatic reintegration, rebuild, failback, or frontend publication. -7. Phase 50: returned-replica preflight status schema. **Closed 2026-06-20, local PASS** - (`internal/docs/finished-plans/phase50_finishedplan_returned_replica_preflight_status_schema.md`). - The preflight is now machine-readable in operator-snapshot JSON and - SwBlockVolume `.status.executorPreflights[]`, with OpenAPI schema and - status-writer coverage. It is still non-mutating. -8. Phase 51: returned-replica ACK evidence gate. **Closed 2026-06-21, QA PASS** - (`internal/docs/finished-plans/phase51_finishedplan_returned_replica_ack_evidence_gate.md`). - The executor preflight now distinguishes explicit ACK non-eligibility from - missing ACK evidence. A future executor may not treat default - `ack_eligible=false` as proof; preflight readiness requires - `ack_eligibility_known=true` and `ack_eligible=false`. -9. Phase 52: returned-replica executor contract. **Closed 2026-06-21, QA PASS** - (`internal/docs/finished-plans/phase52_finishedplan_returned_replica_executor_contract.md`). - The future executor boundary is published as a non-mutating contract: - execution remains disabled, only ACK eligibility is named as the future - allowed mutation class, frontend publication/rebuild traffic/failback remain - forbidden, and terminal evidence is required before any later executor can - claim completion. -10. Phase 53: returned-replica authority executor skeleton. **Closed 2026-06-22, QA PASS** - (`internal/docs/finished-plans/phase53_finishedplan_returned_replica_executor_skeleton.md`). - The executor process boundary is now disabled-by-default with - read-only `SwBlockVolume` access. It consumes executor contracts and fails - closed on execution-enabled or mutating contracts, but still performs no ACK - eligibility mutation, frontend publication, rebuild traffic, or failback. -11. Phase 54: returned-replica reintegration executor milestone. **Closed 2026-06-23, QA PASS** - (`internal/docs/finished-plans/phase54_finishedplan_returned_replica_reintegration_executor.md`). - This is intentionally larger than the previous safety-latch phases. It - groups executor policy, the ACK eligibility mutation target, admission/RBAC, - terminal evidence, failure states, multi-volume isolation, and a live close - gate into one milestone. The first allowed mutation remains narrow: - returned-replica ACK eligibility only. D1-D7 passed live QA through the RBAC - boundary, executor call-site terminal-evidence gate, negative/hold matrix, - dedicated multi-volume isolation, and the live returned-replica close gate. - Frontend publication, rebuild traffic, and automatic failback remain - non-claims. -12. Phase 55: release and documentation hardening. **Closed 2026-06-23, local PASS** - (`internal/docs/finished-plans/phase55_finishedplan_release_docs_hardening.md`). - This phase aligns README, release notes, user capabilities, and developer - wiki pages with the Phase 54 boundary. It should not add a new storage - feature or broaden the claim beyond ACK eligibility target status. -13. Phase 56: returned-replica rebuild/catch-up contract. **Closed 2026-06-23, QA PASS** - (`internal/docs/finished-plans/phase56_finishedplan_returned_replica_rebuild_contract.md`). - The product now surfaces `authority.rebuild_returned_replica` as a disabled - future action when a returned replica is frontend-fenced and behind the - required frontier. It does not start rebuild traffic. -14. Phase 57: rebuild progress target. **Closed 2026-06-23, QA PASS** - (`internal/docs/finished-plans/phase57_finishedplan_rebuild_progress_target.md`). - `SwBlockReplicaRebuild.status` exists as the narrow target for planned - rebuild progress. The authority executor may write only planned status under - the `rebuild_traffic` mutation class; it still does not copy data, publish a - frontend, or fail back a replica. -15. Phase 58: rebuild target owner. **Closed 2026-06-23, QA PASS** - (`internal/docs/finished-plans/phase58_finishedplan_rebuild_target_owner.md`). - A separate target-owner identity can create `SwBlockReplicaRebuild` main - objects from ready rebuild contracts. It cannot write status or mutate - volume, workload, frontend, or storage state. -16. Phase 59: rebuild planning close gate. **Closed 2026-06-23, QA PASS** - (`internal/docs/finished-plans/phase59_finishedplan_rebuild_planning_close_gate.md`). - This gate connects Phases 56-58 as one product path: - rebuild contract -> target-owner-created target CR -> executor planned - status. It is still planning/status only, not real rebuild data movement. -17. Phase 60: rebuild/catch-up data-path gate. **Closed 2026-06-23, QA PASS** - (`internal/docs/finished-plans/phase60_finishedplan_rebuild_catchup_datapath_gate.md`). - The existing engine/adapter/transport/recovery stack now has a repeatable - gate proving catch-up traffic, dual-lane rebuild traffic, session close, - durable ack, live WAL during rebuild, same-LBA arbitration, and byte-equal - convergence. This proves the data path beneath the planning model; it does - not yet wire the Kubernetes authority executor to trigger that traffic in a - live blockvolume pod. -18. Phase 61: authority executor runtime call-site. **Closed 2026-06-23, QA PASS** - (`internal/docs/finished-plans/phase61_finishedplan_authority_executor_runtime_callsite.md`). - The authority executor now has a bounded `AuthorityRebuildRuntime` seam. - With no runtime it preserves the Phase 59 `planned` behavior; with a - runtime it writes `running`, invokes the runtime, and maps terminal evidence - to `caught_up` or `blocked`. This still does not wire a concrete - blockvolume RPC/HTTP/gRPC transport. -19. Phase 62: authority executor HTTP runtime. **Closed 2026-06-23, QA PASS** - (`internal/docs/finished-plans/phase62_finishedplan_authority_executor_http_runtime.md`). - The executor can call a typed HTTP runtime seam and preserve the - no-frontend/no-failback/non-ACK-mutation boundary. -20. Phase 63: rebuild runtime target contract. **Closed 2026-06-24, QA PASS** - (`internal/docs/finished-plans/phase63_finishedplan_rebuild_runtime_target_contract.md`). - Runtime targets carry the explicit endpoint/session/frontier fields needed - before a blockvolume runtime call can be attempted. -21. Phase 64: blockvolume runtime endpoint. **Closed 2026-06-24, QA PASS** - (`internal/docs/finished-plans/phase64_finishedplan_blockvolume_runtime_endpoint.md`). - The blockvolume status server exposes the bounded `/runtime/rebuild` - endpoint for rebuild/catch-up traffic under explicit opt-in. -22. Phase 65: runtime terminal evidence. **Closed 2026-06-24, QA PASS** - (`internal/docs/finished-plans/phase65_finishedplan_runtime_terminal_evidence.md`). - Rebuild runtime results now distinguish running/caught_up/blocked without - claiming frontend publication or failback. -23. Phase 66: caught-up publication preflight. **Closed 2026-06-24, QA PASS** - (`internal/docs/finished-plans/phase66_finishedplan_caught_up_publication_preflight.md`). - Caught-up rebuild evidence feeds the next publication preflight while - keeping ACK eligibility, frontend publication, and failback disabled. -24. Phase 67: ACK eligibility publication. **Closed 2026-06-25, QA PASS** - (`internal/docs/finished-plans/phase67_finishedplan_ack_eligibility_publication.md`). - Terminal caught-up evidence can now record ACK eligibility, still without - frontend publication, rebuild traffic, or failback. -25. Phase 68: frontend publication preflight. **Closed 2026-06-25, QA PASS** - (`internal/docs/finished-plans/phase68_finishedplan_frontend_publication_preflight.md`). - The product surfaces frontend-publication as an explicit disabled - preflight rather than implying it from ACK eligibility. -26. Phase 69: frontend publication target contract. **Closed 2026-06-25, QA PASS** - (`internal/docs/finished-plans/phase69_finishedplan_frontend_publication_target_contract.md`). - A typed `SwBlockFrontendPublication` target exists, but it creates no - frontend or authority side effect. -27. Phase 70: frontend publication executor boundary. **Closed 2026-06-25, QA PASS** - (`internal/docs/finished-plans/phase70_finishedplan_frontend_publication_executor_boundary.md`). - The executor writes disabled status only. -28. Phase 71: frontend publication live API boundary. **Closed 2026-06-25, QA PASS** - (`internal/docs/finished-plans/phase71_finishedplan_frontend_publication_live_api_boundary.md`). - Live Kubernetes API/RBAC proves the executor remains status-only. -29. Phase 72: frontend publication runtime contract. **Closed 2026-06-25, QA PASS** - (`internal/docs/finished-plans/phase72_finishedplan_frontend_publication_runtime_contract.md`). - A generic typed HTTP runtime seam exists for future publication work. -30. Phase 73: frontend publication authority owner guard. **Closed 2026-06-25, local PASS** - (`internal/docs/finished-plans/phase73_finishedplan_frontend_publication_authority_owner_guard.md`). - The returned-replica pipeline now blocks independent frontend publication - when `primaryUnchanged=true`, because making a returned replica active is an - authority/failback operation, not a standalone runtime status success. -31. Phase 74: returned-replica failback contract. **Closed 2026-06-25, local PASS** - (`internal/docs/finished-plans/phase74_finishedplan_returned_replica_failback_contract.md`). - The ACK-after returned-replica state now surfaces an explicit - `authority.failback_returned_replica` action and disabled executor contract. - It names `failback` as the future mutation envelope, requires terminal - evidence for authority ownership, epoch advance, single-primary state, and - publish-target swap, and still performs no failback or frontend publication. -32. Phase 75: returned-replica failback target owner. **Closed 2026-06-25, local PASS** - (`internal/docs/finished-plans/phase75_finishedplan_failback_target_owner.md`). - A disabled-by-default target owner can convert a ready - `authority.failback_returned_replica` contract into a - `SwBlockReplicaFailback` handoff CR only after ACK eligibility, frontend - fencing, durable-frontier coverage, and identity-isolation evidence are - present. It can create the target object only; it cannot write status, - finalizers, Events, storage/workloads, authority state, frontend - publication, or failback execution. -33. Phase 76: returned-replica failback executor boundary. **Closed 2026-06-25, local PASS** - (`internal/docs/finished-plans/phase76_finishedplan_failback_executor_boundary.md`). - The failback executor can read `SwBlockReplicaFailback` targets and write - disabled/blocked status through `swblockreplicafailbacks/status`. It remains - status-only: no failback, authority epoch advance, primary reassignment, - publish-target swap, frontend publication, or storage mutation is executed. -34. Phase 77: returned-replica failback runtime contract. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase77_finishedplan_failback_runtime_contract.md`). - The failback executor now has an explicit runtime request/response contract - and execution-policy gate. Default behavior remains disabled. A test/fake - runtime can prove the terminal evidence shape for authority epoch advance, - single-primary state, publish-target swap, and no storage mutation, but no - real blockmaster failback endpoint or authority mutation is shipped. -35. Phase 78: failback authority runtime seam. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase78_finishedplan_failback_authority_runtime.md`). - Returned-replica failback now has a first product-owned authority seam: - validated endpoint and expected-current evidence can mint - `Publisher.apply(IntentReassign)` and prove epoch advance, single-primary - state, and publish-target swap. Default deployed behavior remains disabled; - no automatic failback call-site, frontend publication, storage mutation, or - workload mutation is enabled. -36. Phase 79: failback authority call-site. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase79_finishedplan_failback_authority_callsite.md`). - The failback executor can now invoke an in-process - `AuthorityFailbackRuntime` adapter under the explicit execution-policy - gate. The adapter advances the Publisher authority line and writes - `failed_back` only after terminal evidence. Stale expected-current evidence - blocks the call-site; frontend publication and storage mutation remain - false. The deployed controller loop still does not perform automatic - failback. -37. Phase 80: master failback runtime factory. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase80_finishedplan_master_failback_runtime_factory.md`). - Blockmaster now exposes a master-owned failback authority runtime factory - backed by its live Publisher. A host-level gate proves product-loop-seeded - authority can advance through the runtime while no public failback RPC, - automatic failback loop, frontend publication, or storage mutation is - enabled. -38. Phase 81: failback service RPC. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase81_finishedplan_failback_service_rpc.md`). - Blockmaster now registers a `FailbackService.ExecuteFailback` RPC that is - disabled by default behind `--failback-runtime-rpc`. When explicitly - enabled, it delegates to the master-owned failback runtime and can advance - the live Publisher with expected-current and terminal evidence. Default - installs still do not expose an active failback mutation path. -39. Phase 82: failback executor gRPC runtime. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase82_finishedplan_failback_executor_grpc_runtime.md`). - The failback executor can now call blockmaster's FailbackService through a - gRPC runtime transport when `--enable-execution`, `--execution-policy`, and - `--failback-runtime-grpc-addr` are all explicit. HTTP runtime remains - supported; HTTP and gRPC transports are mutually exclusive. Default - behavior remains status-only. -40. Phase 83: failback runtime chart wiring. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase83_finishedplan_failback_chart_runtime_wiring.md`). - Helm can now render the disabled-by-default blockmaster failback RPC and - failback-executor gRPC runtime flags when every execution switch is - explicit. Default chart behavior remains non-mutating. The chart fails fast - for dry-run execution, missing execution policy, and ambiguous HTTP/gRPC - runtime transports. -41. Phase 84: failback integrated gRPC smoke. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase84_finishedplan_failback_integrated_grpc_smoke.md`). - A local integrated test now drives the failback executor through - `GRPCFailbackRuntime` into a real blockmaster `FailbackService`, which then - advances the master-owned Publisher. This proves executor status, - authority-epoch advance, and publish-target swap through the real service - path while keeping frontend publication and storage mutation false. -42. Phase 85: failback executor policy safety. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase85_finishedplan_failback_executor_policy_safety.md`). - Execution flags alone are now explicitly tested as insufficient: with no - target, the executor performs zero runtime calls; with an invalid target it - writes blocked status and still performs zero runtime calls. A valid target - remains the only path that may call the failback runtime. -43. Phase 86: failback gRPC runtime endpoint decoupling. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase86_finishedplan_failback_grpc_runtime_endpoint_decoupling.md`). - Explicit gRPC failback runtime no longer depends on the legacy target-local - HTTP `runtimeEndpoint` field. HTTP endpoint fallback remains supported, and - invalid targets still block without runtime calls. -44. Phase 87: failback documentation alignment. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase87_finishedplan_failback_docs_alignment.md`). - README, product roadmap, and engineering wiki now agree that returned-replica - failback runtime is opt-in/source-gated, automatic deployed failback is not - claimed, and frontend publication after failback was still future work at - that point. Phase 98 later closed the explicit opt-in frontend-publication - and workload-I/O gate. -45. Phase 88: failback deployed suite packaging. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase88_finishedplan_failback_deployed_suite.md`). - Helm can now render the complete opt-in failback component suite: - blockmaster failback RPC, failback target owner, failback executor, explicit - execution policy, and gRPC runtime address. The gate also adds - `failbackTargetOwner` values-schema coverage and keeps default installs - non-mutating. This remains a packaging gate, not an automatic live failback - release claim. -46. Phase 89: SwBlockVolume authority facts. **Closed 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase89_finishedplan_swblockvolume_authority_facts.md`). - `SwBlockVolume.status`, operator-snapshot, and reports now carry the - current primary replica, publish target, authority epoch, and endpoint - version so later failback planning does not infer authority from stale or - side-channel state. -47. Phase 90: failback targets require current authority facts. **Closed - 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase90_finishedplan_failback_target_authority_gate.md`). - The failback target owner refuses to create targets unless the source - `SwBlockVolume.status` contains positive current-authority evidence, and it - stamps expected-current replica/epoch guards on the target. -48. Phase 91: explicit failback target activation policy. **Closed - 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase91_finishedplan_failback_target_activation_policy.md`). - Failback target activation is default-off and requires both an explicit - activation policy and a runtime endpoint before the target can be marked - executable. -49. Phase 92: failback target-owner -> executor handoff. **Closed - 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase92_finishedplan_failback_target_executor_handoff.md`). - The target owner and executor now share an executable target contract that - preserves expected-current authority guards and terminal returned-replica - evidence through the handoff. -50. Phase 93: multi-volume failback handoff isolation. **Closed 2026-06-26, - local PASS** - (`internal/docs/finished-plans/phase93_finishedplan_failback_handoff_isolation.md`). - Multi-volume target-owner/executor handoff keeps volume IDs, returned - replicas, expected-current authority, and target data/control addresses - isolated. -51. Phase 94: deployed failback suite render + gRPC smoke. **Closed - 2026-06-26, local PASS** - (`internal/docs/finished-plans/phase94_finishedplan_failback_deployed_grpc_smoke.md`). - The full opt-in Helm suite renders with blockmaster failback RPC, - target-owner activation, and executor gRPC runtime flags, and the executor - can call a real blockmaster FailbackService in a local Go smoke. -52. Phase 95: live deployed failback suite smoke. **Closed 2026-06-26, live PASS** - (`internal/docs/finished-plans/phase95_finishedplan_failback_live_deployed_suite.md`). - This gate pays the real k3s cost: fresh images, Helm install, first-volume - authority line, returned-replica failback contract injection, target - creation, executor gRPC call to live blockmaster, terminal `failed_back` - status, RBAC boundary, and cleanup. It still does not claim frontend - publication or workload-visible path switch. -53. Phase 96: failback terminal evidence to frontend publication target. **Closed - 2026-06-26, runner PASS** - (`internal/docs/finished-plans/phase96_finishedplan_failback_frontend_publication_target.md`). - The frontend-publication target owner now accepts terminal - `SwBlockReplicaFailback.status=failed_back/failback_completed` evidence and - creates a disabled `SwBlockFrontendPublication` target with explicit - failback-source fields. The executor remains default-off; no frontend path - is published. -54. Phase 97: frontend publication executor call-site. **Closed 2026-06-26, - runner PASS** - (`internal/docs/finished-plans/phase97_finishedplan_frontend_publication_executor_callsite.md`). - The executor can invoke a frontend-publication runtime for an enabled - failback-source target only under explicit policy and writes - `frontend_published` only from valid terminal evidence. Workload-visible - I/O remains a separate gate. -55. Phase 98: failback frontend workload close gate. **Closed 2026-06-26, - live PASS** - (`internal/docs/finished-plans/phase98_finishedplan_failback_frontend_workload_close.md`). - The deployed opt-in suite now proves the full returned-replica operation - loop through live k3s: first PVC writer/reader, returned-replica failback, - product-owned frontend publication, post-publication writer/reader I/O, and - zero-residue cleanup. Default automatic failback remains off. -56. Phase 99: NVMe ANA baseline. **Closed 2026-06-26, runner PASS** - Current code already has ANA Identify/Get Log Page behind an ANA provider, - blockvolume projection-backed ANA state, direct-host P4 ANA/multipath - gates, and P5 Kubernetes CSI single-path NVMe protocol selection. The next - parity gap is Kubernetes CSI NVMe multipath attach: multiple NVMe frontend - paths for one NQN/NSID must survive master status, CSI publish context, - NodeStage, app writer/reader, and cleanup evidence. -57. Operation milestone release readiness. **Active, image-publish blocked** - The operation layer is release-ready from code/QA perspective, but it must - not be marked shipped until matching `seaweed-block` and - `seaweed-block-csi` images are published from the same commit and pass the - pinned-image Day-1 smoke. NVMe multipath is not part of this release claim. -58. Phase 100: Kubernetes CSI NVMe multipath attach. **Closed 2026-06-27, - live k3s PASS** - The supported lab path now proves dynamic PVC `protocol=nvme`, - `replicationFactor=2`, two NVMe frontend paths for one NQN/NSID, CSI - publish/NodeStage multipath attach, mounted writer/reader I/O, and zero - Seaweed Block NVMe residue after delete. This is not a RoCE, performance, - broad host compatibility, production HA, or soak claim. -59. Phase 101: NVMe Hardening And Soak. **Closed 2026-06-28, runner PASS** - The supported-lab NVMe path now has status-surface identity and health - projection, a one-path-loss gate that prevents false Ready, a repeated - stage/unstage zero-residue gate, and a bounded mounted writer/reader soak. - This remains a supported-lab claim only: no RoCE, production HA, broad host - compatibility, performance/SLO, or backup/restore claim. -60. Phase 102: NVMe Release Artifact Smoke. **Active, image-publish blocked** - Validate that matching published `seaweed-block` and `seaweed-block-csi` - images contain the Phase 100/101 NVMe behavior. The gate pulls the release - images, runs Kubernetes CSI NVMe multipath attach against the image pair, - and runs the Phase 101 standalone hardening gates using binaries extracted - from the published `seaweed-block` image. If images are missing, the gate - blocks as an artifact-readiness issue, not a product failure. -61. Phase 103: NVMe Multi-Host / RoCE Preflight. **Closed 2026-06-29, - runner PASS** - Adds a read-only host capability gate for NVMe/TCP and RoCE candidacy. RDMA - hardware plus `nvme-rdma` module availability can make a host a candidate, - but still does not permit a RoCE or performance product claim. -62. Phase 104: RoCE Live-I/O Feasibility Boundary. **Closed 2026-06-29, - runner PASS** - Makes the current target boundary explicit: `--nvme-transport=rdma` is - rejected because only NVMe/TCP is implemented. This is a refusal gate, not a - RoCE implementation. -63. Phase 105: NVMe/TCP Multi-Host Topology Boundary. **Closed 2026-06-29, - runner PASS** - Cross-node loopback NVMe/TCP evidence now blocks with - `publish_target_loopback_cross_node`, never emits false `Ready=True`, and - surfaces the read-only `observe.inspect_publish_target_topology` action - instead of an iSCSI remediation. -64. Phase 106: NVMe/TCP Cross-Node Non-Loopback Live Attach. **Closed - 2026-06-29, live k3s PASS** - Proved the positive multi-host path with a routable NVMe/TCP target: - blockvolume on `m01`, workload on `m02`, publish target - `192.168.1.181:4420`, protocol `nvme`, managed-volume - `ready/first_volume_verified`, writer/reader verified, and strict cleanup - audit `cleanup_status=ok`. This still excludes RoCE, performance/SLO, - broad compatibility, and production HA. -65. Phase 107: NVMe/TCP Multi-Volume Cross-Node Isolation. **Closed - 2026-06-29, live k3s PASS** - Proved the new routable NVMe/TCP path with two PVCs in the supported lab: - `protocol=nvme`, app pods pinned to `m02`, `writer_verified_count=2`, - `reader_verified_count=2`, managed volumes - `ready/first_volume_verified`, two distinct volume IDs, two distinct NVMe - NQNs, no loopback publish target, no cross-volume identity mix-up, and - strict cleanup audit `cleanup_status=ok`. This still excludes RoCE, - performance/SLO, broad compatibility, production HA, and broader scale. -66. Phase 108: NVMe/TCP Multi-Volume Lifecycle Soak. **Closed 2026-06-29, - live k3s PASS** - Ran two consecutive two-PVC NVMe/TCP cross-node lifecycle cycles with app - pods pinned to `m02`. Each cycle verified two writers and two readers, then - helper cleanup waited for generated blockvolume pods, matching PVs, and - SeaweedFS NVMe subsystems to drain before declaring `cleanup_status=ok`. - Terminal evidence showed `cycle_1_nvme_residue_count=0`, - `cycle_1_k8s_residue_count=0`, `cycle_2_nvme_residue_count=0`, and - `cycle_2_k8s_residue_count=0`; final strict cleanup returned - `cleanup_status=ok`. -67. Phase 109: NVMe/TCP Status Surface Evidence. **Closed 2026-06-29, - live k3s PASS** - Proved two supported-lab NVMe/TCP PVCs publish matching protocol, NQN, - namespace ID, address, path count, readiness, and reason across - `SwBlockVolume.status.nvme`, report summary, report - `operator-snapshot.json`, dashboard `/operator-snapshot.json`, and - `ops explain`. The gate owns its CRD baseline so stale live CRDs cannot - silently prune new status fields. -68. Phase 110: NVMe/TCP Path-Loss Status Surface Honesty. **Closed - 2026-06-29, runner PASS** - Reused the live mounted NVMe/TCP one-path-loss gate from Phase 101 and - replayed its after-failover `cluster-after-failover.json` through the - support-bundle surfaces. Report summary, report `operator-snapshot.json`, - dashboard `/operator-snapshot.json`, and `ops explain` all preserve - `blocked/nvme_multipath_path_missing`, `path_count=1`, - `multipath_observed=false`, `mutation_allowed=false`, and zero false - `Ready=True`. This is support-surface replay of real standalone path-loss - evidence, not a live Kubernetes CRD negative-path-loss claim. -69. Phase 111: NVMe/TCP K8s Path-Loss CRD Honesty. **Closed 2026-06-29, - runner PASS** - Closed the Phase 110 non-claim in the live Kubernetes path. A real RF=2 - NVMe/TCP PVC first reached `SwBlockVolume.status.nvme.pathCount=2` and - `Ready=True/first_volume_verified`; then one generated blockvolume - deployment was scaled to zero, reducing the observed NVMe path count to one. - `SwBlockVolume.status`, report summary, report `operator-snapshot.json`, - dashboard `/operator-snapshot.json`, and `ops explain` all converged on - `blocked/nvme_multipath_path_missing` with no false volume `Ready=True`, - `mutation_allowed=false`, and zero cleanup residue. -70. Phase 112: NVMe/TCP K8s Mounted Path-Loss I/O. **Closed 2026-06-29, - runner PASS** - Closed the remaining user-visible gap after Phase 111. The live - Kubernetes RF=2 NVMe/TCP path now keeps an already-mounted pod on the same - PVC while one generated blockvolume deployment is scaled to zero. The same - pod UID survives, the pod writes and reads after path loss through the - remaining NVMe path, and the CRD/report/operator-snapshot/dashboard/explain - surfaces still report `blocked/nvme_multipath_path_missing` with no false - volume `Ready=True`, `mutation_allowed=false`, and zero cleanup residue. -71. Phase 113: NVMe/TCP K8s Mounted Path Restore. **Closed 2026-06-29, - runner PASS** - Closed the matching restoration loop for the supported-lab path. After the - Phase 112 one-path-loss state, the removed blockvolume deployment is scaled - back to one replica. The same mounted pod UID survives, the pod writes and - reads after restore, and `SwBlockVolume.status`, report, - operator-snapshot, and explain converge back to two observed NVMe paths and - `Ready=True/first_volume_verified`, with zero cleanup residue. -72. Phase 114: NVMe/TCP K8s Multi-Volume Mounted Path Isolation. **Closed - 2026-06-30, runner PASS** - Extends the Phase 112/113 single-volume mounted path-loss/restore proof to - two independent RF=2 NVMe/TCP PVCs. When one generated blockvolume - deployment is scaled to zero, the affected volume reports - `blocked/nvme_multipath_path_missing` with one live host path, the - untouched volume remains `ready/first_volume_verified` with two live host - paths, both mounted pods keep their UIDs, both continue I/O, and there is - no cross-volume reason mix-up. After the removed deployment is restored, - both volumes return to `Ready=True/first_volume_verified` with two live - host paths and mounted I/O still works, with zero cleanup residue. -73. Phase 115: NVMe/TCP Mounted Multi-Volume Path Churn Soak. **Closed - 2026-06-30, runner PASS** - Extends Phase 114 from a one-shot multi-volume loss/restore proof to a - bounded churn proof: alternate path loss and restore across two mounted - RF=2 NVMe/TCP PVCs for multiple cycles, preserving mounted pod identity, - writer/reader I/O, volume identity, publish-target isolation, reason-code - isolation, two-path restoration, and zero cleanup residue. -74. Phase 116: NVMe/TCP Supported-Lab Release Claim Packaging. **Closed - 2026-06-30, docs PASS** - Convert the closed Phase 100-115 evidence into a user-facing supported-lab - claim: README/docs wording, feature/status matrix, release non-claims, and - a concise release-smoke plan that uses matching published - `seaweed-block`/`seaweed-block-csi` images when available. This is a - packaging and claim-boundary phase, not a new transport feature. -75. Phase 117: NVMe/TCP Published-Image Release Smoke. **Active, gate - implemented; waiting for images** - Run the representative NVMe/TCP supported-lab smoke against matching - published `seaweed-block` and `seaweed-block-csi` images via - `scripts/run-phase117-nvme-release-image-smoke-gate.sh` / - `testops/scenarios/nvme-tcp-release-image-smoke-chain.yaml`. If images are - not available, this phase blocks as artifact-readiness, not as product - failure. Do not mark the NVMe/TCP path as a published-image release claim - until this smoke passes. -76. Phase 118: NVMe/RDMA Transport Seam. **Implemented locally; QA pending** - Start the RoCE/NVMe-RDMA implementation track without making a false RoCE - claim. The NVMe target now has an explicit transport selector and listener - seam: TCP remains the default implemented path, RDMA returns a typed - unsupported error at the target layer, and `blockvolume - --nvme-transport=rdma` still refuses publicly until a real RDMA listener - lands. -77. Phase 119: Mono RDMA Evidence And NVMe/RDMA Decision. **Closed - 2026-07-02, evidence decision** - Use the current mono RDMA/VFS/RustVolume/NIXL work under - `C:\work\rdma\seaweed-mono-rdma-refresh` as read-only evidence before - adding more block RDMA code. That work proves real VFS/object acceleration - and NIXL-shaped object compatibility, but it is not an NVMe-oF/RDMA target - implementation. Phase 119 records the reusable components and performance - evidence, keeps RoCE/NVMe-RDMA as a non-claim, and chooses the conservative - next step: first run a block NVMe/TCP performance baseline to find the - actual bottleneck. -78. Phase 120: NVMe/TCP Management-LAN Baseline. **Closed 2026-07-02, - QA PASS** - Add a supported-lab Kubernetes PVC gate that measures the current NVMe/TCP - path on the default Kubernetes InternalIP/LAN network. The passing run used - `192.168.1.181:4420` and recorded sequential write/read MiB/s plus - small-write IOPS. This is a functional/default-network baseline, not the - authoritative 100GbE performance baseline. It keeps explicit non-claims for - RoCE, NVMe/RDMA, performance SLO, GPU/cuObject, NIXL, broad compatibility, - and published-image support. -79. Phase 121: Data-Plane Address Capability. **Closed 2026-07-02, - QA PASS** - Mirrors the Rust volume RDMA pattern before rerunning performance gates: - data-plane addresses are explicit, queryable, and surfaced as evidence - instead of inferred from Kubernetes InternalIP. The product now carries - per-node `frontendIP` / `frontendNetworkClass`, renders `data_addr` on the - configured data-plane IP while keeping `ctrl_addr` on management/InternalIP, - and surfaces the management/frontend distinction in status evidence. The - gate proves `192.168.1.x` is not reused as the performance target and keeps - RoCE/NVMe-RDMA unsupported. -80. Phase 122: NVMe/TCP 100GbE Live Baseline. **Closed 2026-07-03, - QA PASS** - Re-ran the Phase 120 performance shape using the Phase 121 data-plane - address model. The live publish target was `10.0.0.1:4420` with - `publish_target_network_class=100gbe_tcp`, route device `enp1s0np0`, - sequential write `115.11 MiB/s`, sequential read `250.98 MiB/s`, and - small-write `606.64 IOPS`. This is a baseline, not a performance/SLO - claim. The gate also fixed the ClusterEvidence gRPC wire path so - `frontend_ip` and `frontend_network_class` survive `blockmaster -> - sw-block ops`. -81. Phase 123: NVMe/TCP Performance Bottleneck Triage. **Closed 2026-07-03, - QA PASS** - Added an independent `iperf3` comparator over the same `10.0.0.x` - data-plane route and proved the network is not the immediate bottleneck: - `network_baseline_mibps=4106.55` while mounted Block NVMe/TCP read/write - were `248.06 MiB/s` / `127.74 MiB/s`. The gate names the remaining - bottleneck as `unknown` because target/backend/Kubernetes/test-shape are - not yet separated, and recommends `phase124_target_backend_shape_split`. -82. Phase 124: NVMe/TCP Target / Backend / Shape Split. **Closed 2026-07-03, - QA PASS** - Compared the current Block NVMe/TCP mounted path with a same-shape - Kubernetes `local-path` PVC on the same app node. The network baseline was - `3769.28 MiB/s`; local-path write/read were `324.87 MiB/s` / - `235.29 MiB/s`; Block NVMe/TCP write/read were `118.74 MiB/s` / - `273.50 MiB/s`. The read path is not behind local-path, but write is only - `0.366x` local-path, so the next bottleneck class is - `block_target_or_backend`. -83. Phase 125: Block NVMe/TCP Write-Path Profile. **Closed 2026-07-03, - QA PASS** - Profiled a 512MiB write over the configured `10.0.0.x` NVMe/TCP path and a - same-node `local-path` comparator. Block write was `174.33 MiB/s` while - local-path write was `1147.98 MiB/s` (`0.152x`), but Block read was - `544.10 MiB/s` versus local-path read `513.54 MiB/s` (`1.060x`). Coarse - pod-level CPU samples did not show target CPU saturation - (`blockvolume_cpu_peak_percent=0.80`), so the next direction is backend / - sync write instrumentation. -84. Phase 126: Block NVMe/TCP Backend Write Instrumentation. **Closed - 2026-07-03, QA PASS** - Added product-owned write-path timing/counter evidence on - `/status/durable` and the Phase 126 gate. The same 512MiB mounted - NVMe/TCP shape measured Block write `177.72 MiB/s` versus local-path write - `1115.47 MiB/s` (`0.159x`), with target/backend write bytes matching - `588075008`. Cumulative operation timing localized the immediate write - cost to backend writes (`backend_write_duration_ms=33186`, - `backend_sync_duration_ms=73`), not frontend network or sync/flush. -85. Phase 127: NVMe ANA Change Notice. **Closed 2026-07-03, - source/component PASS** - Closed the source/component NVMe protocol gap before write-path - optimization: OAES ANA Change Notice is advertised only when an ANA - provider exists, and a parked Async Event Request completes as - Notice/ANA Change/ANA log page when the provider's ANA change count - advances. No-provider OAES remains zero and the single-slot AER limit is - still enforced. -86. Phase 128: NVMe ANA Change Notice Host Gate. **Closed 2026-07-03, - runner PASS** - Proved that a real Linux NVMe/TCP initiator receives the ANA Change Notice - during standalone r1->r2 failover. The m02 host tracepoint - `nvme:nvme_async_event` observed `NVME_AEN=0x0c0302`, decoding to - Notice / ANA Change / ANA log page; OAES ANA Change Notice was advertised, - the ANA log change count advanced from `4294967297` to `8589934593`, host - path state refreshed, mounted I/O remained correct, and cleanup was clean. -87. Phase 129: Kubernetes NVMe Mounted Restage Contract. **Closed 2026-07-03, - runner PASS** - Closed the necessary CSI node-side restage contract: if `NodeStageVolume` - is invoked again for an already-mounted NVMe staging path, the node plugin - refreshes publish context, connects missing NVMe paths for the same NQN, - rejects mounted NQN mismatch, and does not remount or reformat. This phase - deliberately does not claim an automatic Kubernetes reconnect trigger. -88. Phase 130: Kubernetes NVMe Reconnect Owner / Trigger Gate. **Closed - 2026-07-04, runner PASS** - Added the source/component owner contract: an opt-in CSI-node loop refreshes - mounted NVMe publish evidence and invokes the bounded reconnect path. It is - disabled by default and does not itself claim live Kubernetes failover. -89. Phase 131: Kubernetes NVMe Host-Path Reconnect Live Gate. **Closed - 2026-07-04, runner PASS** - Proved a mounted RF=2 NVMe/TCP PVC survives scoped host path loss: - `nvme disconnect -d ` removes one path, CSI-node reconnects it, - pod UID/I/O are preserved, and CRD/report/dashboard agree. -90. Phase 132: Kubernetes NVMe Desired Path-Set Change Gate. **Closed - 2026-07-04, runner PASS** - Proved changed control-plane desired path evidence: a generated frontend - address is replaced, `SwBlockVolume.status.nvme.nvmeAddrs` changes - old-to-new, CSI-node connects the new desired path, and mounted I/O - continues. The run exposed stale old host-path residue. -91. Phase 133: Kubernetes NVMe Stale Path Pruning Close Gate. **Closed - 2026-07-04, runner PASS** - Closed the Phase 132 residue: after desired path replacement, CSI-node - connects the new desired path and prunes the stale old host path for the - same NQN using scoped controller disconnects, with pod UID/I/O preserved - and cleanup clean. -92. Phase 134: Durable Backend Write Batching. **Closed 2026-07-04, - runner PASS** - Returned to the Phase 126 backend-write bottleneck with a correctness-first - batch seam. Contiguous full-block writes now use bounded storage - `WriteBatch` calls, `walstore` performs a real batch WAL append path while - keeping one WAL record/LSN per block, and `/status/durable` exposes - internal storage-call/batch counters. The live NVMe/TCP gate observed - `backend_storage_write_blocks=28872`, - `backend_storage_write_calls=3634`, - `backend_storage_batch_calls=3613`, and clean cleanup. This is not a - performance/SLO or NVMe/RDMA claim. -93. Phase 135: Post-Batch NVMe/TCP Write-Path Retriage. **Closed - 2026-07-04, runner PASS** - Reran the comparable 512MiB mounted NVMe/TCP profile after batching. - Batch counters were active at scale - (`backend_storage_batch_calls=17953`, - `backend_storage_batch_blocks=143555`), but write throughput remained in - the same range as Phase 126 (`172.80 MiB/s` versus `177.72 MiB/s`) while - local-path write was `1075.63 MiB/s`. The live gate classified the - post-batch bottleneck as `backend_write` and recommends Phase 136 - `wal_append_copy_checksum_profile`. -94. Phase 136: WAL Append / Copy / Checksum Profile. **Closed 2026-07-04, - runner PASS** - Added product-owned `/status/durable` counters for WAL copy, record encode, - checksum, append/write-at, and dirty-map update. The comparable 512MiB - mounted NVMe/TCP gate kept backend batching active - (`backend_storage_batch_calls=17952`) and named `wal_encode` as the largest - backend-internal cost (`753ms`), with copy close behind (`593ms`). The next - evidence-backed phase is reducing WAL record encode/copy cost, not NVMe/RDMA - or a performance/SLO claim. -95. Phase 137: Reduce WAL Record Encode / Copy Cost. **Closed 2026-07-05, - runner PASS** - Removed the extra pre-encode block copy and changed batch append to encode - records directly into the coalesced pending write buffer, while keeping the - WAL format and one-record-per-block LSN semantics unchanged. The live - 512MiB gate reduced `wal_encode + wal_copy` from the Phase 136 baseline - `1346ms` to `363ms`; the next named bottleneck is `wal_append`, so Phase - 138 should inspect WAL pwrite shape/coalescing. -96. Phase 138: WAL WriteAt Shape Profile. **Closed 2026-07-05, - runner PASS** - Added product-owned append write-at shape counters: - calls/bytes/max/avg plus wrap count and padding bytes. The live 512MiB gate - showed `wal_append_writeat_calls=17979`, - `wal_append_writeat_avg_bytes=33013`, and - `wal_append_writeat_max_bytes=33072`, with only 8 wraps and 13KB padding. - The append bottleneck is therefore small-write/coalescing shape, not - wrap/padding or NVMe/RDMA. -97. Phase 139: WAL Append Batch Shape Coalescing. **Closed 2026-07-06, - runner PASS** - Added upstream write-shape counters and proved the 33KB WAL write-at shape - is frontend-request-limited: `backend_write_request_max_bytes=32768`, - `backend_full_block_batch_max=8`, and - `wal_append_writeat_max_bytes=33072`. The WAL writer is coalescing the - batch it receives; the next evidence-backed phase is frontend/NVMe request - size profiling rather than speculative cross-request WAL buffering. - -The internal release-train contract is -`internal/docs/ref/operation-layer-v0.5-release-train.md`. Phases 41-44 close -the operation-layer loop for a bounded `SwBlockVolume` protection finalizer. -Phase 46 reused this same fact -> judgment -> action -> evidence pattern for -returned-replica reintegration before any larger storage feature is enabled. -Phases 47-54 close the executor-admission, preflight, status-schema, ACK -evidence, executor-contract, disabled executor-process bridge, and first -bounded ACK eligibility mutation without allowing frontend publication, rebuild -traffic, or failback. Phases 56-59 extend that same pattern to returned-replica -rebuild planning: contract, target CR, target owner, and planned status before -any real rebuild/catch-up traffic is enabled. Phases 60-65 prove and wire the -bounded rebuild/catch-up runtime path through terminal evidence. Phases 66-67 -record ACK eligibility after terminal caught-up evidence. Phases 68-73 define -and then deliberately constrain frontend publication: the generic runtime seam -exists, but returned-replica publication remains blocked until a real -authority/failback owner is implemented and gated. Phase 74 names that missing -owner contract explicitly as `authority.failback_returned_replica` while -keeping execution disabled. Phase 75 adds the first target-owner seam for that -contract: `SwBlockReplicaFailback` can be planned as a handoff object, but no -failback, authority mutation, or frontend publication is executed. Phase 76 adds -the matching executor identity and status-only boundary for those failback -targets, still keeping all real failback side effects disabled. Phase 77 adds -the typed failback runtime contract and opt-in execution gate. Phase 78 adds -the first authority-owned failback seam through `Publisher.apply(IntentReassign)`. -Phase 79 wires that seam to the failback executor as an explicit-policy-gated -in-process call-site. Phase 80 exposes the corresponding master-owned factory -from the component that owns the live Publisher. Automatic deployed failback, -frontend publication, and storage/workload mutation remain disabled. Phase 81 -adds the disabled-by-default RPC boundary that a separate failback executor can -call in a later phase; default installs still keep the mutation path off. -Phase 82 adds that executor-side gRPC runtime transport, still requiring -explicit execution policy and an explicit blockmaster address. Phase 83 packages -that path in Helm while preserving the default-off boundary and adding render -guardrails for incoherent execution values. Phase 84 closes the local -fake-service gap by proving the executor gRPC runtime against the real -blockmaster service and master Publisher. Phase 85 proves the deployed-loop -safety invariant: explicit execution flags do not cause runtime calls without a -valid executable target. Phase 86 removes the stale coupling that made the gRPC -runtime path require an unrelated HTTP target endpoint. Phase 87 aligns the -public/internal docs with that source-gated state. Phase 88 packages the -complete failback target-owner/executor/RPC suite behind explicit Helm values -and schema coverage, while still deferring the live automatic failback claim to -a later Kubernetes smoke. Phase 89-95 add the current-authority facts, -activation policy, executor handoff, multi-volume isolation, deployed render, -real blockmaster gRPC smoke, and finally a live Kubernetes smoke that writes -terminal `failed_back` evidence. Phase 96 consumes that terminal evidence to -create a disabled frontend-publication target. Phase 97 wires the -explicit-policy executor call-site for that target and proves terminal -frontend-publication evidence. Phase 98 closes the deployed user-visible loop: -product-owned frontend publication after failback is followed by workload -writer/reader verification and zero-residue cleanup. - -The practical rule is: - -```text -Do not add a new data-plane feature if the product cannot yet explain who owns -the lifecycle action, what evidence authorizes it, how it is blocked, and where -the user sees the result. -``` - -## Future Read-Write Control Plane - -The operation layer should evolve from status-only and bounded finalizer -mutation into broader read-write behavior in stages, not as one large -"operator does everything" jump. - -Current proven boundary: - -- CSI owns `SwBlockVolume` identity/spec creation. -- operator-status owns `.status` and Events. -- lifecycle-owner owns only the Seaweed Block protection finalizer. -- cleanup, repair, rebuild, failback, backup, and upgrade execution are not - automatic operator actions. - -The next read-write stages should be ordered by blast radius: - -1. `safe_k8s`: repair only Seaweed Block-owned Kubernetes objects, with - admission/RBAC confinement and terminal evidence. -2. `host_cleanup`: clean stale iSCSI/multipath/hostPath residue through a - node-scoped executor, never through operator-status. -3. `authority_mutating`: productize returned-replica rebuild/reintegration and - failback with fencing, frontier evidence, and multi-volume isolation. -4. `data_lifecycle`: snapshot, backup, and restore after the consistency and - identity model is explicit. - -The design reference is -[`wiki/deep-dives/read-write-control-plane-roadmap.md`](wiki/deep-dives/read-write-control-plane-roadmap.md). -The product rule remains: a mutating action needs live facts, preconditions, -an owner executor, an admission/RBAC boundary, user-visible status, and QA -evidence before it can be enabled. - -## Future GPU Data Paths - -GPU-oriented storage should be treated as a future design train, not as a -small flag on the current PVC path. There are three different tracks: - -1. `cuFile` over a mounted Seaweed Block PVC: first prove API compatibility - and byte-correct reads/writes on a supported Linux GPU node. -2. `cuObject` / object path: design a SeaweedFS object/S3-style GPU API with - its own consistency, auth, and commit semantics. -3. Protocol-level GPU/RDMA/NVMe path: investigate only after the file/object - claims are separated and the fencing/backpressure model is clear. - -The first acceptable claim is narrow: - -```text -On one supported Linux GPU node, a pod can use cuFile against a mounted -Seaweed Block PVC and verify byte-correct data transfer with documented -environment prerequisites. -``` - -It must not claim broad GPUDirect acceleration, zero-copy, multi-node failover, -or object API support until the evidence proves those separately. The design -reference is -[`wiki/deep-dives/gpudirect-cufile-cuobject.md`](wiki/deep-dives/gpudirect-cufile-cuobject.md). - -## Future Non-Kubernetes Adapters - -Kubernetes CSI remains the primary product surface. A Docker integration is -possible later, but it should be scoped as a Docker Volume Plugin, not a Docker -graph/storage driver. - -Potential Docker Volume Plugin path: - -- `docker volume create -d seaweed-block ...` -- local attach/mount/unmount through a small node agent or local daemon -- reuse ManagedVolume status, cleanup verification, support bundles, and - negative-first evidence -- target single-node Docker, lab, edge, or developer workflows first - -Explicit non-goals for the Docker path: - -- no Docker graph/storage driver to replace `overlay2` -- no broad Docker Swarm HA claim before the K8s lifecycle model is stable -- no production failover claim without fencing, cleanup, and residue gates - -Windows Docker Desktop support is an investigation item, not a current claim. -The likely path is a Linux Docker Desktop VM or WSL2 backend running the -Seaweed Block node component, with Windows accessing the mounted volume through -Docker. Native Windows block-device attachment is out of scope until the Linux -control-plane path is mature. - -## Availability And Recovery Follow-Ups - -1. Multi-node Kubernetes test. - - - at least two nodes - - non-loopback frontend target - - dynamic PVC attach from a pod on another node - -2. Failover while mounted. - - - pod writes - - primary dies - - authority moves - - frontend reconnect path is validated - -3. Productized returned replica lifecycle. - - - observed replica returns after promotion - - returned replica stays frontend-fenced until recovery evidence is current - - candidate -> syncing/rebuilding -> ready is visible in CRD/report/dashboard - - ready status gates placement/ACK eligibility - - rebuild/reintegration/failback action owner is explicit and audited - - current authority facts are visible in `SwBlockVolume.status` - (`primaryReplicaID`, `publishTarget`, `authorityEpoch`) before any - failback activation path consumes them - - failback handoff targets carry `expectedCurrentReplicaID` and - `expectedCurrentEpoch` from volume status, while failback execution and - frontend publication remain separate opt-in gates - - failback target activation is explicit and default-off: policy plus runtime - endpoint are required before a target can be stamped `enabled` - - target-owner to executor handoff is locally gated: expected-current - authority facts reach the runtime request and terminal evidence controls - `failed_back`; live deployed failback remains a separate release gate - - multi-volume handoff isolation is gated before live runtime testing, so - expected-current facts and target addresses cannot silently cross volumes - - the full opt-in failback suite renders coherently and the executor can call - a real blockmaster gRPC FailbackService in local test; live Kubernetes PVC - failback remains a separate release gate - -4. Flow-control and pressure behavior. - - - pin too slow - - WAL retention pressure - - sync/full-ack unavailable policy - -## Protocol And Backend Roadmap - -1. iSCSI and NVMe-oF are the current release-gated frontends. - - iSCSI remains the default path for broad compatibility. NVMe-oF is now - covered by ANA-aware direct-host multipath/failover, CSI protocol selection, - a supported-lab Kubernetes CSI NVMe multipath attach gate, and Phase 101 - path-status/stage-unstage/bounded-soak hardening. Broader host - compatibility, RoCE, performance/SLO, and long-soak claims remain future - work. Mono SeaweedFS RDMA/VFS/object evidence is tracked separately from - Seaweed Block NVMe/RDMA because RDMA memory movement and NVMe-oF/RDMA host - initiator compatibility are different protocol problems. - - The runtime should be managed as a cluster of explicit mini-protocols: - authority/epoch, replication recovery, iSCSI, NVMe, CSI lifecycle, and - TestOps run-control. Each mini-protocol needs structured status and tests; - avoid a single large protocol abstraction until repeated transition logic - proves it is worth extracting. See `runtime-state-machines.md`. - -2. CSI dispatch is protocol-aware. - - The CSI layer dispatches by frontend target protocol: - - ```text - protocol=iscsi -> iscsiadm path - protocol=nvme -> nvme connect path - ``` - -3. `walstore` remains the default backend while its existing commit pipeline - is optimized. - - Phase 167's `parallel-walstore` preserves its tested global LSN/frontier, - crash recovery, and catch-up/rebuild semantics, but remains explicit and - opt-in because its 4 KiB throughput/scaling gate failed. Phase 168 then - tested a bounded Linux `io_uring` submission/completion owner against the - same controls. Correctness passed, but comparable performance did not: - native execution reached only 0.96x the legacy single-writer path and 0.96x - four-writer scaling, so the candidate was removed rather than promoted. - Phase 169 then changed the persistence unit to checksummed multi-entry - segments. Format, recovery, Sync, and failure semantics passed, but the - optimistic m02 gate measured four-writer scaling of only `0.772x` and - `0.990x` the positioned control. That candidate was also removed before - checkpoint/rebuild integration. Phase 170 targets the existing default - `WALStore.Write` path and existing-format `appendBatch` seam instead of - adding another backend. Direct I/O, fixed buffers, FUA, and device - atomic-write support remain evidence-gated follow-ups. - -## Contributor-Friendly Work Items - -Good first technical areas: - -- improve Kubernetes manifests and docs -- add TestOps scenarios -- improve logs and diagnostic collection -- add protocol-neutral CSI target dispatch tests -- reduce `g7-debug` log noise behind a flag - -Requires deeper storage context: - -- recovery/failover semantics -- WAL retention and flow control -- replica reintegration -- multi-node authority/publisher changes -- broader V2 parity and long-running protocol regression coverage - -## Definition Of Beta - -A reasonable beta bar: - -- K8s install path is a Helm chart with documented values and immutable images. -- Dynamic PVC create/delete works repeatedly. -- Volume data survives blockvolume pod restart. -- Multi-node attach works. -- Basic failover is tested under an attached workload. -- Read-only status and support evidence are available without SSH log spelunking. -- Negative and stale states are surfaced without false Ready claims. -- Operator lifecycle is either present behind a clear beta gate or explicitly - listed as the next release boundary. -- TestOps can run the protocol release gate and produce stable artifacts. -- Non-claims are documented and visible to users. - -Detailed post-alpha execution planning is kept in `internal/docs/` so the -public roadmap stays focused on user-visible behavior and non-claims. diff --git a/seaweed-block/docs/user-capabilities.md b/seaweed-block/docs/user-capabilities.md index 50b5632b8a..9ce28691e9 100644 --- a/seaweed-block/docs/user-capabilities.md +++ b/seaweed-block/docs/user-capabilities.md @@ -1,8 +1,15 @@ -# Seaweed Block User Capabilities +# Seaweed Block User Capabilities (Kubernetes) -This page describes what a user can do with the current Seaweed Block alpha, -what evidence is available, and what is still outside the product boundary. -For the exact release evidence, see [`releases/README.md`](releases/README.md). +**Use this when:** you operate the Kubernetes alpha and need to know what it +does today, which read-only operations commands exist, and what its status +vocabulary means. + +This page covers Kubernetes block volumes. Agent workspace disks (chunk +snapshots, forks and host moves, a proof of concept) are described in the +[README](../README.md#agent-workspace-disks-chunk-lifecycle) and the +[standalone deployment](standalone-deployment.md) guide. Feature status is in +[Kubernetes status](kubernetes-status.md); the exact release evidence is in +[`releases/README.md`](releases/README.md). ## Primary User Loop @@ -233,15 +240,9 @@ The current status model is negative-first: ## Cleanup -The documented cleanup path is: - -```bash -helm uninstall sw-block --namespace kube-system -bash scripts/uninstall-k8s-alpha.sh "$PWD" -bash scripts/verify-helm-cleanup.sh -``` - -The verifier checks: +The cleanup commands and the expected clean output are in the +[quickstart](quickstart-kubernetes.md#cleanup). `scripts/verify-helm-cleanup.sh` +checks: - Helm and Kubernetes resources, - iSCSI sessions, @@ -251,17 +252,6 @@ The verifier checks: - product processes, - hostPath residue. -Expected clean shape: - -```text -cleanup_status=ok -k8s_residue_count=0 -iscsi_residue_count=0 -multipath_residue_count=0 -process_residue_count=0 -hostpath_residue_count=0 -``` - ## Recommended Learning Path 1. Run the quickstart: install, first PVC, writer/reader, cleanup. @@ -275,21 +265,13 @@ hostpath_residue_count=0 ## Explicit Non-Claims -- Not production-ready. -- No production-grade operator or controller-manager lifecycle. -- No broad mutating admin/dashboard workflow. The current bounded mutations are - limited to lifecycle-owner finalizer ownership and authority-executor ACK - eligibility target status. -- No finalizer ownership by operator-status. -- No automatic cleanup execution. -- No upgrade or rollback execution. -- No promote, repair, rebuild, failback, delete, backup, restore, or cleanup +The full list is in +[what you should not expect yet](kubernetes-status.md#what-you-should-not-expect-yet). +In addition: + +- The current bounded mutations are limited to lifecycle-owner finalizer + ownership and authority-executor ACK eligibility target status. There is no + promote, repair, rebuild, failback, delete, backup, restore, or cleanup mutation through UI/API/operator. -- No backup/snapshot/restore workflow. -- No returned-replica rebuild traffic, frontend publication, or automated - failback. -- No transparent Kubernetes node-loss failover without pod recreate. - No NVMe ANA parity for the transparent failover path. -- No broad distro/kernel/initiator compatibility matrix. -- No upgrade or rollback execution. - No performance, RTO, RPO, or SLO claim. diff --git a/seaweed-block/docs/wiki/code-map.md b/seaweed-block/docs/wiki/code-map.md index e0234badf5..5baba180b2 100644 --- a/seaweed-block/docs/wiki/code-map.md +++ b/seaweed-block/docs/wiki/code-map.md @@ -3,13 +3,15 @@ This page maps product responsibilities to code entry points. It is a guide for developers; it is not a complete API reference. +**Use this when:** you look for the package or file that owns a behavior. + ## Commands | Command | Responsibility | Key files | |---|---|---| | `sw-block` | operations CLI, report/dashboard/explain, operator-status, lifecycle-owner | `cmd/sw-block/main.go` | | `blockmaster` | control-plane master and launcher coordination | `cmd/blockmaster/main.go`, `core/host/master/` | -| `blockvolume` | per-volume data-plane process, status endpoint, readiness publishing | `cmd/blockvolume/main.go`, `core/storage/` | +| `blockvolume` | per-volume-replica data-plane process, frontends, status endpoint, readiness publishing | `cmd/blockvolume/main.go`, `core/storage/` | | `blockcsi` | Kubernetes CSI controller/node integration | `cmd/blockcsi/main.go`, `core/csi/` | ## Core Packages @@ -18,10 +20,25 @@ developers; it is not a complete API reference. |---|---| | `core/ops` | ManagedVolume model, status projection, CRD writer, action evaluator, lifecycle-owner | | `core/csi` | CSI CreateVolume/DeleteVolume, Kubernetes metadata registration, target staging | -| `core/storage` | WAL/store behavior and dirty-failure handling | +| `core/lifecycle` | desired volumes, node inventory, placement intent, verified placement | +| `core/authority` | assignment and epoch publication, workspace moves | +| `core/launcher` | renders and reconciles per-replica `blockvolume` workloads | | `core/host/master` | blockmaster observation and volume coordination | +| `core/host/volume` | blockvolume host: assignment, projection bridge, status, workspace lease | +| `core/frontend/iscsi`, `nvme`, `ublk` | block frontends over one Read / Write / Sync backend contract | +| `core/frontend/durable` | durable provider and the per-I/O lineage gate | +| `core/frontend/chunkstore` | SeaweedFS chunk backend: HEAD CAS, catalog, snapshots, GC | +| `core/storage` | walstore (WAL plus extent), chunk layer, recovery | +| `core/storage/smartwal` | experimental in-place engine | +| `core/replication`, `core/recovery`, `core/transport` | RF>1 shipping, catch-up and rebuild, replica fencing | | `testops` | scenario descriptions and release gates | +The [core design](../design/block-design.md) explains the storage, +durability, authority and replication packages in depth; the +[agent workspace design](../design/agent-workspace-design.md) covers the +workspace packages and the [Kubernetes block design](../design/kubernetes-block-design.md) +the CSI, operator and promotion packages. + ## Ownership Split The current operation layer uses three separate owners: @@ -41,10 +58,9 @@ mutation and prevents lifecycle ownership from becoming a broad operator. |---|---| | Write operator CRD status | `core/ops/operator_status_controller.go` | | Patch Kubernetes status | `core/ops/kubernetes_status_writer.go` | -| Evaluate safe actions | `core/ops/action_model.go` | +| Evaluate safe actions | `core/ops/managed_volume_action_evaluator.go` | | Add/release protection finalizer | `core/ops/lifecycle_owner_controller.go` | | Register `SwBlockVolume` from CSI | `core/csi/kubernetes_metadata.go` | -| Evaluate future read-write action maturity | `core/ops/action_model.go`, future owner executors | | Project delete-safety from cleanup evidence | `core/ops/observation_bundle.go` | | Parse cleanup verifier output | `core/ops/cleanup_evidence.go` | | Enrich live node/CSI evidence | `cmd/sw-block/main.go`, `core/ops/kubernetes_node_evidence.go` | @@ -54,7 +70,6 @@ mutation and prevents lifecycle ownership from becoming a broad operator. | CRD/RBAC status conformance | `core/ops/kubernetes_status_writer.go`, `core/ops/kubernetes_status_conformance_test.go`, `charts/seaweed-block/crds/` | | blockvolume process readiness | `cmd/blockvolume/main.go`, `core/host/volume/host.go`, `core/frontend/durable/` | | Release image/chart compatibility | `charts/seaweed-block/templates/`, `charts/seaweed-block/values.yaml`, `docs/releases/`, `docs/quickstart-kubernetes.md` | -| Future GPUDirect/cuFile probes | no current product code; expected first home is a TestOps/helper utility plus later `core/ops` evidence ingestion | ## Development Rule @@ -71,7 +86,3 @@ failure bundle evidence ``` If any item is missing, the feature is not ready for product code. - -Future GPU data-path work has an additional rule: identify whether the claim is -file path (`cuFile` over a mounted PVC), object path (`cuObject`/S3-style), or -transport path (RDMA/NVMe). Do not mix those claims in one code path or test. diff --git a/seaweed-block/docs/wiki/coverage-matrix.md b/seaweed-block/docs/wiki/coverage-matrix.md deleted file mode 100644 index b9809bad0a..0000000000 --- a/seaweed-block/docs/wiki/coverage-matrix.md +++ /dev/null @@ -1,81 +0,0 @@ -# Engineering Coverage Matrix - -This matrix is the review checklist for whether the wiki covers the last -several months of Seaweed Block work. It is domain-based rather than phase-based -because developers need to understand subsystems, ownership, and invariants, not -just the order in which phases happened. - -Coverage levels: - -| Level | Meaning | -|---|---| -| `linked` | source docs are linked, but wiki explanation is thin | -| `mapped` | wiki explains the domain, ownership, code area, and source evidence | -| `deep` | wiki includes background, contract, ownership, state transitions, code entry points, evidence, failure taxonomy, implementation checklist, and QA gates | - -## Domain Coverage - -| Domain | Why it matters | Source evidence | Current wiki coverage | Next doc work | -|---|---|---|---|---| -| Product positioning and claims | Prevents over-claiming and release confusion | `docs/releases/`, `docs/roadmap.md`, `docs/user-capabilities.md` | mapped | claim-boundary page by release | -| Day-1 Kubernetes install and first PVC | User entry path and release smoke | Phase 20, 25, 40, 44 finished plans; quickstart | mapped | install flow diagram and troubleshooting | -| CSI lifecycle | PVC/PV path, CreateVolume/DeleteVolume, node stage/publish | `core/csi`, `docs/runtime-state-machines.md`, Phase 44 D2 | deep | expand DeleteVolume details later | -| SwBlockVolume CR identity | Bridge from CSI to operation layer | Phase 44 D2 sign-off, `core/csi/kubernetes_metadata.go` | deep | add field-by-field CRD contract later | -| operator-status | CRD status, Events, node evidence, cleanup/delete-safety | Phases 35-40, `core/ops` | deep initial | add status writer/schema conformance page | -| lifecycle-owner | bounded finalizer add/release | Phases 41-44, lifecycle-owner refs | deep initial | add admission policy field matrix | -| Admission/RBAC boundary | Prevents finalizer owner from becoming broad operator | Phase 42 sign-off, Helm templates | linked | VAP/RBAC decision diagram | -| Delete-safety | Holds unsafe deletion, releases on clean evidence | Phase 39, 42, 44; finalizer-delete-safety contract | deep initial | field-by-field status contract | -| Cleanup verifier | Zero-residue authority and safety evidence | cleanup scripts, Phase 29, 36, 44 | mapped | residue taxonomy | -| ManagedVolume readiness | Shared ready/blocked/unknown model | Phase 22, 32, 35-36 | deep initial | add reason-code taxonomy | -| Node readiness / CSI evidence | Avoids false node-ready status | Phase 37 | deep | keep live K8s evidence current as CRD evolves | -| SmartWAL dirty failure | Proves dirty storage evidence cannot become false Ready | Phase 34 | deep | add exact test log excerpts later | -| WAL/frontier/barrier/recovery | Persistence and recovery vocabulary behind dirty-failure and rebuild | methodology docs, recovery tutorial, Phase 34 | deep | add exact SmartWAL layout diagrams later | -| Authority / epoch / promotion | One-primary, fencing, restart authority persistence | Phases 13-18, 31, invariant ledger | deep initial | add code-level product-loop walkthrough | -| Returned-replica rebuild/reintegration | Next major storage lifecycle feature | recovery refs, roadmap | deep initial | add concrete future gate plan | -| Read-write control-plane maturity | Prevents broad operator mutation from outrunning facts/evidence/admission | Phases 38-44, action/finalizer/delete-safety contracts | deep initial | split future safe_k8s, host_cleanup, authority, and data-lifecycle pages when each starts | -| iSCSI frontend / ALUA / multipath | Current default frontend and transparent failover path | iSCSI refs, Phase 17, 27, 37 | deep | keep artifact examples current as scenarios evolve | -| NVMe ANA parity | Planned protocol parity path | NVMe refs, roadmap | linked | future protocol page | -| GPUDirect/cuFile/cuObject | Future GPU data paths need separate block/file/object/transport claims | NVIDIA GDS/cuFile docs, roadmap | deep initial | add hardware-backed compatibility evidence when available | -| TestOps runner and scenarios | Product evidence, not just tests | `testops/`, Phase 33-34 | deep initial | add runner action reference | -| Support bundle/replay/report/dashboard | Cold-reader diagnosis and support path | Phases 23-24, 28, 32, 36, 44 | deep | keep artifact list aligned with collect script | -| Release engineering | Image/chart skew prevention | Phases 40, 44, release notes | deep | keep current release checklist aligned | -| Status writer conformance | Real CRD/RBAC/admission validation | Phases 35-42, Phase 40 | deep | turn remaining schema-aware gates into envtest/live | -| blockvolume process/readiness | Separates process liveness, diagnostics, durable recovery, and frontend readiness | Phase 34, `cmd/blockvolume` | deep | add flag matrix examples as needed | -| Docker volume plugin idea | Future non-K8s adapter | roadmap | linked | investigation page later | - -## Coverage Decision - -The wiki is useful when each major domain has: - -```text -problem statement -industry/product pattern -Seaweed Block ownership model -state machine or protocol diagram -publish/API shape -main code entry points -evidence contract -failure taxonomy -implementation checklist -QA gates and failure evidence -explicit non-claims -``` - -## Priority For Deep Pages - -1. CSI lifecycle and `SwBlockVolume` ownership. -2. Operation layer v0.5: operator-status + lifecycle-owner + admission. -3. ManagedVolume readiness and negative-first priority rules. -4. SmartWAL dirty-failure path. -5. TestOps authoring and evidence realism. -6. Authority/promotion/restart persistence. -7. iSCSI ALUA/multipath frontend. -8. WAL/frontier/barrier/recovery. -9. Live node/CSI evidence. -10. Support bundle cold-reader path. -11. Returned-replica rebuild readiness. -12. Future read-write control-plane maturity. -13. GPUDirect/cuFile/cuObject future design. - -These pages cover most of the hard-earned knowledge from the last -few months. The rest can remain linked until those are reviewed. diff --git a/seaweed-block/docs/wiki/deep-dives/gpudirect-cufile-cuobject.md b/seaweed-block/docs/wiki/deep-dives/gpudirect-cufile-cuobject.md deleted file mode 100644 index c9ea57e99e..0000000000 --- a/seaweed-block/docs/wiki/deep-dives/gpudirect-cufile-cuobject.md +++ /dev/null @@ -1,281 +0,0 @@ -# GPUDirect, cuFile, And cuObject Future Design - -This page is a future design note for GPU-oriented data paths. It is not a -current Seaweed Block capability. - -## Reader Orientation - -You need this page before proposing: - -- GPUDirect Storage support, -- cuFile-based reads/writes from a Seaweed Block PVC, -- GPU-to-object-store data paths, -- cuObject-like object access, -- RDMA/NVMe protocol changes for GPU workloads. - -The product question is: - -```text -Can Seaweed storage serve GPU workloads without unnecessary CPU bounce buffers, -while preserving the same evidence, fencing, and lifecycle model as the block -product? -``` - -## External Background - -NVIDIA GPUDirect Storage (GDS) is the family of technology that lets supported -storage paths move data between storage and GPU memory with reduced CPU -copying. cuFile is the user-space API commonly associated with GDS file I/O. - -Useful external references: - -- [NVIDIA GPUDirect Storage documentation](https://docs.nvidia.com/gpudirect-storage/) -- [NVIDIA cuFile API reference](https://docs.nvidia.com/gpudirect-storage/api-reference-guide/index.html) - -Important practical point: - -```text -cuFile is a file API path. -Seaweed Block is currently a Kubernetes block/PVC path. -SeaweedFS object is a different object/API path. -``` - -So GPUDirect work must not be treated as one flag on the existing block -frontend. It is a product train with separate prerequisites and gates. - -## Vocabulary - -| Term | Meaning in this design | -|---|---| -| GPU memory | CUDA device memory used by training/inference jobs | -| GPUDirect Storage | storage-to-GPU path that avoids normal CPU bounce behavior where supported | -| cuFile | NVIDIA API for file I/O involving GPU memory | -| cuObject | future object-storage style API concept for GPU-oriented object reads/writes | -| cuObject path | not current code; design placeholder for SeaweedFS object/S3 integration | -| block path | Seaweed Block PVC mounted as filesystem | -| object path | SeaweedFS object/S3-style object access | - -## Product Tracks - -### Track A: cuFile Over A Seaweed Block PVC - -Shape: - -```text -Kubernetes pod --> mounted Seaweed Block PVC --> filesystem path --> cuFile reads/writes --> GPU memory -``` - -This is the most natural bridge from Seaweed Block to GPU workloads, but it is -not automatically supported just because a PVC mounts. GDS compatibility depends -on OS, driver, kernel, filesystem, mount options, device path, and NVIDIA -software stack. - -The first question is compatibility: - -```text -Can a supported GDS/cuFile stack use the mounted Seaweed Block volume path? -``` - -Only after compatibility is proven should we optimize the backend. - -### Track B: cuObject / GPU Object Path - -Shape: - -```text -GPU workload --> cuObject-like client/API --> SeaweedFS object/S3 path --> object storage data -``` - -This is not the same product as Seaweed Block. It belongs closer to SeaweedFS -object/KV/VFS design. It may share: - -- authentication, -- object metadata, -- RDMA/network transport ideas, -- support-bundle methodology, -- TestOps evidence realism. - -But it should not borrow block-volume authority/finalizer semantics without a -separate object lifecycle model. - -### Track C: Protocol-Level GPU/RDMA Data Path - -Shape: - -```text -GPU memory --> RDMA/NVMe/RoCE capable transport --> storage target -``` - -This is the deepest path and should come after Track A compatibility and Track -B object API shape are understood. It touches transport, memory registration, -security, flow control, and failure semantics. - -## Product Contract For A First Gate - -A minimal first claim should be narrow: - -```text -On one supported Linux GPU node, a pod can use cuFile against a mounted -Seaweed Block PVC and verify byte-correct data transfer with documented -environment prerequisites. -``` - -It should not claim: - -- broad GDS support, -- multi-node failover with GPU memory, -- GPU-direct over iSCSI unless proven, -- object API support, -- performance/SLO, -- production compatibility across distros/drivers. - -## Architecture Boundary - -```mermaid -flowchart TD - A[GPU workload] --> B{Access shape} - B -->|file path| C[cuFile / GDS] - C --> D[Mounted filesystem on PVC] - D --> E[Seaweed Block CSI + frontend] - B -->|object path| F[cuObject-style client] - F --> G[SeaweedFS object/S3 path] - B -->|transport path| H[Future RDMA/NVMe data path] - H --> I[Storage target] -``` - -The three branches have different APIs and should have different claims. - -## Required Facts Before Implementation - -Track A needs: - -```text -gpu_present=true -nvidia_driver_version= -cuda_version= -gds_installed=true -nvidia_fs_loaded=true -cufile_available=true -filesystem_type= -mount_options=<...> -volume_protocol= -direct_io_supported= -byte_check_passed= -``` - -Track B needs: - -```text -object_api= -gpu_client_api= -auth_model=<...> -object_consistency_model=<...> -range_read_semantics=<...> -write_commit_semantics=<...> -``` - -Track C needs: - -```text -rdma_device=<...> -memory_registration=<...> -queue_pair_or_nvme_queue=<...> -fencing_model=<...> -backpressure_model=<...> -data_integrity_check=<...> -``` - -## State Machine For Track A - -```mermaid -stateDiagram-v2 - [*] --> PrereqProbe - PrereqProbe --> Unsupported: missing GPU/driver/GDS/cuFile - PrereqProbe --> MountProbe: prerequisites present - MountProbe --> Unsupported: filesystem or mount not usable by cuFile - MountProbe --> CuFileOpen: file path accepted - CuFileOpen --> TransferTest: buffer registration and read/write start - TransferTest --> Verified: checksum matches - TransferTest --> Blocked: I/O error, fallback, or mismatch - Verified --> [*] -``` - -## Evidence Contract - -A first cuFile gate should emit: - -```text -gpu_direct_gate_status= -gpu_model= -nvidia_driver_version= -cuda_version= -gds_version= -nvidia_fs_loaded= -cufile_open= -cufile_read= -cufile_write= -checksum_cpu_path= -checksum_gpu_path= -fallback_detected= -volume_protocol= -filesystem= -mount_path= -``` - -If fallback cannot be detected reliably, the claim must say only -"cuFile API compatibility", not "zero-copy" or "GPUDirect accelerated". - -## Code / Project Map - -| Area | Likely owner | -|---|---| -| K8s PVC mount path | Seaweed Block CSI | -| cuFile smoke utility | new test utility, likely outside core storage first | -| GPU environment probe | TestOps runner action or helper script | -| object path / cuObject | SeaweedFS object/VFS design, not `core/csi` | -| RDMA/NVMe transport | future protocol/transport work | -| status/report integration | `core/ops` once evidence format stabilizes | - -## Failure Taxonomy - -| Reason | Meaning | -|---|---| -| `gpu_not_present` | no usable GPU in test node | -| `nvidia_driver_missing` | driver stack absent | -| `gds_not_installed` | GPUDirect Storage/cuFile unavailable | -| `nvidia_fs_not_loaded` | kernel module/runtime missing | -| `filesystem_unsupported` | mounted volume path not compatible | -| `direct_path_fallback` | cuFile may be falling back through CPU path | -| `checksum_mismatch` | data correctness failed | -| `protocol_path_unsupported` | iSCSI/NVMe path not supported for this gate | -| `object_semantics_undefined` | cuObject track lacks consistency/commit model | - -## Implementation Checklist - -1. Start with a read-only environment probe; do not change storage code first. -2. Write a standalone cuFile smoke utility that can run inside a pod. -3. Mount a normal Seaweed Block PVC and run CPU checksum baseline. -4. Run cuFile read/write checksum against the same file. -5. Record whether the path is API-compatible versus truly accelerated. -6. Add TestOps gate with explicit unsupported/blocked reasons. -7. Only after compatibility is proven, decide whether iSCSI, NVMe, or a new - transport needs optimization. -8. Keep cuObject/object-path design separate from PVC/block semantics. -9. Add support-bundle evidence before any user-facing claim. - -## Non-Claims - -- No current Seaweed Block release supports GPUDirect/cuFile. -- cuFile API success would not automatically prove zero-copy acceleration. -- cuObject is a future object-path design placeholder, not current code. -- GPU/RDMA transport work must not bypass authority, fencing, recovery, or - evidence requirements. diff --git a/seaweed-block/docs/wiki/developer-guide.md b/seaweed-block/docs/wiki/developer-guide.md deleted file mode 100644 index 24c174c978..0000000000 --- a/seaweed-block/docs/wiki/developer-guide.md +++ /dev/null @@ -1,186 +0,0 @@ -# Developer Guide - -The engineering wiki exists to reduce rediscovery. It should answer: - -```text -Why was this built? -What invariant does it protect? -Where is the code? -How is it tested? -What is still out of scope? -``` - -## Documentation Layers - -| Layer | Purpose | Source | -|---|---|---| -| README / quickstart | first user path and narrow claims | `README.md`, `docs/quickstart-kubernetes.md` | -| Release notes | exact user-visible claims and image boundary | `docs/releases/` | -| Wiki | developer navigation and explanation | `docs/wiki/` | -| Finished plans | phase completion and historical decisions | `internal/docs/finished-plans/` | -| Ref docs | contracts, audits, design notes | `internal/docs/ref/` | -| Protocol docs | invariants and control-model reviews | `internal/docs/protocol/` | -| QA sign-offs | evidence that a gate passed or failed | `internal/docs/qa-assignments/` | -| TestOps | executable scenario definitions | `testops/` | - -## Writing Rule - -Do not copy a finished plan into the wiki. Instead, write the explanation a new -developer needs and link to the source evidence. - -Assume the reader: - -- can read Go, YAML, and shell, -- understands basic Kubernetes objects, -- does not yet understand block storage, CSI, iSCSI/NVMe, authority, fencing, - WAL recovery, or why finalizers are dangerous, -- has not followed the phase history. - -Good wiki content: - -- problem context, -- short domain primer, -- industry terms and standards involved, -- what Seaweed Block must deliver, -- why the problem is harder than it looks, -- ownership boundary, -- state transition, -- package/function entry point, -- gate name that proves the behavior, -- explicit non-claim. - -Bad wiki content: - -- phase diary copied line-by-line, -- PM wording without code references, -- claims that are not backed by QA, -- TODO lists without an owner or phase. - -## Deep-Dive Page Standard - -Each deep-dive page should use this shape: - -```text -1. Reader orientation - What domain is this? Why should a developer care? - -2. Domain background - Explain industry terms and standards at a practical level. - -3. Product problem - What does Seaweed Block need to deliver? What can go wrong? - -4. Methodology - What facts are observed? What constraints matter? Who decides? Where does - execution happen? What evidence closes the loop? - -5. State machine / protocol diagram - Mermaid first, prose second. - -6. Implementation map - Main packages, key structs/functions, commands, Helm/RBAC surfaces. - -7. Phase history - Which phases solved which part? Name the meaningful failures too. - -8. QA evidence - Which gates prove the behavior? What would fail the gate? - -9. Non-claims and future work - What is explicitly not delivered yet? -``` - -This standard matters because historical design notes can be stale. Use them as -source material for explanation and vocabulary, not as current release claims. - -## Implementation-Grade Density - -A deep-dive page is not `deep` because it is long. It is `deep` only if a -developer could use it to make a correct code change, write the right gate, and -diagnose a failed run. - -For a feature or subsystem page, require these sections: - -| Section | Required content | -|---|---| -| Protocol / domain background | Industry terms, standards involved, and the Linux/Kubernetes objects that actually participate | -| Product contract | The narrow user-visible claim, exact non-claims, and the condition that would make the claim false | -| Ownership model | Which component decides, which component executes, which component only observes, and which fields each may write | -| State machine | Mermaid state or sequence diagram with success, blocked, stale/unknown, and cleanup paths | -| Publish / API shape | CRD fields, CSI publish context, CLI flags, Helm values, Events, status fields, or bundle artifacts | -| Code map | Concrete packages, key structs/functions, scripts, charts, and scenarios | -| Evidence contract | Stable lines or JSON fields that prove the behavior; not just log examples | -| Failure taxonomy | Named blocker reasons, timeouts, and what a cold reader should inspect next | -| Implementation checklist | Ordered engineering steps and fail-closed checks needed to implement or change the feature | -| QA history | The gates that proved the behavior and the important failures that shaped the design | - -If a page only answers "what is this feature?" it is `summary`. If it also -answers "how would I safely implement or modify this feature?" it can be -`deep`. - -Use this density especially for storage-path features such as iSCSI ALUA, -SmartWAL recovery, authority promotion, returned-replica rebuild, CSI lifecycle, -delete safety, and node evidence. Those areas have enough implicit domain -knowledge that a short summary hides the real engineering cost. - -## Local Preview - -Install MkDocs Material and serve the site: - -```bash -pip install mkdocs-material -mkdocs serve -``` - -Open: - -```text -http://127.0.0.1:8000 -``` - -Docker alternative: - -```bash -docker run --rm -it -p 8000:8000 -v "$PWD:/docs" squidfunk/mkdocs-material -``` - -The site is static. It can be served internally with any static file server -after: - -```bash -mkdocs build -``` - -## Diagrams - -Use Mermaid for state machines and sequence diagrams: - -````markdown -```mermaid -stateDiagram-v2 - Ready --> Blocked: evidence fault - Blocked --> Unknown: evidence stale - Unknown --> Ready: fresh verified evidence -``` -```` - -Avoid screenshots for state machines. Mermaid diagrams stay reviewable in Git -and can be updated with the code. - -## Code Links - -For links to Markdown docs inside `docs/`, use normal relative Markdown links. -MkDocs renders those as site links. - -For links to source code under `cmd/`, `core/`, `charts/`, `scripts/`, or -`testops/`, prefer GitHub source links when the target should be clickable in -the built site: - -```markdown -[operator_status_controller.go](https://github.com/seaweedfs/seaweed-block/blob/main/core/ops/operator_status_controller.go) -``` - -MkDocs' default site only serves files under `docs_dir`. It does not render -repo-root source files as pages unless we add a source-link plugin or copy -generated code references into `docs/`. Keep wiki pages as explanations and -link to source-of-truth code rather than duplicating code. diff --git a/seaweed-block/docs/wiki/historical-sources.md b/seaweed-block/docs/wiki/historical-sources.md deleted file mode 100644 index 948f005c4e..0000000000 --- a/seaweed-block/docs/wiki/historical-sources.md +++ /dev/null @@ -1,90 +0,0 @@ -# Historical Knowledge Sources - -This wiki is built on two generations of design material: - -1. current repo docs under `docs/` and `internal/docs/`; -2. older design/tutorial/methodology notes under - `C:\work\seaweedfs\sw-block\design`. - -The older material is important because it explains why the system is shaped the -way it is. Many current docs record what passed QA; the older docs often explain -the block-storage method behind the decisions. - -## Tutorial Series - -Source directory: - -```text -C:\work\seaweedfs\sw-block\design\tutorial -``` - -Important files: - -| File | Use | -|---|---| -| `01-project-map-and-terms.md` | terminology and mental model | -| `02-daemons-flags-and-process-layout.md` | daemon/process layout | -| `03-host-master-stream-and-assignment.md` | heartbeat, assignment, master stream | -| `04-adapter-single-route-and-async-callbacks.md` | adapter event route and callbacks | -| `05-engine-control-protocol.md` | deterministic engine Event/Command loop | -| `06-persistence-wal-logical-storage.md` | WAL and logical storage | -| `07-replication-volume-and-peers.md` | primary fan-out and peers | -| `08-transport-lineage-barrier.md` | lineage, barrier, transport facts | -| `09-recovery-walshipper-dual-lane.md` | recovery / rebuild / catch-up mechanics | -| `10-frontend-projection-iscsi-nvme.md` | frontend readiness projection | -| `11-master-authority-and-grpc.md` | blockmaster and authority | -| `12-inter-server-wire-protocols.md` | wire protocols and messages | -| `13-data-and-recovery-plane-messages.md` | data-plane vs recovery-plane messages | -| `14-core-code-groups-and-files.md` | core package/file map | - -## Methodology Series - -Source directory: - -```text -C:\work\seaweedfs\sw-block\design\methdology -``` - -Important files: - -| File | Use | -|---|---| -| `01-problem-shape-and-method.md` | observe -> constrain -> decide -> execute -> close method | -| `02-block-clump-initiator-target-session-lineage-barrier-recovery.md` | block-storage vocabulary and obligations | -| `03-csi-clump-lifecycle-compiler.md` | CSI lifecycle thinking | -| `04-iscsi-nvme-clump-wire-state-machines.md` | protocol wire-state concerns | -| `05-code-landings-engine-adapter-frontend-transport-recovery-storage.md` | implementation landing zones | -| `06-authority-placement-clump.md` | authority and placement | -| `07-replication-sync-clump.md` | replication/sync | -| `08-recovery-clump.md` | recovery mechanics | -| `09-storage-wal-clump.md` | WAL and local storage | -| `10-projection-readiness-clump.md` | projection vs readiness | -| `11-observability-clump.md` | observability method | - -## Core Vocabulary To Carry Forward - -| Term | Meaning | -|---|---| -| initiator | client side that sends block commands, e.g. host OS or kube node path | -| target/controller | server side accepting protocol commands | -| session | bounded protocol conversation with identity and lifecycle | -| lineage | generation identity; old generation must not override new generation | -| barrier/fence | explicit durability or ordering checkpoint | -| frontier | durable progress boundary that recovery can trust | -| projection | semantic publication of state | -| readiness | execution permission derived from semantic state | - -## Method Rule - -For any subsystem, answer four questions: - -```text -what facts does it observe? -what constraints must those facts satisfy? -who is allowed to decide? -where does the decision become real? -``` - -This is the lens the deep-dive pages should use. If a page only lists code -files, it is not deep enough. - diff --git a/seaweed-block/docs/wiki/index.md b/seaweed-block/docs/wiki/index.md index b5b6d873c0..fc7c9453eb 100644 --- a/seaweed-block/docs/wiki/index.md +++ b/seaweed-block/docs/wiki/index.md @@ -1,53 +1,23 @@ # Seaweed Block Engineering Wiki -This wiki is the engineering map for Seaweed Block development. It is not a -replacement for finished plans, QA sign-offs, or release notes. It is the entry -point that explains how those documents fit together. +This wiki explains how the Kubernetes line of Seaweed Block works, for +developers changing it. It is not a release-claim source: the +[release notes](../releases/README.md) and +[Kubernetes status](../kubernetes-status.md) hold the claims, and the +design documents are the canonical description: the +[core design](../design/block-design.md) (core block service, verification, +known issues), the [agent workspace design](../design/agent-workspace-design.md) +and the [Kubernetes block design](../design/kubernetes-block-design.md). -Seaweed Block has passed through more than ninety phases. A single architecture -document cannot explain the accumulated product model. The useful structure is: +## Pages -```text -problem background --> industry pattern --> Seaweed Block implementation --> state machine / invariant --> code entry points --> QA gates and failure evidence --> current limits and next work -``` - -## How To Read This Wiki - -Start here: - -- [Developer Guide](developer-guide.md) - what belongs in the wiki and what - remains in source evidence. -- [Coverage Matrix](coverage-matrix.md) - whether the wiki covers the major - months-long engineering domains and where deeper docs are still needed. -- [Topic Inventory](topic-inventory.md) - full topic backlog and whether each - topic is implementation-grade, summary-level, mapped, missing, or future. -- [Historical Sources](historical-sources.md) - older tutorial and methodology - material that explains the block-storage method behind the current design. -- [Code Map](code-map.md) - main packages, commands, and responsibility +- [Code Map](code-map.md) - main commands, packages and responsibility boundaries. - [State Machines](state-machines.md) - the product states developers must not violate. -- [Protocol Catalog](protocol-catalog.md) - the current catalog of mini - protocols and state machines that deserve Mermaid diagrams. -- [Phase Map](phase-map.md) - how the early storage phases, operation-layer - closure, and returned-replica failback line connect. -- [Phase Recap](phase-recap.md) - what each phase solved and how the feature - logic accumulated. - [QA and TestOps Map](testops-map.md) - which gates prove which claims. - -Related local docs: - -- [Seaweed RDMA Engineering Wiki](http://192.168.1.135:8011/wiki/) - Rust RDMA - data path, native RC/DC, UCX, pull-RDMA, and future GPU-style destinations. -- [sw-test-runner TestOps Wiki](http://192.168.1.135:8012/wiki/) - - cross-product scenario runner, product testing guides, and live run - dashboard docs. +- [Runtime State Machines](../runtime-state-machines.md) - control-plane, CSI + and frontend loops. ## Current Product Loop @@ -68,33 +38,52 @@ Helm install This is a bounded operation-layer capability. It is not automatic cleanup, not a production operator, and not backup/NVMe expansion. -Recent returned-replica work adds a separately gated, opt-in failback runtime -path. See [Returned Replica Failback Runtime](deep-dives/returned-replica-failback.md) +Returned-replica work adds a separately gated, opt-in failback runtime path. +See [Returned Replica Failback Runtime](deep-dives/returned-replica-failback.md) for the authority owner, target CR, executor, gRPC service, terminal evidence, -and non-claims. As of Phase 97, that line can plan a frontend-publication -target from terminal failback evidence and invoke the publication runtime only -under explicit policy; workload-visible path switching remains a separate gate. +and non-claims. That line can plan a frontend-publication target from terminal +failback evidence and invoke the publication runtime only under explicit +policy; workload-visible path switching remains a separate gate. + +## Deep Dives + +New pages follow the [deep-dive template](deep-dives/template.md). A page is +deep only if a developer could use it to make a correct code change, write the +right gate and diagnose a failed run. + +- [CSI Lifecycle](deep-dives/csi-lifecycle.md) +- [Operation Layer v0.5](deep-dives/operation-layer-v05.md) +- [Status Writer Conformance](deep-dives/status-writer-conformance.md) +- [ManagedVolume Readiness](deep-dives/managed-volume-readiness.md) +- [SmartWAL Dirty Failure](deep-dives/smartwal-dirty-failure.md) +- [WAL Frontier Recovery](deep-dives/wal-frontier-recovery.md) +- [blockvolume Process Readiness](deep-dives/blockvolume-process-readiness.md) +- [Authority And Promotion](deep-dives/authority-promotion.md) +- [iSCSI ALUA Multipath](deep-dives/iscsi-alua-multipath.md) +- [Live Node Evidence](deep-dives/live-node-evidence.md) +- [Support Bundle Cold Reader](deep-dives/support-bundle-cold-reader.md) +- [Release Engineering Image Skew](deep-dives/release-engineering-image-skew.md) +- [Returned Replica Rebuild](deep-dives/returned-replica-rebuild.md) +- [Returned Replica Failback](deep-dives/returned-replica-failback.md) +- [Read-Write Control Plane](deep-dives/read-write-control-plane-roadmap.md) +- [TestOps Authoring](deep-dives/testops-authoring.md) ## Source Evidence -The wiki links to these source areas: - - `docs/` - public and user-facing docs. -- `internal/docs/finished-plans/` - phase-by-phase completion records. -- `internal/docs/ref/` - design references and product contracts. -- `internal/docs/protocol/` - control-model and invariant documents. -- `internal/docs/qa-assignments/` - gate assignments and QA sign-offs. +- `internal/docs/` - phase plans, design references and QA sign-offs. - `testops/` - scenario definitions and suite structure. -When a wiki page conflicts with a finished plan or QA sign-off, the finished -plan or QA sign-off wins. +When a wiki page conflicts with the code, a release note or a QA sign-off, the +wiki page is wrong. -## Depth Standard +## Local Preview -For storage/control-plane topics, a page is only considered deep if it can guide -a code change and a QA gate. It should include protocol or domain background, -product contract, ownership model, state machine, publish/API shape, code -entry points, evidence contract, failure taxonomy, implementation checklist, -QA history, and non-claims. +```bash +pip install mkdocs-material +mkdocs serve # http://127.0.0.1:8000 +``` -A correct summary is still useful, but it is not enough for feature work. +Use Mermaid for state machines and sequence diagrams. Link Markdown pages under +`docs/` with relative links, and source code with GitHub links, since MkDocs +serves only files under `docs/`. diff --git a/seaweed-block/docs/wiki/phase-map.md b/seaweed-block/docs/wiki/phase-map.md deleted file mode 100644 index 02e647d871..0000000000 --- a/seaweed-block/docs/wiki/phase-map.md +++ /dev/null @@ -1,116 +0,0 @@ -# Phase Map - -The phases form a product-learning sequence. They should not be read as a flat -changelog. - -For a per-phase explanation of the problem, feature logic, and remaining gap, -see [Phase Recap](phase-recap.md). - -## Phase Groups - -| Phases | Theme | Outcome | -|---|---|---| -| 1-8 | protocol readiness and beta hardening seed | early frontend/control-plane gates | -| 9-12 | light-use operations and product-owned blockvolume lifecycle | first user-facing operations loop | -| 13-18 | restart, placement, mounted failover, node loss | data-plane recovery semantics | -| 19-24 | observation, ManagedVolume model, dashboard | AI/cold-reader operations surfaces | -| 25-32 | Helm, multi-volume, restart persistence, status surfaces | productized Kubernetes alpha loop | -| 33-34 | failure hardening and test realism | live dirty-failure gates, no false Ready | -| 35-40 | Kubernetes-native read-only operator foundation | CRD status, Events, node evidence, action model, release hardening | -| 41-44 | bounded lifecycle owner | finalizer add/release, delete-safety hold/release, integrated close gate | -| 47-67 | returned-replica ACK/rebuild planning and runtime | eligibility, rebuild target, catch-up runtime, terminal evidence | -| 68-74 | frontend publication and failback contract separation | publication stays blocked until authority-owned failback exists | -| 75-97 | returned-replica failback control path | target CR, executor, runtime, blockmaster RPC, deployed-suite smoke, frontend-publication call-site | - -## The Important Pivot - -The major pivot was from "model looks coherent" to "live product capability is -closed": - -```text -live fact --> judgment --> status/action --> real Kubernetes API boundary --> QA gate --> failure evidence -``` - -This pivot explains why many later phases are operation-layer hardening rather -than new protocol features. Without this closure, rebuild, NVMe, backup, and -failback would add more states than the product can safely explain. - -## Current Closure - -Phase 44 closes this path: - -```mermaid -flowchart LR - A[Helm install] --> B[First PVC] - B --> C[CSI creates SwBlockVolume CR] - C --> D[lifecycle-owner adds protection finalizer] - D --> E[operator-status writes status and Events] - E --> F[Delete requested] - F --> G{cleanup evidence} - G -->|missing/stale/residue| H[hold finalizer] - G -->|fresh clean| I[release protection finalizer] - H --> E - I --> J[CR deletion completes] - J --> K[uninstall zero residue] -``` - -```text -install --> first PVC --> CSI-created SwBlockVolume CR --> lifecycle-owner protection finalizer --> operator-status status/Events --> delete request --> hold on unsafe evidence --> release on clean evidence --> zero residue -``` - -The remaining release step is artifact validation: publish matching immutable -images and rerun pinned-image smoke. - -Returned-replica failback now has a separately gated control path: - -```mermaid -flowchart LR - A[Live authority facts] --> B[Returned replica terminal evidence] - B --> C[SwBlockVolume failback contract] - C --> D[Failback target owner] - D --> E[SwBlockReplicaFailback target] - E --> F[Failback executor] - F --> G[blockmaster FailbackService] - G --> H[Publisher IntentReassign] - H --> I[failed_back terminal target status] - I --> J[disabled SwBlockFrontendPublication target] - J --> K[explicit-policy frontend publication runtime] -``` - -The Phase 97 boundary is explicit: - -```text -authority control path can run when opt-in -frontend publication target can be planned from terminal failback evidence -frontend publication runtime can be called only under explicit policy -workload-visible path switch is still not claimed -``` - -## Next Feature Rule - -A new storage feature should not enter product scope unless it can answer: - -```text -Who owns the facts? -Who judges safety? -Who owns the action? -What admission/RBAC boundary confines it? -Where does the user see hold/release/progress/failure? -Which gate proves no false Ready=True? -``` - -Returned-replica rebuild/failback is the natural next major product capability -because it can reuse the operation-layer model built in Phases 35-44. diff --git a/seaweed-block/docs/wiki/phase-recap.md b/seaweed-block/docs/wiki/phase-recap.md deleted file mode 100644 index 7d8ea7c363..0000000000 --- a/seaweed-block/docs/wiki/phase-recap.md +++ /dev/null @@ -1,144 +0,0 @@ -# Phase Recap - -This page explains what each phase solved. It is not a full changelog. The -goal is to show the product logic: which user or engineering problem existed, -what capability was added, and why the next phase was necessary. - -Source note: Phases with finished plans link to `internal/docs/finished-plans/`. -Phases without a finished-plan file are summarized from release notes, -TestOps scenarios, QA assignments, and adjacent protocol documents. - -## Reading Pattern - -Each phase should be read as: - -```text -problem -> feature/capability -> product logic -> remaining gap -``` - -The late operation phases are not random polish. They turned a model that could -describe storage into a product loop that Kubernetes users can observe, -delete, block, and release safely. - -## Recap Table - -| Phase | Problem solved | Capability added | Product logic / why it mattered | -|---|---|---|---| -| 1 | The frontend protocol surface was not ready for real initiators. | iSCSI/NVMe frontend readiness gates. | Before Kubernetes claims, the target protocol had to speak enough wire behavior to be testable by real clients. | -| 2 | Early beta gates were too broad and slow to guide daily work. | Seed beta-hardening gate. | Created the habit of defining a release gate instead of relying on ad hoc manual smoke tests. | -| 3 | The first beta seed still had unstable or expensive checks. | Stabilized and reduced gate cost. | Made the gate repeatable enough to use as engineering feedback, not just release ceremony. | -| 4 | Fast operations contracts were not separated from long protocol validation. | Fast gates and operations contract prep. | Split "is the code basically safe to merge" from "is the whole product releaseable." | -| 5 | Users had no compact read-only status/report path. | Read-only operations status report. | First step toward explaining the product without SSH log spelunking or internal grep knowledge. | -| 6 | The iSCSI target needed real Linux initiator compatibility. | OS initiator compatibility checks. | Proved the block target could interact with the host stack, not only with synthetic protocol tests. | -| 7 | iSCSI sessions and backend pressure could fail in ambiguous ways. | Session/backend pressure hardening. | Tightened the boundary between frontend sessions and storage backend behavior. | -| 8 | Main merge needed a clear readiness bar. | Merge-readiness plan and gate cleanup. | Made "ready for main" a concrete state rather than a subjective review. | -| 9 | The project needed a first light-use operations story. | Light-use operations MVP. | Established a minimal user path around installing, observing, and cleaning the system. | -| 10 | Install and lifecycle operations were still fragmented. | Light-use install/lifecycle MVP. | Connected install, use, and cleanup into one small lifecycle, exposing where product ownership was missing. | -| 11 | Operators could not inventory the cluster and volume lifecycle clearly. | Cluster ops inventory and lifecycle visibility. | Added the ability to list what exists and why, which is prerequisite to any safe action. | -| 12 | `blockvolume` processes were product side effects, not owned objects. | Product-owned blockvolume lifecycle MVP. | Started moving from helper-launched processes to product-owned lifecycle semantics. | -| 13 | Restart could lose usable volume state. | Durable volume restart and reattach MVP. | Introduced restart persistence as a product concern, not just a process restart. | -| 14 | Multi-node placement and attach were not proven. | Multi-node attach and placement MVP. | Proved the product had to reason about node identity, placement, and frontend reachability. | -| 15 | Basic failover existed below the user surface but not as mounted recovery. | Basic mounted failover and reattach. | Connected authority change to workload-visible recovery behavior. | -| 16 | Mounted recovery needed an ACK/readiness profile. | Stage-1 mounted recovery ACK profile. | Made recovery safer by distinguishing "process alive" from "safe to acknowledge/serve." | -| 17 | Transparent mounted failover needed host multipath evidence. | Stage-2 iSCSI ALUA/dm-multipath failover. | Proved that a mounted workload can survive path change only when host path state is part of evidence. | -| 18 | Whole-node loss could break assumptions about authority and placement. | Node-loss survival MVP. | Forced the product to treat missing nodes as first-class state instead of accidental process failures. | -| 19 | Control-plane facts were not AI/cold-reader readable. | Control-plane observation and AI-readable ops. | Began the shift from logs to structured evidence and explanations. | -| 20 | Day-1 activation was not packaged as a user loop. | Activation / Day-1 ops MVP. | Produced a first install -> first volume -> verify -> cleanup story. | -| 21 | Helm activation needed runner-native proof. | Helm first-volume scenarios. | Moved Day-1 activation toward Kubernetes-native packaging and repeatable TestOps. | -| 22 | Observability lacked a central product object. | `ManagedVolume` operations model. | Defined the volume as users experience it: PVC, replicas, frontend, readiness, blockers, and safe actions. | -| 23 | The ManagedVolume model was not visible enough. | Report/explain/dashboard/operator-readiness surfaces. | Turned the internal read model into user-facing status and Conditions. | -| 24 | The dashboard was local and not hosted as a simple read-only surface. | Hosted read-only dashboard. | Made support/debug information available through a browser without mutation. | -| 25 | Helm and observable first-volume release had to converge. | v0.3 Helm observable first-volume release. | Tied packaging, first PVC, report, dashboard, and cleanup into a release-shaped path. | -| 26 | Helm lifecycle and support diagnostics needed runner coverage. | Helm release hygiene, upgrade/rollback, multi-volume day-1, support bundle gates. | Converted release packaging assumptions into executable scenarios. | -| 27 | RF=3 and failover had to hold under multi-volume pressure. | Multi-volume RF=3 readiness, reattach, mounted failover, interleaved failover. | Proved identity isolation: one volume's recovery must not corrupt another's authority or publish target. | -| 28 | Productized operations close needed consistent surfaces. | Phase 28 productized ops close and support-bundle/dashboard route hardening. | Made README, quickstart, release notes, report, dashboard, and operator snapshot agree on narrow claims. | -| 29 | Cleanup reliability still depended on helper timing and residue assumptions. | Deterministic cleanup evidence and vocabulary. | Made cleanup itself an evidence object with residue counts, failure counts, and downstream report/dashboard carry-through. | -| 30 | CRD/status protocols needed a stable field contract. | ManagedVolume field/status contract alignment. | Prevented each surface from inventing its own vocabulary for the same product state. | -| 31 | Kubernetes restart could resurrect stale authority. | Restart persistence for single-node and RF=3 promoted authority. | Proved primary, publish target, epoch, and data survive k3s restart without old-primary resurrection. | -| 32 | Status surfaces could disagree or over-claim readiness. | CRD/Condition/Event model and surface agreement gates. | Established negative-first behavior across healthy, blocked, restart, multi-volume, and stale evidence surfaces. | -| 33 | TestOps still had self-proving or weak failure checks. | Failure hardening review and scenario realism plan. | Started classifying tests by evidence strength rather than action count. | -| 34 | Dirty storage failures could be hidden behind false Ready. | SmartWAL corruption live gate and no-false-Ready fix chain. | Forced the storage, process readiness, and projection layers to fail closed when WAL integrity evidence is bad. | -| 35 | Kubernetes users needed native CRD status and Events. | Read-only operator-status foundation. | Added `SwBlockCluster`/`SwBlockVolume` status writes, Events, and RBAC-confined status-only behavior. | -| 36 | Status was visible but not actionable enough. | Node readiness, support evidence refs, cleanup visibility, cross-surface actionability. | Turned "something is blocked" into "why, where is evidence, and what safe next step exists." | -| 37 | Live node evidence was incomplete and replay-only in negative cases. | Live K8s node/CSI/image/host-prereq/loopback blockers. | Closed false node-ready masking: cordon, NotReady, missing CSI driver/image, and loopback cross-node blockers surface live. | -| 38 | Actions were still suggestions without an executable contract. | Action model evaluator: allowed dry-run, rejected unsafe, required facts/evidence. | Defined the bridge from read-only observation toward future mutation without enabling broad mutation. | -| 39 | Delete safety needed status before any finalizer mutation. | Delete-safety status boundary and multi-volume isolation. | Proved blocked/releasable/unknown delete decisions could be shown per volume with zero finalizer mutation. | -| 40 | Operator-status needed release-grade hardening. | Production hardening, release candidate gates, image/chart skew detection. | Caught that a chart can be correct against source but broken against published images; release artifacts became part of the gate. | -| 41 | Lifecycle ownership needed role separation before mutation. | Observer/lifecycle-owner/executor foundation. | Separated who observes, who decides, and who may eventually mutate, avoiding a broad operator role. | -| 42 | Finalizer mutation boundary had to be proven against a real API server. | ValidatingAdmissionPolicy/RBAC admission gate and delete-safety decision model. | Proved lifecycle-owner can only patch the protection finalizer, while operator-status remains status/events-only. | -| 43 | The first real product mutation needed bounded add and release. | Protection finalizer add/release gates. | Added the first admitted metadata mutation: hold on missing/blocked/stale delete safety, release only clean/releasable, preserve foreign finalizers. | -| 44 | The integrated delete lifecycle still had manual gaps. | CSI-created protected CR, status publication, delete-request hold/release, multi-volume close gate. | Closed the user-visible loop: PVC -> CR -> finalizer -> status -> delete hold/release -> zero residue. | - -## Recap Addendum: Phases 45-95 - -Phases after 44 reuse the operation-layer closure instead of bypassing it. The -important line is returned-replica recovery: - -| Phase range | Problem solved | Capability added | Product logic / why it mattered | -|---|---|---|---| -| 45-54 | A returned replica could not be admitted back through a bounded executor path. | ACK eligibility CRs, executor preflight/status schema, terminal-evidence gate, first bounded ACK eligibility mutation. | Reintegrating a returned replica starts as evidence and eligibility, not as automatic primary movement. | -| 56-67 | Returned-replica rebuild/catch-up needed a target and runtime loop before failback. | Rebuild target CR, target owner, planned/running/caught-up status, terminal catch-up evidence. | A replica may only become useful after durable frontier evidence proves it caught up. | -| 68-73 | Frontend publication was too dangerous to couple directly to returned-replica eligibility. | Frontend publication target/executor boundaries that deliberately block returned-replica publication. | Publishing a frontend path is separated from ACK/rebuild evidence so the product cannot accidentally expose an unsafe target. | -| 74-88 | Failback needed an authority-owned path rather than frontend-publication inference. | `authority.failback_returned_replica`, `SwBlockReplicaFailback`, failback executor, typed runtime, blockmaster RPC, Helm packaging. | Authority reassignment belongs to blockmaster/Publisher and remains default-off until explicit evidence and policy exist. | -| 89-95 | The packaged failback path still needed current authority facts and live deployed proof. | Authority facts in `SwBlockVolume.status`, expected-current guards, activation policy, handoff isolation, real gRPC smoke, live k3s deployed-suite gate. | The deployable failback control path can now run end-to-end without claiming frontend publication or workload-visible data-path switch. | -| 96 | Terminal failback evidence existed, but frontend publication had no post-failback source object. | `SwBlockReplicaFailback.status=failed_back/failback_completed` can create a disabled `SwBlockFrontendPublication` target with failback-source fields. | The next publication step is explicit, but executor publication and workload-visible path switching remain separate later gates. | -| 97 | The publication target existed, but executor execution flags were not wired through CLI/Helm for post-failback publication. | Explicit-policy CLI/Helm flags invoke the frontend publication runtime for a failback-source target and require terminal `frontend_published` evidence. | Runtime handoff is proven; workload-visible I/O after publication remains the next gate. | - -## Product Logic Across The Phases - -```mermaid -flowchart TD - A[Protocol can serve bytes] --> B[Host can mount bytes] - B --> C[Kubernetes can create and attach a volume] - C --> D[Product can observe the volume] - D --> E[Status surfaces agree] - E --> F[Negative evidence blocks false Ready] - F --> G[Actions are typed and dry-run first] - G --> H[Admission confines first mutation] - H --> I[Delete lifecycle closes with evidence] -``` - -The important transition is between D and I. The project spent many phases -there because a storage product cannot safely add rebuild, failback, backup, -NVMe expansion, or GPU paths if it cannot first explain: - -- which facts are live, -- which facts are stale, -- why a volume is ready, blocked, unknown, or releasable, -- who owns each mutation, -- what admission/RBAC boundary confines it, -- and what evidence proves the mutation completed safely. - -## Why The Operation Loop Was Necessary - -Earlier engine work built useful protocol and recovery pieces, but some of it -was still a logical loop rather than a capability loop. A logical loop can say -"if facts are X, decide Y." A capability loop must prove: - -```text -live system produces fact X -status writes decision Y -user sees Y consistently -unsafe action is rejected -safe action is bounded -terminal evidence closes the loop -cleanup leaves no residue -``` - -Phases 35-44 were about closing that capability loop. That is why the roadmap -now says new storage features should reuse the same fact -> judgment -> action --> evidence structure instead of creating new isolated engines. - -## Source Index - -Representative source files: - -- `internal/docs/finished-plans/phase1_finishedplan_frontend_protocol_readiness.md` -- `internal/docs/finished-plans/phase22_finishedplan_managed_volume_operations_model.md` -- `internal/docs/finished-plans/phase34_finishedplan_test_realism_dirty_failure_hardening.md` -- `internal/docs/finished-plans/phase35_finishedplan_kubernetes_native_read_only_operator_foundation.md` -- `internal/docs/finished-plans/phase41_finishedplan_lifecycle_owner_foundation.md` -- `internal/docs/finished-plans/phase44_finishedplan_delete_lifecycle_close_gate.md` -- `docs/releases/` -- `internal/docs/qa-assignments/` -- `testops/scenarios/` diff --git a/seaweed-block/docs/wiki/protocol-catalog.md b/seaweed-block/docs/wiki/protocol-catalog.md deleted file mode 100644 index 7b40b5b945..0000000000 --- a/seaweed-block/docs/wiki/protocol-catalog.md +++ /dev/null @@ -1,77 +0,0 @@ -# Protocol And State-Machine Catalog - -This page catalogs the state machines and mini-protocols that should be -documented with Mermaid diagrams. It links to the current source references and -names the code or gate area that owns the behavior. - -The catalog is intentionally broader than the current release claim. Some -protocols are implemented and gated; others are planned but need the same -fact -> judgment -> action -> evidence structure before becoming product -claims. - -## Existing Source References - -- [Runtime State Machines](../runtime-state-machines.md) -- `internal/docs/protocol/README.md` -- `internal/docs/protocol/invariant-ledger.md` -- `internal/docs/protocol/managed-volume-operations-model.md` -- `internal/docs/protocol/operator-readiness-contract.md` -- `internal/docs/protocol/finalizer-delete-safety-contract.md` -- `internal/docs/ref/lifecycle-owner-control-contract.md` -- `internal/docs/ref/operation-layer-v0.5-release-train.md` - -## Catalog - -| # | Protocol / state machine | Current source | Main code area | Mermaid status | -|---|---|---|---|---| -| 1 | Control-plane placement to authority publication | `docs/runtime-state-machines.md` | `core/host/master`, launcher/authority code | existing diagram | -| 2 | Data-plane write / sync / WAL boundary | `docs/runtime-state-machines.md` | `cmd/blockvolume`, `core/storage` | existing diagram | -| 3 | Recovery / replication peer lifecycle | `docs/runtime-state-machines.md`, `internal/docs/ref/rf2-promotion-ready-recovery-contract.md` | recovery / replication paths | existing high-level diagram; needs productized rebuild version | -| 4 | Frontend eligibility / stale-owner fencing | `docs/runtime-state-machines.md`, `internal/docs/protocol/invariant-ledger.md` | frontend projection, authority bridge | existing high-level diagram | -| 5 | CSI node stage/publish flow | `docs/runtime-state-machines.md`, `core/csi` | `cmd/blockcsi`, `core/csi` | existing sequence diagram | -| 6 | ManagedVolume readiness projection | `internal/docs/protocol/managed-volume-operations-model.md` | `core/ops` | needs detailed Mermaid | -| 7 | Kubernetes node readiness evidence | `internal/docs/protocol/operator-readiness-contract.md` | `core/ops` live node evidence | needs detailed Mermaid | -| 8 | Cleanup visibility / cleanup verifier evidence | `internal/docs/protocol/operator-readiness-contract.md`, `internal/docs/ref/operation-layer-v0.5-release-train.md` | cleanup verifier, `core/ops/cleanup_evidence.go` | needs detailed Mermaid | -| 9 | Delete-safety decision model | `internal/docs/protocol/finalizer-delete-safety-contract.md` | `core/ops` delete-safety projection | initial diagram in [State Machines](state-machines.md) | -| 10 | Lifecycle-owner finalizer add/release | `internal/docs/ref/lifecycle-owner-finalizer-strategy.md`, `internal/docs/ref/lifecycle-owner-control-contract.md` | `core/ops/lifecycle_owner_controller.go` | initial sequence in [State Machines](state-machines.md) | -| 11 | Kubernetes admission boundary for lifecycle-owner | `internal/docs/ref/phase42-lifecycle-owner-api-admission-gate.md` | Helm VAP/RBAC templates | needs VAP decision diagram | -| 12 | Action model evaluator | `internal/docs/protocol/engine-design-guidelines.md`, Phase 38 docs | `core/ops/action_model.go` | needs Mermaid decision tree | -| 13 | Status writer / CRD schema conformance | Phase 40 status API docs | `core/ops/kubernetes_status_writer.go` | needs request/validation diagram | -| 14 | SmartWAL corruption fail-closed path | Phase 34 finished plan and QA sign-offs | `core/storage`, `cmd/blockvolume`, `core/ops` projection | needs detailed failure-path diagram | -| 15 | iSCSI ALUA / dm-multipath path state | `internal/docs/ref/iscsi-alua-technical-note.md`, `stage2-transparent-multipath-host-failover-spec.md` | iSCSI frontend and host path evidence | needs protocol diagram | -| 16 | NVMe ANA parity path | `internal/docs/ref/nvme-ana-technical-note.md`, `nvme-ana-parity-plan.md` | future NVMe frontend path | planned diagram | -| 17 | Returned-replica rebuild / reintegration | roadmap + recovery refs | recovery + future lifecycle action owner | planned diagram | -| 18 | TestOps run lifecycle and evidence bundle | `internal/docs/ref/testops-control-data-contract.md`, `testops/` | runner/scenarios | needs run-state diagram | -| 19 | Future read-write action execution | Phase 38-44 contracts + roadmap | future safe_k8s/host_cleanup/authority/data lifecycle executors | initial diagram in read-write control-plane deep dive | -| 20 | GPUDirect/cuFile compatibility gate | future design + NVIDIA GDS/cuFile docs | future TestOps helper + ops evidence ingestion | initial diagram in GPUDirect deep dive | - -## Diagram Priority - -The first detailed Mermaid expansions should be: - -1. Operation layer v0.5: facts -> judgment -> action -> admission -> evidence. -2. ManagedVolume readiness projection: how ready/blocked/unknown wins. -3. CSI lifecycle: PVC -> CreateVolume -> `SwBlockVolume` CR -> status/finalizer. -4. SmartWAL dirty-failure path: storage fault -> local readiness block -> - projection no false Ready. -5. TestOps gate lifecycle: live/replay/adversarial gates and evidence bundles. -6. Future mutating action execution: preconditions -> policy -> executor -> - terminal evidence. -7. GPUDirect/cuFile compatibility: GPU/GDS prereq -> mount probe -> transfer - checksum -> supported/blocked/unsupported. - -## Rule For Adding A Diagram - -Every Mermaid diagram should name: - -```text -state names -transition trigger -owner component -evidence artifact -failure state -QA gate -``` - -If a diagram cannot name the evidence artifact or gate, it is probably still a -design sketch rather than a product behavior. diff --git a/seaweed-block/docs/wiki/state-machines.md b/seaweed-block/docs/wiki/state-machines.md index 78459cca61..ea1eb93bf4 100644 --- a/seaweed-block/docs/wiki/state-machines.md +++ b/seaweed-block/docs/wiki/state-machines.md @@ -4,9 +4,10 @@ Seaweed Block development should be driven by state machines and invariants, not by isolated helper scripts. This page names the states developers must preserve. -For the broader list of mini-protocols and diagrams still to add, see -[Protocol Catalog](protocol-catalog.md). For existing runtime diagrams, see -[Runtime State Machines](../runtime-state-machines.md). +For runtime diagrams, see +[Runtime State Machines](../runtime-state-machines.md). Storage state machines are in the +[core design](../design/block-design.md); HEAD, lease and snapshot state +machines are in the [agent workspace design](../design/agent-workspace-design.md). ## Managed Volume Readiness diff --git a/seaweed-block/docs/wiki/topic-inventory.md b/seaweed-block/docs/wiki/topic-inventory.md deleted file mode 100644 index 1a45f44950..0000000000 --- a/seaweed-block/docs/wiki/topic-inventory.md +++ /dev/null @@ -1,142 +0,0 @@ -# Topic Inventory - -This inventory lists the topics the engineering wiki should eventually cover. -It is broader than current release scope. - -Status meanings: - -| Status | Meaning | -|---|---| -| `deep` | implementation-grade: background, contract, ownership, state machine, code map, evidence, failures, checklist, QA | -| `tutorial` | strong explanatory page, but may still miss one or two implementation-grade sections | -| `summary` | page exists but cannot yet guide a safe code change | -| `mapped` | topic appears in catalog/coverage but has no dedicated deep page | -| `missing` | no useful wiki coverage yet | -| `future` | intentionally deferred feature area | - -## Product And Release - -| Topic | Status | Current page | -|---|---|---| -| Product positioning / claim boundary | mapped | `docs/releases/`, coverage matrix | -| Release train and image/chart skew | mapped | release docs, Phase 40 references | -| User quickstart and Day-1 path | mapped | quickstart, README | -| Feature/status table for public readers | mapped | README/release docs | -| Docker volume plugin idea | future | roadmap only | -| Windows developer path / WSL / remote lab | missing | scattered notes only | - -## Kubernetes / CSI / Operator Layer - -| Topic | Status | Current page | -|---|---|---| -| CSI lifecycle / SwBlockVolume identity | tutorial | `deep-dives/csi-lifecycle.md` | -| CSI ControllerPublish/NodeStage/NodePublish details | summary | CSI page | -| CSI DeleteVolume and CR delete ordering | summary | CSI page + operation layer page | -| SwBlockVolume CRD field ownership | summary | CSI page + operation layer page | -| operator-status CRD status writer | deep draft | `deep-dives/status-writer-conformance.md` | -| lifecycle-owner finalizer add/release | deep | operation layer page | -| Kubernetes VAP/RBAC admission boundary | summary | operation layer page | -| delete-safety state machine | tutorial | state machines + operation layer | -| cleanup verifier / residue taxonomy | mapped | state machines + support bundle page | -| node readiness / CSI evidence | deep draft | `deep-dives/live-node-evidence.md` | -| host prereq projection | mapped | Phase 37 D4/D5 docs | -| loopback/cross-node blocker | mapped | Phase 37 D5 docs | -| install drift status | deep draft | `deep-dives/release-engineering-image-skew.md` | -| Kubernetes Events identity/dedupe | mapped | Phase 35 docs | -| CRD schema conformance/envtest gap | deep draft | `deep-dives/status-writer-conformance.md` | -| read-write control-plane maturity | future design | `deep-dives/read-write-control-plane-roadmap.md` | - -## Storage / Data Plane - -| Topic | Status | Current page | -|---|---|---| -| WAL / frontier / barrier concepts | deep draft | `deep-dives/wal-frontier-recovery.md` | -| SmartWAL dirty-failure path | tutorial | `deep-dives/smartwal-dirty-failure.md` | -| SmartWAL file layout and corruption injection | summary | SmartWAL page | -| durable root / hostPath persistence | mapped | roadmap/ref docs | -| blockvolume process layout and flags | deep draft | `deep-dives/blockvolume-process-readiness.md` | -| frontend projection/readiness | mapped | SmartWAL + ManagedVolume pages | -| local storage adapter readiness | missing | source/code only | -| SCSI command handling / sense errors | missing | `core/frontend/iscsi` only | -| dirty restart / recovery fail-closed | summary | SmartWAL page | - -## Authority / Recovery - -| Topic | Status | Current page | -|---|---|---| -| authority / epoch / promotion | tutorial | `deep-dives/authority-promotion.md` | -| stale-primary fencing | summary | authority page | -| restart authority persistence | summary | authority page | -| recovery/catch-up/rebuild mechanics | mapped | returned-replica page + historical tutorial | -| returned-replica rebuild productization | tutorial initial | `deep-dives/returned-replica-rebuild.md` | -| returned-replica failback runtime | deep | `deep-dives/returned-replica-failback.md` | -| automatic deployed failback policy | future | roadmap only | -| promotion readiness probes | summary | authority page | -| multi-volume authority isolation | mapped | QA/phase docs | - -## Protocol Frontends - -| Topic | Status | Current page | -|---|---|---| -| iSCSI basics | summary | iSCSI ALUA page | -| iSCSI ALUA / dm-multipath | deep draft | `deep-dives/iscsi-alua-multipath.md` | -| iSCSI OS initiator compatibility | mapped | ref/QA docs | -| iSCSI CHAP / auth path | mapped | chart values + quickstart | -| iSCSI stale path write rejection | mapped | ALUA/failover QA docs | -| NVMe-oF basics | missing | ref docs only | -| NVMe ANA parity | future | roadmap/ref docs | -| protocol selection in CSI | mapped | roadmap/ref docs | -| GPUDirect Storage / cuFile | future design | `deep-dives/gpudirect-cufile-cuobject.md` | -| cuObject / GPU object path | future design | `deep-dives/gpudirect-cufile-cuobject.md` | - -## Operations / Observability - -| Topic | Status | Current page | -|---|---|---| -| ManagedVolume readiness | tutorial | `deep-dives/managed-volume-readiness.md` | -| support bundle / report / dashboard | deep draft | `deep-dives/support-bundle-cold-reader.md` | -| operator-snapshot.json | mapped | operations docs | -| Events and reason-code vocabulary | mapped | release docs | -| action model evaluator | mapped | protocol catalog | -| negative-first rule | tutorial | ManagedVolume + SmartWAL pages | -| cold-reader explain path | mapped | Phase 32/36/44 docs | -| cleanup visibility | mapped | Phase 36/39/44 docs | -| action precondition/evidence model | mapped | Phase 38 docs | -| future mutating action execution | future design | `deep-dives/read-write-control-plane-roadmap.md` | - -## TestOps / QA - -| Topic | Status | Current page | -|---|---|---| -| TestOps authoring | tutorial | `deep-dives/testops-authoring.md` | -| scenario registry | mapped | TestOps page | -| evidence realism levels | tutorial | TestOps page | -| release smoke gates | mapped | release docs | -| failure bundle standard | mapped | Phase 32 docs | -| live-vs-mock CRD/RBAC gap | mapped | Phase 35-40 docs | -| dirty-failure scenario design | mapped | Phase 34 docs | -| runner action reference | missing | source/testops only | - -## Priority Gaps - -The highest-value missing or summary-only pages are: - -1. NVMe-oF / ANA background. -2. runner action reference. -3. WAL SmartWAL file-layout detail diagrams. -4. support bundle artifact examples from real runs. -5. returned-replica rebuild concrete future gate plan. -6. field-by-field SwBlockVolume CRD contract. -7. first concrete cuFile/GDS compatibility gate once GPU lab hardware exists. - -## Review Rule - -When reviewing this wiki, do not ask only whether a topic is present. Ask: - -```text -Could a developer implement or safely change this feature from the page? -Could QA derive the required evidence and failure reasons from the page? -Could a cold reviewer map the user claim to code and gates? -``` - -If the answer is no, the page remains `summary` even if it is accurate. diff --git a/seaweed-block/docs/workspace-measurements.md b/seaweed-block/docs/workspace-measurements.md index bb166369f6..0a9e901765 100644 --- a/seaweed-block/docs/workspace-measurements.md +++ b/seaweed-block/docs/workspace-measurements.md @@ -5,8 +5,7 @@ summary: the workload comparison, `fsync` behavior, snapshot and fork cost, cut upload time, and the two-host lifecycle run, with how each was measured. **Source of truth:** lab runs on Firecracker microVMs and a host-side proxy, as -described below. This text moved from the top-level README; only the `fsync` -bullet was updated to say which frontend the runs used. +described below. The workload and lifecycle numbers come from lab runs with Firecracker microVMs (4 vCPU, 4 GiB, guest kernel 6.1). The snapshot, fork and cut numbers @@ -69,4 +68,4 @@ In the same proxy, a cut that writes 64 dirty chunks (256 MiB) took a median These results cover the chunk path (`walstore-chunk`), which is a proof of concept: not yet a default, a release claim or a production path. The -[design reference](design/block-design.md), Part 2, describes how it works. +[agent workspace design](design/agent-workspace-design.md) describes how it works. diff --git a/seaweed-block/mkdocs.yml b/seaweed-block/mkdocs.yml index f9793977d5..272e7f2065 100644 --- a/seaweed-block/mkdocs.yml +++ b/seaweed-block/mkdocs.yml @@ -1,5 +1,5 @@ site_name: Seaweed Block Engineering Wiki -site_description: Internal engineering knowledge base for Seaweed Block. +site_description: Engineering documentation for Seaweed Block. repo_url: https://github.com/seaweedfs/seaweed-block docs_dir: docs site_dir: site @@ -31,20 +31,13 @@ markdown_extensions: nav: - Home: wiki/index.md - - Wiki Links: - - Block Wiki: http://192.168.1.135:8010/wiki/ - - RDMA Wiki: http://192.168.1.135:8011/wiki/ - - TestOps Wiki: http://192.168.1.135:8012/wiki/ - - Developer Guide: - - Wiki Structure: wiki/developer-guide.md - - Coverage Matrix: wiki/coverage-matrix.md - - Topic Inventory: wiki/topic-inventory.md - - Historical Sources: wiki/historical-sources.md + - Design: + - Design Reference: design/block-design.md + - TLA+ Specifications: spec/README.md + - Workspace Measurements: workspace-measurements.md + - Wiki: - Code Map: wiki/code-map.md - State Machines: wiki/state-machines.md - - Protocol Catalog: wiki/protocol-catalog.md - - Phase Map: wiki/phase-map.md - - Phase Recap: wiki/phase-recap.md - QA and TestOps Map: wiki/testops-map.md - Deep Dives: - Template: wiki/deep-dives/template.md @@ -61,17 +54,23 @@ nav: - Support Bundle Cold Reader: wiki/deep-dives/support-bundle-cold-reader.md - Release Engineering Image Skew: wiki/deep-dives/release-engineering-image-skew.md - Returned Replica Rebuild: wiki/deep-dives/returned-replica-rebuild.md + - Returned Replica Failback: wiki/deep-dives/returned-replica-failback.md - Read-Write Control Plane: wiki/deep-dives/read-write-control-plane-roadmap.md - - GPUDirect cuFile cuObject: wiki/deep-dives/gpudirect-cufile-cuobject.md - TestOps Authoring: wiki/deep-dives/testops-authoring.md - Product: - Overview: overview.md + - Kubernetes Status: kubernetes-status.md - User Capabilities: user-capabilities.md - - Roadmap: roadmap.md - Releases: releases/README.md + - Operations: + - Standalone Deployment: standalone-deployment.md + - Kubernetes Quickstart: quickstart-kubernetes.md + - Kubernetes App Demo: kubernetes-app-demo.md + - Chunk Manifests: chunk-manifests.md + - Workspace Lease: workspace-lease.md + - Fsync Latency: fsync-latency.md - Architecture: - Architecture: architecture.md - Developer Architecture: developer-architecture.md - Runtime State Machines: runtime-state-machines.md - Operations v1: operations-v1.md - - Quickstart: quickstart-kubernetes.md diff --git a/seaweed-block/scripts/run-phase157-nvme-rdma-capability-boundary-gate.sh b/seaweed-block/scripts/run-phase157-nvme-rdma-capability-boundary-gate.sh index 22dbb48056..1a0fbd0172 100644 --- a/seaweed-block/scripts/run-phase157-nvme-rdma-capability-boundary-gate.sh +++ b/seaweed-block/scripts/run-phase157-nvme-rdma-capability-boundary-gate.sh @@ -51,7 +51,6 @@ require_grep "docs/releases/nvme-rdma-capability-boundary.md" "read-only capabil require_grep "docs/releases/README.md" "NVMe/RDMA Capability Boundary" "release_index_links_rdma_boundary_doc" require_grep "docs/releases/nvme-tcp-supported-lab.md" "RoCE or NVMe/RDMA data path" "nvme_tcp_doc_keeps_rdma_non_claim" -require_grep "docs/roadmap.md" "Phase 157 keeps RoCE/NVMe-RDMA as a product non-claim" "roadmap_phase157_boundary_documented" require_grep "internal/docs/product-roadmap.md" "Phase 157 keeps RoCE/NVMe-RDMA as a product non-claim" "product_roadmap_phase157_boundary_documented" write_summary "rdma_host_capability_inputs_documented=true" diff --git a/seaweed-block/scripts/run-phase87-failback-docs-alignment-gate.sh b/seaweed-block/scripts/run-phase87-failback-docs-alignment-gate.sh index c3d36fba8a..22505f469d 100644 --- a/seaweed-block/scripts/run-phase87-failback-docs-alignment-gate.sh +++ b/seaweed-block/scripts/run-phase87-failback-docs-alignment-gate.sh @@ -37,7 +37,6 @@ require_text "wiki_names_terminal_evidence" "docs/wiki/deep-dives/returned-repli require_text "wiki_names_code_entry_points" "docs/wiki/deep-dives/returned-replica-failback.md" "core/ops/failback_executor_controller.go" require_text "wiki_names_current_limits" "docs/wiki/deep-dives/returned-replica-failback.md" "automatic deployed Kubernetes failback" require_text "wiki_index_links_failback" "docs/wiki/index.md" "deep-dives/returned-replica-failback.md" -require_text "topic_inventory_classifies_failback" "docs/wiki/topic-inventory.md" "returned-replica failback runtime | deep" require_text "product_roadmap_names_phase86" "internal/docs/product-roadmap.md" "Phases 74-86 add" require_text "product_roadmap_names_opt_in" "internal/docs/product-roadmap.md" "opt-in/source-gated failback" require_text "product_roadmap_defers_automatic" "internal/docs/product-roadmap.md" "automatic deployed failback"