Artifact d152cd8633831954a86e8bb1148b5c3ffe08818ea601d2b57ec4e61ad534551d:
- File
tools/suites.sh
— 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: 2184) [annotate] [blame] [check-ins using]
#!/bin/sh # Run the unit program and the five shell suites, side by side up to JOBS at a # time (JOBS=1: one after another, the old behaviour), each to its own log in # BUILD_DIR/logs. Then print the logs in a fixed order (unit, run.sh, store.sh, # place.sh, project.sh, usage.sh) and exit non-zero if any suite failed or printed no # summary line. # usage: suites.sh BUILD_DIR [SUITE...] (BUILD_DIR holds suit and unit) # SUITE is one of unit run store place project usage; with none, all six. set -u if [ "${1:-}" = --one ]; then # the worker: suites.sh --one BUILD_DIR NAME dir=$2 name=$3 case $dir in /*) ;; *) dir=$PWD/$dir ;; esac start=$(date +%s) case $name in unit) "$dir/unit" ;; *) SUIT=$dir/suit sh "test/$name.sh" ;; esac >"$dir/logs/$name.log" 2>&1 echo $? >"$dir/logs/$name.rc" echo $(($(date +%s) - start)) >"$dir/logs/$name.sec" exit 0 fi dir=${1:?usage: suites.sh BUILD_DIR [SUITE...]} shift case $dir in /*) ;; *) dir=$PWD/$dir ;; esac jobs=${JOBS:-1} want=${*:-unit run store place project usage} rm -rf "$dir/logs" mkdir -p "$dir/logs" build/tmp trap 'exit 130' INT TERM # longest first, so the slowest suite starts at once order= for n in store place project usage run unit; do case " $want " in *" $n "*) order="$order $n" ;; esac done if [ "$jobs" -le 1 ]; then for n in $order; do sh "$0" --one "$dir" "$n"; done else # shellcheck disable=SC2086 printf '%s\n' $order | xargs -P "$jobs" -n 1 sh "$0" --one "$dir" fi status=0 times= for n in unit run store place project usage; do case " $want " in *" $n "*) ;; *) continue ;; esac cat "$dir/logs/$n.log" rc=$(cat "$dir/logs/$n.rc" 2>/dev/null || echo missing) times="$times $n $(cat "$dir/logs/$n.sec" 2>/dev/null || echo '?')s" if [ "$n" = unit ]; then pat='^unit: [0-9]* checks, [0-9]* failed$' else pat="^$n.sh: [0-9]* cases, [0-9]* failed\$"; fi if [ "$rc" != 0 ]; then echo "suites: $n exited $rc" >&2; status=1 elif ! grep -q "$pat" "$dir/logs/$n.log"; then echo "suites: $n printed no summary line" >&2; status=1 fi done echo "suites (JOBS=$jobs, seconds):$times" exit $status