Artifact 709ac52c3ede3d0597bea4b21e2a96362ef57cb5ff70561391583ea70d3b01ef:
- File
src/main.c
— part of check-in
[6516a0e4da]
at
2026-11-13 12:54:25
on branch trunk
— Phase 7a: a lint guards every check-in, and edits made in place are checked in
suit lint and suit commit refuse a change that holds a token-shaped value, tool-attribution text, a symlink, or a skill folder with no header. A suit.lint file in the wardrobe can exempt a path or forbid an extra phrase. The lint never changes a file.
suit tend is the hourly entry point. For now it checks in edits made in the store, after the lint. A change that deletes more than five files and more than a fifth of the wardrobe is held until it is confirmed. Anything that needs a person is written to an attention file, which suit status shows under 'needs you'.
A symlink refusal now comes from the lint and exits 3, where it exited 16 before.
Also fixed, found by the forge's runner: a file suit rewrote came back with default permissions, keeping only its executable bit. On the runner a project's local exclude file went from rw-rw---- to rw-r----- across apply and off. A rewritten file now keeps exactly the permissions it had. Tests rewrite files of four different modes under two different defaults, so the development machine catches it too. Three tests that restored a folder to a fixed mode now put back only the bits they took away.
1204 unit checks, 227 shell cases, 323 store cases, 612 placement cases and 378 project cases, under clang, under gcc 16, with no user name set, and under a strict umask. 100% coverage in all 21 source files. No suite has fewer cases than at the last check-in. (user: dmestas, size: 4275) [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 why NAME\n" " suit machine [NAME]\n" " suit roots [add|rm FOLDER]\n" " suit projects [scan]\n" " suit project set FOLDER KEY | unset FOLDER\n" " suit compare\n" " suit lint NAME\n" " suit commit NAME -m TEXT [--confirm-deletions]\n" " suit tend NAME\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(); } static int cmd_roots_args(int argc, char **argv) { if (argc == 2) return cmd_roots(nullptr, nullptr); bool verb = argc == 4 && (strcmp(argv[2], "add") == 0 || strcmp(argv[2], "rm") == 0); return verb ? cmd_roots(argv[2], argv[3]) : usage(); } static int cmd_project_args(int argc, char **argv) { if (argc == 5 && strcmp(argv[2], "set") == 0) return cmd_project(argv[3], argv[4]); if (argc == 4 && strcmp(argv[2], "unset") == 0) return cmd_project(argv[3], nullptr); return usage(); } static int cmd_commit(int argc, char **argv) { bool confirm = argc == 6 && strcmp(argv[5], "--confirm-deletions") == 0; if (argc < 5 || argc > 6 || strcmp(argv[3], "-m") != 0 || (argc == 6 && !confirm)) return usage(); return store_commit(argv[2], argv[4], confirm); } 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, "why") == 0) return argc == 3 ? cmd_why(argv[2]) : usage(); if (strcmp(cmd, "off") == 0) return argc == 2 ? cmd_off() : usage(); if (strcmp(cmd, "machine") == 0) return argc <= 3 ? cmd_machine(argc == 3 ? argv[2] : nullptr) : usage(); if (strcmp(cmd, "roots") == 0) return cmd_roots_args(argc, argv); if (strcmp(cmd, "projects") == 0) { if (argc == 2) return cmd_projects(false); return argc == 3 && strcmp(argv[2], "scan") == 0 ? cmd_projects(true) : usage(); } if (strcmp(cmd, "project") == 0) return cmd_project_args(argc, argv); 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, "lint") == 0) return argc == 3 ? store_lint(argv[2]) : usage(); if (strcmp(cmd, "tend") == 0) return argc == 3 ? store_tend(argv[2]) : usage(); if (strcmp(cmd, "commit") == 0) return cmd_commit(argc, argv); if (strcmp(cmd, "bench") == 0) return bench_main(argc - 2, argv + 2); return usage(); }