Artifact 0bfb18354453d22bce71198fd3374d94630268ac9e9de69fbd0bc4c4b1c81a01:
- File
src/commands.h
— part of check-in
[1ed63201f4]
at
2026-11-18 03:02:04
on branch trunk
— suit curate apply turns the page's choices into config changes
suit curate apply FILE reads the choices file the curation page makes and prints a plan: which outfits and wears it edits, which wardrobes it checks in and in what order, and the links that will appear and disappear at each scope. Without --yes nothing changes. With --yes it edits each wardrobe's suit.conf and checks it in, with a comment such as "Curate: 3 kept, 1 limited, 12 retired". It does not place anything; the next run sees the config changed and applies.
- keep leaves a worn asset as it is. A loose asset, or one coming back from the attic, goes to the outfit kept.WARDROBE, worn at user scope. - limit moves the asset from its user outfits to personal.WARDROBE.SLUG, worn by [wear personal PROJECT], created or reused wherever it is. - retire removes the asset from every outfit of its wardrobe and adds it to attic.WARDROBE, which nothing wears. Apply refuses if a wear reaches an attic. - Removing one name from an outfit that lists `*` turns the `*` into an explicit list of the names it reached, minus that one, and the plan says so: names added to the store later are then not included by that outfit. No exclusion syntax was added.
Outfit names carry the wardrobe because outfit names are one set across wardrobes; a name too long for that is refused for its line. A wardrobe that defines a new outfit is checked in before any wardrobe whose wear names it, so a failure part-way leaves only an outfit nothing wears; a run that would need the opposite order is refused before anything changes.
Configs are edited as text: only the lines that must change are rewritten, and comments, blank lines, alignment, line endings and the order of everything else are kept. Every edited config must parse and the combined set must pass the merge check before anything is written. A wardrobe with local changes is refused, so the check-in holds the curation only. A failed check-in puts that wardrobe's file back.
A malformed line, a duplicate, a bad header or a path given as a project refuses the whole file, listing every problem. An unknown asset is warned about and skipped; a choice already true is silent.
A new suite, test/curate_apply.sh, with 376 cases, is part of the gate, and a new fuzz target covers the choices parser and the line editor.
3669 unit checks (was 2993), 625 shell cases, 1153 store cases, 985 placement cases, 378 project cases, 236 usage cases, 288 curate cases and 376 curate-apply cases, under clang, under gcc 16, with no user name set, and under a strict umask, in one run of make gate (44 minutes). 100% coverage in all 32 source files. No existing case was changed. (user: dmestas, size: 2045) [annotate] [blame] [check-ins using]
#ifndef SUIT_COMMANDS_H #define SUIT_COMMANDS_H #include "assets.h" #include "conf.h" #include "resolve.h" #include <stddef.h> // Placing takes every wardrobe under $SUIT_HOME/store that holds a suit.conf, // merged into one set (src/wardrobes.h). // Each returns an exit code and reports on stdout and stderr. int cmd_plan(void); int cmd_apply(void); int cmd_status(void); // Every place that supplies the asset NAME for the current folder, and which one is in effect. int cmd_why(const char *name); int cmd_off(void); // `suit hooks`: what `suit-run hook EVENT` would run for each event, changing nothing. int cmd_hooks(void); // Say whether each need is done: 0 when all are, 1 when one is not or cannot be told, 2 on a config error. int cmd_needs(void); // Print the prompt of the need NAME of HARNESS. int cmd_need(const char *harness, const char *name); int cmd_run(void); // `suit check` with no file: the canonical dump of every wardrobe's config as one set, or the first error (exit 2). int cmd_check_set(void); // NAME is null to show the machine's name. int cmd_machine(const char *name); // VERB is null to list the roots, else "add" or "rm" with ARG the folder. ARG is changed. int cmd_roots(const char *verb, char *arg); // Show the list the last scan wrote, or with SCAN make it. int cmd_projects(bool scan); // Set (KEY given) or unset the remote key of the project at PATH by hand. PATH is changed. int cmd_project(char *path, const char *key); // For `suit curate apply` (src/curate_apply.c): $SUIT_HOME and the lock file's path, each into // a buffer of COMMANDS_PATH_CAP bytes. 1 after a message. constexpr size_t COMMANDS_PATH_CAP = 4096; int commands_home(char *suit_home, char *lock_path); // The placements of the User and Project personal scopes that the config C, a set other than the // one on disk, would give for the wardrobes W and the assets A, for this machine and the projects // of the last scan. 1 after a message. int commands_resolve(const Conf *c, const Wards *w, const Assets *a, Plan *out); #endif