Artifact 1540976de6031b04507c48d5a09df1da1946678e32d058dc3cb29897759bf6ab:
- File
src/main.c
— part of check-in
[c3b2afcdc0]
at
2026-11-13 02:12:51
on branch trunk
— Phase 3: the User scope, placed by links that suit owns and nothing else
suit reads suit.conf from the store, works out which links should exist for the User scope, and makes each harness's folders match. suit plan, apply, status and off. suit run now applies when something changed.
The ledger is a text file listing every link suit made. A link is made under a temporary name and renamed into place. A real file, a real folder or someone else's link at a destination is left byte-identical and reported as a clash. suit off leaves a home folder exactly as it was before the first apply.
Proven with a real harness: Claude Code, run against a scratch home through a local proxy on a DeepSeek model, returned the marker word from the instruction file suit placed, listed the skill suit placed, returned a new marker after the file was edited in the store with no suit command run, and no longer saw it after suit off. make live runs this on purpose; it is not part of the automatic gates.
385 unit checks, 227 shell cases, 146 store cases, 157 placement cases. 100% of functions, lines, regions and branches in all 14 source files. The no-change run costs 0.45 to 0.72 ms over an empty program with the stamp now watching 128 paths.
Not yet done in this phase: live proof with Codex and pi, and the document of each harness's paths. (user: dmestas, size: 2553) [annotate] [blame] [check-ins using]
#include "bench.h" #include "commands.h" #include "conf.h" #include "platform.h" #include "stamp.h" #include "store.h" #include <errno.h> #include <string.h> #include <unistd.h> static Conf conf; static int usage(void) { say(STDERR_FILENO, "usage: suit check FILE\n" " suit store open|status|update|repair NAME\n" " suit plan | apply | status | off | run\n" " suit compare\n" " suit commit NAME -m TEXT\n" " suit back NAME\n" " suit stamp PATH...\n" " suit run\n" " suit bench [-n N] [-e EMPTY_PROGRAM] [-t MICROSECONDS] [-m KIB]\n"); return 2; } static int cmd_check(const char *path) { ConfError err; if (!conf_load(&conf, path, &err)) { say(STDERR_FILENO, "%s:%d: %s\n", path, err.line, err.msg); return 2; } if (!conf_dump(&conf, STDOUT_FILENO)) { say(STDERR_FILENO, "suit: cannot write the dump: %s\n", strerror(errno)); return 1; } return 0; } static int cmd_store(int argc, char **argv) { if (argc != 4) return usage(); const char *verb = argv[2]; if (strcmp(verb, "open") == 0) return store_open(argv[3]); if (strcmp(verb, "status") == 0) return store_status(argv[3]); if (strcmp(verb, "update") == 0) return store_update(argv[3]); if (strcmp(verb, "repair") == 0) return store_repair(argv[3]); return usage(); } int main(int argc, char **argv) { if (argc < 2) return usage(); const char *cmd = argv[1]; if (strcmp(cmd, "run") == 0) return argc == 2 ? cmd_run() : usage(); if (strcmp(cmd, "compare") == 0) return argc == 2 ? stamp_check(true) : usage(); if (strcmp(cmd, "plan") == 0) return argc == 2 ? cmd_plan() : usage(); if (strcmp(cmd, "apply") == 0) return argc == 2 ? cmd_apply() : usage(); if (strcmp(cmd, "status") == 0) return argc == 2 ? cmd_status() : usage(); if (strcmp(cmd, "off") == 0) return argc == 2 ? cmd_off() : usage(); if (strcmp(cmd, "check") == 0) return argc == 3 ? cmd_check(argv[2]) : usage(); if (strcmp(cmd, "stamp") == 0) return argc >= 3 ? stamp_write(argc - 2, argv + 2) : usage(); if (strcmp(cmd, "store") == 0) return cmd_store(argc, argv); if (strcmp(cmd, "back") == 0) return argc == 3 ? store_back(argv[2]) : usage(); if (strcmp(cmd, "commit") == 0) return argc == 5 && strcmp(argv[3], "-m") == 0 ? store_commit(argv[2], argv[4]) : usage(); if (strcmp(cmd, "bench") == 0) return bench_main(argc - 2, argv + 2); return usage(); }