Artifact f8b4ff51740af28a5b614a7e65c7da973235e1ffe489a2d6077525f576a8588e:
- File
src/resolve.h
— part of check-in
[71a8d2c4d3]
at
2026-11-16 00:33:58
on branch trunk
— Suit places from every wardrobe, merged into one set
Placing read one wardrobe, named mine. It now takes every folder under the store that holds a suit.conf, in byte order of name, at most 16. Each config is parsed as before and the results are merged: harness, outfit, need and upstream names are shared, so a private outfit can include a public one. Paths and asset names resolve in the store of the wardrobe that defines the section. No wardrobe beats another; scope and limit decide, as before.
The same section in two wardrobes is an error naming both places. The same destination from two wardrobes at one scope is a clash that names the wardrobes. Any error in any config stops plan and apply before anything is placed. A merge that is refused leaves the combined set as it was.
suit check with no file prints the combined dump. suit why names the wardrobe when more than one takes part. The ledger's format did not change: a link's source path already names its wardrobe. The stamp watches every wardrobe's folder and the store folder, so a wardrobe that appears or goes is noticed. Nothing special-cases the name mine.
This is the owner's decision of 2026-11-15, recorded in docs/decisions.md with the rejected alternative, one master config naming assets as wardrobe:path. It corrects the 2026-11-12 line that said wardrobes already stacked.
The message for no config is now STORE:0: no wardrobe with a suit.conf. Fault call numbers in 12 existing cases moved because the store folder is listed first; what each asserts is unchanged.
The no-change run with two wardrobes of 50 files each is 0.83 to 0.85 ms over an empty program, limit 1 ms. The cost is one stat per watched path: 100 files in each wardrobe measured 1.19 to 1.24 ms. The budget fixture watches 100 files in all, as before.
Not covered: suit status with two wardrobes, which needs two repositories in the fixture. A duplicate-section message can be cut short when both paths are very long.
1431 unit checks (was 1355), 612 shell cases (was 606), 669 store cases, 846 placement cases (was 756) and 378 project cases, under clang, under gcc 16, with no user name set, and under a strict umask, in one run of make gate (28 minutes). 100% coverage in all 25 source files. No suite has fewer cases than at the last check-in. (user: dmestas, size: 4986) [annotate] [blame] [check-ins using]
#ifndef SUIT_RESOLVE_H #define SUIT_RESOLVE_H #include "conf.h" #include "project.h" #include <stddef.h> #include <stdint.h> // Resolve works out the placements of the User scope from a parsed config and // a listing of the store. It reads nothing and changes nothing. typedef enum { AK_SKILL, AK_AGENT, AK_COMMAND, AK_INSTRUCTIONS, AK_FILE, AK_SLOT, AK_COUNT } AssetKind; constexpr uint32_t ASSET_MAX = 2048; // names per kind constexpr uint32_t PLACE_MAX = 4096; // placements constexpr uint32_t SKIP_MAX = 1024; // skipped lines constexpr size_t SKIP_LEN = 256; constexpr size_t PLAN_TEXT_MAX = 524288; // paths in a plan // What the stores hold: for a skill the name is the folder's name; for an // agent or a command the name is the file's name without a trailing ".md". // ward is the wardrobe whose store holds it. typedef struct { uint32_t n; const char *name[ASSET_MAX]; const char *file[ASSET_MAX]; uint8_t ward[ASSET_MAX]; } NameList; typedef struct { NameList list[AK_COMMAND + 1]; // skills, agents, commands } Assets; typedef struct { const char *dest; const char *src; const char *harness; // "-" for a file or a slot AssetKind kind; bool limited; // supplied by a wear limited to this machine const char *project; // the project folder a personal placement is in; nullptr for the User scope ProjectKind vcs; // that project's kind const char *outfit; // the outfit that asked for it const char *ward; // the wardrobe whose store holds src (a file suit joins has the first's) } Placement; // A file suit writes: FIRST's content, a blank line, SECOND's content. It is // the source of the placement that has the same path as its source. // Each join takes two placements, so a plan has at most half as many joins. constexpr uint32_t JOIN_MAX = PLACE_MAX / 2; constexpr size_t JOIN_PATH_MAX = 4096; // One place that supplies an asset, for `suit why`: what resolve decided about // it. PENDING is internal and never survives a resolve. typedef enum { FATE_PENDING, FATE_PLACED, FATE_DROPPED, FATE_JOINED, FATE_OTHER_MACHINE, FATE_NO_PROJECT, FATE_NO_FOLDER } Fate; constexpr uint32_t SUPPLIER_MAX = 64; // suppliers of the one name asked about typedef struct { const char *scope; // "user" or "personal" const char *key; // the project's key for personal, else "" const char *machine; // the machine the wear is limited to, "" if none const char *outfit; const char *harness; // "-" for a file or a slot const char *dest; // "-" if there is none (no folder, or no project) const char *src; const char *project; // the project folder; nullptr for the User scope and for no project const char *ward; // the wardrobe that supplies it AssetKind kind; Fate fate; } Supplier; typedef struct { char path[JOIN_PATH_MAX]; const char *first; // the unlimited wear's instructions const char *second; // the machine-limited wear's } Join; typedef struct { uint32_t n; Placement p[PLACE_MAX]; uint32_t njoins; Join joins[JOIN_MAX]; uint32_t nskips; char skips[SKIP_MAX][SKIP_LEN]; // "skipped ..." lines char text[PLAN_TEXT_MAX]; size_t used; bool overflow; // a path did not fit in text uint32_t nsuppliers; // resolve_why only Supplier sup[SUPPLIER_MAX]; } Plan; typedef struct { char msg[512]; } ResolveError; // The Project personal scope is placed in every project of PROJECTS whose key a // `[wear personal KEY]` names, inside the project's folder. // HOME expands a leading ~; WARDS says where each wardrobe's store is (every // path and asset name an outfit or a need gives is in the store of the wardrobe that defines it) // and SUIT_HOME holds slots/ and joined/. MACHINE is this machine's name, "" if it has none: a wear // limited to another machine is ignored. On success P is sorted by destination // with no duplicates. [[nodiscard]] bool resolve(const Conf *conf, const Assets *assets, const char *home, const char *suit_home, const Wards *wards, const char *machine, const Projects *projects, Plan *p, ResolveError *err); // resolve, and in P->sup every place that supplies the asset NAME (the name of a // skill, agent or command with or without .md, "instructions", a slot's name, a // file's destination as the config gives it), with what resolve decided about // each: placed, dropped for a machine-limited one, joined, or never applied. [[nodiscard]] bool resolve_why(const Conf *conf, const Assets *assets, const char *home, const char *suit_home, const Wards *wards, const char *machine, const Projects *projects, const char *name, Plan *p, ResolveError *err); // The kind's name as the config and the reports spell it. const char *asset_kind_name(AssetKind kind); // True if NAME matches PATTERN, where * matches any run of characters. bool glob_match(const char *pattern, const char *name); #endif