Brings seaweed-block main (v1.1.1 plus the docs and a test fix after it) into seaweed-block/ as one commit. Only files under seaweed-block/ change, and the subtree equals seaweed-block main exactly. The module's full history stays in the seaweed-block repository. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
16 KiB
Immutable cleaning and intent list pages
This consumer slice wires persisted snapshot-delete intent continuation into holder maintenance and adds repeated compatibility sweeps of unreachable list pages after root/segment/chunk removal. It preserves conditional removal, current-chain reachability and the existing cut/stop cancellation path. Cut and upload-intent producers remain deferred. Offline volume-delete CLI, durable volume-delete cursors and their scheduled resweep window are separate.
The ProducerSeam r1 encoding reserves four pending-chain slots in HEAD:
existing list plus lists, an optional array of at most three ListCursor
values. New v1.1 volumes leave lists empty (canonical JSON omits it).
Every additional cursor passes the existing context/reference checks; no Ref
may repeat within the array or across list and lists. Version 0 refuses
this field. Every existing HEAD transition preserves the array byte-for-byte,
including the target identities, without consuming it or refusing serving.
When reserved chains are present, the compatibility cleaner retains all list
pages rather than interpreting their future ownership. Maintenance status
reports typed lastPass.skipReason = newer_pending_work for that conservative
skip; the reason is omitted normally and does not change the pass outcome. Ordinary list
continuation still works. No producer append, upload or handoff is enabled.
The page format needs no additional field: a later chain extension prepends one page with Next naming the old head, the same kind/producer/generation and Pages increased by one. A cursor retains its first publishing generation, which may be below the enclosing HEAD generation. The kept commit slot is derived from the future producer protocol, not another durable field. Fixed-byte empty/three-cursor vectors, invalid-slot/reference controls, deep clone isolation and every existing HEAD-update cause pin this representation.
Version 1 is compact canonical JSON with keys in this order:
version, volume_id, kind, producer, generation, pages, next?, target?, entries.
Each reference is {hash, pages}. A snapshot target is {name, gen}.
Kinds are drop, upload-intent, and snapshot-delete-intent; the last
requires a captured nonzero snapshot incarnation. The enclosing full volume
ID binds it to its volume. The producer is an opaque identifier, not authority.
The object name is SHA-256 of swblock:list-page:v1 followed by a NUL and
the exact canonical bytes, stored under lists/<lowercase hex hash>.
The decoder checks the reference hash, full volume ID and remaining-page
count. Entries are strictly sorted unique canonical owned root/segment/chunk
paths, not HEAD, VOLUME, another list or arbitrary paths. Consumers must still
check live roots and retain the existing Stat/HEAD/conditional Mark/Delete
ordering; listing a name gives no right to remove it.
Format ceilings (not time limits): 1 MiB per encoded page, 4,096 entries per page, 4,096 pages per chain, 256 producer bytes. A tail has pages=1 and no next; a non-tail has pages=next.pages+1. One read/encode allocates one bounded page, not a volume-sized chain. A producer reaching a ceiling must refuse before its effect, never truncate or omit required work. These explicit ceilings are proposed for format review and must be confirmed before declaration.
ReadListChain validates producer/kind/target/generation consistency across pages, holding one bounded page at a time. The consumer advances progress only after completing the page executor's idempotent effects. An unread continuation must remain reachable until retirement is authorized. Neither an absent page nor malformed metadata may mean empty/completed work.
Fixed files in layout/testdata/list-page-v1 cover a drop page, upload intent,
and a two-page snapshot-delete intent. Their independent SHA-256 names are
pinned in tests. Negative controls exercise truncation, unknown/duplicate
fields, kind confusion, identity/hash mismatch, counts, canonical ordering,
forbidden paths and size/entry limits. Unknown newer versions are refused.
The fallback cleaner stays a full mark/sweep until a separately reviewed
switch. Its catalog pass now also enumerates lists/ in bounded pages after
the root, segment and chunk phases, using the same holder/session and
conditional removal guards. It authenticates the whole HEAD-reachable chain
before removing any candidate page, preserving shared tails; a missing
continuation stops retirement. A restarted catalog can re-enumerate from the
beginning: completed deletions are absent and cannot be deleted again. The
in-memory cursor only schedules retries; it grants no reclamation authority.
Maintenance totals include list pages, with separate plannedLists and
removedLists counters so they never count as chunks.
This is the compatibility sweep, not the by-change switch. Complete V8 producer/consumer activation, restore-source and volume-delete progress integration, and their crash/counting qualification remain required. No proportional-to-changes claim is made for this full namespace scan.
Publication, continuation and retirement
sequenceDiagram
participant Producer
participant Store
participant HEAD
participant Consumer
Producer->>Store: StageListPage (data before exclusive entry, session-owned)
Producer->>Store: read and validate complete chain
Producer->>HEAD: CAS base generation + open snap session -> list cursor
Note over Producer,HEAD: unknown reply retains ownership; reread/retry same attempt
Consumer->>Store: read authenticated current page under clean session
Consumer->>Consumer: finish idempotent, independently guarded effects
Consumer->>HEAD: CAS observed continuation -> next page or none
Note over Consumer,HEAD: lost reply settled from HEAD before success
Consumer->>Store: tags -> current HEAD reachability -> conditional mark/delete
HEAD has an active optional list field, containing ref, kind, producer,
generation, and optional captured target. It is a serialized admission
slot: a second outstanding chain is refused, never overwrites unfinished
work. The slot is bounded and admitted only in version 1; a legacy encoding
cannot carry it. The three reserved lists slots are not populated or consumed
by this binary; their presence does not change the active slot admission. The version remains 1;
all v1.1 fields belong to the final schema, never to ext.
Pages are staged by the already-open snap session. The original base HEAD generation and the full holder identity gate publication. Ending a session while an upload runs may leave an orphan, but its publication cannot land afterward. No failed/unknown publish path discards pages or ends its session. A replay that observes its exact live cursor settles a landed send even if a resend was refused. Otherwise the error remains unknown/refused, with no cleanup side effect.
ConsumeListPage authenticates one page, invokes an idempotent executor,
and advances only after that executor returns success. The executor must
use existing authority, reachability and conditional mutation rules; a list
is a set of candidates, not permission to remove an object or a snapshot.
A crash or refused cursor CAS can repeat that page's effects. Only a
confirmed persisted continuation is progress. Page retirement is separate:
Cleaner.Page(ListDir, ...) reads tags before HEAD, requires the existing
clean session, walks the current live chain and conditionally marks/deletes
only unreached pages. An open snap session refuses cleaning altogether,
protecting unsettled publication. A shared tail remains live even if an
abandoned attempt also contains it. A missing/corrupt live continuation
stops retirement, never means empty or complete.
Storage uses ordinary data-first exclusive filer objects with session and volume metadata. Reads check declared inline/blob sizes before payload fetch; the blob interface returns one object, so a dishonest blob backend that returns more than its declared size can allocate before the final size check. No stronger streaming allocation guarantee is claimed. Existing full-volume deletion remains the authority for namespace removal; this slice does not replace its sweep with the dormant list consumer.
Model trace: PageChain rows 246-253 (NoDangling, NoLostWork). Seven
mutations cover premature HEAD publication, loss of session protection,
unsettled abandonment, membership-based retirement, retirement before
cursor settlement, cursor before effects, and absent-as-end. Tests also
cover session end during upload and shared-tail continuation after restart.
The list publishing CAS also stamps legacy snapshot entries through the
shared helper; already stamped entries keep their generation. General snapshot
producer/binding integration, complete restore ancestry,
volume-delete cursor, final queue layout, driver activation and release
qualification remain separate required work before the v1.1 declaration.
Snapshot deletion owns an intent before removing its row
The dormant delete seam is separate from the generic session API:
sequenceDiagram
participant Catalog
participant Store
participant HEAD
participant LaterExecutor
Catalog->>Store: StageSnapshotDeletePage (captured name/gen, durable pages)
Catalog->>HEAD: RunDeleteSnapshotWithIntent (one CAS: remove exact row + name intent)
Note over Catalog,HEAD: receipt may retire after this step
LaterExecutor->>HEAD: read current snapshot-delete intent, require idle live/detached
LaterExecutor->>Store: authenticate page; live roots; conditional mark/delete
LaterExecutor->>HEAD: CAS continuation only after effects finish
The target is the retained (name, publishing gen) in this volume, never a
new lookup by name. Its root must occur in the authenticated candidate chain.
The chain's producer/generation is a stable attempt identity, independent of
the HEAD CAS base: a retry after an unrelated metadata write reuses durable
page bytes and the original target. Before publication, every page is
conditionally adopted with a writer tag specific to its page hash and current
CAS base, clearing old removal marks. This metadata update invalidates both a
delayed Mark planned at an earlier base and a delayed DeleteMarked from that
cleaning. The publishing transition then explicitly checks every page is
present, belongs to the full volume ID, carries this attempt's writer tag and
has no removal mark; a failed check refuses the HEAD write. The page hash in
that tag binds its immutable producer/generation, and the CAS base makes it
fresh for a refreshed attempt. Admission of a new request against an absent
name and receipt ownership remain catalog responsibilities.
The unlink and intent publication are one HEAD write. Losing its reply cannot
leave an unlinked row without its reclamation facts. After publication,
RunConsumeSnapshotDeleteIntent needs only current HEAD and its immutable
pages, not the receipt, original host or holder lease. It can resume offline
on live/detached volumes and never claims a volume or changes its holder epoch.
Open snapshot or cleaning activity refuses these effects. Candidate membership
is not liveness: every removal still checks tags before current HEAD roots,
then conditionally marks and deletes. A conflicting mark or delete leaves
the intent page pending for retry; routine full-sweep skip behavior is unchanged.
This is an explicit additional authority branch inside Cleaner.removePlanned,
not a weakening of the holder's routine cleaning guard.
Before publication, an ordinary cleaner must begin at a later HEAD generation; that fences an outstanding delete CAS before it can name swept pages. A refreshed-base retry additionally adopts every page; a base fence alone cannot invalidate an earlier cleaner's outstanding conditional object operations. Adoption orders Stat -> validate current HEAD/base -> conditional Reuse, so an old adopter cannot read a new tag and then restore an old one. Staging only creates missing entries and never changes existing tags; a delayed staging request cannot undo adoption. An unsettled upload finishing after the fence is merely an orphan. After publication, page retirement uses current-chain reachability as before. Missing pages and unfinished effects never advance the intent. A same-name replacement is preserved both by the retained target and by current live-root checks.
StaleClean rows 159-161 cover conditional adoption and stale removal (including the no-metadata-change Reuse mutant); PageChain rows 246-253 cover publication and effect/cursor ordering; SnapDelete 241-245 cover incarnation identity. The offline consumer refinement and its new authority branch require exact-head model/code review before activation. No product delete driver calls this seam yet. The one-slot admission capacity, remaining producer wiring and Linux/race qualification remain outstanding.
The catalog exposes CleanSnapshotDeletePage for an executor to resume exactly
one page from the current durable intent. It reconstructs the store and reader
from the full volume reference and delegates to the same guarded consumer;
it neither claims the volume nor looks up a receipt. pending is meaningful
only on success. No directory listing is used, and an unread tail is left for
the next call. A failed cursor CAS leaves that page pending; a lost reply is
settled from HEAD. The catalog restart controls count actual conditional
deletions and require each completed object to be deleted once. Live-root
reachability still has its existing manifest-read cost: absence of namespace
enumeration is not a claim that the whole path is proportional to changes.
Automatic maintenance and general drop/upload-intent producer wiring are not
enabled by exposing this catalog entry point.
The generic StageListPage rejects snapshot-delete intent before any HEAD or
object I/O, just as generic publication and consumption reject that kind. Its
ordinary EnsureObject adoption must never restore a snapshot-intent producer
tag after dedicated publication protected it. The held-generic-staging control
crosses snap end, cleaner planning and refreshed publication and proves this
door cannot recreate an earlier cleaner's removal authority.
Candidate-shard decoding cost
The by-change intent path selects the candidate's shard in Reader.EachRef.
layout.ShardSize is the fixed 10000-entry limit; DecodeSegment rejects a
larger segment. The two-chunk counting control decodes that same shard twice,
so its bound is 20000 decoded references, rather than a full-volume scan.
With the fixture's five-byte owner and shard-zero indexes this is at most
1120054 encoded segment bytes (1119764 measured once saturated). It checks
one distinct shard as well as GET, entry and byte limits: two partial shards
are not admitted merely because their aggregate fits those limits.
At 1024, 16384, 262144 and 1048576 current entries, aggregate segment bytes are 114452, 1119764, 1119764 and 1119764. Root bytes remain the separate size-dependent term: 126, 225, 2700 and 10422. The by-change segment index and two-level root are deferred; these measurements do not remove the compatibility full sweep's namespace cost.
Staging request bound
Each staging attempt starts a 30 s deadline before its HEAD read and passes it through the object write; an earlier caller deadline wins. This covers snapshot intent creation, generic list-page staging, and adoption's Stat, HEAD check and conditional Reuse. A new adoption attempt gets a fresh check and deadline; EnsureObject retries within an attempt do not renew that attempt's deadline. The bound limits client waiting, not a queued server apply. A volume-delete rerun collects a late page; durable scheduled resweep and its window starting at the deleting mark remain separate work.