Review of #130 r2 (three P2s):
- The unsupported-volume gate records the current primary's own fresh
slot fact on every pass (RecordPrimaryBootFact), not only when a
promotion is considered, so a ready report ends the grace and ready
restarts count toward flap history.
- The grace decision is ordered like the history: a superseded fact
(older than the newest recorded one, or equal-time with another
incarnation) is not a decision input. The decision follows the newest
recorded fact (its incarnation, placeability and grace clock), and a
superseded fact's endpoint is never used for a refresh. A fresh fact
still needs to be placeable and not ready.
- The cap uses the observation store's effective freshness window
(FreshnessConfig.EffectiveFreshnessWindow), so an omitted window caps
at its 10s default; an unset or nonpositive grace takes the window.
Lock order unchanged: state under TopologyController.mu; the gate reads
the store snapshot (its own lock, released) before calling the
controller; no new locks.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Controls for the review of #130 r2 (tests only, on b5a23c2):
- unsupported path, full product tick: a READY tick (probe says the
current primary is ready) must still record the fact, so unready again
in the same incarnation fails over; and ready restarts count toward
flap history, so a third start gets no grace;
- controller: a delayed UNREADY fact of the previous incarnation, and an
equal-time fact with a changed incarnation, must not defeat the
restarted primary's grace;
- cap: an omitted freshness window is the effective 10s default and caps
an explicit 5m grace; a nonpositive grace takes the window.
The unsupported tests now use a switchable promotion probe.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #130:
- P1: the unsupported-volume promotion gate reassigned directly even
when only a different slot was stale. It now judges the current
primary from its own fresh heartbeat slot in the observation store
(FreshSlotCandidate, server reachability/eligibility folded in) and
skips the direct reassign while that slot is placeable and inside its
boot grace. Placement-synthesized facts are never used for it.
- P2: boot history is ordered by observation time. A fact changes the
incarnation, start count, or ready latch only if its ObservedAt is
strictly newer than the last recorded one for that replica, so a
delayed or superseded snapshot (or an equal-timestamp replay) never
counts a start nor resets or ends a grace. Both gates go through
PrimaryBootGraceHolds, which records the fact under the same rule and
evaluates it.
- P2: a configured PrimaryBootGrace above the freshness window is
capped at it (logged), never widened.
Lock order: boot-grace state stays under TopologyController.mu and the
new code adds no call out of it (existing paths call the authority
reader under c.mu, unchanged). The gates call PrimaryBootGraceHolds and
read the observation store's snapshot (its own lock, released before
the controller call) while holding no host lock. No new locks.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Controls for the review of #130, on 6c00734 with declarations only
(ReplicaCandidate.ObservedAt copied by the snapshot builder; a
PrimaryBootGrace() accessor):
- full product tick on the unsupported-volume path: the third server's
facts age out (StaleObservation) while the current primary reports a
fresh, placeable, restarted, not-ready slot. Today the gate reassigns
directly inside the grace;
- an ineligible restarted primary still fails over at once (control);
- a configured grace above the freshness window is capped, and an
unready primary fails over at the capped limit;
- an out-of-order snapshot carrying the previous incarnation's older
fact, and an equal-timestamp fact, must not change boot history.
The controller rig now advances its clock after the steady fact, so
every later fact is strictly newer.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A freshly started volume reports ReadyForPrimary=false until its engine
has a promotion fact, so any restart of the current primary failed over
at the first heartbeat whenever a ready peer existed (#128; T1/T2).
The controller now keeps the current primary while it is placeable and
inside its boot grace: the grace starts at the first heartbeat of a new
incarnation and lasts PrimaryBootGrace (the master sets it to its
freshness window). Only its endpoint may be refreshed meanwhile. The
grace never covers an explicit unhealthy report (unreachable,
ineligible, withdrawn); ends for good once the replica reports ready or
the grace expires (no extension by repeated not-ready heartbeats); and
is refused to a replica with PrimaryBootFlapRestarts process starts
within PrimaryBootFlapWindow (defaults 3 in 10 min). No incarnation (an
older volume binary) means no grace.
The promotion gate's direct reassign skips a current primary that is
placeable by its own report and inside its boot grace.
Lock order: grace state lives under TopologyController.mu, written only
by observeIncarnationsLocked inside the existing snapshot path; the
controller calls nothing outward while holding it. The gate calls
PrimaryInBootGrace (takes c.mu) holding no controller-visible lock, the
same direction as its existing controller calls.
Fixes#128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
blockvolume reports a random incarnation, new on every process start, in
each heartbeat slot (proto field 12, regenerated with the checked-in
generator versions). It flows through the wire, observation and snapshot
layers to ReplicaCandidate.Incarnation as a raw fact. The controller
config gains PrimaryBootGrace and the flap bounds, unused here.
The new controller tests pin the #128 boot-grace contract and fail
against today's rule (a not-ready current primary with a ready peer
fails over at once): restart -> endpoint refresh; no ask inside the
grace; ready ends the grace; a flapper gets none. The explicit-unhealthy
and no-incarnation cases pass on both sides as controls.
Refs #128
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* storage: capture-path intent schedules (RED)
A cut that uploads writes an intent naming exactly its keys before the
first upload and deletes its own intent after the confirmed CAS; no
upload, no intent; a failed intent write uploads nothing; a failed
upload or a refused CAS deletes the intent; an unknown CAS outcome keeps
it until the next cut settles the proposal; a lost CAS response
confirmed by re-read deletes it; a failed delete is retried at the next
cut; other intents are untouched. The fake remote gains intent failure
hooks and records written intents.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* storage: the capture path writes an intent before uploading and settles it
A cut that uploads chunks now writes one intent naming exactly the keys
it will upload, at the cut's base HEAD generation with the layer's epoch
and holder. The intent is durable before the first upload; if it cannot
be written, nothing is uploaded. A cut that only drops chunks writes
none.
The cut deletes only its own intent, once its outcome is settled:
- after the HEAD CAS succeeds, or a HEAD re-read confirms its proposal;
- on a clean abort: a failed upload, a refused admission, a fence, or a
HEAD that moved past the CAS's base.
An unknown CAS outcome keeps the intent with the pending proposal. The
next cut deletes it once that proposal is settled, whether it landed or
can never land. A failed delete never fails a settled cut; the next cut
retries it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A fresh host restoring an epoch-1 HEAD with an LSN-ordering observer
installed: at the takeover CAS the observer must already be rebased to the
seeded next LSN, and a refused post-seed rebase must fail the restore with
HEAD still owned by its previous holder and I/O refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SetWriteObserver published the observer first and only logged a refused
ship-LSN rebase, so the volume kept serving writes its observer would
mis-order.
Now:
- SetWriteObserver rebases an LSN-ordering observer to the store's next
LSN before installing it. If the rebase is refused, the observer is
not installed and the error is returned. The backend also records the
fault and refuses every I/O until an install succeeds, so a later
attach that marks the volume operational cannot reopen it. blockvolume
reports the error.
- The frontier seed and its observer rebase run in one critical section
with observer installs (observerMu). Whichever runs second sees the
other's result; a seed landing between an install's rebase and its
publication can no longer leave the observer on the old LSN. A refused
rebase after the seed records the same fault.
- RebaseShipLSN documents that it moves only the ordering cursor:
entries already dispatched to peer queues carry lower LSNs and are
untouched.
The composition test checks the install error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An observer whose RebaseShipLSN is refused at install must not be
published with I/O left open: the next write must be refused. A later
install whose rebase succeeds reopens I/O.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ReplicationVolume orders writes from the store's next LSN, captured
when it is built. On a restored walstore-chunk host the frontier seed
moves that LSN to HEAD.remote_lsn+1 later, during the deferred attach.
The resequencer then waited forever for the LSNs below it, and writes
and flushes hung.
Whoever moves the next LSN now tells every component that cached it:
- ReplicationVolume.RebaseShipLSN(lsn) moves the ship order forward. It
is refused while any write is pending or in flight, never dropping
one, and never moves backwards; an equal LSN is a no-op.
- The provider calls it through the backend's observer right after
SeedChunkFrontier, before the layer attaches and the volume serves
I/O.
- StorageBackend.SetWriteObserver rebases a newly installed observer
to the store's next LSN, covering a seed that landed before the
observer was installed (blockvolume installs it after
SetReplicationVolume, while the attach is still deferred).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fresh walstore-chunk host restoring from a remote HEAD, in the
production order of cmd/blockvolume, with the real RF=1
ReplicationVolume as the backend's write observer:
1. Recovery runs before the master's assignment is visible, so the
chunk layer attach is deferred.
2. blockvolume builds the ReplicationVolume, which captures the store's
next LSN.
3. The replayed assignment lets the deferred attach claim HEAD and seed
the frontier to HEAD.remote_lsn.
4. A frontend write and flush then wait forever for LSNs below the
seeded frontier to be shipped.
The control differs only in having no remote HEAD, so nothing is
seeded; it writes and flushes fine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the attempt-scoped layout (one rule for both P1s: the decision
comes from ONE read of the entry acted on, and success from re-reading the
entry the operation tried to create):
- EnsureVolume decides a fork's attach from one HEAD read: absent and
aborted both refuse (fork_incomplete), so a sweep between two reads can
no longer pass an aborted HEAD.
- Fork decides from the HEAD it re-reads after its create: a real HEAD
completes the fork; an aborted tombstone means the fork lost to a sweep
(target_exists, its intent dropped, the tombstone is permanent); an
unreadable HEAD after a refusal is retryable, never a replay.
- A snapshot completes from its own attempt entry, never by resolving the
reusable name again; a snapshot tombstone carries no attempt stamp, so it
is never taken for this attempt's create.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
W5 ruling (2026-11-15 17:30Z), W2 part: a GC sweep settles a dead copy
attempt by claiming the operation's final publishing entry with an aborted
tombstone, and every attempt publishes to a target that is never freed.
- Snapshot: the name is taken by an exclusive name record
snapnames/<name> {request, attempt}; the intent names the attempt
(holder "snapshot:<vol>/<name>/<attempt>"); the snapshot is published by
an exclusive create at snaps/<name>/<attempt>. A retry of the same
request publishes to the same attempt path. List and Fork resolve names
through the record and skip aborted or unpublished attempts.
DeleteSnapshot marks the attempt deleting (or claims an unpublished
attempt's path with a tombstone) and removes the name record, freeing
the name; attempt paths are never removed, so a late insert always
fails. Catalog.AbortSnapshot(vol, name, attempt) is the sweep's claim.
- Fork: the publishing entry is the target's HEAD. Catalog.AbortFork
claims it with an aborted HEAD tombstone (state "aborted", gen 1, no
chunks); a fork whose HEAD is a tombstone never attaches
(fork_incomplete) and its replay is target_exists.
- The copy-intent deadline stays as metadata only.
A deleted snapshot no longer holds its name: it is no longer listed (even
with includeDeleting) and a fork of its name is snapshot_not_found; its
attempt entry stays for GC.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A cut that uploads chunks now writes one intent naming exactly the keys
it will upload, at the cut's base HEAD generation with the layer's epoch
and holder. The intent is durable before the first upload; if it cannot
be written, nothing is uploaded. A cut that only drops chunks writes
none.
The cut deletes only its own intent, once its outcome is settled:
- after the HEAD CAS succeeds, or a HEAD re-read confirms its proposal;
- on a clean abort: a failed upload, a refused admission, a fence, or a
HEAD that moved past the CAS's base.
An unknown CAS outcome keeps the intent with the pending proposal. The
next cut deletes it once that proposal is settled, whether it landed or
can never land. A failed delete never fails a settled cut; the next cut
retries it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A cut that uploads writes an intent naming exactly its keys before the
first upload and deletes its own intent after the confirmed CAS; no
upload, no intent; a failed intent write uploads nothing; a failed
upload or a refused CAS deletes the intent; an unknown CAS outcome keeps
it until the next cut settles the proposal; a lost CAS response
confirmed by re-read deletes it; a failed delete is retried at the next
cut; other intents are untouched. The fake remote gains intent failure
hooks and records written intents.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
W5 ruling (2026-11-15 17:06Z), W2 part: a snapshot or fork copy intent
records its absolute publication deadline (DeadlineNs: the read time plus
OpDeadline); the deadline is re-checked immediately before the publishing
exclusive create, and that create runs under a context bounded by the same
deadline, so it never publishes after it. GC may then expire a copy intent
by its recorded deadline (plus RPC timeout and grace) instead of by epoch.
The re-read that settles an ambiguous create keeps the caller's context.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Integration ruling F2: when the chunk layer attaches fenced (HEAD belongs
to a newer epoch or another holder, e.g. another server serving the same
replica), RecoverVolume fails with ErrChunkLayerFenced and the volume stays
non-operational, before anything can serve; the deferred authority attach
does not enable I/O either. HEAD is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Integration ruling F1(a):
- Catalog.EnsureVolume (the attach check) gives a created volume its
initial HEAD with the VOLUME entry: gen 1, epoch 0, no holder,
remote_lsn 0, no chunks (all zero), by exclusive create. An existing HEAD
is kept (a volume published before VOLUME entries), and a missing one is
created on the next attach.
- A fresh local volume (FreshFromHead) without a saved bitmap starts with
an empty bitmap bound to HEAD instead of hash mode: it took no write
before its first attach, so its image is HEAD's. Its first cut uploads
only the chunks written. Hash mode stays for an existing volume whose
bitmap is lost (F1(b)'s background reconciliation is separate work).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Prints one volume's VOLUME entry and HEAD from the filer (B9 W2 §0.1 and
appendix 2026-11-15 14:30Z): {volumeID, volume, head}, each null when it
does not exist; a HEAD without a state shows as active. Catalog.ReadHead
reads the HEAD; the show body lives with the other shared API bodies.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ops chunk failures print {code,message,retryable} on stdout, the same body
the routes answer (relayed as-is for an HTTP error), with a log line on
stderr and a non-zero exit (2 for usage errors) (B9 W2 appendix,
2026-11-15 14:30Z). CLI-side failures use the routes' codes: bad_request
for usage, remote_unavailable (retryable) when blockvolume or the filer
cannot be reached, internal otherwise; catalog refusals keep their code.
Messages no longer repeat the code: CatalogError.Detail is the message
and cause without it, used by the routes and the CLI.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>