Repository navigation
fix(store): preserve and rebuild SQLite project manifests across worker init and store move - #751
Merged
yifanxuaaa merged 2 commits intoNov 22, 2026
Conversation
…r init and store move project.init on a worker machine now returns encoded manifest and installed bytes so init_on_worker writes the complete host ProjectRecord instead of the 88-byte PostgreSQL stub. store.move completes any existing incomplete SQLite project record read-only via SqliteHandles::open_diagnostic when moving to or from native, and sandbox.create (lifecycle::installed) repairs an existing incomplete local SQLite record on demand. project.doctor fails project.record when a SQLite project without an init op lacks a complete manifest. Tests: new project_family worker_inited_project_keeps_manifest_across_move_to_native_and_back and move_and_sandbox_repair_an_existing_incomplete_project_record, doctor_targets a_sqlite_project_without_a_manifest_fails_project_doctor, restored_records repair_project_completes_an_incomplete_record_from_sqlite_store, installed_repair sandbox_create_repairs_an_incomplete_sqlite_project_record; updated doctor_targets a_project_s_record_is_checked_against_its_store fixture to carry valid manifests. Docs: docs/architecture/control/stores-and-projects/projects.md, docs/architecture/control/stores-and-projects/sqlite-and-postgresql.md, docs/architecture/control/sandboxes/README.md, docs/architecture/control/doctor/README.md. Durable: NOT_RUN — disabled by owner until explicit reauthorization. Production LOC: 205844 -> 206050 (delta +206) core 40988 -> 40988 (0) engine 95845 -> 95845 (0) control 58745 -> 58951 (+206) layerfs-store +161, layerfs-sandbox +32, layerfs-control +13 api 10266 -> 10266 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --root on parent ed91189 (/data/wt/dshv2-repro) and the staged tree
Make complete_existing skip per-project read, rebuild, and write errors so a single corrupted project record.json is left untouched and neither aborts repairing other incomplete records nor breaks healthy projects. Also treat complete_existing during store.move's record phase as incidental best-effort so record-repair failure cannot stall store.move at op.phase = "record" with uncertain = true. Tests: added project_family move_skips_unreadable_project_record_and_still_repairs_incomplete_ones; ran restored_records (7 passed), store_transfer_recovery (4 passed), project_family (7 passed), store_family (5 passed, 1 ignored), doctor_targets (7 passed), and lf-ci.sh fast (2901/2918 passed, 17 pre-existing env/baseline failures). Durable: NOT_RUN — disabled by owner until explicit reauthorization. Production LOC: 206050 -> 206049 (delta -1) core 40988 -> 40988 (0) engine 95845 -> 95845 (0) control 58951 -> 58950 (-1) layerfs-store -1 api 10266 -> 10266 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --json on parent f57829a and the staged tree
yifanxuaaa
added a commit
that referenced
this pull request
Nov 22, 2026
fix(store): review follow-ups to #751 project-record repair
yifanxuaaa
added a commit
that referenced
this pull request
Nov 22, 2026
…rol-plane fixes) Brings in the six origin commits (#751, #754, #755 and the store.move manifest repairs) beside the local LF14 commit 712f4d0. Production LOC: 205907 -> 206226 (delta +319); first-parent comparison (parent 712f4d0 vs the merged tree), counted with tools/production_loc.py --root on git archive extracts of both snapshots; control scope 58808 -> 59068 (delta +260). Reference absent (retired R9c; last counted 65,417 at tree 498dd19). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jiangkoumo
pushed a commit
to jiangkoumo/layerfs
that referenced
this pull request
Nov 23, 2026
…repair Review of Ephemeral-AI-Lab#751 (merged as fae5488) found these; each is fixed here. - project doctor: a SQLite project's record must be complete only where this process runs the Store's calls. A worker's Sandboxes read the entry that worker keeps, so a host stub there is not a project.record fault. A failed project.record no longer skips project.listed or the --full project.data walk. - sandbox.create: the repair is decided by the record (no manifest, no installed, or bytes that do not decode), not by one refusal message, and is best effort: a repair that fails or cannot complete the record leaves the call's own refusal as it was. The repaired record is decoded in hand (discovery::project_of) instead of reading the entry again. - store.move: a record the record phase leaves incomplete is a line of log/repair.jsonl (call, store, project, why) instead of a silent drop. - project.init on a worker: a manifest/installed pair that is not a complete Disposable pair (restored::complete) is left out and logged in log/repair.jsonl, for a move or Sandbox create to complete. - restore and record repair share one Store scan, restored::found_in. Tests: doctor_targets checks project.listed still runs after a project.record failure; project_family checks store.move logs a record it cannot rebuild; installed_repair removes a Sandbox it did start instead of requiring create to fail; restored_records follows repair_project's new return (the written record). No tests deleted. Ran (TMPDIR=/tmp, 120 s limit each): restored_records 7, installed_repair 1, doctor_targets 7, project_family 7, backup_family 5, project_doctor_full 3, project_init_worker 7, store_family 5 (1 ignored), store_transfer_crash 6, layerfs-control doctor 12, project_delete_worker 14, store_transfer_recovery 4, restore_install 3: all pass. fmt, Clippy (-D warnings) on layerfs-store/-sandbox/-control/-api and the product boundary guard pass. Not run: a doctor of a project whose Store is on a ready worker machine (needs a running VM), a restore from a bucket. Docs: doctor, home, sandboxes, projects, sqlite-and-postgresql. Durable: NOT_RUN — disabled by owner until explicit reauthorization. Production LOC: 206,108 -> 206,163 (delta +55) core 40,988 -> 40,988 (0) engine 95,845 -> 95,845 (0) control 58,950 -> 59,005 (+55) layerfs-store +48, layerfs-control +8, layerfs-sandbox -1 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 fae5488 and the staged tree Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tier: P1 (control/crates/layerfs-store) ; risks: risk:store ; gate: yes: risk:store ; de-escalated: none
Refs #749.
Reason
project initon a worker machine (for exampledocker),add_project(control/crates/layerfs-store/src/project/add.rs) computes(manifest, installed)in the worker's store directory, but its response omitted those encoded bytes. The host'sinit_on_worker(control/crates/layerfs-store/src/project/family.rs) therefore wrote an 88-byte{v, name, stack, created}stub withoutmanifestorinstalled.store moveback tonativetransferredstore.sqliteand deleted the worker's store directory inretirewithout populating the host's project records, permanently destroying the only copy of the manifest. Subsequentsandbox create --machine native(and even moving back todocker) failed withNotFound: no complete project manifest(NoSuchProject).project doctor(control/crates/layerfs-control/src/doctor/project_target.rs) only checked whetherrecord.jsonparsed as JSON and read the textstackfield, soproject doctor --fullstill reportedok: trueon broken 88-byte records.f57829a3c->9831deab2), propagatingProjectRecord::read/ repair errors with?duringstore.move'srecordphase allowed one corrupted projectrecord.json(such as{) to abortstore.moveafterinstall, leavingop.phase = "record"anduncertain = trueand blocking healthy projects on the same Store withBusy.What changed
project.init:add_project(control/crates/layerfs-store/src/project/add.rs) now returns encodedmanifestandinstalledbytes (SdkValue::Bytes), andinit_on_worker(control/crates/layerfs-store/src/project/family.rs) validates and writes them into the hostProjectRecordwhile remaining compatible with older workers that omit them.control/crates/layerfs-store/src/backup/restored.rsexposescomplete, addsprojects_in_diagnostic(usinglayerfs_persistence::SqliteHandles::open_diagnosticso no-wal/-shmor byte changes occur),complete_existing, and single-projectrepair_project.complete_existingskips per-project read, rebuild, or write errors instead of altering corrupted JSON or aborting repair of other valid incomplete projects.store.move:control/crates/layerfs-store/src/sqlite/transfer/phases.rsrunscomplete_existingduring therecordphase wheneversourceortargetisExecutor::Local, ignoring errors as incidental best-effort work sostore.moveproceeds cleanly toretireand clearsop.sandbox.create:control/crates/layerfs-sandbox/src/lifecycle.rscatchesNoSuchProject: no complete project manifestininstalledwhen localstore.sqliteexists, repairs the record viarestored::repair_project, and retriesdiscovery::project.project doctor:control/crates/layerfs-control/src/doctor/project_target.rschecksrestored::complete(&project)for non-init SQLite projects and reports aproject.recorderror whenmanifestorinstalledis missing/invalid.store.moveandsandbox.createself-repair,project doctor, and skipping unreadablerecord.jsonfiles duringstore.move; updated architecture docs in the same change.Scope
control/crates/layerfs-store/src/project/add.rscontrol/crates/layerfs-store/src/project/family.rscontrol/crates/layerfs-store/src/backup/restored.rscontrol/crates/layerfs-store/src/sqlite/transfer/phases.rscontrol/crates/layerfs-sandbox/src/lifecycle.rscontrol/crates/layerfs-control/src/doctor/project_target.rsapi/crates/layerfs-api/tests/project_family.rsapi/crates/layerfs-api/tests/doctor_targets.rscontrol/crates/layerfs-store/tests/restored_records.rscontrol/crates/layerfs-sandbox/tests/installed_repair.rsdocs/architecture/control/stores-and-projects/projects.mddocs/architecture/control/stores-and-projects/sqlite-and-postgresql.mddocs/architecture/control/sandboxes/README.mddocs/architecture/control/doctor/README.mdpython3 -B tools/production_loc.py --json,ed9118963 -> 9831deab2):205844 -> 206049 (delta +205)(core:40988 -> 40988,engine:95845 -> 95845,control:58745 -> 58950 (+205),api:10266 -> 10266;referenceabsent, retired R9c).Trade-offs
DaemonSetupformat changes: Keeping the fix incontrolavoids cross-component wire/bundle compatibility breaks and leaves PostgreSQL Stores andnative -> dockerinit paths unchanged.record-phase repair: Openingstore.sqlitewithSqliteHandles::open_diagnosticpreserves byte-for-byte Store identity across empty Store moves. Treatingcomplete_existinginstore.move'srecordphase as best-effort ensures a corruptrecord.json(which is left untouched) cannot stallstore.movewithop.phase = "record"anduncertain = true.project doctorfix: null: Missingmanifest/installedfrom older workers is accepted atinit_on_workerand repaired lazily duringstore.moveorsandbox.create.project doctorkeepsfix: nullbecausestore move <s> nativemutates Store placement if the Store still sits on a worker.Impact
project initon worker machines,docker <-> nativeround-tripstore move, on-demandsandbox createrecovery for pre-existing 88-byte records, fault isolation when another project'srecord.jsonon the same Store is unreadable, andproject doctor/project doctor --fulldetection.mainbranch instore.sqlitecannot be reconstructed read-only and still refuse withNoSuchProject. Verification ran on Linux (unit/integration suites, full Linux CI lanesfast/slow/mount/pg, and the Docker E2E suite re-run on9831deab2undernamespacesruntime) and on real-machine macOS (Apple Silicon: Colimaaarch64dockerworker, Apple Container1.6.1, and Lima2.2.1withnativeloopback NFS sandbox); only Windows remains untested (the 30 s first-time uncached Limamachine createtimeout is a pre-existing issue on baseed9118963, tracked in 首次创建 Lima 机器因 limactl create 30 秒超时必失败(无镜像缓存时) #750 and unrelated to this PR).Verification and how to re-run
9831deab2(tests built with--no-runfirst and executed underTMPDIR=/tmp timeout 120):python3 -B tools/check_product_boundary.py(PASS: scanned 1596 production Rust/SQL/JavaScript files)python3 -B -m unittest discover -s tools -p 'test_*.py'(181 tests ... OK)cargo +1.85.1 fmt --all -- --check(passed)cargo +1.85.1 clippy --locked --all-targets -- -D warnings(passed)restored_records(7 passed),store_transfer_recovery(4 passed),project_family(7 passed, includingmove_skips_unreadable_project_record_and_still_repairs_incomplete_oneswhich failed with exit 101 before9831deab2),store_family(5 passed, 1 ignored),doctor_targets(7 passed).9831deab2:fast:2918 tests run: 2901 passed (2 slow, 1 leaky), 17 failed, 26 skipped(all 17 failures reproduce identically on baseed9118963in the same environment:machine_power::start_and_stop_a_machine, 10 tests insandbox_get_no_lease,sandbox::workspace_isolation, plus 5TMPDIRSUN_LEN/0700tests that pass onfix749underTMPDIR=/tmp; 0 new failures).slow:177 tests run: 176 passed (4 slow), 1 failed, 11 skipped(the sole failurelayerfs-persistence::writer_admission read_only_close_does_not_wait_for_a_held_writer_lanefails oned9118963forSUN_LENand passes onfix749underTMPDIR=/tmp).mount:pass=46 fail=0.pg:layerfs-persistence(29/29),layerfs-store-service(10/10),layerfs-project(1/1),layerfs-api(2/2),layerfs-cli(2/2) passed;layerfs-control [password]exited101becausedoctor_store_postgresqldoes not exist inlayerfs-control(identical on baseed9118963).9831deab2(LAYERFS_SANDBOX=namespaces, real Docker worker): passed 3/3 new-project round trips, 3/3 legacy 88-byte recovery scenarios, thenative -> docker -> nativecontrol case, plus the new mixed corrupted-record scenario (good+ 88-bytelegacy+{-corrupteddamagedin the same Store: bidirectionalstore movecompleted withoutop/uncertain,damaged/record.jsonstayed{,legacywas repaired,good/legacysandboxes mounted and executedls -la, andproject doctor --fullreportedproject.recorderror ondamaged).9831deab2(Apple Silicon, Colimaaarch64dockerworker +nativeloopback NFS sandbox): passed the new-project round trip (docker -> native -> docker), both pre-existing 88-byte broken-record repair paths (store move nativeand directsandbox create --machine native), and thenative -> docker -> nativecontrol case.1.6.1and Lima2.2.1E2E on9831deab2(Apple Silicon M2 Air, with pre-warmed Lima image cache): passed all 4 scenarios on both runtimes (new-project round trip, both pre-existing 88-byte broken-record repair paths, and thenative -> vm -> nativecontrol case). The uncached first-time Limamachine create30 s timeout is a pre-existing baseline issue (ed9118963) tracked in 首次创建 Lima 机器因 limactl create 30 秒超时必失败(无镜像缓存时) #750 and unrelated to this PR.NOT_RUN— disabled by owner until explicit reauthorization.