Artifact 7aaff8621954673dffebc364c4adc2f0acb50478182acba264ec7b3a195437a7:
- File
docs/install.md
— part of check-in
[38c2e6220a]
at
2026-11-16 21:25:35
on branch trunk
— Suit counts how often each skill, agent and command is used
The counts come from the records a harness already keeps of its own work, read afterwards. What those records look like is data in the wardrobe's harness section: where the files are, where a record's time and folder are, and rules that say what an invocation looks like. No harness is named in suit's code. docs/harnesses.md has the rules for the first harness, checked against real records.
A streaming reader walks each JSON line against the rules in 64 KiB chunks, keeps at most the first 512 bytes of any string and stops at 64 levels, so a line of any length cannot grow its memory. It has its own fuzz target.
Suit keeps its own tally per machine under usage/ in its home folder, outside any wardrobe: one line per invocation with time, harness, kind, name, project and call id. A call copied into a resumed or forked record is counted once, by its id. The tally outlives the harness's own clean-up and drops what is older than 400 days.
suit usage scan reads what is new; a first scan reads files changed in the last 45 days and later scans read only new bytes. suit usage prints the table for a window, default 30 days, and --tsv gives the same rows for other tools. suit tend with no name runs the scan after tending; a failed scan is reported and changes nothing else. suit-run is untouched and the speed budget passes as before.
Measured: a generated tree of 200 files and 200 MiB scans in about half a second and a second scan opens no record file. On a real tree of 2547 files, read-only into a scratch home: 3756 invocations in 60 seconds, 10 MiB at peak.
A new suite, test/usage.sh, with 236 cases, is part of the gate.
2855 unit checks (was 1473), 620 shell cases, 1153 store cases, 846 placement cases, 378 project cases and 236 usage cases, under clang, under gcc 16, with no user name set, and under a strict umask, in one run of make gate (41 minutes). 100% coverage in all 28 source files. One existing unit line changed: a table of fault points gained entries. (user: dmestas, size: 5524) [annotate] [blame] [check-ins using]
Install
suit install makes suit run by itself. It sets up two timers, both owned by
suit and named so they are recognisably suit's:
| Timer | Every | Starts | Does |
|---|---|---|---|
| run | 60 seconds | suit-run |
The no-change compare. It replaces itself with suit run when something differs. |
| tend | 3600 seconds | suit tend |
Every wardrobe: lint, check in, sync; then the usage scan (usage.md). |
Two timers, not one, so the minute run stays inside its speed budget and each job can be seen and stopped by itself.
The files
On macOS they are two launchd user agents in $HOME/Library/LaunchAgents:
app.zeitforge.suit.run.plistapp.zeitforge.suit.tend.plist
Each holds Label, ProgramArguments (absolute paths), StartInterval, RunAtLoad
(false), ProcessType Background, LowPriorityIO, StandardErrorPath
($SUIT_HOME/log/run.err or tend.err) and, only when SUIT_HOME is set to
something other than $HOME/.suit, an EnvironmentVariables entry for SUIT_HOME.
On Linux they are systemd user units in $HOME/.config/systemd/user (or
$XDG_CONFIG_HOME/systemd/user when that is set):
suit-run.serviceandsuit-run.timer(OnBootSec and OnUnitActiveSec 60s, AccuracySec 1s)suit-tend.serviceandsuit-tend.timer(3600s, Persistent true)
The services are Type=oneshot; the timers are WantedBy=timers.target.
suit install --print shows the exact text of each file for this machine.
Paths are XML-escaped in a property list and quoted for systemd; a path with a
space works. A path with a newline or other control character, or one over
1024 bytes, is refused.
suit install
- Finds the absolute path of the running
suitand of thesuit-runbeside it. Refuses, saying which, whensuit-runis not there or either is not an existing executable file. - Makes the folder if needed (and, on macOS,
$SUIT_HOME/log, which launchd needs before it can open the error file), then writes each file whose text differs, atomically, mode 0644. - Asks the loader to load the timers: on macOS
launchctl bootstrap gui/UID PLIST(afterbootout gui/UID/LABELwhen an older file was there); on Linuxsystemctl --user daemon-reload, thensystemctl --user enable --now NAME.timer. The loader is run directly with an absolute path, never through a shell, and waited for.
It says one line per timer: installed, updated or already installed.
Run again with nothing changed it writes nothing, loads nothing and says
already installed. A file that differs from what suit would write (an old
version, a changed path) is rewritten and its timer loaded again.
When any file is written, both timers are loaded again, so an install that
stopped half way is finished by the next one. If the loader exits non-zero the
command exits 3, names the loader's exit status, leaves the files in place and
says so; load them by hand (below). It also leaves one item in the attention
file, timers load: written but not loaded (LOADER exit N), where LOADER is
launchctl or systemctl and N its exit status, or could not run. So
suit status --line says suit: 1 need you and suit status shows the item
under needs you:.
Running install again, with the files unchanged and the item there, does not say
already installed: it asks the loader to load again. If that works the item
goes (and the attention file with it, when it is empty) and each timer says
installed; if not, the item is updated and the command exits 3 again. A
successful install by any path, and suit uninstall, remove the item.
If a write fails, nothing is loaded and the command exits 1; a file already
written stays, and the next suit install finishes the job.
It never touches a file in those folders that is not one of its own names.
suit uninstall
Asks the loader to unload each timer, then removes exactly the files above and
says removed PATH for each. Folders are left. When no file is there it says
not installed and calls nothing. A loader that exits non-zero on unload is
reported but the files are still removed: a timer that was not loaded is
normal.
suit status --line
One short line for a status bar, exit 0, at most 60 characters:
suit: N need youwhen the attention file has N items (an item is a line that is not indented);suit: not installedwhen any timer file is absent;suit okotherwise.
Attention wins when both apply. It reads only the attention file and checks that the timer files exist; it opens no repository. If it cannot tell it exits 1 and says why on standard error.
Plain suit status ends its timers line the same way: timers: installed,
timers: not installed or timers: differ from this suit (run suit install).
Checking by hand
macOS:
launchctl print gui/$(id -u)/app.zeitforge.suit.run
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/app.zeitforge.suit.run.plist
launchctl bootout gui/$(id -u)/app.zeitforge.suit.run
Linux:
systemctl --user list-timers 'suit-*'
systemctl --user status suit-run.service
systemctl --user enable --now suit-run.timer
Tests
The tests set HOME and SUIT_HOME to a scratch folder and point suit at a fake
loader with SUIT_LOADER, and can choose which set of files is written with
SUIT_PLATFORM=linux|macos. Both variables exist only in the test builds (the
ones with fault injection); the release build has no code that reads them, which
test/release_clean.sh checks. No test runs launchctl or systemctl.