- A test-only hook right before the capture barrier's Lock request; the
pause tests hold the barrier shared for 300 ms after that handshake (not
after admission plus a sleep), so the cut provably waited at its Lock and
pre-barrier time is excluded.
- The helper releases the shared hold on every path (also on a failed
assertion) and joins the cut within a bound.
- Design docs: barrierPauseNs runs from the Lock request and includes
lockWaitNs.
Mutants (declared, 4/4): pause timed after the Lock, lock wait unset, body
drops the field, the hook fired after the Lock (no handshake).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fix H and candidates under the short barrier; save pending chunks before mutation.
Drain owners and waiters before cleanup, recovery, reset and close. Preserve
intent/CAS and local durability contracts. Include native caller controls,
existing model correspondence and a real-mount rehearsal note.
TestWALStoreV3StaleLapBytesAtTheWrapAreNotReplayed replays the forged
replay reproduction (docs/spec/README.md, open item 2) end to end on a
mapped v3 WALStore: a guest batch in lap 1 carries a well-formed record
bound to the volume's own nonce at its lap-1 cursor (LSN 999, LBA 7); the
WAL wraps so one newer record overwrites only the batch's start and the
lap-2 scan resumes exactly at the embedded record. The cursor binding
stops the scan there; after a crash and reopen the frontier is the newest
real LSN and LBA 7 is never the forged data. With the lap dropped from the
cursor check the scan admits the record and the test fails.
README: open items 1 (corrupted synced records) and 2 (forged replay) move
to "resolved in v3 (code)", citing the v3 tests. Still open: the mode C
newest-batch residual (silent truncation until an idle refresh or
SetWMode(A)) and the TLA model, which has no nonce/cursor/lap binding
(S3v1_root_lww_I1 and S3f_* rerun on cc5cf09a with TLC 2.19: unchanged).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All 27 W4_*/RED_* configurations re-run against the model at 7dd83eb6
(TLC 2.19, BFS): existing passes still pass, the new horizon
configurations pass with failing extension writes and a restart,
RED_hz_noclamp violates HostWithinHorizon as expected, the existing REDs
and witnesses keep their verdicts, the two large and the two "both"
configurations reached their time limits with no violation, and the two
open findings (W4_drift, W4_forced_exact) are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lease.exp is now the published horizon, dhz the horizon on disk and
deadline the latest grant. A renewal of a live lease writes nothing:
grant = min(now + TTL, horizon), refused while uncertain or without
validity, and it may trigger an extension. The extension (MasterExtend)
is an ordinary serialized writer that raises the horizon to
trigger + TTL + HSlack; with ExtFail its write may fail without landing or
after landing, and either way latches uncertain. Revocation, ACK and move
writes are refused while uncertain; a restart reloads the disk horizon and
clears uncertainty. The revoking drain reply is clamped to
min(horizon, deadline). Nondecreasing time is stated as a model assumption.
New invariants HostWithinHorizon and DiskCoversMemory; witnesses
W_NoExtension, W_NoExtLanded, W_NoUncertain. New cfgs W4_hz_* (failing
extensions, clean/forced/both, one restart) and RED_hz_noclamp (no clamp:
EXPECTED to violate HostWithinHorizon) with the control
RED_hz_noclamp_safety (no clamp, split-brain invariants: expected to pass,
the restart rule covers grants). Existing cfgs gain Clamp = TRUE and
ExtFail = FALSE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review folds, tests and docs only:
- The combined concurrency control now requires its schedule: a bounded
handshake holds the first horizon-extension write inside the store
while renewals keep succeeding and the writers and Close are in flight
behind it, then releases it. It counts successful grants per eligible
volume and extension writes classified by content (a raised horizon at
the same epoch, not an ordinary writer's record) and requires both.
- It adds the forced-move arm next to the clean move: the forced volume
is granted at an earlier injected time, so its horizon + skew barrier
has passed when the writers run; the clock only moves forward.
- Held-write controls install their release cleanup before the hold is
triggered, bound every admission and completion wait, and on any
failure release, settle workers with bounded joins and only then close
fixtures.
- Docs: an uncertain volume refuses renewals that would issue a new or
extended grant; a Revoking lease still gets its bounded drain reply,
min(horizon, deadline), never extended, as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- invariants.md: M2 lease rows (first grant writes the horizon, renewal
from memory under a clamp, revoking reply carries the grant, expiry
and forced barrier on the persisted horizon); new rows
INV-LEASE-VIEW-001, INV-WS-LEASE-HORIZON-001,
INV-WS-RENEW-NONBLOCKING-001 and INV-LIFECYCLE-SNAPSHOT-001;
INV-WS-FORCED-MOVE-001 now names the horizon and the reply clamp.
- INV-AUTH-UNCERTAIN-001 moves from STUB to ACTIVE: its renewal reader is
documented, and the ambiguous-extension control now also asserts that
a revocation and an endpoint change of the uncertain volume are
refused.
- Proof-text folds: the forced-barrier argument assumes nondecreasing
master time, an assumption of the current WorkspaceTakeover model,
not a consequence of time.Now's monotonic reading; the horizon
invariant treats an ambiguously persisted issued successor (lease
cleared) as the ordered clean-handoff or forced-barrier case.
- agent-workspace-design.md section 7 and workspace-lease.md: the
master side of a renewal, the extension, the capacity bound, the logs.
The WorkspaceTakeover specification is not changed here; its update and
recorded configuration results are a later acceptance step.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Step 6 counted only saved-chunk readers. A saving writer and a copier
reading the live chunk also do I/O outside the per-chunk mutex, so an abort
or Close could see zero references and delete the side store while they
were still in I/O. Now every saving or copying owner holds a window
reference from its state claim until its I/O ends, readers hold one too,
abort does not wait for its caller's own reference (a self-aborting owner
releases first), Recover/reset/Close join every owner and reader before
their destructive transition, and the side store is deleted exactly once
at a terminal state with no reference outstanding. The test list names the
held saving owner and held live-copy owner cases. Text only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Design review of the copy-before-write proposal, folded in one revision:
- the COW step runs before publication and outside store.mu (right after
captureMu shared, before lifecycleMu/mu, the WAL append and the dirty-map
insert), because the save uses the ordinary read path; a post-publication
hook cannot do this; lock order stated;
- one owner per chunk (copier: pending -> copying -> done; writer:
pending -> saving -> saved), a per-chunk mutex never held across I/O,
waiters on a per-chunk condition;
- batches visit chunks in ascending index and finish each before the next,
so they cannot deadlock with each other or the copier;
- terminal states closed or aborted; abort on save error, cancel, fence,
and before Recover/reset/Close in the same open, taken before the
mutation proceeds; waiters woken; the cut fails retryable and keeps its
dirty set; a guest write is never refused for a cut problem;
- the side store is deleted only after close/abort with its refcount at
zero; upload, manifest and CAS work from the buffers, so an unknown CAS
keeps today's semantics;
- BASE: capMu stays held for the whole cut and already excludes
Begin/EndBaseInstall (the earlier open point is removed);
- reads bind to the format-v3 read path, no flusher hook;
- the Model paragraph states what the model does not cover (owner races,
batch order, abort), and the test list grows to match.
Text only; the TLA+ model is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cut copies every candidate chunk under the capture barrier, so writes
stall for the whole copy (1.50 s at 3 GiB dirty in a lab measurement).
agent-workspace-design.md section 5 now has a proposed (not implemented)
copy-before-write design: the barrier only fixes H and the candidate set;
the first write to an uncopied candidate saves its at-H content to a local
side store; a write to a chunk being copied waits; the copier reads the side
store or the live chunk; the side store is dropped at the CAS and on crash,
and recovery never reads it. Alternatives, the open BASE-install point, and
the tests to write with the code are listed. Section 14's cut-cost gap
points at it.
docs/spec/CutCOW.tla (S4c) models today's barrier cut and the design, with a
two-step chunk copy and one crash. Both pass exhaustively at MaxLSN 6 with 2
cuts (COW 34,342,214 states, barrier 5,070,320). Each of the six design rules
is necessary: dropping any one violates BufFrozen. 11 configs, run.sh and
the spec README updated; all 13 specs pass SANY with tla2tools 1.7.4.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codex03's row 12a retirement-timing seam, store half: a completed BASE
must not retire while the provider's fresh-from-HEAD marker could still
make a reopen seed from HEAD over the completed local bytes.
- CommitChunkAttachV3(commit) runs the provider's commit (the marker
removal and directory fsync; no store re-entry) under installMu
exclusive, and only when it succeeds records this open's durable
attach and lifts the retirement deferral of an installed volume. A
failed commit changes nothing.
- OwnerChunkAttachDurableV3 reports that flag (atomic); Defer resets it at
every managed open; a begin re-arms the gate but keeps the flag.
New edge: the provider's attachMu -> installMu; the store takes no
provider lock. Not a v3 store: commit only.
Control: the commit runs under installMu exclusive; a failed commit sets
no flag and the volume stays installed; a successful one retires it on
the next publication; Defer resets the flag. Mutants: lifting on a
failed commit, not recording the flag, committing outside installMu.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Descriptor-owner ruling on codex03's row 12a retired-BASE RED (6f545aad):
once a completed BASE retires to none, nothing durable tells the provider
that the local image is complete rather than a lazy seed. Retirement may
now be deferred, opt-in per store, so the installed descriptor stays that
evidence until the chunk layer has durably recorded local presence:
- DeferBaseRetirementV3 (the provider, at open, before Recover and any
publication) and AllowBaseRetirementV3 (the chunk layer, after durable
local presence) set an atomic gate on the publisher;
- retireBaseV3 is skipped while the gate is deferred; once allowed,
retirement happens on the next ordinary publication;
- every successful begin re-arms a lifted deferral, so a later install in
the same open needs its own durable presence before it may retire.
The publisher only reads the atomic under descMu: no new lock edge, no
format or durable field. Stores that never set the gate retire as
before, so a volume without a chunk layer cannot be stuck installed.
Control: a deferred store stays installed through publications whose
8.4 conditions hold, retires on the first one after Allow, and a second
install in the same open is deferred again. Mutants: a publisher that
ignores the gate; a begin that does not re-arm it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agent-workspace-design.md:
- section 3: a HEAD, a snapshot and a fork root are each a complete map
(no backing chain, no per-layer bitmap); a cut uploads only changed
chunks and rewrites only their segments; the dirty bitmap is local
holder state, not part of a snapshot; a worked example (100 chunks,
init, 20 rewritten, snap1: 120 objects, deleting init frees 20).
- section 6: the GC roots line now says what the code does: a deleted
snapshot's attempt stays a root for one grace period after its delete
time (Collector.snapshotAttemptHeads), then stops counting.
- section 6: freeing an old snapshot's data in three steps (delete the
name, GC --apply with two marks a grace apart, SeaweedFS volume vacuum)
with the timing at the default grace, and why GC uses a reachability
mark rather than reference counts.
No invariant row changes (INV-GC-REACHABLE-001 already covers attempts).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.4 section 10.1. The tool (cmd/sw-block/migrate.go) runs the
steps, each durable before the next: the read-only exhaustive scan and
the geometry check (a refusal changes no byte), the atomic operator
backup of the v2 superblock, the initial map sidecar (generation 1, every
chunk UNKNOWN, covered = the v2 checkpoint), the prepared slot B at 4096,
slot A at phase 0 (the commit point), slot B at phase 0, then the v2
chunk bitmap retirement, and prints the new descriptor hash. A rerun
decides from the slot bytes alone (the 10.1 table): a v2 A restarts with
a full rescan; a committed A finishes the rollover and the retirement; a
committed B only the retirement; a prepared B with an invalid A refuses
with ErrMigrationIncomplete; neither valid refuses. It never reads or
restores the backup.
core/storage/migrate_v3.go is the tool-only export: it reuses the row-1
slot codec and the row-6 map codec (no second encoder), keeps the extent
base (new WALSize = old - 4096), and opens or serves nothing.
Controls through the actual CLI entry and, tagged, the actual v3 open:
a clean migration (extent unchanged, backup, retirement, the old binary
refuses, an idempotent rerun, v3 serves the v2 blocks with an all-UNKNOWN
map), refusals changing nothing, a crash after each step, the old binary
after preparation, a partly and wholly overwritten prepared B, and the
backup never restored. Mutants: no clean scan, commit before prepare,
retire before the commit, no rollover on rerun, an unrefused incomplete
state, a clean initial map. Not yet: the shared advisory lock (12b) and
committed raw v2 fixtures (13c).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The activation limiter codex01 named: v3 WriteBatch (the real 8 KiB
multi-block write) and its replay/read path returned errV3NotYet. Dark:
- WriteBatch on a v3 store appends one multi-block record (type 0x04)
with LSNs first..first+n-1 and one CRC32C, so a crash keeps all of it
or none; the writer consumes the whole range (DESIGN 6.7, r16), the
map coverage follows every block's LSN, and each block's dirty entry
names its data offset inside the record. A single block is a write.
- One whole-record reader (readWholeRecordV3, blockOfRecordV3) serves the
store read, the flusher and codex03's dark offline reader: it sizes the
record from its type and Length, validates the whole record and the
block's LBA, LSN and offset in it. The read retry also compares the
data offset.
- Recovery's replay and the install-path replays (the reopen cut and the
same-open continuation) republish every block of a batch.
Controls: round trip across a crash in both modes, a torn batch (dropped
whole when unacknowledged, fail-closed when acknowledged), a crash
mid-batch (latched, never acknowledged, none served), the ack boundary,
the flusher, the offline reader and the map coverage. Mutants: block 0
reads, first-block replay, a split batch, a flusher at offset 0, an
offline reader indexing only block 0, no map coverage.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codex01 review of aa477c09 (pre-existing live-continuation P1): a
same-open installing Recover cleared the dirty map without replaying it.
With BASE LBA 1 = B0 and then install-lane LSN 11 at LBA 1 acknowledged,
the original handle could continue (r17.4), apply and acknowledge LSN 12
and complete, and a same-open read of LBA 1 then fell back to B0.
When the installing ID was begun in this open, the Recover now either
republishes the live install's trusted records (<= R) in the dirty map,
keeping the volatile map coverage (the BASE writes' UNKNOWN) as it is,
or, when the recovered cut is short of the live writer (damage under a
live install), latches the store so the handle cannot append behind the
gap; a physical reopen then decides intact or damaged. No DESIGN text
change.
Controls: codex01's exact schedule completed and read through the
original handle in the same open; a same-open Recover over a damaged
record fails closed. Mutants: no replay (serves B0), no latch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codex01 row 11b review (3c67ee56): a same-open Recover while this open's
install was live cached E and R but left the install's handle valid
(r17.4: until the next begin). That handle could apply and acknowledge
LSN 12 past the cut; a resume then fenced from the cached E and
fsync-erased the acknowledged record before the forward-only writer
refused to move back.
An installing Recover now records its recovered bounds only when the
installing ID was not begun in this open (a physical reopen). After a
same-open Recover the live install simply continues; a resume or a
fenced supersession refuses before any I/O. No DESIGN text change:
section 8.3's resume is the reopen case, and r17.3.1 already says a
same-open continuation keeps the live writer position.
Control: the held schedule (same-open Recover, the old handle applies
and acknowledges LSN 12, then a resume): the resume refuses, LSN 12's
bytes are unchanged, and a physical reopen still resumes and serves it.
Mutant: recording the cut on a same-open Recover erases LSN 12.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.4 section 8.3, "Resume (same ID)", store level and dark (no
current caller resumes: both receivers begin fresh install IDs). Under
installMu exclusive the resume appends nothing until all three hold:
1. trusted-through-W: the recovered suffix is intact (R >= W*) and E is
at or past the persisted retainedHead;
2. the 6.6 fence of [E, floor + WALSize) with fsync;
3. a publication of retainedHead = E (G3).
Otherwise it refuses with ErrInstallSuffixDamaged, writing nothing, and
the volume stays installing. The writer continues at E (forward only)
and the reopen's trusted install-lane records are replayed so the
completed image serves them. The installing Recover now keeps those
records with its recovered bounds.
Controls: an intact resume that serves the recovered LSN 11 and fences
the dropped LSN 13; a damaged suffix refused; E below the persisted head
refused, while a covering supersession anchors at P = that head and stays
resumable across a crash. Mutants: no fence, ignoring the damage, no
E >= head check, anchoring the supersession at P = E.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.4 sections 6.6 (G3) and 8.3, dark:
- An installing Recover keeps its recovered bounds (E, R, intact or
damaged) and moves the allocator state above every trusted record, but
fences, publishes and admits nothing; the outcome stays the typed
ErrBaseIncomplete.
- A superseding begin after that reopen checks the coverage rule, then
fences [E, floor + WALSize) and fsyncs before its two-slot installing
publication, so no record of the old install beyond E re-chains;
it anchors at P = max(E, the persisted retainedHead), never lowers
retainedHead, and restarts the writer at P (advanceHeadV3, forward
only, no LSN change). Reads and the flusher see a recovery boundary.
- A damaged suffix refuses nothing here: the supersession does not need
trusted-through-W, because the new BASE covers every record <= W.
Controls: the G3 revival schedule (A's LSN 13 beyond the gap would chain
on after B's 12 at the same position) and a covering supersession over a
damaged, acknowledged suffix (below W refused, at W installs and serves).
Mutants: no fence; trusted-through-W applied to the supersession.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DESIGN r17.4 section 8.7, caller 2 (core/transport/replica.go, the
production default --recovery-mode=legacy):
- the first admitted MsgRebuildBlock of a connection, or an empty
rebuild's MsgRebuildDone, begins one install at the lineage's frontier
hint under a fresh random ID; a different hint on the connection is
refused; a reconnect is a new connection and so a superseding install
under the coverage rule;
- each block is written through the handle's WriteBase, never the
store-level WriteExtentDirect;
- MsgRebuildDone completes through the handle, then calls Sync, which is
ordinary once installed, and stops discarding the Sync error: a failed
completion or Sync closes the connection with no MsgBarrierResp.
Stores without the seam keep their pre-seam behaviour behind the legacy
handle (lazy BaseStager staging, WriteExtentDirect, AdvanceFrontier at
completion). The one behaviour change on them is the DESIGN 8.7 rule: a
Sync error on the done path no longer replies AchievedLSN 0 but closes
the connection. The live MsgBarrierReq handler keeps replying the gated
Sync's 0 while installing (section 7).
Tagged controls on a dark v3 replica: the positive and empty rebuilds,
the real BlockExecutor.StartRebuild -> doRebuild path, injected
MarkBaseComplete and Sync failures, and reconnect supersession.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
codex01 row 10a review (66be344b): after the publisher's final check, a
queued append of the same install could fail and latch the store while
holding WALStore.mu; SyncInstallLog then returned H anyway. It now
rechecks stickyIOFault under WALStore.mu immediately before it moves the
acknowledged frontier and returns H (the #172 ack-boundary rule section 7
imports), and returns the fault instead.
Control: a held same-ID append whose pwrite fails between the
publication and the ack; the ack is refused and the acknowledged frontier
does not move. Mutant: no final locked check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>