From 2229a0699c586a3772c1c4b053e5ee1a0b824f39 Mon Sep 17 00:00:00 2001 From: rain Date: Tue, 24 Nov 2026 05:37:49 +0000 Subject: [PATCH 01/12] engine: the lean GC admission, place authority and retained done rows Rebase the p4 lean phase-3 engine delta onto the current layerfs_v2_0_0 release (87e46c652a): 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 498dd1917812) Method: tools/production_loc.py --detail on parent tree 97d6fc24735b1ce6e0f004b586d8fcc787088d48 and committed tree 9e42d2f0894a719fd23558eb00f564b47b0cfd57 --- .../layerfs-history/src/contract/authority.rs | 292 +++++++++ .../layerfs-history/src/contract/catalog.rs | 103 +++- .../crates/layerfs-history/src/contract/gc.rs | 332 +++++++++++ .../layerfs-history/src/contract/holder.rs | 79 +++ .../layerfs-history/src/contract/mod.rs | 3 + .../layerfs-history/src/contract/records.rs | 224 +------ core/crates/layerfs-history/src/lib.rs | 17 +- .../tests/mounted_sequential_read.rs | 7 +- .../layerfs-persistence/sql/postgresql/gc.sql | 5 + .../layerfs-persistence/sql/sqlite/gc.sql | 5 + .../queries/history/gc_intent_all_branch.sql | 3 +- .../queries/history/gc_intent_all_project.sql | 3 +- .../queries/history/gc_intent_all_store.sql | 3 +- .../sqlite/queries/history/gc_intent_done.sql | 7 + .../queries/history/gc_intent_done_delete.sql | 6 + .../queries/history/gc_intent_done_insert.sql | 8 + .../sqlite/queries/history/gc_intent_get.sql | 3 +- .../queries/history/gc_intent_insert.sql | 16 +- .../sqlite/queries/history/gc_intent_list.sql | 3 +- .../history/gc_intent_list_machine.sql | 6 + .../queries/history/gc_intent_ops_branch.sql | 3 +- .../queries/history/gc_intent_ops_project.sql | 3 +- .../queries/history/gc_intent_ops_store.sql | 3 +- .../history/gc_intent_release_done.sql | 15 + .../queries/history/gc_intent_renew.sql | 8 + .../src/backend/postgresql/schema.rs | 37 +- .../backend/postgresql/schema_diagnostic.rs | 4 + .../src/backend/postgresql/session/query.rs | 1 + .../src/backend/records.rs | 16 +- .../src/backend/sqlite/compact/build.rs | 32 +- .../src/backend/sqlite/schema.rs | 22 +- .../src/backend/sqlite/session/connection.rs | 16 +- .../src/backend/sqlite/session/query.rs | 19 + .../src/backend/sqlite/session/rows.rs | 1 + .../layerfs-persistence/src/diagnostic/mod.rs | 2 + .../src/diagnostic/mounts.rs | 141 +++++ .../src/diagnostic/sqlite.rs | 25 + .../src/history/admission.rs | 363 +++++++----- .../src/history/admission/authority.rs | 148 +++++ .../src/history/admission/lease.rs | 33 ++ .../src/history/admission/place.rs | 203 +++++++ .../src/history/admission/removal.rs | 34 +- .../src/history/admission/session.rs | 121 ++++ .../src/history/bindings.rs | 5 + .../src/history/catalog.rs | 33 ++ .../layerfs-persistence/src/internals.rs | 1 + engine/crates/layerfs-persistence/src/lib.rs | 1 + .../layerfs-persistence/src/store/config.rs | 24 +- .../layerfs-persistence/src/store/open.rs | 2 + .../layerfs-persistence/tests/admission.rs | 482 ++++++++++++++- .../tests/fixtures/sqlite_compact_golden.json | 2 +- .../tests/gc_conversion.rs | 354 +++++++++++ .../tests/gc_intent_authority.rs | 148 +++++ .../tests/gc_intent_done.rs | 301 ++++++++++ .../tests/gc_place_view.rs | 192 ++++++ .../tests/gc_place_writers.rs | 308 ++++++++++ .../layerfs-persistence/tests/gc_schema.rs | 174 ++++++ .../tests/lineage_backfill.rs | 3 +- .../tests/old_format_columns.rs | 3 +- .../tests/old_format_open.rs | 3 +- .../tests/postgresql_gc_fence.rs | 148 ++++- .../tests/postgresql_gc_mark.rs | 3 +- .../layerfs-persistence/tests/sealed_open.rs | 152 +++++ .../tests/sqlite_compact_done.rs | 245 ++++++++ .../tests/sqlite_compact_matrix.rs | 116 +++- .../tests/sqlite_group_rows.rs | 2 +- .../tests/sqlite_group_rows_indexed.rs | 6 +- .../tests/sqlite_inode_values.rs | 2 +- .../tests/sqlite_publication.rs | 4 +- .../tests/visibility_guard.rs | 7 + .../src/history/admission.rs | 252 +++++++- .../src/history/listing.rs | 22 +- .../layerfs-store-service/src/store/bind.rs | 17 +- .../src/store/operation.rs | 22 + .../layerfs-store-service/tests/admission.rs | 238 +++++++- .../tests/fixtures/merge-forms-root.sqlite | Bin 221184 -> 315392 bytes .../tests/golden/sdk_methods.txt | 6 +- .../tests/merge_forms_fixture.rs | 6 +- .../tests/place_incarnation.rs | 62 ++ .../tests/sdk_mount_lookup.rs | 30 + tools/store_blocks.py | 1 + tools/store_gc_convert.py | 558 ++++++++++++++++++ tools/test_store_blocks.py | 21 +- tools/test_store_gc_convert.py | 391 ++++++++++++ 84 files changed, 6209 insertions(+), 513 deletions(-) create mode 100644 core/crates/layerfs-history/src/contract/authority.rs create mode 100644 core/crates/layerfs-history/src/contract/gc.rs create mode 100644 core/crates/layerfs-history/src/contract/holder.rs create mode 100644 engine/crates/layerfs-persistence/sql/sqlite/queries/history/gc_intent_done.sql create mode 100644 engine/crates/layerfs-persistence/sql/sqlite/queries/history/gc_intent_done_delete.sql create mode 100644 engine/crates/layerfs-persistence/sql/sqlite/queries/history/gc_intent_done_insert.sql create mode 100644 engine/crates/layerfs-persistence/sql/sqlite/queries/history/gc_intent_list_machine.sql create mode 100644 engine/crates/layerfs-persistence/sql/sqlite/queries/history/gc_intent_release_done.sql create mode 100644 engine/crates/layerfs-persistence/sql/sqlite/queries/history/gc_intent_renew.sql create mode 100644 engine/crates/layerfs-persistence/src/diagnostic/mounts.rs create mode 100644 engine/crates/layerfs-persistence/src/history/admission/authority.rs create mode 100644 engine/crates/layerfs-persistence/src/history/admission/lease.rs create mode 100644 engine/crates/layerfs-persistence/src/history/admission/place.rs create mode 100644 engine/crates/layerfs-persistence/src/history/admission/session.rs create mode 100644 engine/crates/layerfs-persistence/tests/gc_conversion.rs create mode 100644 engine/crates/layerfs-persistence/tests/gc_intent_authority.rs create mode 100644 engine/crates/layerfs-persistence/tests/gc_intent_done.rs create mode 100644 engine/crates/layerfs-persistence/tests/gc_place_view.rs create mode 100644 engine/crates/layerfs-persistence/tests/gc_place_writers.rs create mode 100644 engine/crates/layerfs-persistence/tests/gc_schema.rs create mode 100644 engine/crates/layerfs-persistence/tests/sealed_open.rs create mode 100644 engine/crates/layerfs-persistence/tests/sqlite_compact_done.rs create mode 100644 engine/crates/layerfs-store-service/tests/place_incarnation.rs create mode 100644 tools/store_gc_convert.py create mode 100644 tools/test_store_gc_convert.py diff --git a/core/crates/layerfs-history/src/contract/authority.rs b/core/crates/layerfs-history/src/contract/authority.rs new file mode 100644 index 0000000000..4544913483 --- /dev/null +++ b/core/crates/layerfs-history/src/contract/authority.rs @@ -0,0 +1,292 @@ +//! Place/incarnation authority, lease and fencing values. +//! +//! These are the pure decisions phase 3 admission needs before it touches a +//! Store: a changed machine incarnation or a retired Sandbox generation is +//! dead; an expired lease is **uncertain**, never dead; and a stale fencing +//! token may not renew or release. The adapter owns the records and the +//! clocks; this crate only names the rule. +//! +//! Place values are ordered. A value minted by this release is +//! `p1: