Skip to content

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.

LocationRole today
packages/rust/fleet/src/lib.rsFleet::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.rssuite_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 ScratchVaultMints 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.rsThe store resolves to the real durable home. Its own test asserts that path
solutions/determined/crates/determined-platform/tests/http_smoke.rsPuts 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.rsSets FLEET_ROOT on the spawned server. The only Rust test that does
solutions/ontological/desktop/src-tauri/tests/*.rsSet SDF_FLEET_ROOT to a tempdir per test
.moon/tasks/rust.ymlcargo 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.tsHand-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.

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:

MechanismForAgainst
[env] FLEET_ROOT in .cargo/config.tomlOne line, every crateAlso 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_ROOTPer-run root, test-onlyMoves the repo from cargo test to cargo nextest. Plain cargo test stays unguarded
Moon task env: FLEET_ROOT set on the test taskTest-only, no new toolA bare cargo test outside moon stays unguarded
Guard in fleet: when FLEET_REQUIRE_OVERRIDE is set, BaseDirs::from_env errors without an overrideFails loudly; pairs with any of the aboveNeeds 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.

  1. Survey. List every Rust and TS test that resolves a fleet home without a scratch root: callers of Fleet::new(), the determined-core::workspace helpers, ScratchVault, Tier::*, and Fleet.fromSystem() in TS tests. Record which write and which only compute paths.
  2. 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.
  3. Apply it to the Rust test tasks and the TS test runner. Fix tests that break because they assumed the real home.
  4. Add a guard test: with the default test env, fleet::Fleet::new() resolves under the scratch root.
  5. 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.
AreaNote
packages/rust/fleet/Optional guard
.moon/tasks/rust.ymlTest task env
solutions/determined/crates/determined-parity/src/doubles.rsScratchVault
solutions/determined/crates/*/Tests that assumed the real home
packages/ts/fleet/, TS test runner configTS default
docs/planning/standards/S-0020-desktop-apps-tested-web-first-in-scratch-root.mdRecord the rule
  • AC-1: moon run determined-backup:test leaves no new entry under the real com.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 HOME set 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.json and leftover vaults/test-* directories.
  • E2e launchers. T-GXNH and T-VEK2 move them onto the harness.
  • App-specific overrides such as VAULT_BACKUP_STORE. T-2YHP decides them.
  • The CI lane with an empty HOME. T-CAWD runs it; this task makes the unit tests pass in it.
  • Stopping boot adoption of vaults, which belongs to the determined task T-IOD8.
  • T-NNAG: FLEET_ROOT moves every fleet home. Done.
  • cargo test -p determined-backup wrote test-* vault directories under the real durable home.
  • A developer’s real vault roster held about 11 test and dev entries.

T-NNAG


← Back to Tasks