Commit Graph
969 Commits
Author SHA1 Message Date
pingqiuandClaude Opus 5.5 f947bd4063 volume, chunkstore: lsn_behind, closing 409 after detach, invalid_label, no cut stats
Contract revisions from integration (B9 W2 appendix, 2026-11-15 14:30Z, and
the rulings of 14:09Z):
- a cut behind HEAD's remote_lsn answers lsn_behind (409, not retryable);
- a detached layer answers closing with 409 (it stays closed until a new
  attach); a closed layer (process shutdown) stays closing 503;
- an invalid label is invalid_label (400), and SnapshotReplay validates
  labels and consistency with the name and request id, so a bad request is
  refused before any cut;
- the /chunk/cut body omits the cut statistics until W3 fills them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:12:20 -08:00
pingqiuandClaude Opus 5.5 e483d45728 blockvolume: HEAD holder is <server-id>/<replica-id>
The replica id alone made two hosts that both serve replica r1 look like
the same holder returning, so the later one was not fenced (B9 W2
appendix, 2026-11-15 14:30Z). blockvolume now passes
<server-id>/<replica-id> as the provider's ChunkHolder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:11:08 -08:00
pingqiuandClaude Opus 5.5 b06bf7dc45 storage: HEAD's remote_lsn never decreases
A cut whose LSN is below the base HEAD's remote_lsn is refused before any
upload (ErrChunkCaptureRefused with ErrChunkLSNBehind; the expected gen
pins that base HEAD), unless that HEAD belongs to a newer holder, which
fences as before. MemChunkRemote refuses a lowering CAS too (B9 W2
appendix, 2026-11-15 14:30Z).

Until LSN continuity across hosts exists, a fresh, migrated or forked
volume cannot cut or detach; the carry-forward must merge before or with
this check. Tests that model a host continuing from a seeded HEAD now
advance the local log to that HEAD's remote_lsn first, as the
carry-forward will.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:11:08 -08:00
pingqiuandClaude Opus 5.5 95b6b7d62e sw-block: ops chunk never exits 0 with its result lost
An HTTP response over the 64 MiB limit is refused (read limit+1) instead of
being relayed truncated, and every result write checks for a failed or
short write, for the route commands and the filer commands alike. There is
no retry of the operation: the error says the result was not relayed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:51:12 -08:00
pingqiuandClaude Opus 5.5 399d3a8ead sw-block: ops chunk cut|snapshot|detach|snapshots|snapshot-delete|fork
The walstore-chunk control plane on the command line (B9 W2 §0.1, §3):
- cut, snapshot and detach call a blockvolume's /chunk/* routes
  (--status-addr, with --chunk-control-endpoint); the request carries
  timeoutMs and the client waits a little longer;
- snapshots, snapshot-delete and fork read and write the filer directly
  (--chunk-filer, --chunk-path), so they work while the volume is offline;
- snapshot and fork generate a request id when none is given and print it
  on stderr for a retry; --label k=v repeats;
- stdout carries the operation's JSON body (the route's, or the shared
  list/delete bodies, or the fork result with remoteLSN); a failure prints
  "<code>: <message> (retryable=...)" and exits 1; usage errors exit 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:35:16 -08:00
pingqiuandClaude Opus 5.5 0c5ea94830 chunkstore: the snapshot list and delete bodies as shared API types
SnapshotListItem / SnapshotListBody (exactly B9 §3.3's fields) and
SnapshotDeleteBody move from the volume routes to chunkstore, so the
sw-block CLI, which reads the filer directly, emits the same bodies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:35:16 -08:00
pingqiuandClaude Opus 5.5 f94b20724b durable, volume: one owned drain, one handle lookup, one JSON object per request
- StopIO keeps one pending drain per backend; every StopIO waits on it,
  so timed-out detach retries behind a held I/O no longer each leave a
  goroutine waiting for the admission lock.
- CutVolume resolves the volume's handle and layer in one critical section
  (chunkHandle) and keeps that handle: a Close that empties the volume map
  mid-call no longer leaves the minLSN check reading a missing handle.
- A /chunk/* request body must be exactly one JSON object: trailing data
  is bad_request before any operation runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:34:42 -08:00
pingqiuandClaude Opus 5.5 410efb6d03 volume: snapshot replay before the cut, minLSN in the provider, JSON transport errors
- Snapshot resolves its request with Catalog.SnapshotReplay first: a retry
  of a recorded request returns it and another request gets
  snapshot_exists, both without cutting (so a replay survives a detached,
  fenced or unreachable cut path).
- Cut passes minLSN to the provider, which refuses an LSN never written
  before publishing.
- outcome_unknown is reported whenever an unresolved CAS is in the error,
  also when the re-proposal was refused for authority.
- Transport errors are JSON like every /chunk/* response (ruling of
  2026-11-15): bad_request (400), method_not_allowed (405), forbidden (403).
- timeoutMs is compared with OpDeadline in milliseconds before converting,
  so a huge value selects OpDeadline instead of overflowing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:22:27 -08:00
pingqiuandClaude Opus 5.5 861855a021 chunkstore: SnapshotReplay resolves a snapshot request before a cut
The recorded snapshot for the same request id (Replayed), snapshot_exists
for another, or a free name, after validating the name and request id
(B9 W2 §3.2 step 1). CreateSnapshot uses it for its own pre-check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:22:27 -08:00
pingqiuandClaude Opus 5.5 97f460d181 durable: Detach drains admitted I/O and stays stopped; minLSN refused first
- StorageBackend gains an I/O admission boundary: Read, Write and Sync
  hold the read side of ioMu for the whole operation, gate included, and
  check the closed and operational flags once before the lock so I/O
  arriving during a drain fails at once. StopIO refuses new I/O and waits,
  bounded by ctx, for the I/O admitted before the stop.
- DetachVolume latches the volume as detached for this process (under the
  attach lock), stops and drains frontend I/O before the periodic loop
  and the final cut, so no write is acknowledged outside the detached
  image; a drain that times out fails the detach with I/O still stopped.
  RecoverVolume and the deferred authority attach no longer reopen a
  latched volume (ErrChunkLayerDetached); a retry settles the detach and a
  repeated call returns the first result.
- CutVolume takes minLSN: an LSN never written is refused before anything
  is published (MakeRemoteDurable's refusal), and the cut must reach it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:22:27 -08:00
pingqiuandClaude Opus 5.5 608f9efbfc blockvolume: --chunk-control-endpoint mounts the /chunk/* routes
Off by default; only with --durable-impl=walstore-chunk and a
--status-addr. The routes are served from the durable provider and the
catalog under --chunk-path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:54:50 -08:00
pingqiuandClaude Opus 5.5 985a825ac5 blockvolume: apply the VOLUME attach rules before the chunk layer attaches
walstore-chunk now dials one filer client for the per-volume remotes and
a catalog under the same --chunk-path, and wires the provider's attach
check to Catalog.EnsureVolume with the local geometry (B9 W2 §4.2, ruling
of 2026-11-15): the first attach creates VOLUME, and an attach is refused
with geometry_mismatch, or with fork_incomplete for a fork whose HEAD is
not written yet. It runs before any HEAD read or CAS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:54:24 -08:00
pingqiuandClaude Opus 5.5 8b3e0cfbce chunkstore: MemFiler, an in-memory Filer for tests outside the package
Exclusive create, conditional update and delete on extended attributes,
and name-ordered listing of one directory's children, like
storage.MemChunkRemote for the chunk remote. The volume control adapter's
test uses it instead of its own copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:54:14 -08:00
pingqiuandClaude Opus 5.5 4f2e85fea0 volume: /chunk/* control routes on the status listener
POST /chunk/cut, /chunk/snapshot, /chunk/snapshot/delete, /chunk/detach and
GET /chunk/snapshots (B9 W2 §2.1-§2.2, §3.1-§3.4, §3.6), mounted only
after EnableChunkControlEndpoint and wired by SetChunkControl:
- loopback-only like the listener; JSON request bodies (unknown fields are
  refused) and ?volume= for the list; volume_not_served for another volume
  and not_chunk_volume until a control is wired;
- success bodies carry exactly the spec's field names (§3.1-§3.4, §3.6);
- failures answer {"code","message","retryable"} with the §2.2 code and
  status, plus the 2026-11-15 rulings: awaiting_assignment (409, retryable)
  for a layer that waits for the master's assignment, not_primary not
  retryable, internal (500) for anything unmapped; transport errors
  (method, client, malformed request) stay plain text as on the rest of
  the listener;
- long operations run under min(timeoutMs, OpDeadline).

NewChunkControl serves the routes from the durable provider (cut, detach)
and the catalog (snapshots): Snapshot validates the name and request id
before it cuts, then stores the HEAD that cut installed; Cut with minLSN
fails unless the cut reaches it. The cut statistics fields read zero until
W3 fills them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:51:55 -08:00
pingqiuandClaude Opus 5.5 7581a5b51a durable: CutVolume and DetachVolume
CutVolume takes one quiesced cut and returns what it installed (cut LSN,
HEAD, statistics). DetachVolume is a clean stop's final cut (B9 W2 §3.6):
under the volume's attach lock it stops frontend I/O and the periodic
cuts, then publishes the one detached-HEAD cut, and returns it with the
last written LSN. A repeated call returns the first result; a failure
leaves I/O stopped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:50:59 -08:00
pingqiuandClaude Opus 5.5 70853854f3 durable: an attach-time check hook ahead of the chunk layer attach
ProviderConfig.ChunkAttachCheck runs before every chunk layer attach, ahead
of any remote read or CAS (and so ahead of a takeover CAS), with the
volume's local geometry (blocks, block size, chunk blocks). A non-nil error
refuses the attach and the volume stays non-operational. blockvolume wires
it to the VOLUME entry's attach rules (B9 W2 §4.2, ruling of 2026-11-15).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:50:46 -08:00
pingqiuandClaude Opus 5.5 9d7156dc8d storage, durable: typed causes for the chunk control codes
The causes the /chunk/* routes report as B9 codes are now reachable with
errors.Is:
- storage: ErrChunkLayerClosed (closing), ErrChunkBaseInstalling
  (base_installing, inside ErrChunkCaptureRefused), ErrChunkRemoteUnavailable
  (an upload failure), and ErrChunkHeadPrecondition on every CAS that did
  not apply because HEAD moved, whatever error the CAS returned;
- durable: ErrChunkNotPrimary and ErrChunkEpochStale as the causes of the
  provider's capture admission refusals.

Messages are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:50:28 -08:00
pingqiuandClaude Opus 5.5 53e5262fda storage: re-check capture admission before re-proposing a held CAS
Re-proposing an unresolved CAS at its base is a new publication. It now
passes the capture admission again right before the CAS is sent, after
the blocking HEAD read: a demotion or lineage change during that read sends
no CAS, keeps the CAS unresolved, and returns the refusal (with
errChunkCASOutcomeUnknown still in the chain). Once authority is back, the
same proposal settles at the same base.

The fake remote gains onGetHead, a hook that runs inside each HEAD read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:47:55 -08:00
pingqiuandClaude Opus 5.5 2d598a4dbd storage: gofmt the chunk layer's state fields
The r4 field pendingBase left the rest of the block misaligned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:38:07 -08:00
pingqiuandClaude Opus 5.5 24cbab0f27 chunkstore: each attempt deletes only its own intent
Snapshot and fork attempts stamp the entry they create with their intent id
(swb.attempt). An attempt deletes its own intent only when its own create is
confirmed (applied, or found by the re-read with its attempt id) or refused
by the filer's "already exists" answer, or when it never sent the create
(deadline). Any other failure leaves the create unsettled and the intent in
place, even when the re-read finds another attempt's entry: the held create
may land after that entry is removed. No attempt, and no replay, deletes
another attempt's intent (W5 rule); tag-wide settleIntents is removed.

The fake filer gains held creates (deferCreate) and releaseDeferredCreates,
which applies them later only if the name is still free.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:26:56 -08:00
pingqiuandClaude Opus 5.5 fe9df65af8 storage: settle a held cut CAS by re-proposing it at the same base
A cut or detach CAS whose outcome is unknown while HEAD still reads its
base generation may still be applied by the server later. Reading HEAD
alone no longer settles it: the capture keeps the proposal pending, and the
next cut, durability point or Detach re-issues the same proposal at the same
base. Whichever lands first, HEAD ends at that proposal and the other fails
its precondition, so a delayed detach can never land after a no-op cut.

The fake remote gains a held CAS mode (casDeferred) and releaseDeferredCAS,
which applies held CAS calls later only if HEAD is still at their base.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:26:56 -08:00
pingqiuandClaude Opus 5.5 d0e3107c57 storage, chunkstore: HEAD state/detachedBy per the schema ruling; one-CAS Detach
Follows the HEAD schema ruling (2026-11-15), replacing the boolean
detached flag of the previous revision:

- HEAD carries a canonical "state": "active" | "detached" (a document
  without it reads as active), and "detachedBy": {holder, epoch, gen}
  only when detached; a reader refuses a detachedBy that is not the
  HEAD's own holder, epoch and generation.
- Detach is one detach cut: its CAS publishes the final cut with state
  detached and detachedBy = {holder, epoch, the generation that CAS
  installs}. It always CASes, also with nothing new. Afterwards cuts are
  refused (ErrChunkLayerDetached); a repeated Detach returns the result.
- Every normal cut publishes state active and no detachedBy, so a new
  holder's cut over a detached HEAD clears it.
- An unresolved detach CAS is settled like any unresolved CAS, before the
  next capture or Detach: applied means detached, not applied continues,
  a newer holder fences, unreadable is ErrChunkCASOutcomeUnknown. This
  replaces the separate pending-mark state.
- A fork's HEAD is published with state active.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:20:41 -08:00
pingqiuandClaude Opus 5.5 681becfff0 chunkstore, storage: settle intents and fork replays; settle a pending detach
Review fixes for the snapshot catalog, fork and Detach:

- Intents stay until the operation's outcome is settled. An exclusive
  create that fails is resolved by re-reading the entry: our entry
  confirms the publish; another entry means our create can never land
  (clean abort); a failed re-read or no entry leaves the outcome unknown
  (it may still land), so the intents are kept and the call reports
  outcome_unknown. A retry with the same request id settles it and
  removes every intent of the operation (by its holder tag).
- Fork records its operation in the target's VOLUME (request id, source,
  snapshot, source gen, the SHA-256 of the snapshot's HEAD document and
  the original result). A retry resolves the target first: a completed
  fork replays the recorded result without reading the source (also
  after the source snapshot is deleting, or the target advanced); a
  request id reused with other parameters is target_exists; an
  incomplete fork resumes only if the snapshot still has the bound image.
- An unresolved Detach mark (CAS outcome and re-read both failed) becomes
  a pending detach that every later capture, durability point and Detach
  settles first: applied means detached, not applied continues, a newer
  holder fences, still unreadable is ErrChunkCASOutcomeUnknown. A cut can
  no longer succeed at the pre-mark generation. Unresolved capture CAS
  outcomes now also wrap ErrChunkCASOutcomeUnknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:20:41 -08:00
pingqiuandClaude Opus 5.5 1ec7b9975b chunkstore, storage: snapshot catalog, fork, detached HEAD and Detach
Control-plane metadata and operations over the filer (B9 W2 spec §3-§5):

- Catalog (core/frontend/chunkstore/catalog.go):
  - VOLUME entry <base>/<vol>/VOLUME: identity, geometry, origin and
    parent, write-once. EnsureVolume applies the attach rules (create a
    missing one; geometry_mismatch; fork_incomplete for a fork without
    HEAD).
  - CreateSnapshot stores the HEAD a cut installed as snaps/<name>
    (o_excl; the same request id replays, another is snapshot_exists),
    under an intent naming its keys until the entry is written, and
    refuses the write past OpDeadline.
  - ListSnapshots pages in name order (deleting ones hidden unless asked);
    DeleteSnapshot only marks deleting (conditional on state and gen);
    ListVolumes lists volume directories for GC.
  - Fork: VOLUME (origin fork, parent) then HEAD at gen 1, epoch 0, no
    holder, the snapshot's remote_lsn (LSNs carry forward), every ref
    owner-qualified as "@<owner>/<key>" (an already qualified ref keeps
    its owner), under an intent on the target; replays by request id.
  - Typed errors with the spec's codes (CatalogError, CodeOf).
- HEAD gains Detached (JSON "detached", omitted when false). The chunk
  layer's Detach takes a final cut, then CASes the same image once more
  with Detached set; afterwards cuts are refused (ErrChunkLayerDetached)
  and a repeated Detach returns the first result. A normal cut always
  publishes Detached = false.

No entry carries filer chunks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:20:41 -08:00
pingqiuandClaude Opus 5.5 ade97bcb8f durable: intent calls on the close-bound remote use pointer receivers
On #114 the close-bound remote holds a mutex for the attach context, so
the intent wrappers take a pointer like every other bound call; a value
receiver copied the lock (go vet copylocks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:20:33 -08:00
pingqiuandClaude Opus 5.5 eba04ab67d storage, chunkstore: enforce the chunk key domain before persistence
Review fix for the intents seam: an intent document is JSON, which would
silently replace invalid UTF-8 in a key, while a key binding preserves the
bytes, so a protected key could list back as a different key. The chunk
key domain is now non-empty valid UTF-8, refused at Put and, for every
key, at PutIntent by the SeaweedFS remote, MemChunkRemote and the test
fake before anything is written (storage.ValidChunkKey,
ErrChunkKeyInvalid; chunkstore wraps it in ErrInvalidKey). Unicode and
owner-qualified keys round-trip byte-identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:20:06 -08:00
pingqiuandClaude Opus 5.5 008b96307b chunkstore: filer list and conditional delete, owner-qualified keys, intents
Remote plumbing for the chunk control plane (snapshot, fork, GC):

- Filer gains ListEntries (one page, name order, a missing directory lists
  as empty) and DeleteEntry with expected_extended (never deletes data;
  a failed condition, including a missing entry, is ErrPrecondition). The
  filer proto subset adds ListEntries with seaweed-mono's field numbers;
  regenerated with the same protoc and plugin versions.
- ChunkRemote resolves owner-qualified keys "@<owner>/<key>" in the owner
  volume's keys/ directory, so a fork can name its parent's chunks with
  one HEAD write. Put refuses them: a volume writes only its own keys.
  The owner must be one plain path element (CheckVolumeID).
- storage.ChunkRemote gains the W5 intents seam: PutIntent returns a
  per-call id "<gen>-<nonce>", DeleteIntent removes only that id, and
  ListIntents lists every live intent or fails (never skips one). The
  SeaweedFS remote stores them at <root>/intents/<id>; MemChunkRemote,
  the storage test fake and the provider's close-bound wrapper implement
  them too. The capture path calling them is separate work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:20:06 -08:00
pingqiuandClaude Opus 5.5 4c810b007c storage: carry-forward LSN note; witness the injected takeover race
Review follow-ups for the chunk Cut change:
- the ChunkCutResult comment now states the W4 ruling: a volume's LSNs
  carry forward across hosts (a new host starts at HEAD.RemoteLSN + 1, a
  fork after its snapshot's RemoteLSN), so RemoteLSN never decreases;
- the tagged takeover race test accepts a failed attach only when the
  old holder's competing CAS was actually injected before the takeover
  CAS, and only when the new holder published nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:19:47 -08:00
pingqiuandClaude Opus 5.5 dfcc9e7126 storage: chunk Cut returns the installed HEAD; typed capture refusals
Cut(ctx) takes the same quiesced cut as Capture and returns the HEAD its
own CAS installed (or the current HEAD for a cut with nothing new), so a
snapshot can copy exactly the image of cut H even when other cuts follow.
Capture keeps returning H through Cut. A ChunkCutStats struct is declared
for the periodic-cut work to fill.

A capture refused by the owner's CaptureAllowed check now wraps the
owner's error with %w, so callers can tell "not primary" from "lineage
changed" with errors.Is.

Also adds the RED tests for the takeover CAS at attach, behind the
chunk_takeover_red build tag, for the work that implements it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:19:47 -08:00
pingqiuandClaude Opus 5.5 fdb339f091 durable: schedule for a stale authority wait past its tick check
The authority wait of recovery A passes its per-tick generation check
and is parked (test-local one-shot projection barrier) inside its
projection read. Recovery B then fails on the real WAL integrity fault.
Released with authority, A must not start a remote attach, publish a
layer or admit I/O; only the re-check under the per-volume
serialization stops it. Repaired recovery C converges. Tests only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:10:17 -08:00
pingqiuandClaude Opus 5.5 c1a986a63e durable: walstore-chunk authority wait is bound to its recovery generation
A deferred authority wait kept acting after a newer RecoverVolume. If
that newer recovery failed, the old wait still attached the layer and
set the backend operational once authority arrived, overriding the
failed recovery.

Each RecoverVolume of a walstore-chunk volume now takes the next
recovery generation (under the per-volume serialization), and an
authority wait carries the generation that registered it. A wait whose
generation is no longer the latest exits. It checks on every tick, and
again under the per-volume serialization right before attaching, so it
never attaches or touches the backend for a superseded recovery. After
a failed recovery the backend stays refused until a later recovery
succeeds; that recovery attaches directly or starts its own wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 03:32:47 -08:00
pingqiuandClaude Opus 5.5 e7ac52d6ae durable: walstore-chunk stale authority wait schedule (RED)
Recovery A succeeds before authority and registers the authority wait;
recovery B fails on a real WAL integrity fault (a CRC-valid write-batch
record with no block count); authority arrives. I/O must stay refused
and no layer may attach. A repaired, later successful recovery
converges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 03:32:26 -08:00
pingqiuandClaude Opus 5.5 70457de5fd durable: walstore-chunk attaches under master authority, within the caller deadline
The chunk layer attached right after local recovery. In blockvolume that
is while the host still blocks the master's assignment, so the layer was
bound to epoch and endpoint version 0. After the assignment replayed, the
host became healthy but every cut was refused against that 0/0 lineage.

The layer now attaches only when the projection names the volume, is
healthy and carries a master-assigned epoch. RecoverVolume attaches at
once when that holds. Otherwise it reports the volume recovered, keeps
its I/O refused, and starts one authority wait per volume. The wait is
registered with Close like a recovery; it attaches when the assignment
is applied, then makes the volume operational, and retries a failed
attempt. Capture operations report ErrChunkAwaitingAuthority meanwhile.
The lineage that later cuts are checked against is the one at that
attach.

The attach's remote calls now also end with RecoverVolume's caller
context, besides provider Close. The attached layer is not bound to that
context: later captures keep working after it ends.

New control: Close settles an in-flight deferred attach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:50:09 -08:00
pingqiuandClaude Opus 5.5 e301c80f17 durable: walstore-chunk startup authority and caller deadline schedules (RED)
The production startup order with a real Host (readiness blocked, the
assignment retained, recovery, readiness cleared and the assignment
replayed, frontend write, on-demand and periodic capture), recovery
before the assignment is visible, and the caller deadline over the
attach's first remote call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:49:40 -08:00
pingqiuandClaude Opus 5.5 b585648099 durable: walstore-chunk fresh marker, lineage-bound capture, attach settlement
Fresh initialization survives interruption. A walstore-chunk volume
gets a durable <path>.chunkfresh marker (file and directory fsynced)
before its volume file is created. The provider reads the marker on
every open, and removes it (durably) only after the first attach has
persisted the absence of every HEAD chunk. A create that failed or
crashed before that point reopens fresh and reads HEAD, never the
untouched local zeros.

Captures publish only under the attach-time lineage. The admission
check, made at the start of a cut and again right before its HEAD CAS,
requires the current projection to be healthy and to carry the same
volume, replica, epoch and endpoint version as at attach. A moved
lineage refuses the cut instead of publishing under the old epoch. The
configurable holder name is not part of the comparison.

Attach settles with shutdown. RecoverVolume on a walstore-chunk volume
registers with the provider and serializes recovery and attach per
volume. Close cancels the attach's remote calls through a close-bound
remote, waits for admitted recoveries before closing any store, and an
attach that finishes after Close publishes nothing (the store closes
the layer).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:16:39 -08:00
pingqiuandClaude Opus 5.5 d60be35e70 durable: walstore-chunk provider lifetime schedules (RED)
Interrupted fresh initialization, lineage drift before and during a
held upload, Close against a held attach, and concurrent RecoverVolume,
through the real provider entry points.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:16:39 -08:00
pingqiuandClaude Opus 5.5 da4fde6747 blockvolume: --durable-impl=walstore-chunk with a SeaweedFS remote
walstore-chunk is opt-in and needs --durable-root and --chunk-filer.
Each volume's HEAD and key bindings live under --chunk-path/<volume-id>
(the volume id must be one plain path element); --chunk-collection and
--chunk-replication apply to chunk needles, and --chunk-capture-interval
runs periodic cuts while healthy (0: on demand only). The --chunk-*
flags are refused with any other implementation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:16:39 -08:00
pingqiuandClaude Opus 5.5 2ef8b82c2d chunkstore: SeaweedFS remote for the walstore chunk layer
ChunkRemote implements storage.ChunkRemote over the imported Filer and
Blobs client. Under one volume's filer directory, HEAD is an entry whose
content is the JSON HEAD and whose extended attributes mirror
{gen, epoch, holder}; each chunk key is a write-once entry (exclusive
create) naming the needle that holds the chunk's bytes, because the
layer names chunks itself while SeaweedFS assigns needle ids.

The HEAD CAS is UpdateEntry with expected_extended {gen, epoch}; the
first HEAD is an exclusive create. Only definite refusals map to
ErrChunkHeadPrecondition; any other error is returned as is, so the
layer treats the outcome as unknown and re-reads HEAD. A proposal that
lowers the epoch is refused. A HEAD entry that exists but does not
decode, carries filer chunks, or whose attributes disagree with its
document is an error, never the absent HEAD. Needles are not reclaimed;
Delete reports ErrDeleteUnsupported.

Tests run against the in-memory fake filer and needle store, including
the chunk layer end to end (capture, then a fresh host reading lazily
from HEAD); an integration test (build tag chunkstore_integration) runs
the same against real weed master, volume and filer processes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:16:39 -08:00
pingqiuandClaude Opus 5.5 a8d02778bf chunkstore: import the minimal SeaweedFS client from the D1 PoC
Copied unchanged from the D1 chunkstore PoC (commit 05818b3): the Filer
and Blobs interfaces with their sentinel errors, the SWFS client over the
filer gRPC API (vendored proto subset) plus plain HTTP to volume servers,
its gRPC error-mapping tests, and the in-memory fake filer and needle
store. The PoC's demo Backend, volume and flat manifest are not imported:
the walstore chunk layer publishes its own HEAD.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:16:39 -08:00
pingqiuandClaude Opus 5.5 c71a2cbc02 durable: walstore-chunk provider wiring
Adds ImplWALStoreChunk ("walstore-chunk"): a walstore volume with the
storage chunk layer attached. On disk it is a walstore file, so the
selector accepts the walstore magic; it refuses other formats.

- ProviderConfig: ChunkRemoteFor (required for this impl), ChunkBlocks
  (default 1024), ChunkHolder (default the replica ID),
  ChunkReadMissTimeout, ChunkCaptureInterval (periodic cut; 0 = off).
- The layer attaches in RecoverVolume after a successful Recover (the
  restart rules read the replayed dirty map). A volume this provider
  created starts from the remote HEAD; an existing one stays
  authoritative. The manifest epoch is the projection's master-assigned
  epoch, held separately from the frontend Identity. A cut is admitted
  only while the projection is healthy for the volume.
- CaptureVolume and MakeVolumeRemoteDurable; Close stops the cut loop
  before the stores close (the store closes the layer).

Storage gains the exported surface the provider needs (aliases of the
seam types plus AttachChunkLayer), FileChunkBitmapStore (atomic,
checksummed state file plus an append-only delta log; a corrupt file
reads as lost, which falls back to the hash compare) and MemChunkRemote
(an in-memory remote for development and provider tests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:16:39 -08:00
Ping QiuandClaude Opus 5.5 69ff216bc3 storage: chunk layer under the walstore flusher (C1-C11 green, r4) (#102)
* storage: bound flusher snapshot to published LSN cut

* storage: make checkpoint snapshot atomic with write publication

* storage: chunk layer seam and RED contract tests C1-C11 (r4)

Successor to the earlier seam drafts, reworked after three reviews.

Capture is a quiesced cut: block writes, Sync, copy the chunks dirtied
since HEAD through the normal read path, release, upload outside walstore
locks, then CAS HEAD with RemoteLSN = H. The seam declares Capture,
MakeRemoteDurable, EvictChunk (per chunk; absence survives restart), Close,
an owner admission gate (the epoch fence is what stops a demoted primary),
an explicit fresh-from-HEAD mode, a bounded read-miss timeout, chunk refs
with SHA-256, and a persisted dirty-since-HEAD bitmap kept off the write
path: made durable inside persistCheckpoint before any checkpoint or WAL
tail advance on every path, a header plus delta archive per cut, and a
hash-compare fallback. A BASE rebuild is recorded in the header as
installing (interrupted: cuts stay refused after restart until a complete
install) or installed-awaiting-cut (EndBaseInstall only after its frontier
is durable; the next cut hashes fully).

The fakes log remote calls and CAS outcomes in order, gate Put and Get,
inject unknown and applied-but-lost CAS outcomes and pre-CAS takeovers,
enforce chunk hashes, detect buffer mutation on every Put exit, key reuse
and deletion of referenced keys, and park bitmap persistence with an entry
handshake. Every held worker is unblocked, joined and its resources closed
with a bound, from cleanups registered before it starts. The layer is not
implemented, so every C test fails at attachChunkLayer; the fakes' own
tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* storage: chunk layer under the walstore flusher (C1-C11 green)

Implements the seam pinned by the contract tests. Store wiring, each a
no-op without an attached layer:
- a capture write barrier (captureMu) held shared by Write, WriteBatch,
  ApplyEntry and WriteExtentDirect, exclusively by a cut;
- OnExtentWrite from the flusher's extent write (with LSN) and from
  WriteExtentDirect (BASE, LSN 0);
- BeforeCheckpointAdvance inside persistCheckpoint and inside Sync's
  direct-frontier path, before any metadata write; an error refuses the
  advance;
- OnReadMiss before readFromExtent takes its lock;
- the layer's Close from WALStore.Close, before the lifecycle lock.

The layer (chunk_layer.go):
- quiesced cut (barrier, Sync, copy dirty chunks through Read, release),
  upload of changed chunks under fresh immutable keys, CAS of HEAD at H;
- an uncertain or refused CAS is resolved by re-reading HEAD: our own
  proposal is adopted, a newer epoch or competing holder fences, anything
  else stays unresolved without a success claim; admission is re-checked
  before the CAS;
- dirty-since-HEAD bitmap off the write path: dirty map chunks plus
  in-memory marks, saved before every checkpoint advance, rolled over with
  a delta per cut, hash-compare fallback on a lost or mismatched header;
  entries at or below the latest cut do not re-mark their chunk;
- BASE install states (installing / installed-awaiting-cut) recorded
  durably; EndBaseInstall refuses until its frontier is durable;
- lazy fill of absent chunks with SHA-256 verification, never over a newer
  local block, bounded by ReadMissTimeout; eviction per clean chunk with
  absence (and local writes inside absent chunks) persisted next to the
  volume after an fsync.

Adds C3_WriteDuringCopyWaitsForTheCut, which holds a cut's copy on a lazy
fetch and requires a concurrent write to wait for it, and the bitmap
self-test's registered unblock and bounded join.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* storage: chunk layer fixes for presence, fill generation, stale attach

- Presence saves are serialized end to end (snapshot, volume fsync,
  sidecar replace, version update) under one mutex, so an older eviction
  snapshot can no longer overwrite a newer checkpoint-protected save; the
  sidecar's directory is fsynced after the rename.
- A lazy fill is bound to the chunk's absence generation (bumped on every
  eviction) and the HEAD ref it fetched; it installs blocks and clears
  absence only while both still match, so a fill held across
  fill/write/publish/re-evict cannot install older bytes.
- A HEAD that already belongs to a newer epoch or a competing holder
  fences the layer at attach and before the CAS, instead of serving as
  this holder's publication guard.
- Capture registers with Close in the same critical section that checks
  closure, and every concurrent Close returns only after shutdown is done.

Each fix comes with a deterministic schedule test (test-only hooks on the
layer, a one-shot held fetch in the fake) that fails on the previous
code. startCapture's cleanup releases registered unblockers before it
joins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* storage: chunk layer fixes for directory durability and stale fills

- A presence replacement counts as saved only after its directory entry
  is durable: syncDir returns open and fsync errors, persistPresence
  returns them without advancing the saved version, and so a checkpoint
  advance (or an eviction) that needs the save is refused. Windows cannot
  fsync a directory handle; there syncDir is a no-op.
- A read miss never authorizes reading an unresolved extent. Within one
  ReadMissTimeout it fetches the chunk as the current HEAD names it; a
  fill that went stale (eviction generation or HEAD ref changed) installs
  nothing and the read retries, so the extent is read only once the chunk
  is no longer absent or the block has a local version.
- A hash-compare cut no longer copies chunks that are absent and
  unwritten: they are HEAD's content by definition, and copying them made
  a fresh host's first cut fetch the whole volume.

Schedule tests: a failed directory open or fsync leaves the presence
unsaved and the checkpoint and physical WAL tail unchanged, and a retry
succeeds after the fault clears; a held fill that goes stale when a
competing holder publishes H2 returns H2's block or an error from the
original read, never the zero extent; a fresh host's first cut fetches
no untouched chunk. The stale-attach test also asserts fencing right
after attach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* storage: chunk layer read re-resolves after a miss

A read miss that waited on a remote fetch could fall through to the
extent after the same block was written to the WAL (synced, not flushed):
the fill skipped the dirty block, cleared absence, and readFromExtent read
the untouched zero extent. Now:

- After OnReadMiss resolves, readFromExtent re-resolves through the normal
  path (dirty map/WAL first) before reading the extent. No lock is held
  there.
- A fill installs HEAD's block beneath an unflushed WAL write instead of
  skipping it. Reads resolve the dirty map first and the flusher replaces
  the extent later, so this is safe, and the extent holds HEAD's value
  rather than zero if that unsynced write is lost in a crash.

Schedule test: a fresh host's held read of LBA 9 overlaps a synced,
unflushed write to LBA 9; the original read returns HEAD's block or the
write or an error, never the zero extent; the next read returns the write;
the extent beneath it holds HEAD's block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:10:57 -08:00
Ping QiuandClaude Opus 5.5 cd1555b705 transport: close the replica connection when ApplyEntry fails (#93)
* storage: bound flusher snapshot to published LSN cut

* storage: make checkpoint snapshot atomic with write publication

* transport: close the replica connection when ApplyEntry fails (#89)

The production replica listener (no apply hook) only logged a failed
store.ApplyEntry and kept reading. Later entries on the same connection
were still applied, so the next barrier acked a frontier past the LSN
that was never applied. walstore's ApplyEntry can fail when its WAL is
full, and the primary only checks that AchievedLSN reaches the target,
so the gap went unnoticed.

A failed apply now ends the connection, as the apply-gate path already
does. Nothing after the failed LSN is applied on that connection, and
the primary sees the close, marks the peer degraded and recovers it
from the replica's real frontier.

The new test ships LSNs 1, 2 and 3 with LSN 2 failing and checks that
no barrier, on the same connection or a fresh one, acks LSN 2 or later.
It fails before this change (the barrier acks 3) and passes after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: prove the failed apply, the close and the primary's recovery (#89)

The replica test now waits for the injected ApplyEntry(2) failure, requires
the failed connection to end with EOF or a reset (a timeout fails), and
checks that LSN 3 never reaches the store.

A new component test runs the production primary path with the host's
PeerAdapterRegistry and probe loop: a transient replica apply failure
degrades the peer, recovery replays from the replica's frontier starting
exactly at the failed LSN with exact bytes, the peer returns to healthy,
and a later write and barrier succeed. Without the fix the peer is never
degraded and the failed block stays missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 02:10:50 -08:00
Ping Qiu 47c8d1482b storage: prevent dirty snapshots from checkpointing past synced writes (#91)
* storage: bound flusher snapshot to published LSN cut

* storage: make checkpoint snapshot atomic with write publication
2026-11-15 02:09:50 -08:00
Ping Qiu 1440b789e5 fix(nvme): honor FUA before completing writes (#90)
* test(nvme): require FUA completion to wait for backend sync

* fix(nvme): sync FUA writes before sending completion
2026-11-15 02:09:44 -08:00
Ping QiuandClaude Opus 5.5 b1871160e0 Fence the dual-lane rebuild port with the replica admission rules (#85)
* test: red test for the unfenced dual-lane rebuild port

A host fenced as primary still accepts base blocks on the dual-lane
port. Expected to fail until the port is fenced (#84).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fence the dual-lane rebuild port with the replica admission rules

The dual-lane port applied base blocks and WAL entries with no epoch or
role check. SessionStart now carries the sender epoch, and the
production ReplicaBridge asks ReplicaListener on SessionStart and each
mutating frame: no frame on a primary, below the floor, with epoch 0,
or before the role is known. A higher epoch is persisted first, and a
fence waits for frames already admitted.

The SessionStart frame grows from 28 to 36 bytes, so both ends of a
dual-lane rebuild must run this version.

Fixes #84

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* keep BaseDone and BarrierReq inside the dual-lane counted section

BaseDone released admission before MarkBaseComplete advanced the
frontier, so a fence could return while that mutation was pending.
BarrierReq was not gated, so a fenced replica could still answer it.
Both now stay inside the section; the barrier holds it until its
response is written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* end the barrier section before its reply

A fence drains effects, not network writes: holding the barrier
section through BarrierResp let a peer that does not read make
FenceAsPrimary time out after every effect had finished. The section
now covers the sync and the completion check, and ends on every path
before the reply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 22:40:52 -08:00
Ping QiuandClaude Opus 5.5 2e204b533c fix(G1): persist the replica epoch floor across restarts (red test first) (#83)
* test(G1): red - a restarted replica applies a ship below its acknowledged epoch

fencing-gaps-todo.md G1, red test first, as the doc describes it: a
listener accepts a ship at epoch 2, is stopped and restarted on the same
store, and a ship at epoch 1 arrives. Today it is applied: the floor was
in memory only.

Adds the seam the fix uses: NewReplicaListenerWithFloor(addr, store,
floorPath), which cmd/blockvolume now uses with
<durable-root>/<volume-id>.replica-floor (empty for memback). floorPath
is ignored in this commit, so the test is red on behaviour.

Stacked on the G2 branch (it reuses G2's epoch floor).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(G1): a durable replica epoch floor, and no mutation before the role is known

fencing-gaps-todo.md G1, per the plan accepted on #83 (claude03; codex01
rounds 1-3).

- core/transport/floor.go: a versioned, volume-bound floor record,
  strictly decoded (unknown/duplicate/missing fields, trailing data, wrong
  schema or volume, over 4 KiB refuse); persisted by temp write+fsync,
  rename, directory fsync, each checked; InitReplicaFloor creates the
  bootstrap record (epoch 0) before the volume and never replaces one.
- Listener: NewReplicaListenerWithFloor(addr, store, volumeID, floorPath)
  loads the record (missing or invalid refuses) and starts unassigned:
  every mutating frame is refused until a role call succeeds. A frame
  whose epoch raises the floor persists it inside its G2-counted section
  before any effect or ACK (a barrier too); serialized under floorMu and
  monotonic; a refused frame leaves the lineage unchanged.
  FenceAsPrimary drains, persists, then returns; AdmitAsReplica persists
  first; both return the error.
- Host: AdmitAsReplica errors fail the supporting path closed; any failed
  role call sets an admission latch that makes the projection unhealthy
  (writes refuse even on a prior-healthy host), reported in /status;
  a later successful role call clears it. SetSelfFence returns the
  replay error and cmd/blockvolume then does not serve.
- cmd/blockvolume: the floor record is created before a new volume
  (DurableProvider.VolumeExists), and required on every later start.

Tests: the red test, revised to the accepted 3-phase form (epoch-2
barrier ACK; restart refused before assignment; a stale epoch-1
admission still refuses epoch 1; current epoch accepted), barrier-only
restart, fresh restart before assignment, record negatives and the
existing-empty missing-record refusal, per-step persist failures on
ship/barrier/rebuild, role-call persist failure incl. after a drain,
fence-then-crash, concurrent monotonic raises, probes never persist, and
the admission latch through the real StorageBackend. Each mechanism is
load-bearing: without persistence 5 tests fail, without the startup gate
2, without the latch 1. Ledger: INV-FENCE-FLOOR-DURABLE-001.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(G1): stale role replays never reconcile a newer failure; the floor record's key set is closed

codex01 review of 66446e0:
- R1: a stale successful role call (e.g. an epoch-2 replay after the
  epoch-3 persist failed) cleared the admission latch and reopened
  writes. The host's desired role is now monotonic in epoch: a role call
  below the current desired epoch is refused as stale, without
  replacing the desired role or touching the latch; only the current (or
  a newer) epoch's success clears it, and install replay targets the
  retained current role.
- R2: encoding/json struct decoding accepted case variants, so
  {"epoch":7,"EPOCH":0} loaded as floor 0. The key check now runs before
  decoding and accepts exactly schema, volume_id and epoch, case-sensitive,
  none repeated.

Red (66446e0's floor.go and host.go) / green: codex01's two controls;
the stale-replay cases on the primary, supporting and install-replay
paths; uppercase keys, case-folded duplicates in both orders and a
case-folded schema key refuse; canonical epoch 0 stays valid. All 23
G1/G2 tests pass 3/3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 08:44:36 -08:00
Ping QiuandClaude Opus 5.5 cb353bccea fix(G2): a new primary fences its own replica listener (#82)
* test(G2): red - a promoted host applies the deposed primary's ship

fencing-gaps-todo.md G2, red test first. A real ReplicaListener and the
real Host.applyFact primary path: ship at epoch 1 to listener B, master
promotes B to primary at epoch 2 (a self AssignmentFact), the old primary
ships at epoch 1 again. Today the ship is applied.

Adds the seam the fix uses: Host.SetSelfFence / fenceSelf call the
host's own listener on the primary path (after UpdateReplicaSet, before
OnAssignment) and on the supporting-replica path, and replay an already
adopted role when the listener is installed later (cmd/blockvolume wires
it before Serve). The listener's FenceAsPrimary / AdmitAsReplica are
no-ops in this commit, so the test is red on behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(G2): a new primary fences its own replica listener

fencing-gaps-todo.md G2. The replica listener gets an epoch floor and a
primary flag. FenceAsPrimary(e), called by the host on the primary path
before OnAssignment, sets the floor to at least e and refuses every
replication mutation; AdmitAsReplica(e), on the supporting-replica path,
re-admits replication but keeps the floor. acceptMutationLineage, the
single gate for ship, recovery lane start and rebuild block/done,
applies both. Probes are unchanged.

Green: TestG2_PromotedHostRefusesShipFromDeposedPrimary (real
Host.applyFact primary path + real listener) passes 3/3; new listener
tests: a primary refuses ship / recovery lane start / rebuild but answers
probes; the floor stays after AdmitAsReplica and never goes down.
Ledger: INV-FENCE-SELF-ON-PROMOTE-001.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* style(G2): gofmt replica.go field alignment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(G2): the fence drains replication mutations already past the gate

Review of cc884db (claude03 P2-1, codex01 P1): acceptMutationLineage
released r.mu before the store write, and FenceAsPrimary only flipped
flags, so a deposed-epoch ship or rebuild admitted just before promotion
was applied after the fence returned, while the host served as primary.

Each mutating frame (ship, recovery lane start, rebuild block, rebuild
done, barrier) is now counted under r.mu from before its gate check until
its storage effect is done; its ack is written after it is uncounted, so
the fence never waits on the network. FenceAsPrimary sets primary and the
floor (no new admissions), then waits for the count to reach zero, bounded
(10 s); on timeout it returns an error and the host fails closed: no
OnAssignment, as for an UpdateReplicaSet failure; master redelivers.

Lock order: Host.selfFenceMu -> ReplicaListener.mu, never the reverse;
r.mu is held only for gate state and the counter (Cond.Wait releases it),
never across storage or network calls.

Red (fence without the wait) / green: in-flight controls for ship (direct
and ApplyHook paths) and a rebuild base write fail, then pass 3/3; a
mutation stuck past the bound makes the fence report an error; the host
does not adopt primary when the fence fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 00:49:38 -08:00
Ping QiuandClaude Opus 5.5 5605d45b97 docs(protocol): track epoch/fencing gaps G1-G5 (#81)
* docs(protocol): track epoch/fencing gaps G1-G5

Opens a TODO for five fencing gaps found while reviewing the epoch
protocol at b1ff581. G1-G3 are confirmed by reading the code (replica
floor in memory only, new primary does not fence its own listener,
production promotion runs without a required ACK frontier). G4 is a
design decision (no primary lease). G5 needs a test first (caught-up
check has no epoch). Each item has the failure scenario, the proposed
fix, and the red test to write first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(protocol): record the G4 decision (option A, non-claim for alpha/beta)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 22:39:12 -08:00
Ping Qiu b1ff581924 Merge pull request #80 from seaweedfs/phase174-frontend-replication-execution
storage: close execution architecture decisions
2026-08-01 05:07:22 -07:00
pingqiu e13e3f6620 docs: trim phase174 signoff whitespace 2026-08-01 04:41:56 -07:00