Skip to content

tm-exclusions v1.4.2

Latest

Choose a tag to compare

@my-housekeeper my-housekeeper released this 05 Dec 22:27
· 1 commit to master since this release
v1.4.2
eca14b4

Documentation

  • Animated terminal demo on the README and the website: a 25-second recording of --version, a --dry-run (16 paths, 4.4G that would be excluded) and an apply, plus a tmutil isexcluded check. The GIF lives in docs/assets/demo.gif and is copied into _site/assets/ by scripts/build-site.sh. Regenerated with docs/demo/generate.sh (sources and notes in docs/demo/).
  • The website has install commands and an English version (#179): a Homebrew install and --dry-run block opens the page. The French (/) and English (/en/) pages are generated by scripts/build-site.sh from one template (site/src/index.template.html) and one text file per language (site/i18n/<code>.lang); the build fails on a missing, unknown or unused key. make check-site is part of make check, and tests/test_site_build.sh part of make test. Shared links to the site show a preview image, docs/assets/social-preview.png (#185).
  • Maintainer and security documents (#198): MAINTAINERS.md lists who can access sensitive project resources and their roles, docs/THREAT_MODEL.md describes the threat model and docs/DEPENDENCIES.md the dependency policy. SECURITY.md links to them, and .vex/tm-exclusions.openvex.json records, in OpenVEX format, known findings that do not affect the released CLI.

Changes

  • The report inventory is opt-in (#152): the === Inventory (informational) === section (installed applications with sizes, Homebrew casks and formulae, PATH tools; about 270 lines, a du per .app) is no longer collected or printed by default. Add --inventory, or setting|inventory|true in a config file, to get it as before (the flag always enables it; TM_EXCLUSIONS_SKIP_INVENTORY=1 still wins). The saved report keeps the section heading with one line saying how to enable it, interactive runs print no inventory block, and no du per application, brew list or PATH scan runs, so default runs are faster (brew --cache still runs on every run for cache discovery, outside the inventory). setting|inventory accepts true/1/yes and false/0/no (an invalid value warns and is ignored; scripts/check-conf.sh validates it too). Option A of the issue; the Opportunities idea (option B) is not part of this change. English and French --help list the new flag. Covered by tests/test_apps_inventory.sh, tests/test_path_inventory.sh and tests/smoke.bats-like.sh.
  • The report splits disk usage by exclusion status: Disk usage total: 174.8G summed the size of every touched path, including those whose exclusion was blocked or failed (so not excluded), next to a Space excluded: 32.5M that counted only the new additions. It is replaced by three lines: Excluded on disk (total): (paths really excluded: already excluded plus added by the run; only the already excluded with --dry-run and --report-only), New this run: (the former Space excluded, same value; still labelled simulated or needing exclusion in --dry-run and --report-only) and Under blocked or failed rules (upper bound): (paths under a blocked or failed rule, shown only when there is one; an upper bound because a blocked rule can cover children already excluded). The detailed "Disk usage" section is unchanged. --uninstall no longer prints a size total. English and French labels are aligned.
  • --tmux stacks the panes: the progress/status pane is now on top and the log pane below it, both at full terminal width (split-window -v), instead of side by side. Long paths in the progress line and in the trace lines are cut less.
  • Application bundle skips (#158). The bundle guard already covers Electron build output (since #143). The report lists each discovered bundle match, including nested matches reached with a keep rule. Smoke tests cover nested matches and a lowercase contents directory with Info.plist.
  • Test suites run under the pinned /bin/bash even with Homebrew bash first on PATH (Bash 3.2 on macOS; the system bash on Linux, so Linux CI does not check 3.2): the Makefile exports a bash symlink to it first in PATH for test runs, so every bash the suites or their children start — env, shebangs, hook internals, tmux panes — uses it. The shim dir is per-user and mode 700, and setup refuses a planted symlink, foreign owner or wrong mode. Each suite prints its own shell version and the shim target on stderr.

Fixes

  • --version and the report header no longer rewrite .git/index (#171): git describe --dirty refreshes the index and writes it back, even with GIT_OPTIONAL_LOCKS=0, so a read-only command modified the source checkout (and a sudo run could leave .git/index owned by root). The build info now comes from git describe without --dirty plus git status --porcelain --untracked-files=no, both run with --no-optional-locks, so .git/index is never rewritten (git's own optional features, split index and fsmonitor, may still touch other files under .git, such as .git/sharedindex.* or the .git/fsmonitor--daemon cookies). The dirty flag keeps its meaning (tracked files changed or staged; untracked files ignored), and a file that was only touched is not reported as dirty. Two read-only git calls instead of one; if status fails (corrupt or unreadable index) the plain version is shown, as when describe --dirty failed. Covered by tests/test_version_display.sh (inode and checksum of .git/index unchanged after --version and a report run).

  • --trace completes with stderr closed on macOS Bash 3.2 (#160). The scan writes its report and keeps its normal exit status.

  • Report files are private (#149): the saved report (default path, setting|report_path or TM_EXCLUSIONS_REPORT) and the Desktop copy were written with the current umask (usually 0644), so other local accounts could read the list of installed apps, PATH directories and project paths. They are now created with mode 0600, and an existing file is set to 0600 before it is rewritten, including a read-only (0444) file the user owns, which was a write failure before. Covered in tests/smoke.bats-like.sh.

  • Dry runs predict privilege blocks (#146): planned exclusions and removals that need unavailable sudo report BLOCKED. When sudo is usable, the verbose terminal output and report mark the planned change with (sudo). Dry runs never prompt for sudo.

  • Interactive runs prompt for sudo instead of reporting BLOCKED (#163): the terminal check ran inside the processing loops, whose stdin is a heredoc, so it was always false and a privileged path was blocked even in a terminal. Interactivity is now decided once at startup. With a terminal and no sudo cache, the first privileged change prompts once and the keepalive covers the rest; a failed prompt blocks the remaining privileged paths without asking again. Non-interactive runs (cron, launchd, CI) keep BLOCKED. The dry run predicts the same route, marks it (sudo), and still never prompts.

  • Partially readable paths contribute to the report counters (#147). The counters reuse the partial sizes shown in the Disk usage section and display a lower bound.

  • The per-path size column truncates partial sizes too (#164): a partially readable 2047 KiB path showed 2.0M in the verbose per-path column but 1.9M in the Disk usage section and the counters. The column now uses the same lower bound. Complete sizes keep their rounding.

  • Pattern matches inside application bundles are skipped, not excluded: a node_modules inside Some.app/Contents/Resources is part of the installed app and npm install cannot rebuild it. tmutil addexclusion also fails on some of these paths, which gave a persistent ERROR on every run. Apply, --dry-run and --report-only now report such a match as SKIP (inside an application bundle) in the report and the trace, count it as checked and skipped, and make no tmutil call for it. Only a real bundle counts: the path must be under <name>.app/Contents/ and <name>.app/Contents/Info.plist must exist, and both .app and Contents are matched without regard to case. A repository or folder merely named *.app is still processed. --uninstall is unchanged, so it still removes exclusions added by earlier versions. Covered in tests/smoke.bats-like.sh.

  • The ERROR line shows why tmutil addexclusion failed: the report, the log and the trace now append the one-line tmutil error text, for example Error excluding: /path (reason). Control characters (CR, LF, ESC, tab) become spaces and the text is cut at 200 characters.

  • Privilege blocks have their own counter. Blocked (privileges) counts separately from Errors. A run with a privilege block still exits with status 1.

  • Prune zones are reported as PRUNE, under their own category: the report showed them as SKIP <path> (Pruning (skipping scan of):), filed under "Uncategorized" and not counted anywhere distinct. They now read PRUNE <path> (scan skipped, not an exclusion), sit under a dedicated "Prune zones" category with the covering rule's provenance, and are counted by a new Prune zones: line in the report header and the console. Skipped: is unchanged. Tests that pinned the old SKIP … Pruning format now assert the new PRUNE contract. With TM_EXCLUSIONS_NO_SCAN_PRUNE=1, a match below a prune zone is counted in “Summary by rule” under the covering prune rule instead of the pattern rule.

  • --trace no longer lists the inside of pruned matches: the WALK pass replayed the prune zones and static exclusions but not the name-based pruning (layer 3). It listed every package under each node_modules (and other unconditional matches) although the work scan never descends there. The walk now lists the match once, then prunes it, like the work scan. With TM_EXCLUSIONS_NO_SCAN_PRUNE=1, or keep rules, the walk still descends, as the work scan does.

  • --uninstall verifies privileged removals (#158). It checks an excluded symlink target against its own parent and removes fixed-path exclusions from the target. An unreadable parent on the writable route does not trigger the sudo fallback. After a successful privileged removal, an unreadable status reports ERROR. An excluded child can report REMOVE when its parent is confirmed excluded and its sticky attribute is absent. A writable child processed before its excluded parent can still need two runs to clear a fixed-path exclusion. When the parent is excluded outside the tool's rules, it stays excluded, so the sudo fallback is skipped, the child's fixed-path exclusion is never removed and every run reports REMOVE.

  • Documented an --uninstall verification limit (#174). If an item remains excluded through its parent and xattr cannot read it, a run reports ERROR even after a successful privileged fixed-path removal, and repeats it whenever a later run again reaches that check (a run without usable sudo reports BLOCKED instead).

  • Every --trace token has its own colour in the --tmux log pane: TMUTIL, SKIP, KEEP, PRUNE and WALK were only dimmed and looked uncoloured, and several tokens shared a colour. Each of the 16 tokens now has a distinct colour from the 256-colour palette (for example green ADD, orange REMOVE, bold red ERROR, blue TMUTIL). The colours are mid-luminance, with at least 3:1 contrast on both a dark and a light pane. Debug files and FIFOs stay plain. Tests check that every token the script emits gets a distinct, non-dim colour that meets that contrast.

  • The --tmux log pane now looks like the status pane: the log pane printed bare log lines, with no spacing and no colours, so categories and actions were hard to tell apart. In the tmux child only, the debug log stream now receives the same indented, coloured lines as the terminal (green ✓ for exclusions, cyan for dry-run, heading colour for ━━ section titles and ══ Category ══, yellow ⚠ for warnings and errors, a blank line between entries). The --trace vocabulary stays: in the pane only, each token takes its own colour (see the entry above) and the timestamps are dimmed. Debug FIFOs and files used outside --tmux stay plain. Covered in tests/test_tmux_ui.sh.

  • The progress line keeps its information in narrow panes: in --tmux, the left pane measured its width once, while the detached session still had tmux's 80x24 default, then kept that stale width after the client attached. The status line (for example Me…uv while measuring a folder) was cut far below the real pane width. The session is now created at the terminal size, the width is read again at most once per second, and the activity line keeps the stage name whole and shortens the path from its start (Measuring directory …/folder/name/uv). After a folder is measured, its path stays on screen instead of an empty line.

Performance

  • Faster prune reporting during full traversal (#158). Each prune decision looks up its source in the explicit prune rules collected at config load. With TM_EXCLUSIONS_NO_SCAN_PRUNE=1, a synthetic tree with 400 matches under one default prune zone took 6.4 s, down from 7.3 s (median of three runs with Bash 3.2). All 400 entries kept the same rule context.
  • Time Machine statuses are read in parallel: a run checks about a thousand paths, and one tmutil isexcluded costs an XPC round trip of 0.07-0.15 s (more while a backup runs), so a full run spent minutes between paths. The candidate lists (static rules, discovered matches, extra paths) are now read once by TM_EXCLUSIONS_STATUS_JOBS concurrent tmutil processes (default 4) before the decision loop, which finds each answer in that table; writes stay one at a time, in order. Measured on a developer Mac with a backup running: status checks went from ~180 s to ~25 s. TM_EXCLUSIONS_STATUS_JOBS=1 restores the previous behaviour. The time is not in du: on the same machine TM_EXCLUSIONS_SKIP_DU=1 saves ~70 s but leaves the per-path round trips. Covered by tests/test_status_prefetch.sh (one check per path, real concurrency, sequential mode, unreadable status still an error).

Features

  • --version and the report header show the build of a git checkout (#148): when the script (symlinks followed) runs from a checkout or worktree of this repository (.git, locales/en.sh and config/default.conf next to it), the displayed version gains the commits since the v<VERSION> tag, the short commit and a dirty flag, for example tm-exclusions 1.4.1+5 (9171049, dirty). When that tag is not reachable (shallow clone, no tags), the commit is marked untagged: tm-exclusions 1.4.1 (9171049, untagged). Two read-only git calls, git describe and git status (see the .git/index fix for #171 above), only for --version and the report header. A make install or Homebrew copy, a copy in an unrelated repository, a PATH without git or a broken .git (even one inside another repository) prints the plain version as before, with no stderr output. VERSION and make version stay X.Y.Z. Covered by tests/test_version_display.sh.

  • User-writable paths outside $HOME are excluded without sudo: every path outside $HOME was treated as a system path and needed sudo tmutil addexclusion -p, so a non-interactive run without a sudo cache reported it as privilege-blocked and it stayed in the backup. On Apple Silicon this left /opt/homebrew/Cellar and /opt/homebrew/Caskroom (owned by the user, several GB) backed up. The route now follows the write permission (path_needs_privilege()): a path the user can write takes plain tmutil addexclusion (extended attribute, no sudo, no -p), wherever it is. Paths the user cannot write (/private/var/folders, /Library/Developer/CoreSimulator) keep the sudo … -p route and the privilege-blocked report; so does root, for which -w tells nothing. If the attribute cannot be set on a writable path outside $HOME (ACL, SIP), the run falls back to sudo … -p, privilege-blocked without sudo. --uninstall removes the attribute without sudo and, when the path is still excluded although its parent is not, falls back to sudo tmutil removeexclusion -p for a fixed-path exclusion left by an older version (privilege-blocked without sudo); a status inherited from an excluded parent never calls sudo. Rollback: revert the commit, then tmutil removeexclusion on the paths excluded this way. Covered by tests/smoke.bats-like.sh (attribute add/remove without sudo, legacy fixed-path removal, inherited status, refused attribute, read-only path still privileged); these cases cannot run as root and are then reported as a SKIP (root) line plus a Skipped blocks count in the suite summary (test_skip in tests/test_helpers.sh).

  • --tmux's log pane is now a real trace, and --trace makes it complete: the pane streamed the same log_info lines as the left pane, batched at the end of each stage, so a scan showed almost nothing while it ran. Every action now writes one line to the debug log as it happens — ADD, OK, SKIP, NEED, WOULD, REMOVE, KEEP, BLOCKED, ERROR, the SCAN start/end counters, MATCH, PRUNE and the exact TMUTIL invocation — in the saved report's untranslated vocabulary, with elapsed seconds. The new --trace flag adds a WALK line per directory the scan visits, streamed from a second pass that reuses the path-based prune layers (prune zones, known static exclusions, photo libraries and newline paths); it also works without tmux (debug FIFO, else stderr) and costs one extra traversal of $HOME. The scan result, the exclusions and the exit status are unchanged. Covered by the new tests/test_trace.sh, including a slow-tmutil scenario that proves the log grows mid-run.

  • A closed stderr no longer aborts the run: log_error printed to fd 2 without guarding the redirection, so with set -e a closed stderr (or any write failure) ended the process with status 1 and lost the report. Both branches now ignore the write error. Reproduced on Linux with 2>&- under --trace, covered by tests/test_trace.sh.

CI and automation

  • actionlint, markdownlint-cli2 and lychee now run in CI (make lint-workflows, make lint-docs, make check-links). actionlint and markdownlint live in .github/workflows/lint.yml and run on every pull request; the link check lives in .github/workflows/links.yml, runs when documentation changes, and once a week on master. They are not part of make check.
  • Dependency review blocks a pull request (#199): .github/workflows/security.yml no longer uses continue-on-error and fails on a vulnerability of moderate severity or higher. Manual runs of release.yml and auto-patch.yml validate their inputs (a vX.Y.Z tag, a positive integer threshold, a boolean dry_run) before using them. The Homebrew tap is updated only with the Housekeeper App token; the HOMEBREW_TOKEN / RELEASE_TOKEN fallback is removed.
  • Hardened workflows: job tokens get minimal permissions and CI dependencies are pinned (#196); workflows run on GitHub-hosted runners (#194); triage runs on pull_request instead of pull_request_target (#193).
  • OpenSSF Scorecard workflow and README badge (#191).
  • ShellCheck 0.10 and 0.11 agree on indirectly called helpers (#189).