Artifact 612e5feb599791ae08fb950e7419c8f8bc0fded0ba07c4f8acee41b16f72e938:
- File
src/resolve.h
— 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: 1983) [annotate] [blame] [check-ins using]
#ifndef SUIT_RESOLVE_H #define SUIT_RESOLVE_H #include "conf.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 store holds: 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". typedef struct { uint32_t n; const char *name[ASSET_MAX]; const char *file[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; } Placement; typedef struct { uint32_t n; Placement p[PLACE_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 } Plan; typedef struct { char msg[512]; } ResolveError; // HOME expands a leading ~; STORE is the store's folder and SUIT_HOME holds // slots/. 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 char *store, 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