Skip to content

shell: the test of a model written from the home uses a home of its own - #819

Open
kitokey-sam[bot] wants to merge 2 commits into
mainfrom
shell/migrate-test-home
Open

kitokey-sam[bot] wants to merge 2 commits into
mainfrom
shell/migrate-test-home

Conversation

@kitokey-sam

@kitokey-sam kitokey-sam Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

shell: the test of a model written from the home uses a home of its own


Module

modules/shell — exactly one.

  • This pull request touches a single module
  • ⚠️ Cross-module — the cross-module label is required, justification below

Deliverable

Out of cycle: the coordinator's GO from the 2026-11-13/14 retrospective (P2). tests/migrate.rs's a_model_written_from_home_is_named_where_it_went created its folder in the person's real home (tempfile::tempdir_in(dirs::home_dir())).

  • Wherever the home is read-only, as in the authors' sandbox, it failed (ReadOnlyFilesystem), so every shell PR carried « 1 failed, not mine ».
  • Everywhere else, it wrote into the home.

What it changes

  • The test moves to tests/migrate_home.rs, its own test binary. There it points HOME and XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_CACHE_HOME, XDG_STATE_HOME at a tempdir, and checks that dirs::home_dir() now answers that folder.
  • Why its own binary: the environment belongs to the process, and every other test in migrate.rs reads the home. settings::from_home calls dirs::home_dir() for every path. Setting it beside them would race, so it follows the practice of tests/licence.rs: one test sets the environment, in a file where no other test does.
  • What it tests is unchanged: Summit's settings name the model as ~/…/summit/models/a.bin; once carried over, Kitokey's settings name it under kitokey/models/, and model_named is said.
  • No code changes.

Oracle

It still tests what it says. A mutant of settings::from_home that leaves ~ unexpanded ((Ok(_), Some(_)) => written, applied: git diff --numstat 1 1, then restored) makes it fail at assert!(carried.model_named), at c4d3f08.

Kind of oracle: unit tests.


Review budget

  • Lines changed (excluding generated), at c4d3f08 against main: 70 (+49 −21): tests/migrate_home.rs +49, tests/migrate.rs −21
  • Files touched: 2
  • Within budget

Contracts

  • No contract affected

Definition of Done

  • Oracle green
  • Lint, format, types: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings clean at c4d3f08
  • Unit tests: cargo test --locked --no-fail-fast at c4d3f08, 47 test binaries, 0 failed (the first full run with none failed in the author's sandbox)
  • E2E on critical journeys: not applicable, a test moved, no behaviour changed
  • Affected documentation updated: none names this test
  • Diff self-reviewed line by line

Test sheet

Verifier: session 14f73956-90b9-46a3-9fcc-52dc45c43948

# Given · when · then Kind Result Evidence Commit Confirmed
S1 Given a home that cannot be written, when the shell's tests run, then a_model_written_from_home_is_named_where_it_went passes, and no test writes in the person's home automated passed At the head, in this sandbox where the home is read-only (touch ~/.w819: « Read-only file system »): cargo test --locked --no-fail-fast, the shell's 47 test binaries all ok, migrate 23 passed, migrate_home 1 passed. migrate.rs's binary run with HOME set to an empty folder: 23 passed, the folder still empty after. Both binaries run 20 times each, one after the other: 0 failures. A first full run had 7 of sessions.rs's 12 fail with the shared tmpfs 80 % full; alone and in the full re-run with 19 % used, 12 of 12 pass: the environment, not this change. c4d3f08 —
S2 Given Summit's settings naming the model from the home (~/…), when it is carried over, then Kitokey's settings name it where it went, as before: a from_home that leaves ~ unexpanded makes the test fail automated passed Hand mutants, one per run under timeout 600, each applied (git diff --numstat), the source restored after each: 4 killed — from_home leaving ~ unexpanded ((Ok(_), Some(_)) => written): fails at migrate_home.rs:44, carried.model_named; ~ expanded to /: fails at :44; the test no longer setting HOME (the XDG_* still set): fails at :26, left: Some("/home/f"), the person's home; the same with that assert removed too: fails at :42, the model not found in the person's home, and nothing written there. c4d3f08 —

Verifier's remarks: No race. Cargo runs the test binaries one after another, and migrate_home holds one test, so its set_var meets no other test. It follows licence.rs, start.rs and summarising.rs, which set the environment the same way. A detail that changes nothing: the test points XDG_DATA_HOME at <home>/XDG_DATA_HOME, while Summit's data sits at <home>/.local/share. Places is given whole, so no XDG_* is read; they only keep a stray read away from the person's folders. The e2e is the coordinator's, after #817. Ground: as on #811, a git clone --shared detached at c4d3f08, its build in modules/shell/target/verify-819 of this session's own repository, removed at the end.


Summary

DONE

  • a_model_written_from_home_is_named_where_it_went runs in its own binary, with HOME and XDG_* pointed at a tempdir; it no longer touches the person's home.

VERIFIED

  • At c4d3f08, with a read-only home: the test passes, migrate.rs 23 passed, and the whole suite has 0 failed. fmt and clippy are clean.
  • The from_home mutant above is killed.

ASSUMED

  • dirs::home_dir() reads $HOME on Linux and macOS. The test asserts it, so a platform where it does not would fail on that assertion, not silently.

NOT VERIFIED

  • Windows: there dirs::home_dir() asks the system, not HOME, and the assertion would fail. The shell's CI runs Linux. If a Windows job runs this binary, the test needs #[cfg(unix)].

RISKS

  • None to the product: tests only.

🤖 Generated with Claude Code

a_model_written_from_home_is_named_where_it_went made a folder in the
person's home, so it failed wherever the home is read-only and wrote
there everywhere else. It now points HOME and XDG_* at a tempdir, in a
test binary of its own (tests/migrate_home.rs): the environment belongs
to the process, and every test of migrate.rs reads the home.

Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: 92ded11e-58ef-492d-ba56-c820b9011de8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

out-of-cycle Work outside the current cycle: an incident, a production defect; justified in the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants