Skip to content

p4: lean phase-3 GC authority (final) - #73

Merged
mengmengmengqiang merged 11 commits into
layerfs_v2_0_0from
p4-lean-phase3
Nov 24, 2026
Merged

mengmengmengqiang merged 11 commits into
layerfs_v2_0_0from
p4-lean-phase3

Conversation

@mengmengmengqiang

@mengmengmengqiang mengmengmengqiang commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Lean phase-3 GC authority — final

p4-lean-phase3 @ ba4469db (p4 code + docs), based on layerfs_v2_0_0 ed9118963.

What this is

  • 0 new tables. gc_intent keeps 4 authority columns; ordered MachineRecord.incarnation / SandboxRecord.generation; machine-level tombstone machine/<machine>/sandbox-retired/<name>.json; compact Copy::Done keeps the done-row audit; store.repair_mount_holders + bounded done row read.
  • Removed vs the 3-table phase-3: gc_machine_authority, gc_sandbox_tombstone, gc_audit, the two authority migrations, gc_authority.sql, old-source acceptance, blank-boundary compat. 2.0 schema version bumped directly (SQLite 39/40/41, PG 3).
  • Docs: LayerFS-GC-spec.md, gc-runbook.md, mount-authority-lease.md updated to the lean design (no Store-side authority/tombstone/audit tables; per-machine conversion).

Verification

  • cargo check --workspace --all-targets exit 0.
  • layerfs-api contract/calls_table/gc_calls; layerfs-persistence gc_schema/gc_place_view/gc_place_writers/gc_conversion; layerfs-control store_repair_live; layerfs-store-service sdk_method_golden — all pass.
  • FUSE 7/7 (privileged container, rebuilt daemon).
  • sandbox_get_no_lease (10) is a pre-existing Linux limitation (native sandbox is macOS-only), not a merge defect.

Supersedes


Verification at 87890d7 (2026-11-24)

Run in a privileged Linux container with a real /dev/fuse (the sandbox lacked it; --privileged is required for the mount tests):

  • FUSE mount binaries: kernel_application 1, kernel_mount_routes 2, observed_application 8, r5_1_actual_daemon_commit 1 — 12/12.
  • Device/lock suites: install_directory 4, kernel_guard 5 (TMPDIR on ext4), closed_streams 3 (build-identity bypass) — all pass.
  • mounted_sequential_read: 2/2; 141 Store demands for 64 MiB on SQLite and 141 on PostgreSQL (bound 192). The old PostgreSQL bound of 64 had no code or measurement behind it: the engine reads ahead in 512 KiB windows (history/objects/edges.rs BATCH_BYTES).
  • machine_list_live 1/1; project_stats 4/4, store_stats 2/2, saved_continuation 2/2, each on a clean layerfs schema.
  • Hygiene: fmt, boundary, ruff, clippy -D warnings; every test target builds.

Known limitations (pre-existing; neither is run by tools/ci/test_store_ext4.sh)

  • repair_postgresql cannot pass on PostgreSQL as written: its setup calls add_project, which is deliberately SQLite-only ("adding a project needs a SQLite Store"). It needs the project.init setup path.
  • project_stats and store_stats cannot share one PostgreSQL database: one layerfs schema is one Store, so the second binary's project.init meets the first's project p. Each passes alone on a clean schema; the CI lanes run targets separately.

@mengmengmengqiang mengmengmengqiang changed the title p4: lean phase 3 onto the 2.0 release p4: lean phase-3 GC authority (final) Nov 23, 2026
mengmengmengqiang added a commit that referenced this pull request Nov 23, 2026
The tree of this commit is exactly the export of LayerFS p4-integration at
123e2825d3108687660882011f6b71f34e36bbdb549a6b62b6b61bb955526766ae (code
12f5785a511cb79064885c9bda5a3033e7f5a8bc5f049a0bb06d5b1aede7a17cc5 plus the
phase-3 audit docs). The parent is layerfs_v2_0_0 (ed91189), the PR #73
base, so the PR diff is the whole p4 tree against the release.

This replaces the previous p4-lean-phase3 head (ba4469d), a lossy merge of
p4 into main that dropped p4 code: the store.call place_view carry,
api/crates/layerfs-api/src/store/repair_mount_holders.rs, the p4
postgresql home, and more.

Raw p4: no p4-on-release post-merge adaptations are included. In particular
the p4 gc_intent_release_done.sql has no `AND state <> 'done'` guard (that
guard was added on p4-on-release, not in p4).
mengmengmengqiang added a commit that referenced this pull request Nov 23, 2026
Whole-tree export of the published LayerFS main
32ef35895b01b50fa838f63e6d5ebd7ae96ba54f6606d7ce4e33dff4d76851f00d,
placed on the PR #73 base ed91189.
Not a patch or merge: the tree is exactly the export minus
.git, .cargo-home, tmp and target.
@mengmengmengqiang
mengmengmengqiang force-pushed the p4-lean-phase3 branch 2 times, most recently from 73a89f2 to 337336b Compare November 23, 2026 21:13
mengmengmengqiang and others added 10 commits November 23, 2026 21:36
`the_converted_store_serves_the_operator_audit` was spliced into the body
of `the_converted_store_opens_and_the_home_holds_the_old_authority`: that
test's PRAGMA, dropped-table and sequence assertions and its closing brace
sat after the second test, so the second `#[test]` was nested in a fn item
and `cargo check --all-targets` failed with E0434.

Move the block back to the end of the first test. One file, no other
change; found by the caec1b07 audit and fixed the same way in the merge.
… does

The worker-start reconcile test seeded the older ordered incarnation before
the newer restore and the current machine record, so admission settled the
older row itself; the fixture now registers the restore, the retired
generation and then the older incarnation, and writes the machine record and
the Sandbox tombstone after the seed, before the worker serves.

The done-audit preview rows name the Branch the operator previewed, not main,
and the doctor's worker-side read is one bounded 16-row page. Assert both as
the p4 tree emits them.

Tests: cargo test -p layerfs-control --test store_repair_live -> 2 passed.
…ema is

The PostgreSQL DDL still constrained store_policy.schema_version and
history_meta.schema_version to 2, so schema::create's insert of SCHEMA_VERSION
(3) raised a check violation; every PostgreSQL create and open then failed
with Malformed. A fresh Store creates, opens and projects store.status again.
The diagnostic contract golden carries the same version.

Tests: postgresql_open_check 3 passed; postgresql_status 1 passed (libpq and
URL sources).
…topped machine

merge-forms-root.sqlite was a released schema version 2 Store (user_version
42), which the lean open refuses by design. Regenerate it as a version 45
Store: the same root-form data, packs and allocation counters, carried into
the current schema with the current schema source/definition, history serials
and project epochs. The ignored generator's note names the current version.

project.get needs the Store's live project list, so a stopped machine's
worker refuses it Unavailable with the start hint; it starts nothing. The
read test now pins that refusal instead of expecting a record-only answer.

Tests: merge_mixed_forms 2 passed; merge_metadata_only 6 passed;
machine_no_start 1 passed.
The table's help is "list, settle, release, audit or archive mount holders
(operator)"; the test still expected the old list without archive.

Tests: layerfs-cli --test gc -> 5 passed.
…window

The mounted 64 MiB read reaches the Store in 141 demands with the SQLite
engine's 512 KiB read-ahead window; PostgreSQL's larger window stays under
64. Keep the tight PostgreSQL bound and give SQLite its own 192-demands
bound, still far below the about-512 one-demand-per-kernel-read case.

Not run here: this host has no /dev/fuse. Evidence: the privileged FUSE lane's
MOUNTED_READ sqlite object_batches 141; the PostgreSQL arm passed.
Run cargo +1.85.1 fmt --all, ruff format (0.17.2), and fix the product
boundary and clippy findings.

- Move the inline test modules out of src/ into tests/support files loaded by
  a path module; the product source keeps no test-only attributes. Tests
  moved: control doctor mount_holders/project_target, machine endpoint/record,
  sandbox tombstone, store place_view/service, history authority and
  store-service admission.
- Add the documented line-limit waiver for the two inherited cohesive files
  (history records.rs and persistence admission.rs); every other file stays
  under 999 lines.
- Clippy: allow the one removal-admission signature and the two operator
  repair signatures, elide two test lifetimes, drop a duplicate allow, and
  remove three needless borrows.
- Ruff formats the 10 drifted tools files.

Checks: fmt --check clean; ruff format --diff clean; boundary PASS (1575
files); tools unittest 195 passed; clippy --workspace --exclude layerfs-node
--all-targets -D warnings clean.
Under the machine feature the worker route resolves the Store's owning
machine from the home record; caller_home recorded the Store on box but no
machine named box, so seven project_delete_worker cases failed NotFound
before the fake worker saw the frame. Seed the machine record the code
expects.

Tests: project_delete_worker 8 passed with --features machine (and 8 without).
The diagnostic guard compares the live column projection with a golden that
still carried a leading newline, so no freshly created Store could pass:
schema_definition is exactly the ordered column lines, and the constant now
is that text with one trailing newline. The compact, diagnostic, doctor and
compact-fixture PostgreSQL suites run their offline audit again.

Also make the PostgreSQL repair fixture's temp home owner-private, as the
home guard requires.

Tests: postgresql_compact 32 passed; postgresql_diagnostic 9; doctor_physical
16; open_check 3; acquisition 4; position_columns 4; compact_fixtures 9;
doctor_access 10; status 1. repair_postgresql still stops at add_project's
deliberate SQLite-only refusal (reported, not changed).
The engine reads objects in 512 KiB windows (history/objects/edges.rs
BATCH_BYTES), so a 64 MiB sequential read costs about 141 Store demands on
either backend; the kernel reads 128 KiB at a time, so no read-ahead would be
about 512. The PostgreSQL arm asserted 64, which no measured run supports (the
mounted lane measured 140 at a0ef644), so the split bound is one 192 for both.
@mengmengmengqiang
mengmengmengqiang merged commit fb7e1a5 into layerfs_v2_0_0 Nov 24, 2026
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