TestC2_NoGapDenseLSNEdge asserted that a Realtime NotifyAppend at the
dense edge (cursor=10, head=11, lsn=11) emits EmitKindLive, while the
shipper's 2 ms timer drain was running. When a tick landed between
primary.Write and NotifyAppend, the timer shipped lsn 11 from substrate
first (EmitKindBacklog, debt-first per §6.3) and NotifyAppend took the
idempotent skip, so the test saw kind=1. That is correct product
behavior: the entry ships exactly once at the right LSN, and the kind
tag is observability only (WALKindBacklog vs WALKindSessionLive
counters; the LiveTail probe is marker-only).
- TestC2_NoGapDenseLSNEdge now disables the timer drain and drains the
initial backlog with DrainBacklog, so the Live assertion no longer
depends on scheduling.
- New TestC2_DenseLSNEdge_TimerWinsRace_ShipsOnce pins the other order
deterministically: the timer ships the new entry before NotifyAppend
arrives; NotifyAppend returns nil and does not emit again.
No product change, no timeout changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflict in cmd/sw-block/chunk.go resolved as the union: the usage
string lists cut|snapshot|snapshots|snapshot-delete|fork|detach|show|
gc|usage|retain, and the switch keeps #140's "gc" case with "usage"
and "retain".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up: the release was a t.Cleanup registered before Start, and
cleanups run LIFO, so the executor shutdown Start registers ran first; a
t.Fatal while the base frame was held would deadlock StopAndWait. A defer
inside the scenario runs before every t.Cleanup, including on t.Fatal.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dropForkClaim's write is conditioned on {state, claims} as read; a lost
condition re-reads a fresh copy, so delete metadata is never
overwritten. (With the shared mark path a delete also clears the dead
claim first, which changes the condition on its own.)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of 02d0631 (P2): dropForkClaim conditioned its write on the
claims only, so a completed fork's cleanup that read the parent, paused
while an explicit delete marked it, then wrote back its stale copy,
resurrecting an unnamed active snapshot. TestCatalog_ClaimCleanupNever
UndoesADelete fails against the old cleanup condition and the old
(claim-blind) delete mark, restored as stubs: state "active",
deleted_ns gone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
markDeleting is the only way an attempt is marked deleting: conditioned
on {state active, gen, no claims}, dead claims cleared first, a lost
condition decided again. Retain keeps a claimed snapshot (fork_held);
DeleteSnapshot refuses it with snapshot_claimed naming the fork
(claude05's ruling, 23:58Z).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude05's ruling (2026-11-15 23:58Z): an explicit DeleteSnapshot of
a snapshot an incomplete fork claims is refused with snapshot_claimed
(409, not retryable, naming the fork volume); a completed or aborted
fork no longer blocks. Controls, failing against the old mark (blind to
claims) restored as a stub: TestCatalog_DeleteRefusesAClaimedParent, the
409 mapping, the real-filer refusal in TestIntegration_RetainHeldSchedules,
and TestFork_IncompleteRetryBoundToOriginalImage, which now expects the
refusal and drops the claim (as a pre-claim fork) to keep testing the
image binding.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up. The pre-barrier hold proved in-session delivery and
convergence but no longer the test's point: a newer WAL write for an LBA must
win over an OLDER base frame for that LBA that arrives later.
Drop the production SetPreBarrierHook seam (core/recovery is back to main)
and hold the base lane instead, through the existing WithPrimaryStorageWrap:
staleBaseHold captures the base read of LBA 5 (old value A) and holds it; the
test pushes the same-LBA overwrites (the session cannot seal its recovery cut
while base is held, so they ship in-session: this is also what fixes the
flake), waits until the replica holds B at LBA 5, then releases the stale A
frame. Convergence requires LBA 5 == B: RebuildSession.ApplyBaseBlock must
skip a base frame for an LBA the WAL lane already applied (bitmap).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replaces the separate hold objects with one conditional write on the
parent attempt's own entry (codex01's design):
- Fork adds its claim (target/request) to the entry before using it,
conditioned on {state active, claims as read}; a deleting parent is
refused. It removes its claim once its HEAD exists (or a sweep's
tombstone settles the target).
- Retain marks deleting only conditioned on {state active, gen, no
claims}; a lost condition re-reads and decides again. Claims that
can never matter (target has a HEAD, or its VOLUME is another
request's) are cleared conditionally first; any other claim keeps the
snapshot, with no lifetime. No listing, so no paging.
- A dry run lists attempts a stopped pass left deleting, as apply
frees them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Controls for the four fork schedules of the second review, failing
against stubs where Fork writes no claim, the delete mark is not
conditioned on claims, and a dry run omits unfinished deleting
attempts:
- a fork claiming between retention's check and its mark (unit and
real filer);
- a fork that died before its VOLUME keeps the parent 30 days later;
- a refused same-target request leaves the first request's claim;
- a dry run lists the attempt a lost response left deleting.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TestPillar3Slice2_EngineDriven_SameLBAArbitration was flaky (on main baca5fd,
-race -count=40: 25/40 failures at -cpu 1, 6/40 at -cpu 2, 1/40 at -cpu 4).
Root cause is a timing assumption in the test, not a product race: with a
12-LBA backlog, base copy and DrainBacklog finish in microseconds and
Sender.Run seals the recovery cut (SealBeforeBarrier) before the test pushes
its same-LBA overwrites. PushLiveWrite then returns ErrSinkBarrierSealed,
the documented 'retain the WAL entry for replay' outcome that production
FeedLiveWrite maps to LiveWriteRetained, and the test treated it as fatal.
Once in a while the whole session also finished inside waitBridgeLiveReady's
1 ms poll gap.
Tolerating the error would defeat the test (the overwrites would never ship
in-session, so convergence could not be checked), and a larger backlog would
only shift the timing. Instead add a test-only hook,
PrimaryBridge.SetPreBarrierHook: each sender runs it after base + backlog
drain and before SealBeforeBarrier. The test installs it before the probe
that starts the rebuild, waits until the sender reaches it (session live,
cut not made), pushes the overwrites, releases, and asserts convergence.
With no hook installed the sender path is unchanged.
The now-unused waitBridgeLiveReady helper in this package is removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Retain deletes the exact attempt it planned: the attempt's entry is
marked deleting conditionally and the name record is removed only
while it names that attempt; a replacement is reported as replaced.
- Fork records a hold (forkholds/<name>/<attempt>/<target>) before it
reads the parent. Retain marks first, then reads the holds: a live
hold reverts the mark (fork_held); a fork holding after that read
finds the attempt deleting and refuses before installing anything.
A hold counts while its target has no HEAD and its VOLUME records the
fork, or while it is younger than the operation deadline.
- A pass stopped after a mark finishes (or reverts) it on the next run.
- Log-spaced keeps use rolling windows anchored at now.
- Exclusive bytes resolve "@owner/key" refs and count every volume's
HEAD and live snapshots as holders; documented as eligible for GC
subject to its grace period and intents.
- Retain reports confirmed deletions, the failing snapshot (uncertain
or not) and what it never reached; the CLI prints them with the
error and exits nonzero.
- chunkControl.Snapshot validates the class before any cut;
invalid_class and invalid_policy map to 400.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Controls for the six review findings on retention, failing against
stubs that restore each old behaviour:
- a same-name pinned replacement made after planning is deleted
(retain deletes by name);
- a fork that starts after the scan loses its parent; a stale hold;
a fork after the hold check;
- log-spaced keeps use calendar periods (10:20 and 09:50 both kept
at 10:30 with keep-hourly 1);
- exclusive bytes ignore a fork's "@owner/key" holders;
- a failing pass discards its partial result (catalog and CLI);
- an invalid class cuts before it is refused, and maps to 409.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude05's rulings (2026-11-15 22:53Z).
Retention, policy on the VOLUME entry: keep the newest KeepNewest
unpinned snapshots, every pinned snapshot not yet past its ExpiresAtNs,
every snapshot younger than KeepYounger (a future creation time from
clock skew counts as young), the newest snapshot of each of the last
KeepHourly / KeepDaily / KeepWeekly periods, and every snapshot a fork
still needs (named by a fork whose HEAD is absent or aborted). Everything
else is deleted through DeleteSnapshot (attempt-scoped tombstones; HEAD
untouched; names freed); GC reclaims the chunks. Equal creation times
rank by name. Semantic and labeled snapshots are not exempt; a pinned
snapshot past its expiry is unpinned. Defaults: 10 newest, 1h. A dry run
plans and writes nothing. The policy is stored as extended attributes on
the VOLUME entry, conditional on a revision.
Accounting, from manifests and filer listings (no data reads; a chunk is
ChunkBlocks x BlockSize, the last clipped): live bytes from HEAD;
per-snapshot exclusive bytes (referenced by no other holder); stored
bytes from the volume's chunk-key bindings, exact for referenced keys
and a full chunk (an upper bound, flagged) for the rest. The
unreferenced-not-yet-collected bytes come from GC's preview once #140
merges; bytes uploaded since creation need a counter (follow-up).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude05's rulings (2026-11-15 22:53Z): the surfaces and the controls,
with the behavior stubbed (the planner keeps everything, the policy is
not stored, usage reports nothing, no fork needs a parent, the class is
neither validated nor stored).
- chunkstore: snapshot class (semantic / pinned) on the snapshot;
RetentionPolicy stored on the VOLUME entry (extended attributes, CAS on
a revision); planRetention / Retain [dry run]; Usage (live, per-snapshot
exclusive, stored bytes).
- volume: GET /status/chunk?volume= (usage and policy); the snapshot
route carries "class".
- sw-block: ops chunk usage, ops chunk retain [--dry-run | --set-policy
--keep-*], snapshot --class / --pin / --expires.
- controls: policy edges (newest N with name tie-break; pinned never
expired by count or age but unpinned past its expiry; semantic and
labeled snapshots not exempt; younger than T and clock skew; hourly
buckets; fork parent), an agent checkpointing every step stays bounded,
dry run writes nothing, retain keeps N + pinned and frees names, the
policy CAS, class validation, an incomplete fork's parent kept, usage
from manifests; CLI usage/retain; and a real-service test against
SeaweedFS (chunkstore_integration, CHUNKSTORE_WEED): N+5 snapshots plus
pinned ones -> retain leaves N + pinned, accounting follows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Close marks the target closed before its once-only close; a later
Start refuses before creating anything (a Start in progress holds the
target lock, so Close waits for it and then closes its device).
- teardown skips DEL_DEV only when settleQueues reports a queue whose
thread is still running (leaked); a stopped queue's error is reported
and the device is still deleted.
- A FETCH/COMMIT completion that is neither a new request nor the abort
of a stopping device ends the tag and is joined into the queue's error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r3 (6afa34ac), actual-caller controls with the old behaviour kept:
- a Start after Close must refuse (Close before Start consumed the once);
- the Close path (teardownWith, driven with a recording controller) must
delete the device when every queue thread exited, even one that ended
with an error; only a queue whose thread still runs keeps its mappings
and suppresses DEL_DEV;
- a completion that is neither a new request nor the expected abort must
be reported as the queue's error (onCQE, the loop's per-CQE path).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #139 (codex01 AMEND):
1. #133 covers open AND replay. A classifiable EnsureStorage failure now
takes the same fail-closed path as a replay failure: local readiness
blocked (frontend I/O refused), the typed reason recorded through
ReportLocalRecoveryFailure, and the process kept up serving status and
heartbeats, so a primary assignment reports it at once. An open
failure that cannot be classified exits as before.
2. io_error is documented as deliberately broad: the volume's local
storage could not be opened or read at startup. A path error such as
ENOENT, EACCES or EISDIR is io_error too, which says the storage is
unusable, not that the disk is physically damaged. The underlying
error stays in the readiness evidence and is now in the log line.
Refs #133
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #139 (codex01 AMEND):
- main's durable open and replay move into openAndRecoverDurable (the
function main now runs), with the open-path behavior unchanged here:
any EnsureStorage failure still exits unreported.
- controls driving that function: a classifiable open failure (EIO path
error; and a real provider whose volume file is truncated, so the magic
read hits io.ErrUnexpectedEOF) must fault fail-closed and report
io_error; an unclassified open failure stays fatal with no report; a
replay failure faults and reports (a real provider's corrupted smartwal
volume reports wal_corrupt); a clean recovery clears the block.
- classifier controls: ENOENT and EACCES path errors are io_error by
contract (local storage unusable, not proof of disk damage); a WAL
integrity fault wrapping a path error stays wal_corrupt.
Refs #133
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- No automatic reclaim: Start refuses a /dev/ublkcN already present at
the requested id, with an error naming it, before sending any command
(the device-info read, pid probe and pid-namespace questions are gone).
A device created by another starter between the check and ADD_DEV makes
ADD_DEV itself fail (EEXIST); nothing is deleted. Removing a leftover
device is a documented operator step (package doc).
- Target.Close runs the device close once; every caller, concurrent or
later, gets that result.
- A queue thread's abnormal error, including a failed ring close, is kept
and returned through the shutdown (settleQueues joins it).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r2 (6afa2fe0): a pre-existing ublk id must be refused with zero
commands of any kind (no automatic reclaim: GET_DEV_INFO + pid probe +
numeric STOP/DEL races a replacement device, and ESRCH across PID
namespaces is no proof of death); concurrent and repeated Target.Close
callers must all get the first close's result; a queue thread's abnormal
error (failed ring, failed ring close) must reach the shutdown result.
The old behaviour fails all four.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>