Skip to content

p4: lean phase-3 GC authority - #770

Merged
mengmengmengqiang merged 12 commits into
Ephemeral-AI-Lab:layerfs_v2_0_0from
tokenaissance:p4-lean-phase3
Nov 24, 2026
Merged

mengmengmengqiang merged 12 commits into
Ephemeral-AI-Lab:layerfs_v2_0_0from
tokenaissance:p4-lean-phase3

Conversation

@mengmengmengqiang

@mengmengmengqiang mengmengmengqiang commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

GC mount lock: why it deadlocks and how the fix breaks the chain

Problem

A mount is protected by a row in gc_intent. While a Sandbox may still read a Branch, compaction must not delete that Branch's objects, so the row acts as a lock. The lock is released only when the system can prove the holder is gone.

That proof was taken from the caller's process and boot identity: "is the process that mounted this Branch still alive on this machine, on the same boot?" It works only while the mounting machine is reachable and still running that boot.

It fails exactly when it matters most: the machine was restored from a snapshot or rebooted, the Sandbox was deleted while its mount row stayed behind, or the machine is offline. The check then cannot prove the holder is gone. Because "unprovable" is treated as "still live" — correctly, since reclaiming data a live mount is reading would corrupt it — the row stays live forever.

And the lock is not per-Branch: the compact barrier is Store-wide. One such row stops compaction for the whole Store, so objects no one can read anymore are never reclaimed, retired Branches and Sandboxes pile up, and the only way out is an operator settling or releasing the row by hand.

The design was conservative but incomplete: it had no durable way to prove death, and no audit of what an operator did when they cleared a row.

Shipped

The lean phase-3 design keeps the 2.0 schema change direct (2.0 is still in development; no compatibility migration) and adds no new tables. Authority lives in two columns on the existing gc_intent: machine_incarnation and sandbox_generation.

  1. Ordered evidence, not elapsed time. MachineRecord.incarnation and SandboxRecord.generation increase strictly on machine restore / Sandbox create. Admission compares tokens: newer ⇒ Dead, older ⇒ Uncertain, equal or missing ⇒ Live. Death is concluded only from evidence that is provably newer; anything unprovable stays Live. There is no lease or fence in the shipped tree.
  2. A removed Sandbox leaves durable evidence. A machine-level tombstone (machine/<machine>/sandbox-retired/<name>.json) records the retired generation, written before the Sandbox record is deleted, so a later admission can order a Sandbox whose row is already gone. A missing record and a missing tombstone are both "no proof", never death.
  3. A retained done-row audit. release and preview write a done row (owner columns cleared, the action/operator/op in evidence) instead of deleting the intent; the done-row read is bounded and Branch-scoped. Compact maps these rows with Copy::Done, so the audit survives compaction and the barrier has a well-defined end.
  4. Operator-only reclamation. store.repair_mount_holders exposes list, preview, settle, release and audit for one Branch. preview changes no live intent and writes its own retained done row (action=preview, op=null, operator label in evidence). settle marks an uncertain holder; release retains the row as the durable operator audit. There is no automatic release of an unprovable owner.
  5. Doctor rows. store.mount_holders and store.gc_audit (plus project.mount_holders) report the typed holder view and the bounded done audit from the Store owner's side.
  6. Authority wiring on the daemon mount path. The daemon is the real mount path: layerfs-sandbox reads the Sandbox record's generation and the machine record's current incarnation under the same home the Store uses, sends both in the mount place, and store/bind.rs records both on the mount intent. A private or place-unknown bind records no place authority and keeps the owner-token fallback. The real-daemon end-to-end test is layerfs-control/tests/mount_place_authority.rs.
  7. Read-ahead containment (Sequential read: 141 Store demands for 64 MiB on base (read-ahead re-opens windows under concurrent FUSE reads) #779). Streams::follow now follows a same-root window that contains the read start (until > start, taking the furthest end) instead of opening a second window and re-demanding its tail. This fixes the base regression from d19d98f138 (FUSE out-of-order READ continuations). mounted_sequential_read is now expected to pass, and its bound stays 64 demands. Measured on the Sequential read: 141 Store demands for 64 MiB on base (read-ahead re-opens windows under concurrent FUSE reads) #779 prototype with the 8 MiB READ_AHEAD and cache sizes unchanged: 141 → 20 demands on SQLite, 141 → 27 on PostgreSQL; SQL statements 498 → 314 on SQLite and 284 → 82 on PostgreSQL.

Deferred

Tracked in #775: lease/fence renewal (no producer/heartbeat yet, so a row is not renewed and release is unfenced), the cross-home PlaceView merge (machines.<m>.home has no public writer; PlaceView reads the caller's home alone), and durable archive --prune (audit is Branch-scoped and bounded; no jsonl archive). The Lean formalization track is #769.

Rebase status

Rebased onto the current layerfs_v2_0_0 release fe9b4d1a3c9bdc01265d7a959c40ab102d6a47a5; the branch has 12 ordinary commits, all authored by rain <mengmengmengqiang@gmail.com>. git diff --shortstat up/release HEAD = 173 files changed, 10,362 insertions(+), 1,686 deletions(-).

The 8 conflicts reported by git merge-tree were resolved with current base code winning and p4 semantics carried into the 2.0 shapes:

  • api/crates/layerfs-api/src/lib.rs, api/crates/layerfs-cli/src/worker.rs: the 2.0 worker surface keeps prepare_network and adds the incarnation-aware serve_with_incarnation; the worker binary passes its LAYERFS_WORKER_INCARNATION.
  • control/crates/layerfs-platform/src/platforms/docker/power.rs: the 2.0 entry(host_network) shape, with the worker incarnation environment variable added.
  • control/crates/layerfs-sandbox/src/lifecycle.rs: the 2.0 handed-intent comment plus the retirement tombstone write.
  • docs/architecture/engine/store/postgresql.md, docs/architecture/control/stores-and-projects/sqlite-and-postgresql.md: 2.0 URL/schema text, with the shipped table counts and no cross-home claim.
  • engine/crates/layerfs-persistence/src/backend/postgresql/schema.rs, records.rs, diagnostic/postgresql_contract_expected.rs: 2.0 schema version 3 and PostgreSQL v2 refusal, keeping the SQLite v2 → v3 conversion refusal (SchemaVersion2) and the p4 GC schema.

The rebase also removed a previous-rebase artifact that had moved place from the 2.0 WorkspaceApi back onto Control; the branch now keeps WorkspaceApi.place and the authority commit's MountPlace wiring sits on top of it.

Verification

On this head (ec99bf29c2):

  • cargo check --offline --workspace --all-targets: exit 0.
  • Targeted suites, all with TMPDIR on ext4 and PostgreSQL unset:
    • layerfs-persistence --test gc_conversion: 3 passed, 0 failed.
    • layerfs-persistence --test sqlite_compact_done: 2 passed, 0 failed.
    • layerfs-store-service --test admission: 10 passed, 0 failed.
    • layerfs-control --test store_repair_live: 2 passed, 0 failed.
    • layerfs-control --test mount_place_authority: 1 passed, 0 failed.
    • layerfs-cli --test gc: 5 passed, 0 failed.
    • layerfs-api --test gc_calls: 11 passed, 0 failed.
    • layerfs-api --test calls_table: 26 passed, 0 failed.
    • layerfs-daemon --test mount_holders: 2 passed, 0 failed.
  • cargo test -p layerfs-workspace: 189 passed, 0 failed across its suites (including read_ahead 4/4).

Environment limits:

Earlier runs in a privileged Linux container with a real /dev/fuse (pre-rebase head; kept for reference, not re-run here): FUSE mount binaries 12/12 (kernel_application 1, kernel_mount_routes 2, observed_application 8, r5_1_actual_daemon_commit 1); install_directory 4/4; kernel_guard 5/5; closed_streams 3/3; machine_list_live 1/1; project_stats 4/4, store_stats 2/2, saved_continuation 2/2 on clean layerfs schemas.

Known limitations

What this fixes for an already-stuck Store (upgrade note)

  • New mounts record the machine incarnation and the Sandbox generation, so a deleted Sandbox or a restored machine is provably dead and its intent is settled automatically. The leak class that blocks compaction stops recurring.
  • Mount intents created before this version carry neither value (the legacy rows, e.g. the six on the live Store). Nothing can retroactively prove them dead, so they stay conservative (live/uncertain) and still block a Store-wide compaction. They are not removed automatically.
  • To unblock an existing Store after deploying: store.repair_mount_holders list / preview shows the holders with safe / reason; then settle (evidence-backed) or release (explicit operator escape hatch) the rows known to be dead. audit keeps the retained done rows.
  • The compaction admission remains Store-wide: one unresolved holder still blocks store.compact. Per-generation pinning (a stuck mount blocking only its own generation) is the follow-up design (B3), not part of this PR.

The live Store is operator-owned; this PR does not touch it.

@mengmengmengqiang mengmengmengqiang changed the title p4: lean phase-3 GC authority (final) p4: lean phase-3 GC authority Nov 24, 2026
@yifanxuaaa

Copy link
Copy Markdown
Contributor

Thanks Rain. The phase-3 GC design is good: the ownership rule never declares an owner dead without proof, and the operator repair, retained done audit and doctor check fill a real gap. Before this can merge, two things need to happen.

1. Please rebase onto the latest layerfs_v2_0_0

8cf5694320 ("p4 tree: LayerFS main@32ef3589") replaces the whole tree. That tree forked from #739 (7d2ac982c3, 2026-11-19), so on top of today's layerfs_v2_0_0 it reverts about 240 commits merged since then. Examples:

This is why the diff is +52k / −110k over 1,350 files.

Please re-apply only your own changes (7d2ac982c3..p4-lean-phase3) onto the current layerfs_v2_0_0, as ordinary commits under your own author identity. The follow-up commits are authored dsh <dsh@localhost>. Your real work is 196 files, +12,450 / −440 lines, of which +3,038 are production LOC.

A trial 3-way re-apply gives 151 of 197 files clean and 46 conflicting. The conflicts are where the base has since rewritten code you hook into:

  • Sandbox removal. control/crates/layerfs-sandbox/src/close.rs no longer exists on the base. Your record::retire calls have to move into remove.rs / force.rs / lifecycle.rs, or no tombstone is ever written.
  • Doctor. doctor/project_target.rs and doctor/store_target.rs conflict; doctor/dispatch.rs and api/.../doctor/options.rs no longer exist on the base.
  • Machine start. layerfs-machine/src/endpoint.rs and create.rs, layerfs-control/src/machine.rs.
  • Store. call.rs, diagnostic.rs, service.rs, record.rs.
  • The rest. calls_table.rs, the SDK golden file and about 10 docs.

Follow-up commits during the rebase:

  • Keep:
    • 623d5817 (the test that was pasted into the wrong place)
    • 22bf4fcf (PostgreSQL schema version 3)
    • f4e3f26e (help text)
    • a0ef644d (PostgreSQL schema check text, 0700 test home)
    • 2482fe04 (repair fixture order)
  • Regenerate merge-forms-root.sqlite on the rebased schema; the base changed sqlite/schema.rs after the fork.
  • Drop d9dbf841; the base already seeds the box machine.
  • Please drop these, because they hide regressions or work around repository rules:
    • 6159cbac, the machine_no_start change. On the base, project.get on a stopped machine answers from records; the test now expects a refusal.
    • 2fbfe809 / 87890d78, read-ahead limit 64 → 192. 910f686c5a measured 20 Store demands for the 64 MiB read on both engines. 141 is a regression, most likely from the snapshot rollback. Please measure again after the rebase instead of raising the limit.
    • LINE_LIMIT_WAIVERS in tools/check_product_boundary.py. The 999-line rule has no waivers. Please split history/src/contract/records.rs (1,014 lines) and persistence/src/history/admission.rs (1,087) by responsibility.
    • The #[path = "../tests/support/…"] mod tests; modules in 9 src/ files. engine/AGENTS.md forbids redirecting test paths and adding includes to get around the source rules. Please use real tests under tests/, or delete the ones that are hard to adapt.
  • Five new tests use SqlitePersistenceProfile::Disposable, which no longer exists on the base. Switch them to Normal:
    • gc_conversion
    • gc_intent_authority
    • gc_schema
    • sealed_open
    • sqlite_compact_done
  • Each commit needs its Production LOC: before -> after (delta …) line (AGENTS.md §4).

2. Issues found in review

Main issue: real mounts never record the new evidence, so the fix does not apply to them yet.

  • engine/crates/layerfs-store-service/src/store/bind.rs (the only product mount path) registers every intent with PlaceAuthority::default().
  • The Sandbox side sends only the machine and Sandbox names (layerfs-sandbox/src/workspace/serve.rs).
  • machine_incarnation comes from the MACHINE_INCARNATION process global. Only worker_server.rs sets it, but Sandbox mounts are made by layerfs-daemon, a separate process that never sets it.
  • sandbox_generation is never set on any product mount.
  • So in admission/place.rs, every real mount row has neither value, and admission falls back to the old process/boot check. A snapshot restore, a deleted Sandbox or an offline machine still leaves the row stuck until an operator clears it.
  • The PR's tests (including the "six of 331" case) pass because they write the authority onto rows by hand.

Please have the daemon's bind record the Sandbox generation and the machine incarnation, and add one end-to-end test with a real daemon mount instead of hand-written rows.

Other issues:

  1. Leases and fences are never set. Nothing in product code sets lease_expires_ms or fence_token, and nothing calls BoundWorkspace::heartbeat(). Either connect a real heartbeat or leave the lease and fence code out for now.
  2. machines.<m>.home has no writer, as you noted, so the cross-home part of place_view.rs has nothing to merge yet. It could wait until there is one.
  3. The audit can be lost after archive --prune. log/gc-audit.jsonl is written with log_line, which rotates at 16 MiB and deletes the previous .1. So the only copy of pruned audit rows is eventually discarded. The lines are also not synced before the Store rows are pruned.
  4. Audit and archive ignore the Branch they name. The call takes <project> <branch>, but audit and archive --prune read and prune done rows for the whole Store.
  5. release has no liveness check. That is fine for an operator escape hatch. But since real rows carry no evidence (main issue), list and preview cannot show the operator which rows are safe to release.
  6. Nit. Two ordered tokens minted in the same millisecond are ordered by their random nonce, so one can be judged "older" (dead) without real evidence. Consider treating equal milliseconds with different nonces as unordered.

Smaller is fine here: the operator repair and doctor check are useful on their own. The lease/fence code, cross-home merge and jsonl archive could follow once something uses them.

When the branch is rebased, please push to this PR. We'll merge it with a merge commit, not a squash, so your commits keep your name. Thanks!

@mengmengmengqiang

Copy link
Copy Markdown
Contributor Author

Rebase is done on p4-lean-rebase (171 files, +9,951/−1,688 against current layerfs_v2_0_0, 10 ordinary commits under my identity, SQLite suites green). The drop list is applied: read-ahead bound restored to the release's 64, machine_no_start restored, LINE_LIMIT_WAIVERS/#[path] modules removed, records.rs/admission.rs split, five Disposable tests switched to Normal, merge fixture rebuilt on the trimmed schema. The authority wiring is implemented (dbfe6c0c: the daemon sends the Sandbox generation + machine incarnation, real-daemon e2e) and will be cherry-picked before the push.

On the read-ahead bound: 141 is not introduced by this branch. d19d98f138 is already in layerfs_v2_0_0 (git merge-base --is-ancestor confirms) and sets history/objects/edges.rs:55 BATCH_BYTES = 512 KiB (:53 BATCH_RANGES = 1024), so 64 MiB is ~128 data demands + ~13 metadata demands on both engines; the 20-demand figure is from 910f686c before that cap. The branch keeps the release's 64 bound, so mounted_sequential_read will fail on this PR until the base is fixed — opened #779 for that (raise/adapt the batch with a demands+RSS measurement, or change the contract deliberately).

Deferred per your note: lease/fence, cross-home merge and archive --prune are removed from the branch and tracked in #775. The Lean formalization (#769) is trimmed to the shipped subset as well. Will force-push the rebased branch once the authority commit is in.

Rebase the p4 lean phase-3 engine delta onto the current layerfs_v2_0_0
release (87e46c6): the typed GC intent vocabulary, the SQLite and
PostgreSQL GC schema and queries, admission with the machine incarnation and
Sandbox generation ordering, the bounded place view, and the retained done
audit; the store-service branch list records main's Branch id, and the
merge-forms fixture is the patch's rebased-schema copy.

Resolved against the rewritten release: the Branch list lives in
history/listing.rs, the diagnostic mount reads sit on SqliteHandles, the
contract records are split into contract/gc.rs and admission's session locks
into admission/session.rs to keep the 999-line rule without waivers.

Production LOC: 207,783 -> 208,969 (delta +1,186)
  core     40,989 -> 41,324 (+335)   layerfs-history +335
  engine   96,923 -> 97,774 (+851)   layerfs-persistence +643, layerfs-store-service +208
  control  59,546 -> 59,546 (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 tree 97d6fc2 and committed tree 9e42d2f0894a719fd23558eb00f564b47b0cfd57
Rebase the p4 lean phase-3 control delta onto the current release. Store
repair of mount admissions (preview/settle/release/settle_legacy/audit,
archive export and prune) runs locally or through the Store owner's worker;
the doctor reports store.mount_holders and store.gc_audit; machine.start
stops and confirms the old worker, mints and records the ordered
incarnation, launches the worker with it and reconciles the Stores on that
machine; Sandbox close/remove write the durable retirement tombstone and end
the mount intents; the worker server records and serves its incarnation.

Resolved against the rewritten release: the removed sandbox/close.rs calls
moved into lifecycle.rs and force.rs, the doctor target follows the 2.0
store_target/Checks framework instead of the removed dispatch/options
modules, machine.start keeps the release's not_answering refusal and adds
the incarnation/reconcile order, and the store_target doctor reports the
mount holders and done audit from the shallow cut.

Production LOC: 208,969 -> 210,375 (delta +1,406)
  core     41,324 -> 41,324 (0)
  engine   97,774 -> 97,774 (0)
  control  59,546 -> 60,952 (+1,406)  layerfs-control +579, layerfs-home +14, layerfs-machine +62, layerfs-platform +10, layerfs-sandbox +79, layerfs-store +662
  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 tree 9e42d2f0894a719fd23558eb00f564b47b0cfd57 and committed tree bbae9ab47a7c257fd71542d59ccfb4337ef0fcfe
Add the explicit operator repair call and its worker route, the CLI worker's
incarnation setting, the gc help and help-test updates, and the api test
adjustments. The call table keeps the 2.0 families without a pinned count;
the machine_no_start test keeps the release's answer that project.get reads
from records on a stopped machine (the p4 refusal change is dropped) and
sandbox.get's blocked state.

Production LOC: 210,375 -> 210,437 (delta +62)
  core     41,324 -> 41,324 (0)
  engine   97,774 -> 97,774 (0)
  control  60,952 -> 60,952 (0)
  api      10,325 -> 10,387 (+62)   layerfs-api +59, layerfs-cli +3
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent tree bbae9ab47a7c257fd71542d59ccfb4337ef0fcfe and committed tree 0f86056ffbf4357016d5b19f9b87b4ec92703a3e
Rebase the p4 lean-phase-3 documentation onto the 2.0 guides: the GC
specification and runbook, the mount-authority design supplement, the
store/doctor/machine/SDK guides, the lean coordination/gap/verification
records, and the product-boundary tool without the 999-line waivers (the
two files are split by responsibility instead).

Production LOC: 210,437 -> 210,437 (delta 0)
  core     41,324 -> 41,324 (0)
  engine   97,774 -> 97,774 (0)
  control  60,952 -> 60,952 (0)
  api      10,387 -> 10,387 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent tree 0f86056ffbf4357016d5b19f9b87b4ec92703a3e and committed tree 01facc5f12973d1a5aeb639cfda09a4064498bed
Port the p4 benchmark harness changes that exercise the lean GC Store:
the compact-build prototype and the install-lane hazard, store, suite and
WAL drivers.

Production LOC: 210,437 -> 210,437 (delta 0)
  core     41,324 -> 41,324 (0)
  engine   97,774 -> 97,774 (0)
  control  60,952 -> 60,952 (0)
  api      10,387 -> 10,387 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent tree 01facc5f12973d1a5aeb639cfda09a4064498bed and committed tree fea9ca7a99c777da248e08f860bb97f81607dcff
…erge

The shipped subset keeps the ordered place identity — machine_incarnation,
sandbox_generation, their ordering rule and the machine-level retired
Sandbox tombstone — and drops everything deferred to Ephemeral-AI-Lab#775:

- the gc_intent lease_expires_ms and fence_token columns (both schemas and
  every intent select/insert), gc_intent_renew, GcIntent::renewed,
  gc_renew_lease/gc_release_fenced, the Bind heartbeat and the store-service
  renewal plumbing, the holder/diagnostic lease field and the fence tests;
- the machines.<machine>.home cross-home discovery: OwnConnection.home,
  StoreRecord::machine_homes, PlaceView::from_homes/from_store and the
  merged/capped view. PlaceView now reads the caller's home alone;
  current/for_intent_with behavior is unchanged.

The authority columns are now two, not four. gc_intent_release_done keeps
its `state <> 'done'` guard.

Production LOC: 210,437 -> 210,156 (delta -281)
  core     41,324 -> 41,292 (-32)   layerfs-history -32
  engine   97,774 -> 97,712 (-62)   layerfs-persistence -39, layerfs-store-service -23
  control  60,952 -> 60,765 (-187)  layerfs-store -187
  api      10,387 -> 10,387 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent tree fea9ca7a99c777da248e08f860bb97f81607dcff and committed tree f8fe2797089bed7fa6fa9f75803986d92e50b92d
- The jsonl `archive`/`--prune` export is removed (Ephemeral-AI-Lab#775): the control
  archive action and its file export, the service prune_done, the API
  `--prune` option, the worker `store.prune` operation, and the archive
  tests and help text.
- `audit` is scoped to the named `<project> <branch>`, matching the actions
  above it: a new gc_intent_done_branch read filters on the recorded
  project and Branch names, so one Branch's retained rows never leak into
  another's page and a removed Branch's rows stay readable by the names
  they recorded. A two-branch isolation test covers it.
- `list` is the read-only companion of preview: same typed holders, no
  retained done row. Every holder row now carries `safe` and `reason` from
  the admission verdict: a settled/uncertain row is safe to release, a live
  one is not.
- Ordered place tokens compare by their millisecond only. Values minted in
  the same millisecond with different nonces are `Unordered`, never ordered
  by nonce; a test pins it.
- The store_repair_live/worker and gc_calls tests follow the trimmed call
  surface, and the forgotten-sandbox doctor expectation follows the lean
  store.mount_holders check.

Production LOC: 210,156 -> 210,021 (delta -135)
  core     41,292 -> 41,292 (0)
  engine   97,712 -> 97,712 (0)
  control  60,765 -> 60,631 (-134)  layerfs-control -151, layerfs-store +17
  api      10,387 -> 10,386 (-1)    layerfs-api -1
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent tree f8fe2797089bed7fa6fa9f75803986d92e50b92d and committed tree 0c8c4adeedef7965b8e3d759a5ae216dd81a9ba5
…-Lab#775)

Label the deferred design (lease expiry/heartbeat/fencing, the cross-home
place merge, and the jsonl archive export) in the GC specification, the
mount-authority supplement and the runbook, keeping the rationale. Update
the store.md repair section for the shipped actions (list, preview, settle,
release, settle_legacy, Branch-scoped audit) and the two place columns.
Production LOC: 210,021 -> 210,021 (delta 0)
  core     41,292 -> 41,292 (0)
  engine   97,712 -> 97,712 (0)
  control  60,631 -> 60,631 (0)
  api      10,386 -> 10,386 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent tree 0c8c4adeedef7965b8e3d759a5ae216dd81a9ba5 and committed tree e95fc00d87adff1fcc9e8e8cb717e31d3c4e5263
…ture

The mounted_sequential_read test returns to the release's 64-demand bound:
the p4 change raised it to 192, which would accept the 141-demand behaviour
the maintainer flagged as a regression. The project_delete_worker caller_home
drops the p4 machine-record seed; the base fixture already supplies the box
machine, and the suite passes without it. Tests only.

Production LOC: 210,021 -> 210,021 (delta 0)
  core     41,292 -> 41,292 (0)
  engine   97,712 -> 97,712 (0)
  control  60,631 -> 60,631 (0)
  api      10,386 -> 10,386 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent tree e95fc00d87adff1fcc9e8e8cb717e31d3c4e5263 and committed tree ab47f90653b0398b33299f08f1eb9f2fa35895fd
The conflict resolution left project.doctor twice in the project family;
remove the duplicate. The calls_table expected project order follows the
family's own order, and store_doctor expects the lean store.mount_holders
and store.gc_audit rows. The merge-forms fixture is rebuilt on the trimmed
two-column schema and its schema source/definition copied from a fresh Store
of this build, so the root-form merge suites open it again. Tests and
fixtures only.

Production LOC: 210,021 -> 210,021 (delta 0)
  core     41,292 -> 41,292 (0)
  engine   97,712 -> 97,712 (0)
  control  60,631 -> 60,631 (0)
  api      10,386 -> 10,386 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent tree ab47f90653b0398b33299f08f1eb9f2fa35895fd and committed tree a93066a9b9dcd4f4e85bc81c02d603e8910b75c3
The daemon is the real mount path: it never sets the worker process-global
incarnation. layerfs-sandbox now reads the Sandbox record's generation and
the machine record's current incarnation under the same home the Store uses
and sends both in the mount place; the placed bind records them on the
mount intent. A private or place-unknown bind records no place authority
and keeps the owner-token fallback. lease_expires_ms and fence_token stay
absent: no heartbeat is connected yet.

A retirement tombstone then proves the mount dead at admission, so
branch.remove settles it without an operator. Tests: a placed bind records
both values; a tombstoned Sandbox settles its mount; a private bind records
none and still holds by its owner tokens; and an end-to-end daemon mount
over its authenticated control channel reads the home records, records both
values, and is settled by the tombstone.

Production LOC: 214,004 -> 214,073 (delta +69)
  core     42,466 -> 42,466 (0)
  engine   98,213 -> 98,266 (+53)   layerfs-bridge +46, layerfs-store-service +7
  control  62,934 -> 62,950 (+16)   layerfs-sandbox +16
  api      10,391 -> 10,391 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent tree 5d1ca1c and committed tree e87ee9e
…pening it

A base read that continues inside a window another request already fetched
opens a second window in `Streams::follow`, so its tail is demanded and
transferred again. Follow the same-root window that contains the start
(`until > start`), taking the furthest end, instead.

Measured on the Ephemeral-AI-Lab#779 prototype, with the 8 MiB READ_AHEAD and cache sizes
unchanged: 141 -> 20 demands on SQLite and 27 on PostgreSQL; SQL statements
498 -> 314 (SQLite) and 284 -> 82 (PostgreSQL). References Ephemeral-AI-Lab#779, the base
regression from FUSE out-of-order READ continuations.

Production LOC: 214,073 -> 214,081 (delta +8)
  core     42,466 -> 42,466 (0)
  engine   98,266 -> 98,274 (+8)   layerfs-workspace +8
  control  62,950 -> 62,950 (0)
  api      10,391 -> 10,391 (0)
  reference absent (retired R9c; last counted 65,417 at tree 498dd19)
  Method: tools/production_loc.py --detail on parent tree e87ee9e and committed tree 57ccf29
@mengmengmengqiang
mengmengmengqiang merged commit 2f9cb97 into Ephemeral-AI-Lab:layerfs_v2_0_0 Nov 24, 2026
mengmengmengqiang added a commit to tokenaissance/layerfs that referenced this pull request Nov 24, 2026
…p; review round 1

Formal tree from LayerFS Branch lean-gc-admission-src (12b0a54b + review
round 1).  Rebased onto layerfs_v2_0_0 2f9cb97 (PR Ephemeral-AI-Lab#770 merged); the old
0b4b20a/fe9b4d1a base is superseded.

- ms-only Ordered.lt/comparePlace (same-ms different nonce = unordered)
- authority-gated placeOf with the per-field PlaceView::record fallback
- total Store.intents + EntriesSound support invariant
- one CompactBarrier (no inv5 field), hypothesis restatements
- close MountsActive + mount_intents::end, unmount release_or_mark
- branch existence guard, preview evidence, 23 axiom receipts

tools: check_lean_axioms requires Inv3/Inv4; test_production_loc carries the
formal-tree-outside-product-LOC test.
yifanxuaaa added a commit that referenced this pull request Nov 24, 2026
fix(gc): make the merged lean GC authority (#770) never worse than the base
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.

2 participants