Artifact 587dc5c93a21304f1eac100cea8f5d6e9fce2a669f035a9fa77cae484218ccce:
- File
src/stamp.h
— 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: 1210) [annotate] [blame] [check-ins using]
#ifndef SUIT_STAMP_H #define SUIT_STAMP_H #include <stddef.h> constexpr int EXIT_UNCHANGED = 0; constexpr int EXIT_CHANGED = 10; constexpr int EXIT_NO_STAMP = 11; constexpr int EXIT_BAD_STAMP = 12; constexpr size_t STAMP_FILE_MAX = 1048576; constexpr size_t STAMP_PATH_MAX = 4096; // Fill OUT with "$SUIT_HOME/NAME" ("$HOME/.suit/NAME" without SUIT_HOME). // Returns the length of the home folder part, or 0 after saying why. size_t suit_home_path(char *out, size_t cap, const char *name); // Writes $SUIT_HOME/stamp (default ~/.suit/stamp) atomically: the line // "suit stamp 2", then one line for each path. Returns 0 or a nonzero exit code // after reporting on stderr. int stamp_write(int npaths, char *const *paths); // The no-change compare. Reads the stamp, stats each path, and writes only // to stdout and stderr: no file is created or changed and nothing is // allocated. With REPORT it prints "changed: PATH" for each path that differs. // A stamp whose first line is not "suit stamp 2" but a path line was written by // an older suit: it is a change, reported as the stamp's own path. // Returns one of the EXIT_ codes, or 1 if it cannot read the stamp. int stamp_check(bool report); #endif