Skip to content

v2 Commit path: settle by phase, --expected in the publication, live-overlap refusal, one custody resolution - #765

Merged
yifanxuaaa merged 6 commits into
layerfs_v2_0_0from
claude/v2-commit-path-fixes-96087d
Nov 23, 2026
Merged

yifanxuaaa merged 6 commits into
layerfs_v2_0_0from
claude/v2-commit-path-fixes-96087d

Conversation

@yifanxuaaa

@yifanxuaaa yifanxuaaa commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the v2 Commit-path findings from the overlay and capture/Commit reviews: #1, #4, #5, #6, and #14 with CC-8. Each finding was re-confirmed in source before it was fixed. There is one commit per fix, each with its tests and architecture docs.

Commits

Commit Finding Change
37c0a8b149 settle pre-publish failures by phase; conflicts take no lane #4 (V-CC-2), #6 (V-CC-4) CommitFailure::uncertain() depends on the phase. Before Publish, only local uncertainty (overlay, owner job, binding) keeps custody. A Store, Content or History failure there folds back and answers Failed. A conflicted merge never takes the publication lane, or releases it before validation and install. The lane is dropped right after commit_branch.
c7eb6ac1f6 --expected inside the publication; force reads the head in the lane #14, CC-8 New CommitRequest.required_head. commit_branch refuses HeadMoved inside its own transaction. The advance SQL (commit_advance_branch.sql, shared by both backends) gains a head_commit_id predicate; zero rows returns HeadMoved. --force is decided by the head read in the lane. --expected travels through bridge, daemon and Sandbox. CC-8 ("record every displaced head") was judged not a loss: the intermediate Commits are first-parent ancestors of the displaced head, so the closure keeps them. This is documented, not changed.
54e4913c5f refuse a merged install that overlaps the live generation #1 After a merge, the Commit holds the Workspace's mutations (MutationHold) and reads the active generation's rows. A row of a serial the merge changed, or a binding under a changed directory, refuses with a definite LiveConflict (daemon code Busy, paths named). Nothing is published and the capture folds back. With no overlap the hold lasts through publication and install. Overlay::install_merged drops carried mtime-only rows whose serial the merge changed. The UpToDate-over-a-differing-view case takes the same path.
384dbb33fc one exact resolution of retained custody at the next Commit #5 (V-CC-3) An unknown publication outcome, or an install that failed after a known publication, keeps a record. The Workspace's next Commit request first runs resolve_retained once: it reads the head through the control reader's own connection. If the head is our Commit (our root over the expected head and base), it installs it. If the head is the expected head, it folds the capture back. Anything else stays retained, and the Commit is refused Unknown with the reason. This is never a retry: nothing is resent and the record is used once.

cecee1eaab is a test-only follow-up to the #4 contract in layerfs-control mount_control.rs. It was found on an integration branch of #762–#765. an_original_unknown_blocks_… now injects a local overlay uncertainty, which still blocks, and is renamed an_original_local_unknown_blocks_another_commit_and_normal_unmount. The Store unknown it used to inject moves to the new a_store_unknown_before_publication_folds_back_and_admits_a_commit.

ec1936cf3a is a test-only follow-up to #5, found by the nightly mount lane. In mounted_commit_failures.rs, F3 (a lost acknowledgement) expected the next Commit to be refused; under #5 its one resolution installs the landed Commit. F3 is renamed f3_unknown_history_outcome_is_resolved_by_the_next_commit_and_the_mount_still_serves and now asserts:

  • the head is our Commit, published once over the bound head;
  • the next Commit is admitted with that Commit as its parent and installs exactly the mount's tree;
  • the mount serves throughout and the normal unmount drains.

Its retained_tail, Kept, refused() and SECOND, whose only caller was F3, are deleted.

37c0a8b149 also updates one daemon test to the #4 contract: store_commit.rs nested_storage_unknown_keeps_original_capture_and_blocks_another_commit became nested_storage_unknown_before_publication_folds_back. No test was deleted.

Checks (macOS, tools/worktree.py, toolchain 1.85.1)

  • cargo test --all-targets --no-run for store-service, daemon, overlay, workspace, persistence, bridge, history, sandbox, nfs, api and cli: clean.
  • cargo clippy --all-targets -D warnings for store-service, daemon, overlay, workspace, persistence, bridge, history and sandbox: clean.
  • layerfs-store-service: all 83 test targets pass, run in groups under 100 s. The whole package does not fit in one 100 s run.
  • layerfs-daemon: all 67 test targets that run on macOS pass. New or changed: store_commit (14).
  • layerfs-control: all 49 targets pass (166 tests).
  • layerfs-sandbox: all 37 targets ran (169 passed). The only failures are the two already on base: lp176_image_recovery (6, no Sandbox images on the native machine) and workspace_isolation (1, lifecycle.rs imports workspace/).
  • Linux FUSE, mounted_commit_failures (built with tools/worktree.py cargo --platform linux, run in the build image with /dev/fuse, SYS_ADMIN, --test-threads=1 and a 120 s cap): 4 of 4 pass, F1, F2, F3 and F5. The build has no warnings; the Linux image has no clippy.
  • New test files:
    • commit_settle (3)
    • commit_expected (4)
    • commit_live_merge (6)
    • persistence commit_required_head, run on SQLite and on PostgreSQL against a private postgres:17 container
  • With the docs: Define product requirements #1 check disabled, 4 of the commit_live_merge tests fail: the touched file was truncated to 11 bytes.
  • tools/check_product_boundary.py: PASS. Tools unittest: 181 OK. rustfmt is clean on every changed file.

Not verified

  • Of the mounted tests, only mounted_commit_failures was run here. It exercises resolve_custody through the Service for a landed non-merge Commit. The kernel invalidation after a resolved merged install is not staged.
  • No test covers the PostgreSQL zero-row advance (the head moving between the in-lane read and the UPDATE).
  • The Commit-level mutation-hold window has only an owner-level test. A Commit-level test would need the harness to mutate while holding a counted base source, which no product caller does.
  • Resolving a known publication whose install failed is not tested directly: the test fixture's install failure, a stopped owner, would also fail the resolution.
  • On PostgreSQL, a COMMIT whose connection was lost may still finish on the server shortly after the head read. The docs state this.

Production LOC

Production LOC: 206,537 -> 207,195 (delta +658)
  core      40,988 ->  40,989 (+1)    layerfs-history +1
  engine    95,899 ->  96,515 (+616)  layerfs-bridge +5, layerfs-daemon +78, layerfs-overlay +36, layerfs-persistence +20, layerfs-store-service +467, layerfs-workspace +10
  control   59,325 ->  59,366 (+41)   layerfs-sandbox +41
  api       10,325 ->  10,325 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd1917812)
  Method: tools/production_loc.py --detail on parent 343c59b2ca and the committed tree

Per commit: +46, +98, +217, +297. Each commit message carries its own block.

🤖 Generated with Claude Code

yifanxuaaa and others added 6 commits November 23, 2026 14:56
Finding #4 (V-CC-2): settle_failure kept custody whenever
CommitError::uncertain() held, whatever the phase. Content failures with no
provider cause (merge-stage Save reads, logical counts, binding hints,
removals) and unknown Storage errors from Save::finish happen before the
Publish phase, when nothing in history can have changed, yet they locked the
Workspace in Uncertain until a force unmount discarded its work.

CommitFailure::uncertain() now depends on the phase: before Publish only
local uncertainty counts (CommitError::locally_uncertain(): an uncertain or
quarantined overlay, an uncertain owner job, a poisoned binding or port);
from Publish until the answer is known CommitError::uncertain() decides.
settle_failure and the daemon's reply code use it, so such a failure folds
the capture back and answers Failed, not Unknown. The merge stage reports
the Save's own failure (Save::take_failure) as its first cause.

Finding #6 (V-CC-4): a conflicted merge publishes nothing but held the
publication lane (Session turn and directory flock) through validation and
its local install. A conflict found before the lane no longer takes it; one
found by the in-lane step releases it before validation and install. The
lane is dropped right after commit_branch on the publish path. Docs
(engine/commit, engine/store, flows/commit) now agree.

Tests (new engine/crates/layerfs-store-service/tests/commit_settle.rs):
a pre-publish Content failure folds back and the next Commit publishes the
change; local uncertainty keeps custody; a conflicted merge never enters
the lane phase. No test deleted. Changed to the new contract:
layerfs-daemon tests/store_commit.rs
nested_storage_unknown_keeps_original_capture_and_blocks_another_commit is
now nested_storage_unknown_before_publication_folds_back: a Construct-phase
Storage failure with a nested unknown outcome publishes nothing, so every
case folds back and a later Commit publishes.

Production LOC: 206,537 -> 206,583 (delta +46)
  core      40,988 ->  40,988 (0)
  engine    95,899 ->  95,945 (+46)  layerfs-daemon +3, layerfs-store-service +43
  control   59,325 ->  59,325 (0)
  api       10,325 ->  10,325 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent 343c59b and the staged tree

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

Finding #14 (V-CC-6): --expected was one read in the Sandbox before the
Commit was sent, so a head that moved after it was merged with, and
--force --expected C displaced whatever head the publication found.

- CommitRequest gains required_head: the node the Branch must answer as
  its head (its head Commit, else its base Layer). commit_branch refuses
  another head HeadMoved inside its own transaction, forced or not.
- The Workspace Commit carries it end to end: the Sandbox parses the
  resolved --expected id into CommitControl.expected (bridge record field),
  the daemon passes it as CommitOptions::expected, the Commit checks it when
  it reads the head (HeadMoved before any merge), does not merge in the
  lane with a head that moved again, and sends it as required_head. A
  daemon HeadMoved for a Commit sent with --expected is answered as the
  Sandbox's own check answers: Conflict naming the head as commit.
- commit_advance_branch (shared by SQLite and PostgreSQL) gains a
  head_commit_id predicate on the head the transaction read; zero rows is
  HeadMoved, not Integrity (finding #10's missing predicate: a PostgreSQL
  lane connection lost inside the lane can no longer let one Commit
  overwrite another).

CC-8: a forced Commit sent force && moved, with moved read before the lane,
so a head that moved inside the lane was refused HeadMoved. It now sends
force and lets the publication's own in-lane read decide, displacing the
head it reads. Re-confirmed and not changed: "only the newest displaced head
is recorded" loses nothing. The Commits between the forced Commit's parent
and the displaced head are that head's first-parent ancestors, and the
history closure follows displaced_id and parent edges, so all stay
reachable and kept. The docs now say so.

Tests: persistence commit_required_head.rs (another head refused forced or
not; force over the required head displaces only it; force decides on the
head its transaction reads), each on SQLite and on PostgreSQL when
LAYERFS_TEST_POSTGRES_URL is set; store-service commit_expected.rs (moved
expected head refused before the merge and the change kept; a head landing
just before the lane refused forced or not; force publishes over the head
read in the lane; force --expected displaces that head). CommitRequest,
CommitOptions and CommitControl literals in tests and examples gain the
new field as None (including three NFS test/example literals). No test
deleted.

Docs: core/history, engine/store, engine/commit, api/sdk/workspace.

Production LOC: 206,583 -> 206,681 (delta +98)
  core      40,988 ->  40,989 (+1)  layerfs-history +1
  engine    95,945 ->  96,001 (+56)  layerfs-bridge +5, layerfs-daemon +1, layerfs-persistence +20, layerfs-store-service +30
  control   59,325 ->  59,366 (+41)  layerfs-sandbox +41
  api       10,325 ->  10,325 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent 37c0a8b (377c64dd92 before a test-only fixup) and the staged tree

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finding #1 (merged install over the live generation): a Commit that merged
with a head that moved installs the merged root as the new base under rows
written after its capture. Those rows hold absolute facts (size, inherited
cutoff, link and entry counts) computed against the old base, so a row the
merge changed under was silently wrong: a touch after the capture truncated
or zero-filled a file the merge lengthened, a removal under a directory the
merge added to counted the directory empty, and a write in the Commit's
window could land between the check and the install. A carried mtime-only
row (keep_live_row) kept the old base's facts after the merge changed the
file. And UpToDate (the merge equal to the head) installed over a view that
still differed.

Now, after the merge, the Commit collects the serials whose stored inode
value differs between its constructed root and the merged root
(inode_differences, first-stage and in-lane merges unioned). When the merged
candidate differs from its own root it takes a MutationHold on the Workspace
(store-service overlay/hold.rs: later mutations wait behind it as behind a
waiting Capture), then reads the active generation's inode rows and name
bindings a window at a time. An inode row of a changed serial, or a binding
under a changed directory, is an overlap: the Commit drops the hold and the
lane and refuses with the new definite CommitError::LiveConflict (paths
named best effort, at most 16; daemon code Busy). Nothing is published and
the capture folds back. With no overlap the hold lasts through publication
and install, so no checked row changes before the new base is in place; the
install (Overlay::install_merged) deletes carried mtime-only rows whose
serial the merge changed, so they fall through to the merged base. The
UpToDate case runs the same check, because its candidate is the merged head.

Docs in the same commit: engine/commit (results, phases, limits),
flows/commit, engine/overlay/lifetimes, core/compare-and-merge,
engine/workspace.

Tests (new engine/crates/layerfs-store-service/tests/commit_live_merge.rs):
a touched file is not truncated by a longer merge; rm d/x after the capture
with the merge adding d/y is refused; a write in the Commit window to a
merged file is refused; rows under a directory the merge replaced are
refused; a merge with no overlap publishes and installs; a held Workspace
delays mutations until the hold ends (owner level: a Commit-level window
test would need the harness to mutate while holding a counted base source,
which no product caller does). With the check disabled the first four fail
(the touch left the file truncated to 11 bytes). No test deleted.

Production LOC: 206,681 -> 206,898 (delta +217)
  core      40,989 ->  40,989 (0)
  engine    96,001 ->  96,218 (+217)  layerfs-daemon +8, layerfs-overlay +36, layerfs-store-service +163, layerfs-workspace +10
  control   59,366 ->  59,366 (0)
  api       10,325 ->  10,325 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent c7eb6ac and the committed tree

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finding #5 (V-CC-3): a Commit whose publication answered with an unknown
outcome, or whose install failed after a known publication, kept custody;
every later Commit was refused Unknown, and the only exit was a force
unmount (needing relinquish_unknown and an attached kernel connection) that
discarded every change made since the capture. Nothing compared the head
with the saved candidate.

Such a failure now also leaves a record on the BoundWorkspace (new
store-service store/resolve.rs): the capture, the intent, the binding, the
known publication, a merge's own root and changed serials (new
CommitFailure::merged_over), and the captured reader and operation owner.
Only an unanswered publication (phase Publish, nothing known published) or
an install that failed definitely after a known publication qualifies;
local uncertainty, an unreleased construction custody and a release error
keep no record and stay as before.

The Workspace's next Commit request first runs
BoundWorkspace::resolve_retained once (daemon control/resolve.rs, before
admission; activity Committing, phase resolve). It reads the head once,
through the control reader's own connection (a writer session the unknown
outcome quarantined does not stop it): a known publication, or a head that
is a Commit with our candidate root over the head and base Layer we
published against, is installed with the same validation, live check and
mutation hold as a merged install; the head still the one we published
against folds the capture back (or, holding our root, installs it as
UpToDate); anything else stays retained and refuses the Commit Unknown with
the reason. It is not a retry: nothing is resent and the record is used
once, whatever it finds. Resolved, the captured owners are released, the
entry goes Idle and the Commit is admitted; an install of a merged root is
invalidated in the kernel as a Commit's own.

Docs in the same commit: engine/commit (custody table, new "One resolution
of retained custody" section, demonstration rows for this branch's tests),
engine/daemon/control-calls, flows/commit, api/sdk/workspace.

Tests (layerfs-daemon tests/store_commit.rs, new
history_boundary::Boundary::LostRequest): a lost acknowledgement is
resolved by installing the Commit, and the next Commit's parent is it; a
lost request folds back and the next Commit publishes the kept change; an
unknown outcome under a head another Commit moved stays retained and still
refuses a Commit; a product (captured) Commit's resolution releases its
reader and operation owner and the next product Commit publishes. No test
deleted. Not covered: the daemon's resolve_custody wiring runs only through
the Service (mounted, Linux) tests, which were not run here.

Production LOC: 206,898 -> 207,195 (delta +297)
  core      40,989 ->  40,989 (0)
  engine    96,218 ->  96,515 (+297)  layerfs-daemon +66, layerfs-store-service +231
  control   59,366 ->  59,366 (0)
  api       10,325 ->  10,325 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent 54e4913 and the staged tree

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow-up to 37c0a8b (finding #4), found on an integration branch of
PRs #762-#765. layerfs-control tests/mount_control.rs
an_original_unknown_blocks_another_commit_and_normal_unmount injected a
StorageError::UnknownOutcome from the producer during construction and
expected the Workspace to stay Uncertain. Before the Publish phase a Store
unknown cannot have published, so under the phase-aware
CommitFailure::uncertain() it folds back and answers Failed; the test
failed at mount_control.rs:298.

The test keeps its intent ("an original unknown blocks another Commit and a
normal unmount") with an uncertainty that still holds before Publish: an
overlay outcome unknown (OverlayError::Uncertain). It is renamed
an_original_local_unknown_blocks_another_commit_and_normal_unmount. The
Store unknown it used to inject moves to a new test,
a_store_unknown_before_publication_folds_back_and_admits_a_commit: Failed,
the Workspace stays Idle on its binding with nothing published, a later
Commit publishes over the bound head, and a normal unmount is admitted. No
test deleted.

Production LOC: 207,195 -> 207,195 (delta 0)
  core      40,989 ->  40,989 (0)
  engine    96,515 ->  96,515 (0)
  control   59,366 ->  59,366 (0)
  api       10,325 ->  10,325 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent 384dbb3 and the staged tree (test-only change)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow-up to 384dbb3 (finding #5), found by the nightly mount lane on
an integration branch of PRs #762-#765. layerfs-daemon
tests/mounted_commit_failures.rs F3 stages Boundary::LostAcknowledgement
(a real publication, then UnknownOutcome) and its retained tail expected
the next Commit to be refused; under #5 that Commit's one resolution reads
the head, finds exactly this Commit and installs it, so the Commit was
admitted (panic at mounted_commit_failures.rs:478).

F3 is renamed
f3_unknown_history_outcome_is_resolved_by_the_next_commit_and_the_mount_still_serves
and ends in a new resolved_tail: after the failure the Workspace is
Uncertain with both owners kept and the mount still serves the same view
and a new write; an independent session reads the head as one Commit of
the candidate root over the bound head (published once), and a fresh bind
of it is the captured tree; the next Commit is admitted, its parent is that
landed Commit, its root carries the write made since and equals the
mount's tree (later_exact), the registry is Idle; reads still work and the
normal unmount drains and removes the mount.

Deleted: the retained_tail helper, its Kept enum, the refused() helper and
the SECOND constant, whose only caller was F3's old expectation that the
next Commit and a normal unmount are refused under retained custody. That
contract no longer holds for a resolvable unknown outcome; retained
custody that cannot be resolved is covered without a mount by
store_commit.rs an_unknown_outcome_under_a_moved_head_stays_retained and
by layerfs-control mount_control.rs
an_original_local_unknown_blocks_another_commit_and_normal_unmount. The
module header notes F3's new end and where the nothing-published case is
staged.

Production LOC: 207,195 -> 207,195 (delta 0)
  core      40,989 ->  40,989 (0)
  engine    96,515 ->  96,515 (0)
  control   59,366 ->  59,366 (0)
  api       10,325 ->  10,325 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent cecee1e and the staged tree (test-only change)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yifanxuaaa
yifanxuaaa merged commit 8676948 into layerfs_v2_0_0 Nov 23, 2026
2 checks passed
@yifanxuaaa
yifanxuaaa deleted the claude/v2-commit-path-fixes-96087d branch November 23, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant