T-G5ZV-tests-default-to-scratch-fleet-root
State: planning/proposed · Impact: high · Complexity: medium
Unit and integration tests write state under the real fleet homes unless FLEET_ROOT is set.
cargo test -p determined-backup leaves test-* vault directories under
~/Library/Application Support/com.sizerllc.determined/vaults/. Make a scratch root the default
for every test run, so P-0017-scratch-root-isolation holds for tests as well as for e2e.
| Location | Role today |
|---|---|
packages/rust/fleet/src/lib.rs | Fleet::new() reads BaseDirs::from_env(): overrides, else the OS homes. BaseDirs::rooted and from_env_with are seams, but production code calls Fleet::new() directly, so a test cannot inject a root below it |
solutions/determined/crates/determined-core/src/workspace.rs | suite_state_dir, app_durable_dir, app_state_dir, vault_state_dir, vault_durable_dir each call Fleet::new() |
solutions/determined/crates/determined-parity/src/doubles.rs ScratchVault | Mints test-<tag>-<pid>-<n> vault ids. Per-vault state lands in the real homes and is removed on drop. A panic that aborts, a killed run or a skipped drop leaves the directory behind. 42 call sites across backup, engine-client, index, media, ocr, photos, polish and sync |
solutions/determined/crates/determined-backup/src/config.rs | The store resolves to the real durable home. Its own test asserts that path |
solutions/determined/crates/determined-platform/tests/http_smoke.rs | Puts vault and state dirs in a tempdir, but the fitness import cache resolves to the real cache tier. The test deletes a leftover first |
solutions/determined/crates/determined-platform/tests/platform_server_paths.rs | Sets FLEET_ROOT on the spawned server. The only Rust test that does |
solutions/ontological/desktop/src-tauri/tests/*.rs | Set SDF_FLEET_ROOT to a tempdir per test |
.moon/tasks/rust.yml | cargo test -p $project --all-features. No FLEET_ROOT, no nextest config, no .cargo/config.toml |
packages/ts/fleet/ | TS has an injection seam: new Fleet(rootedBaseDirs(tmp)). Most TS tests use it. Fleet.fromSystem() appears in tests in cli-tool/config, cli-tool/devlink, apps/connector, apps/mail-sync, apps/todo-sync, apps/site-builder and ontological/lib/util/fleet.test.ts, mostly to compute expected paths |
solutions/determined/scripts/dev-web.ts | Hand-run web dev with no state isolation. T-GXNH gives it a scratch root |
A developer’s real roster (workspace.json) was found holding about 11 test and dev entries:
agent worktree fixture vaults, /vault, a scratchpad test vault and Orca workspace checkouts. Rust
tests build AppState over a tempdir state dir, so most of these likely come from dev runs that
boot-adopt a vault. The determined task T-IOD8 (no active vault state, in
solutions/determined/docs/planning/tasks/) stops boot adoption.
Proposed
Section titled “Proposed”Every cargo test and TS test run resolves fleet homes under a scratch root unless a test opts
out on purpose. A test that resolves a real home fails loudly instead of writing there.
Choose the mechanism in step 2. Candidates:
| Mechanism | For | Against |
|---|---|---|
[env] FLEET_ROOT in .cargo/config.toml | One line, every crate | Also applies to cargo run, so dev runs would land in scratch. Needs a fixed path, not a per-run tempdir |
nextest setup script exporting a per-run FLEET_ROOT | Per-run root, test-only | Moves the repo from cargo test to cargo nextest. Plain cargo test stays unguarded |
Moon task env: FLEET_ROOT set on the test task | Test-only, no new tool | A bare cargo test outside moon stays unguarded |
Guard in fleet: when FLEET_REQUIRE_OVERRIDE is set, BaseDirs::from_env errors without an override | Fails loudly; pairs with any of the above | Needs the variable set in every test entry point |
A likely shape: the moon test task sets a per-run FLEET_ROOT and FLEET_REQUIRE_OVERRIDE, and
ScratchVault keeps its cleanup. Tests that assert on the OS default (fleet’s own) clear the
override explicitly.
Approach
Section titled “Approach”- Survey. List every Rust and TS test that resolves a fleet home without a scratch root: callers
of
Fleet::new(), thedetermined-core::workspacehelpers,ScratchVault,Tier::*, andFleet.fromSystem()in TS tests. Record which write and which only compute paths. - Choose the mechanism from the table and record the choice in S-0020-desktop-apps-tested-web-first-in-scratch-root or S-0011-application-state-locations.
- Apply it to the Rust test tasks and the TS test runner. Fix tests that break because they assumed the real home.
- Add a guard test: with the default test env,
fleet::Fleet::new()resolves under the scratch root. - Document a one-time cleanup of stray entries in a developer’s real roster and of leftover
vaults/test-*directories. A manual step in a README, or a small op that lists candidates and removes only what the user confirms. Never an automatic deletion.
| Area | Note |
|---|---|
packages/rust/fleet/ | Optional guard |
.moon/tasks/rust.yml | Test task env |
solutions/determined/crates/determined-parity/src/doubles.rs | ScratchVault |
solutions/determined/crates/*/ | Tests that assumed the real home |
packages/ts/fleet/, TS test runner config | TS default |
docs/planning/standards/S-0020-desktop-apps-tested-web-first-in-scratch-root.md | Record the rule |
Acceptance criteria
Section titled “Acceptance criteria”- AC-1:
moon run determined-backup:testleaves no new entry under the realcom.sizerllc.determined/vaults/. - AC-2: A test that resolves a fleet home with no override fails with a message naming the fix, unless it opts out explicitly.
- AC-3: Every Determined Rust crate’s tests pass with
HOMEset to an empty directory. - AC-4: TS unit tests that write state do so under a scratch root. The survey lists any exception with its reason.
- AC-5: A documented step, or a confirm-first op, removes stray test and dev entries from a
developer’s real
workspace.jsonand leftovervaults/test-*directories.
Out of scope
Section titled “Out of scope”- E2e launchers.
T-GXNHandT-VEK2move them onto the harness. - App-specific overrides such as
VAULT_BACKUP_STORE.T-2YHPdecides them. - The CI lane with an empty
HOME.T-CAWDruns it; this task makes the unit tests pass in it. - Stopping boot adoption of vaults, which belongs to the determined task
T-IOD8.
Dependencies
Section titled “Dependencies”T-NNAG:FLEET_ROOTmoves every fleet home. Done.
Discovery context
Section titled “Discovery context”cargo test -p determined-backupwrotetest-*vault directories under the real durable home.- A developer’s real vault roster held about 11 test and dev entries.
Depends on
Section titled “Depends on”T-NNAG