Artifact f644bcf241faaf4c144548f2082e4fa479ed8003d35f7f67b337a1e1c3ad6261:
- File
src/conf.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: 4019) [annotate] [blame] [check-ins using]
#ifndef SUIT_CONF_H #define SUIT_CONF_H #include <stddef.h> #include <stdint.h> constexpr size_t CONF_LINE_MAX = 4096; constexpr size_t CONF_FILE_MAX = 1048576; constexpr size_t CONF_NAME_MAX = 128; constexpr uint32_t CONF_HARNESS_MAX = 64; constexpr uint32_t CONF_OUTFIT_MAX = 512; constexpr uint32_t CONF_WEAR_MAX = 256; constexpr uint32_t CONF_NEED_MAX = 256; constexpr uint32_t CONF_UPSTREAM_MAX = 128; constexpr uint32_t CONF_ENTRY_MAX = 8192; constexpr uint32_t CONF_SECTION_MAX = CONF_HARNESS_MAX + CONF_OUTFIT_MAX + CONF_WEAR_MAX + CONF_NEED_MAX + CONF_UPSTREAM_MAX; // Wards that take part in placing (docs/conf-format.md, "More than one wardrobe"). constexpr uint32_t WARDROBE_MAX = 16; constexpr size_t WARDROBE_PATH_MAX = 4096; // One wardrobe that takes part: its name, its store's folder and its config's path. typedef struct { char name[CONF_NAME_MAX + 1]; char store[WARDROBE_PATH_MAX]; char conf[WARDROBE_PATH_MAX]; } Ward; // The wardrobes that take part, in byte order of name. A Section's ward indexes w. typedef struct { uint32_t n; Ward w[WARDROBE_MAX]; } Wards; typedef enum { KIND_HARNESS, KIND_OUTFIT, KIND_WEAR, KIND_NEED, KIND_UPSTREAM, KIND_COUNT } Kind; // Every string points into Conf.buf. A list value is stored with its words // separated by single spaces; walk it with conf_list_next. typedef struct { const char *key; const char *val; int line; } Entry; // harness, outfit, upstream: arg[0] is the name. // need: arg[0] is the harness, arg[1] the name. // wear: arg[0] is the scope, arg[1] the target ("" if none), arg[2] the // machine name ("" if none). typedef struct { Kind kind; const char *arg[3]; int line; uint32_t first; uint32_t count; uint8_t ward; // the wardrobe whose config defines the section; 0 for one file } Section; typedef struct { uint32_t nsections; uint32_t nentries; uint32_t kind_count[KIND_COUNT]; Section sections[CONF_SECTION_MAX]; Entry entries[CONF_ENTRY_MAX]; size_t len; // bytes of the files held, at most CONF_FILE_MAX size_t used; // bytes of buf in use: each file's bytes and one more char buf[CONF_FILE_MAX + 1 + WARDROBE_MAX]; } Conf; // line is 0 when the error concerns the whole file. ward is the wardrobe whose // file it is (0 when only one file is read). typedef struct { int line; uint32_t ward; char msg[256]; } ConfError; // Parse DATA (LEN bytes) into C. On failure C holds nothing usable and ERR // says what and where. [[nodiscard]] bool conf_parse(Conf *c, const char *data, size_t len, ConfError *err); [[nodiscard]] bool conf_load(Conf *c, const char *path, ConfError *err); // conf_load without the checks of references and cycles, for a file that is one // of several: what it names may be defined in another. Follow with conf_merge. [[nodiscard]] bool conf_parse_part(Conf *c, const char *data, size_t len, ConfError *err); [[nodiscard]] bool conf_load_part(Conf *c, const char *path, ConfError *err); // Empty the combined set C. void conf_merge_init(Conf *c); // Add SRC, a file read with conf_load_part, to the combined set DST as wardrobe // WARD of W. A section already in DST, or a limit passed by the combined set, // is an error in WARD's file. [[nodiscard]] bool conf_merge(Conf *dst, const Conf *src, uint32_t ward, const Wards *w, ConfError *err); // Check the references and the include cycles of the combined set C. [[nodiscard]] bool conf_check(const Conf *c, ConfError *err); // Write the canonical dump to FD: sections and entries in stable order, one // fact per line. Reorders C in place. False if a write fails (errno set). [[nodiscard]] bool conf_dump(Conf *c, int fd); // True if the LEN bytes are a name: 1 to 128 of A-Z a-z 0-9 . _ - (and * // if GLOB). bool conf_name_ok(const char *s, size_t len, bool glob); // Step through a list value. Returns false at the end. bool conf_list_next(const char **cursor, const char **word, size_t *len); #endif