Harden single-host checks and removal guidance #102

Merged
Collaborator

Preserve unresolved environment and code paths for ownership checks, cap linked-tree walks at 100,000 entries, fail closed on ValueError, and ignore SystemExit in sync and forget thread hooks. Explain the retained overlapping safety checks.

Strengthen the documented removal guard, remove legacy secrets, use the store volume for snapshot commands, and narrow snapshot-reporting claims. Document uv lock permissions and the one-time nature of check.

This PR replaces PR #101 (53b5d37, closed without merge). Rework round 1 is the first rework of this SVD run. It fixes two §9 Removal blockers that a fresh security review reproduced:

  • The guard now runs git status --porcelain --ignored --untracked-files=normal. Without it, status.showUntrackedFiles=no in the repository, global or system config hid untracked files, and the guard deleted them.
  • store_volume now comes from /bin/df -P. On the operator's Mac, df on PATH is GNU coreutils. It reports / for a path on the Data volume, while check probes /System/Volumes/Data.

ADR 0007 Amendment 1 item 4: DRAFT for the operator and mind-spec

This is a draft only. This PR does not edit docs/adr/*. The ADR text changes only after mind-spec ratifies the wording at an exact head (operator ruling at the #72 gate, 2026-11-16).

Current text:

  1. Time Machine stays on. The single-host shape does not require local snapshots to be off. check reports snapshots=present, none or unknown: whether local Time Machine snapshots exist on the store's volume. The value does not show which files a snapshot holds or how old it is, and check does not inspect other volumes. The value does not fail check.

Proposed text:

  1. Time Machine stays on. The single-host shape does not require local snapshots to be off. check reports snapshots=present, none or unknown: whether tmutil listlocalsnapshots lists a snapshot whose name starts with com.apple.TimeMachine. on the volume of the store directory, the directory that holds the Mirror. check does not see other local snapshots, for example one that macOS makes for an update or one that another backup tool makes. The key, the salt and the Tombstone store may sit on another volume, which check does not probe. The value does not show which files a snapshot holds or how old it is. The value does not fail check.

The proposed text matches README line 14, SECURITY and install §5 in this PR (docs/install-single-host.md:164). ADR 0011 keeps similar broad wording. That is noted for mind-spec and is not drafted here.

Mutant to failing test

Each mutant was applied alone, the targeted tests were run, and the mutant was reverted. Every mutant is killed.

Mutant Killed by
M1 last non-excluded tm test_report_names_the_first_non_excluded_value_for_each_field
M2 sp = probes[0][1] test_report_names_the_first_non_excluded_value_for_each_field
M2b tm = probes[0][0] test_report_names_the_first_non_excluded_value_for_each_field
M3 prefix com.apple. test_local_snapshots_parses_only_successful_known_output
M3b any non-empty line is present test_local_snapshots_parses_only_successful_known_output
M4 _contain_faults after start() test_sync_and_forget_contain_a_warning_raised_during_start
M5 drop the SystemExit guard test_a_systemexit_in_a_thread_is_ignored_like_the_default_hook
M6 drop ValueError from the outer except test_a_nul_in_a_root_or_a_link_fails_closed_without_a_traceback
M7, M7b, M7c (walk cap) test_the_tree_walk_fails_closed_past_its_cap
M8, M8b (unresolved-path check) test_a_root_reached_through_a_link_in_a_writable_directory_fails
M9 restore .resolve() in cli._check test_check_passes_the_store_directory_to_the_host_probes, test_check_fails_when_the_environment_is_reached_through_a_writable_directory
M10a drop [ "$top" = "$checkout" ] test_the_removal_guard_keeps_a_checkout_it_cannot_prove[nested-checkout], test_the_removal_deletes_the_checkout_only_after_it_proves_the_checkout
M10b drop --ignored the exact-line pin, plus the guard test [env, notes, mypy-cache]
M10c drop [ -z "$stashes" ] the exact-line pin, plus the guard test [stash]
M10d drop [ -z "$extra" ] the exact-line pin, plus the guard test [env, notes, mypy-cache, untracked, modified]
M10e s=$(…); instead of && the exact-line pin, plus the guard test [corrupt-index, untagged]
M11 restore listlocalsnapshots / test_the_removal_names_local_snapshots_and_the_logs_limit
M12 drop the old secrets path test_the_removal_names_local_snapshots_and_the_logs_limit
M13 drop the §2 .lock paragraph test_the_install_document_states_why_the_venv_chmod_is_required
RW1-M1 drop --untracked-files=normal test_the_removal_guard_keeps_a_checkout_it_cannot_prove[untracked-hidden], test_the_removal_deletes_the_checkout_only_after_it_proves_the_checkout
RW1-M2 /bin/df -P back to df -P test_the_removal_names_local_snapshots_and_the_logs_limit

Notes on the table:

  • Rows M1 to M13 were measured at 53b5d37. The code and those tests are unchanged at 464e1d3.
  • M10a and the RW1 rows were measured at 464e1d3.

Gate evidence at 464e1d3

  • make check (full): ruff check is clean, ruff format reports 64 files formatted, and mypy reports no issues in 46 files. pytest gave 1570 passed, 58 skipped. Nothing was deselected, there was no collection error and no "command not found".
  • The integrate raw log (dev/stables#2237 check) has no "command not found" and no collection error. The touched suites gave 713 passed.
  • CI ci/woodpecker/pr/validation is green.
  • On macOS, test_the_removal_guard_keeps_a_checkout_it_cannot_prove passed for every case, with no skips, including stash, untracked-hidden and nested-checkout.
  • The guard line was run literally on this host. A clean tagged tree is removed. An untracked file is kept under both a global and a repo-level status.showUntrackedFiles=no. The old guard deleted that case.
  • On this host, df -P on PATH (/etc/profiles/per-user/piers/bin/df) reports /, and /bin/df -P reports /System/Volumes/Data.

Decisions (operator rulings at the #72 gate, 2026-11-16)

  • The removal guard also allows __pycache__/ directories under src/ and nothing else.
  • Local branches that were never pushed are not checked; §9 states this limit.
  • Adjacent findings are filed as #100.
  • The ADR 0007 draft above goes to mind-spec before merge.

Operator checks after merge

  • On the Mac, confirm that /bin/df -P "$store_dir" prints the mount that check probes, and that tmutil listlocalsnapshots "$store_volume" exits 0.
  • Run check against a fresh uv sync --locked --no-dev --link-mode=clone checkout, after the §2 chmod. Expect environment=owner-only code=owner-only.

Closes #72
Co-Authored-By: gpt-6.1-sol noreply@openai.com

Preserve unresolved environment and code paths for ownership checks, cap linked-tree walks at 100,000 entries, fail closed on ValueError, and ignore SystemExit in sync and forget thread hooks. Explain the retained overlapping safety checks. Strengthen the documented removal guard, remove legacy secrets, use the store volume for snapshot commands, and narrow snapshot-reporting claims. Document uv lock permissions and the one-time nature of check. This PR replaces PR #101 (`53b5d37`, closed without merge). Rework round 1 is the first rework of this SVD run. It fixes two §9 Removal blockers that a fresh security review reproduced: - The guard now runs `git status --porcelain --ignored --untracked-files=normal`. Without it, `status.showUntrackedFiles=no` in the repository, global or system config hid untracked files, and the guard deleted them. - `store_volume` now comes from `/bin/df -P`. On the operator's Mac, `df` on PATH is GNU coreutils. It reports `/` for a path on the Data volume, while `check` probes `/System/Volumes/Data`. ## ADR 0007 Amendment 1 item 4: DRAFT for the operator and mind-spec **This is a draft only. This PR does not edit `docs/adr/*`.** The ADR text changes only after mind-spec ratifies the wording at an exact head (operator ruling at the #72 gate, 2026-11-16). Current text: > 4. **Time Machine stays on.** The single-host shape does not require local snapshots to be off. `check` reports `snapshots=present`, `none` or `unknown`: whether local Time Machine snapshots exist on the store's volume. The value does not show which files a snapshot holds or how old it is, and `check` does not inspect other volumes. The value does not fail `check`. Proposed text: > 4. **Time Machine stays on.** The single-host shape does not require local snapshots to be off. `check` reports `snapshots=present`, `none` or `unknown`: whether `tmutil listlocalsnapshots` lists a snapshot whose name starts with `com.apple.TimeMachine.` on the volume of the store directory, the directory that holds the Mirror. `check` does not see other local snapshots, for example one that macOS makes for an update or one that another backup tool makes. The key, the salt and the Tombstone store may sit on another volume, which `check` does not probe. The value does not show which files a snapshot holds or how old it is. The value does not fail `check`. The proposed text matches README line 14, SECURITY and install §5 in this PR (`docs/install-single-host.md:164`). ADR 0011 keeps similar broad wording. That is noted for mind-spec and is not drafted here. ## Mutant to failing test Each mutant was applied alone, the targeted tests were run, and the mutant was reverted. Every mutant is killed. | Mutant | Killed by | | --- | --- | | M1 last non-excluded `tm` | `test_report_names_the_first_non_excluded_value_for_each_field` | | M2 `sp = probes[0][1]` | `test_report_names_the_first_non_excluded_value_for_each_field` | | M2b `tm = probes[0][0]` | `test_report_names_the_first_non_excluded_value_for_each_field` | | M3 prefix `com.apple.` | `test_local_snapshots_parses_only_successful_known_output` | | M3b any non-empty line is present | `test_local_snapshots_parses_only_successful_known_output` | | M4 `_contain_faults` after `start()` | `test_sync_and_forget_contain_a_warning_raised_during_start` | | M5 drop the `SystemExit` guard | `test_a_systemexit_in_a_thread_is_ignored_like_the_default_hook` | | M6 drop `ValueError` from the outer except | `test_a_nul_in_a_root_or_a_link_fails_closed_without_a_traceback` | | M7, M7b, M7c (walk cap) | `test_the_tree_walk_fails_closed_past_its_cap` | | M8, M8b (unresolved-path check) | `test_a_root_reached_through_a_link_in_a_writable_directory_fails` | | M9 restore `.resolve()` in `cli._check` | `test_check_passes_the_store_directory_to_the_host_probes`, `test_check_fails_when_the_environment_is_reached_through_a_writable_directory` | | M10a drop `[ "$top" = "$checkout" ]` | `test_the_removal_guard_keeps_a_checkout_it_cannot_prove[nested-checkout]`, `test_the_removal_deletes_the_checkout_only_after_it_proves_the_checkout` | | M10b drop `--ignored` | the exact-line pin, plus the guard test [env, notes, mypy-cache] | | M10c drop `[ -z "$stashes" ]` | the exact-line pin, plus the guard test [stash] | | M10d drop `[ -z "$extra" ]` | the exact-line pin, plus the guard test [env, notes, mypy-cache, untracked, modified] | | M10e `s=$(…);` instead of `&&` | the exact-line pin, plus the guard test [corrupt-index, untagged] | | M11 restore `listlocalsnapshots /` | `test_the_removal_names_local_snapshots_and_the_logs_limit` | | M12 drop the old `secrets` path | `test_the_removal_names_local_snapshots_and_the_logs_limit` | | M13 drop the §2 `.lock` paragraph | `test_the_install_document_states_why_the_venv_chmod_is_required` | | RW1-M1 drop `--untracked-files=normal` | `test_the_removal_guard_keeps_a_checkout_it_cannot_prove[untracked-hidden]`, `test_the_removal_deletes_the_checkout_only_after_it_proves_the_checkout` | | RW1-M2 `/bin/df -P` back to `df -P` | `test_the_removal_names_local_snapshots_and_the_logs_limit` | Notes on the table: - Rows M1 to M13 were measured at `53b5d37`. The code and those tests are unchanged at `464e1d3`. - M10a and the RW1 rows were measured at `464e1d3`. ## Gate evidence at `464e1d3` - `make check` (full): ruff check is clean, ruff format reports 64 files formatted, and mypy reports no issues in 46 files. pytest gave **1570 passed, 58 skipped**. Nothing was deselected, there was no collection error and no "command not found". - The integrate raw log (dev/stables#2237 check) has no "command not found" and no collection error. The touched suites gave 713 passed. - CI `ci/woodpecker/pr/validation` is green. - On macOS, `test_the_removal_guard_keeps_a_checkout_it_cannot_prove` passed for every case, with no skips, including stash, `untracked-hidden` and `nested-checkout`. - The guard line was run literally on this host. A clean tagged tree is removed. An untracked file is kept under both a global and a repo-level `status.showUntrackedFiles=no`. The old guard deleted that case. - On this host, `df -P` on PATH (`/etc/profiles/per-user/piers/bin/df`) reports `/`, and `/bin/df -P` reports `/System/Volumes/Data`. ## Decisions (operator rulings at the #72 gate, 2026-11-16) - The removal guard also allows `__pycache__/` directories under `src/` and nothing else. - Local branches that were never pushed are not checked; §9 states this limit. - Adjacent findings are filed as #100. - The ADR 0007 draft above goes to mind-spec before merge. ## Operator checks after merge - On the Mac, confirm that `/bin/df -P "$store_dir"` prints the mount that `check` probes, and that `tmutil listlocalsnapshots "$store_volume"` exits 0. - Run `check` against a fresh `uv sync --locked --no-dev --link-mode=clone` checkout, after the §2 chmod. Expect `environment=owner-only code=owner-only`. Closes #72 Co-Authored-By: gpt-6.1-sol <noreply@openai.com>
Harden single-host checks and removal guidance
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
464e1d3fdc
Preserve unresolved environment and code paths, cap tree walks across linked targets, fail closed on invalid paths, and silently ignore thread SystemExit during sync and forget.

Strengthen checkout removal guards, target snapshots on the store volume, remove legacy secrets, and clarify snapshot coverage, uv lock permissions and probe timing. Add regression tests for each approved case.

Validation: make check passed with 1568 passed and 60 skipped, versus 1533 passed and 60 skipped on the pristine base. All 24 required mutants were detected and reverted. Native source distribution and wheel builds passed.

Closes #72
Co-Authored-By: gpt-6.1-sol <noreply@openai.com>
svc-svd-writer deleted branch feat/svd-dev-messages-mind-mcp-72-single-host-install-follow-bca03f9a 2026-11-16 13:35:17 +00:00

Merge record.

  • mind-spec ratification: "RATIFIED: ADR 0007 Amendment 1 item 4 draft exactly as PR #102 at 464e1d3fdc9587bd14235ad574460a3bff3eec9e (base c6c9e1f)." The record is /private/tmp/dd469-messages72-adr0007-ratification-20261117.md on voyager. This satisfies the pre-merge referral (operator ruling at the #72 gate). This PR made no ADR edit. Applying the ratified wording to docs/adr/0007-store-encryption-and-backup.md is separate work.
  • Pre-merge checks: the live head was 464e1d3, CI ci/woodpecker/pr/validation reported success, git diff c6c9e1f 464e1d3 -- docs/adr was empty, and ship accepted the class. The merge is squashed as acc6c05, and the rewind check passed.
  • Evidence custody:
    • The final make check at 464e1d3 (1570 passed, 58 skipped) is a saved log: gate-make-check-464e1d3.log in run 20261116T130328Z-bca03f9a, sha256 prefix ff613b9945e4ea37.
    • The pristine base at c6c9e1f (1535 passed, 58 skipped) is a count reported by the independent reviewer, not a saved log.
    • The PR body's 1566/60 and 1533/60 are counts from the dispatch sandbox, which skips 2 host-only tests. All three sources show the same +33 delta, and the 2 rework cases make +35 in total.
  • Follow-ups: #100 (adjacent findings), #103 (removal-guard limits), and the ADR 0011 wording follow-up.
**Merge record.** - **mind-spec ratification:** "RATIFIED: ADR 0007 Amendment 1 item 4 draft exactly as PR #102 at `464e1d3fdc9587bd14235ad574460a3bff3eec9e` (base `c6c9e1f`)." The record is `/private/tmp/dd469-messages72-adr0007-ratification-20261117.md` on voyager. This satisfies the pre-merge referral (operator ruling at the #72 gate). This PR made no ADR edit. Applying the ratified wording to `docs/adr/0007-store-encryption-and-backup.md` is separate work. - **Pre-merge checks:** the live head was `464e1d3`, CI `ci/woodpecker/pr/validation` reported success, `git diff c6c9e1f 464e1d3 -- docs/adr` was empty, and ship accepted the class. The merge is squashed as `acc6c05`, and the rewind check passed. - **Evidence custody:** - The final `make check` at `464e1d3` (1570 passed, 58 skipped) is a saved log: `gate-make-check-464e1d3.log` in run `20261116T130328Z-bca03f9a`, sha256 prefix `ff613b9945e4ea37`. - The pristine base at `c6c9e1f` (1535 passed, 58 skipped) is a count reported by the independent reviewer, not a saved log. - The PR body's 1566/60 and 1533/60 are counts from the dispatch sandbox, which skips 2 host-only tests. All three sources show the same +33 delta, and the 2 rework cases make +35 in total. - **Follow-ups:** #100 (adjacent findings), #103 (removal-guard limits), and the ADR 0011 wording follow-up.
Sign in to join this conversation.
No description provided.