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.
At RF=1 every local write logged 'replication: OnLocalWrite volume=...
lba=... lsn=... peers=0'; under sustained writes one volume's log grew to
162 MB in 13 minutes and the useful lines were buried. The counters (Stats:
WriteOps, WriteFanoutNanos) keep the per-write evidence.
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>
If another writer created the lease after the renewal read the view, the
first-grant path now returns a retryable error instead of re-entering the
memory path. The host has no deadline before its first grant, so a failed
first renewal does not fence it; its retry takes the memory path.
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>
GREEN-gating controls for the memory-only renewal:
- grants clamp to the durable horizon under a permanently stalled
store, renewals without host validity or at the horizon are refused,
and a real guard fences by horizon - skew/2;
- a restart honours the persisted horizon in the forced barrier;
- an extension whose rename landed but whose directory sync failed
latches uncertainty, refuses the next renewal, and reloads with the
landed horizon barring a forced move until horizon + skew;
- an extender held inside its write orders a same-volume revocation or
forced move after it;
- same-volume renewals during held revocation and forced-move writes;
- the lease view equals derive(published) after every writer kind;
- N volumes renew concurrently with apply, revocation, ACK, a clean
move, extenders and Close (run with -race);
- Close joins a held extender, and an extender admitted before closing
writes nothing;
- lifecycle snapshots follow every records change, stay immutable, are
read without the store mutex, and keep a protective unknown outcome;
- through the services layer, query and revoke replies report the
grant, and a renewal during a held same-volume reservation returns
the revoking lease.
The r1-r3 slow-store wrappers count the delayed writes and require at
least one, so a green cannot bypass the injected stall. Tests that own
a Publisher directly join its extenders before their store closes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A renewal of a live workspace lease persisted the new expiry with a
temp-file fsync under the publisher's global lock, and the renewal RPC
also read two lifecycle stores whose mutexes writers hold across file
I/O. A slow or busy master disk therefore made the host's 2 s renewal
RPC time out, the guard fence and the volume shut down.
Renewal now takes only a small leaf lock (leaseMu) over a per-volume
lease view and does no I/O:
- grant = min(now+TTL, durable horizon), where the horizon is the
published Lease.ExpiresAtNS; the deadline is raised to the grant.
- It refuses stale, pending-move, expired, uncertain or storeless
state as before (never bypasses INV-AUTH-UNCERTAIN-001), and refuses
with an error when the grant would leave no positive host validity.
- The first grant of a lease still writes synchronously under p.mu and
persists horizon = now + 1.5*TTL.
- A per-volume single-flight extender is an ordinary p.mu writer: it
writes horizon = trigger + 1.5*TTL through persistWorkspaceLocked, so
its write and publication are one p.mu section; any write error
latches uncertainty as before.
Writers keep persist-before-publish and refresh the view (p.mu ->
leaseMu, the only new lock edge) at every derive-input change.
Revocation and query replies report the granted expiry, never the
horizon. Host.Close joins extenders before the store closes.
The renewal RPC reads lock-free immutable snapshots of the Volumes and
deletion-reservation stores, republished at every records change
(including load, delete and the protective unknown outcome).
Behaviour change: a forced move now waits for the durable horizon plus
skew, at most TTL/2 later than before. Existing tests that read the
persisted lease as the grant, or waited only grant + skew, are updated
with that reason. The store-write boundary guard now skips _test.go
files: a test double that delays and delegates Put is not a production
write caller.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add DeletionReservationStore.SetPersistHookForTest, an instance-local
test seam that installs the existing write-fault hook under the store
mutex (nil by default).
r5: while the deletion-reservation write of an unrelated volume is held
in that hook, a renewal through the services layer must return within
2 s. On main it waits on the reservation store's mutex.
r4 and r5 now release held writes first and settle every worker with
bounded waits before clearing hooks or closing fixtures.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
r4: while the revocation write of volume a is held inside the
authority store, a renewal of volume b must return within 2 s.
On main the renewal waits on the publisher's global lock until a's
write is released.
Tests only; no fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fold for #207: a valid reply that lands after the renewal call's
context ended, while the old lease and the new grant are still valid, was
recorded as "arrived after the lease deadline". The refusal is unchanged;
the cause now says which limit the reply missed: the lease deadline, its
own grant, or the call's context (with the lease's remaining validity).
Adds a bounded regression where the reply lands just after the 2s call
timeout with a 20s lease.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A renewal of a live workspace lease persists the new expiry with a
temp-file fsync under the publisher's global lock. When the master's
disk is slow, the host's 2 s renewal RPC times out, the guard fences
and the volume shuts down.
- r1: one renewal behind a 2.5 s store write must return within 2 s.
- r2: six concurrent renewals behind 0.5 s writes must not serialize.
- r3: a real WorkspaceLeaseGuard must not fence while the store takes
2.5 s per write (TTL 6 s).
Tests only; no fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fold for #207:
- A failed renewal now logs whether the call reached the lease deadline,
the 2s per-call timeout, or neither, so a slow master is told apart from
a lease that ran out.
- A stop that fails after a fence returns an error that names the fence
cause and wraps the stop error; after a renewal expiry or an invalid
reply both the renewal error and the stop error are kept (errors.Is).
- Tests assert the first cause wins, the fence is logged once, the cause
carries the exact deadline, and a late revoking reply keeps the
late-reply cause.
- The #205 test comment states the renewal-failure trigger as a hypothesis
that matches the code path, not a diagnosis the logs proved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guard fenced silently: when renewals kept failing until the lease
expired, it drained the volume through blockvolume's lease-stop path, which
logged nothing, and returned the raw RPC error (issue #205).
- Every fence records its first cause: lease expired without a successful
renewal, expired after a failed renewal (with the renewal's latency and
error), an invalid reply, a reply that arrived after the deadline,
revocation by the master, or shutdown. The guard logs it once as
"workspace lease: fenced ...", FenceCause() returns it, and the non-ACK
drain error carries it.
- Every failed renewal is logged with its latency and the lease deadline,
also when the lease is still valid: a run of them is the warning before
an expiry fence.
- An expiry after a failed renewal returns "workspace lease expired:
renewal failed after <d>: <err>", wrapping the RPC error.
- blockvolume logs when it stops because the guard requested the drain.
The fence behaviour itself is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Issue #205: under sustained write load a volume fenced because its lease
renewals kept failing until the lease expired, and nothing said so. The
shutdown path logged nothing; the only trace was the raw RPC error printed
at closeout. The fence itself is correct.
Two tests fail on main:
- a renewal that times out past the lease deadline fences (as today), but
the returned error must say the lease expired and keep the RPC error,
and the fence and its cause must be logged;
- a renewal that fails while the lease is still valid must be logged with
its latency (it does not fence).
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>
ScanLBAs on v3 now returns entries only when the trusted chain covers the
whole captured range [fromLSN, head): a chain that stops short is a WAL
integrity failure carrying the scanner's stop cause (CRC, binding,
truncation), a chain that starts after fromLSN is WALRecycled, and a
missing LSN mid-range is an integrity failure. Nothing is emitted before
the check.
An installing source is refused with ErrBaseInstalling before emitting.
The capture (recover generation, descriptor, head) is taken under s.mu
and revalidated after the scan, with no lock held across the callbacks;
a transition during the scan retries from a fresh capture, and a source
that began installing meanwhile is refused.
Controls: corrupt middle and first records (store), an installing
source, an install begun during a held scan, a Recover during a held
scan (retry), and a corrupt middle record through the actual catch-up
sender (the session does not close successfully).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 12b census found WALStore.ScanLBAs walking only the v2 WAL writer, so
a v3 primary served no catch-up: every catch-up shipped nothing and the
replica then refused the next live LSN as an unanchored gap. On v3 it now
scans the trusted v3 chain from the selected descriptor's scan start
(after the unchanged retention gate): a write record is one entry, a
batch record one entry per block with consecutive LSNs, every LSN in
[fromLSN, head), in LSN order. If the WAL no longer holds fromLSN it
refuses with the typed WALRecycled failure (the caller rebuilds) rather
than skip a range; today no v3 tail release exists, so that guard is
defensive until one lands.
Controls: the store scan (singles and a batch, from the start and from
mid-batch, the retention refusal) and the actual catch-up sender from a
v3 primary to an empty v3 replica (byte-identical). Mutants: the v2 scan
on v3, a batch emitting only its first block. The missing-fromLSN guard
has no discriminating control until a v3 tail release exists.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ordinary replicated ApplyEntry was still refused (errV3NotYet) on dark
v3, while its real callers are the replica's MsgShipEntry handler
(replica.go) and the ReplicaApplyGate's recovery and live lanes. It now
shares one body with the install-lane apply (applyEntryV3, DESIGN 8.1,
6.7, r16.1): through the v3 writer in LSN order; an LSN at or below the
highest appended is a superseded no-op when the LBA holds a higher LSN
and ErrWALLSNOrder otherwise; an unanchored gap is refused (recovery
needs a contiguous prefix); and an ordinary apply while installing is
refused with ErrBaseInstalling (the install lane is the handle's).
Controls: the store rules and a crash; the real ship handler on a v3
replica (apply, barrier ack, crash and reopen; an out-of-order entry
ends the connection); the real apply gate (recovery lane with its
stale-skip, live lane). Mutants: ApplyEntry refused on v3, no gap check,
no installing refusal. The store's order check alone is equivalent: the
v3 writer refuses the same LSN with ErrWALLSNOrder.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>