feat(cli): harden resumable run sessions and add status preflight - #7
Merged
Conversation
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This was referenced Jul 27, 2026
A plain MS_BIND self-bind of an allowed directory shadowed any mount nested beneath it, so an externally materialized checkout under an allowed data dir served the raw base tree to absolute-path resolution while the inherited-cwd view stayed on the overlay. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
# Conflicts: # crates/vfs-cli/src/cmd/run/darwin.rs
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.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.
Description
What
Hardens
vfs runinto a resumable, externally-materializable session runtime, and addsvfs status <session-id> --jsonfor daemon preflight.Why
Handoff receive means a daemon writes two files and expects
vfs run --session <id>to just work, on a machine where the session has never run, possibly after a previous owner was SIGKILLed mid-flight. Run needed a defined receiver contract and a recovery story instead of assuming it created every session it resumes.How
delta.db+base_path(UTF-8 text file naming the receiver's base checkout).mnt/,procs/,.session.lock, and SQLite sidecars are created or recovered lazily by run.vfs-core,vfs-mount): interrupted pack publications roll forward from backup, stale mounts detach, dead-owner proc records are reaped, all under the session lock.vfs status --json: reportsstopped | busy | live | stale-recovered, pid, pack generation, and seeded flag; preflight performs the same recovery so the daemon reads a truthful state.0dc24f1, found by the live cross-machine handoff demo): a plainMS_BINDself-bind of an--allow'd directory shadowed any mount nested beneath it. An externally materialized checkout under an allowed data dir kept its overlay for the inherited-cwd view but served the raw base tree to any subprocess spawned with an absolute cwd, silently losing the delta. Directory allows now bind withMS_BIND | MS_REC.Stack (merged bottom-up 2026-07-28, vfs main @
3b2af42):Related Issue
Part of AC-768
Reviewer Guide
Diff shape: ~40%
run/mod.rs(lifecycle + recovery + status), ~25% platform run paths simplified against the shared core, ~25% tests (run/tests.rs,test-run-resume-hardening.sh), ~10% mount recovery (vfs-mount).Review depth: Standard, deep on the recovery ladder in
run/mod.rs.Read order:
crates/vfs-cli/src/cmd/run/mod.rs— resume ladder: validate external materialization, recover pack publication, detach stale mount, reap procs, then startcrates/vfs-mount/src/lib.rs— stale-mount detection/detach primitivescrates/vfs-cli/src/cmd/run/linux.rs/darwin.rs— platform paths now delegating to the shared lifecyclecrates/vfs-cli/tests/test-run-resume-hardening.sh— the receiver-contract and crash-resume matrixRisk & Impact
Recovery runs on every resume, so a false-positive "stale" classification could detach a healthy session; liveness is derived from the advisory lock plus proc records, both released by the kernel on process death, which keeps the classification crash-consistent. Exit statuses 3/4/5 are now API for the daemon caller; changing them later is a breaking change.
Verification
Behavior verified. Two-file external materialization resumes cold; SIGKILL of the owner mid-run then resume recovers mount and proc state;
vfs statusreportsstale-recoveredafter preflight cleanup; wrapped-command exit statuses pass through including 128+n (verified @fb69618). Full cross-machine handoff demo (Factory/handoffover a relay, delta read back on the receiver) verified @0dc24f1; clip in Factory-AI/factory-mono#16942.Regression coverage.
test-run-resume-hardening.sh(new) pins the receiver contract, the crash-resume matrix, and the nested-checkout-under-allowed-ancestor case (fails on a plainMS_BINDbinary, passes withMS_REC);test-sigkill-recovery.shupdated for the shared recovery path;run/tests.rscovers status classification.Not tested. Cross-platform handoff (darwin sender to linux receiver) end-to-end in CI; exercised manually, no darwin CI runner.
Standard validators. cargo build/test and CLI shell suites clean.
Changes after the last review pass (post-`0dc24f1`)
3480120preserves live-session joiners: exclusive-lock startup rejectedvfs run --session <id>against a running session asSessionStillRunning.prepare_sessionnow downgrades to a shared lock and validates the live mount, runtime status file, and session database before joining (StartState::Live); teardown validation aligned with mount-failure exit code 4. Caught bytest-run-resume-hardening.shon the first CI run against main.5e4010eand9a74282cfg-gate Linux-only session-preparation helpers and theLivestart state out of macOS builds.9a74282: full workspace suite plus resume-hardening, bounded-teardown, and corruption-torture (legacy and io_uring) shell suites green.