Artifact d0b1e8faee49e0deb50a7c38a2fc00382e8687ef0850a27700c5859010a32ba1:
- File
test/budget.sh
— part of check-in
[cb7d42f351]
at
2026-11-17 10:01:38
on branch trunk
— The no-change run watches what apply acts on, not every file in the stores
The stamp listed every file and folder in every store, and the compare costs one stat per path, so the per-minute run grew with the wardrobes. On a fixture of two wardrobes with 300 skills of five files, 40 agents and 20 commands it watched 1890 paths and cost 7.1 to 7.6 ms quiet and 12.6 to 13.4 ms loaded, against a budget of 1 ms.
Apply links skill folders, agent and command files, and slot and file sources, and never reads them. From a store it reads the content of only the wardrobe's suit.conf and the sources of a joined instructions file, and nothing is placed by copy. An edit inside a linked skill, or to an agent's or command's content, is already seen by the harness through the link; apply would place the same links. So those are no longer watched.
The stamp now watches the store folder and each folder in it; each wardrobe's folder, suit.conf, and skills, agents and commands folders (whose own entry changes when something in them is added, removed or renamed); entries in those folders that are links, whose target can come or go without the folder changing; every instructions, file and slot path of every outfit, whether or not it exists; need prompts; and the ledger, machine name, roots and project lists as before. docs/decisions.md lists every input apply reads and why each is or is not watched, and replaces the 12 Nov sentence that made an edit anywhere in a store a reason to apply.
On the same fixture it watches 24 paths: 0.26 to 0.28 ms quiet, 0.48 to 0.50 ms loaded. The count no longer depends on files inside skills. Over 128 paths apply stops with a clear error and keeps the old stamp.
The stamp starts with a format line, suit stamp 2. A stamp from before makes the compare report it changed, and the apply that follows rewrites it. suit and suit-run must be updated together: an older suit-run calls the new stamp bad.
Known: on Linux a change within one clock tick of the stamp's own stat can be missed until the next change, as before.
Ten placement cases and five shell lines changed expectation: an edit inside a store no longer causes an apply, a store with many files or deep folders no longer exceeds a limit, and the stamp has one more line. Each case is kept.
2993 unit checks, 625 shell cases (was 620), 1153 store cases, 985 placement cases (was 846), 378 project cases, 236 usage cases and 288 curate cases, under clang, under gcc 16, with no user name set, and under a strict umask, in one run of make gate (40 minutes). 100% coverage in all 31 source files. (user: dmestas, size: 5039) [annotate] [blame] [check-ins using]
#!/bin/sh # The speed test: suit-run, the program a timer starts every minute, may cost at # most 1 ms and 1 MiB more than an empty program built the same way (build/empty, # next to the binary). The hook dispatcher on an event with no slot # (`suit-run hook NOSUCHEVENT`) has the same 1 ms limit. The bench runs once on a quiet machine and again under # CPU load from loadgen, whose workers carry their own deadline. # # Each of the two measurements is taken three times, all three are printed, and # it passes if the best of the three is within budget. A machine kept busy by # other work (a load average above about 100) adds noise to a 1 ms difference # that the test cannot tell from suit's own cost; the budget is not loosened. # SUIT names the binary (default build/suit); suit-run is beside it. SUIT=${SUIT:-build/suit} case $SUIT in /*) ;; *) SUIT=$PWD/$SUIT ;; esac LOADGEN=${LOADGEN:-$HOME/.claude/bin/loadgen} RUNS=3 ROUNDS=600 LOAD_WORKERS=8 # Three loaded runs of about 20 seconds each, with room to spare. LOAD_SECONDS=100 mkdir -p build/tmp T=$(mktemp -d "$PWD/build/tmp/budget.XXXXXX") || exit 1 trap 'rm -rf "$T"' EXIT INT TERM # The stamp `suit apply` writes over two wardrobes of a real size: 300 skills of # 5 files each (one with a subfolder), 40 agents, 20 commands, a joined # instructions file for each wardrobe's harness, slots and files, all placed by # a real apply into a scratch HOME on a machine named bench. export HOME="$T/hm" SUIT_HOME="$T/home" mkdir -p "$HOME" "$SUIT_HOME/store" # wardrobe W HARNESS: 150 skills, 20 agents, 10 commands, two instruction sources, a slot and a file wardrobe() { w=$SUIT_HOME/store/$1 mkdir -p "$w/skills" "$w/agents" "$w/commands" "$w/instructions" "$w/files" i=0 while [ $i -lt 150 ]; do s=$w/skills/$1-skill-$i mkdir "$s" for f in SKILL.md one.md two.md three.md four.md; do echo "$1 $i $f" > "$s/$f"; done i=$((i + 1)) done mkdir "$w/skills/$1-skill-0/sub" mv "$w/skills/$1-skill-0/four.md" "$w/skills/$1-skill-0/sub/four.md" i=0; while [ $i -lt 20 ]; do echo "agent $i" > "$w/agents/$1-agent-$i.md"; i=$((i + 1)); done i=0; while [ $i -lt 10 ]; do echo "command $i" > "$w/commands/$1-command-$i.md"; i=$((i + 1)); done echo "$1 base" > "$w/instructions/base.md" echo "$1 bench" > "$w/instructions/bench.md" printf '#!/bin/sh\n' > "$w/files/slot.sh"; chmod +x "$w/files/slot.sh" echo '{}' > "$w/files/extra.json" cat > "$w/suit.conf" <<CONF [harness $2] skills.user = ~/.$2/skills agents.user = ~/.$2/agents commands.user = ~/.$2/commands instructions.user = ~/.$2/INSTRUCTIONS.md [outfit $1-all] only = $2 skills = * agents = * commands = * instructions = instructions/base.md slot $1/status = files/slot.sh file ~/.$2/extra.json = files/extra.json [outfit $1-bench] only = $2 instructions = instructions/bench.md CONF } wardrobe mine claude wardrobe public pi printf '\n[wear user]\noutfits = mine-all public-all\n' >> "$SUIT_HOME/store/mine/suit.conf" printf '\n[wear user machine=bench]\noutfits = mine-bench public-bench\n' >> "$SUIT_HOME/store/public/suit.conf" "$SUIT" machine bench || { echo "budget: cannot name the scratch machine"; exit 1; } "$SUIT" apply >/dev/null || { echo "budget: apply of the two scratch wardrobes failed"; exit 1; } [ -f "$SUIT_HOME/joined/claude" ] && [ -f "$SUIT_HOME/joined/pi" ] || { echo "budget: the instructions were not joined"; exit 1; } # The stamp lists 6 paths of SUIT_HOME, 5 for each wardrobe (its folder, its # suit.conf and its skills, agents and commands folders) and each path the # configs name: 24 here, whatever the 1500 files in the skills hold. The old # stamp listed every file and folder of the stores, about 1900 here. WATCH_LIMIT=64 watched=$(grep -vc '^suit stamp ' "$SUIT_HOME/stamp") echo "budget: the stamp watches $watched paths (limit $WATCH_LIMIT)" "$SUIT" compare || { echo "budget: scratch stamp does not read back as unchanged"; exit 1; } # best_of LABEL: run the bench RUNS times, print every run, succeed if one passed. best_of() { ok=1 n=1 while [ $n -le $RUNS ]; do echo "-- $1, run $n of $RUNS" if "$SUIT" bench -n "$ROUNDS"; then ok=0; fi n=$((n + 1)) done return $ok } failed=0 [ "$watched" -lt "$WATCH_LIMIT" ] || { echo "budget: the stamp watches $watched paths, not fewer than $WATCH_LIMIT"; failed=1; } echo "== quiet (load average: $(uptime | sed 's/.*load averages*: //'))" best_of quiet || { echo "budget: no quiet run was within budget"; failed=1; } [ -x "$LOADGEN" ] || { echo "budget: $LOADGEN not found"; exit 1; } echo "== under load: loadgen $LOAD_SECONDS $LOAD_WORKERS" "$LOADGEN" "$LOAD_SECONDS" "$LOAD_WORKERS" & load=$! sleep 2 echo "load average: $(uptime | sed 's/.*load averages*: //')" best_of loaded || { echo "budget: no loaded run was within budget"; failed=1; } wait "$load" if [ "$failed" -eq 0 ]; then echo "budget: pass"; else echo "budget: FAIL"; fi [ "$failed" -eq 0 ]