Artifact 37448708f89867bf8cb2ee5e40031eb1c513f8857f53788c34eff5fa5afcf01e:
- File
src/curate.h
— part of check-in
[cef6a0ad45]
at
2026-11-17 07:37:01
on branch trunk
— suit curate writes a page for deciding what each asset is worth keeping
suit curate [--since DAYS] [--out FILE] runs a usage scan and writes one self-contained HTML page, mode 0600, atomically, to curate.html in suit's home folder or to FILE. It changes no wardrobe file, config, stamp or ledger. The page names projects and stays on this machine; it loads nothing from the network and has no inline handlers.
Each skill, agent and command in the wardrobes is a row: uses in the window and in each of the last four weeks, last used, the projects it was used in, its description and what that costs every session, where it is worn, whether it is in the attic, and whether it is the owner's or an upstream's. Origin comes from the entries of the check-in the upstream's record names, so an upstream's skills beside the owner's own in skills/ are told apart. A name in two wardrobes is tagged with its wardrobe.
Each row starts from a suggestion with its reason: retire when unused in the window, unless its files changed within it; limit when three or more uses all came from one known project; otherwise keep. A folder that is not a known project cannot be limited to, and the page says how to make it one. The owner picks keep, limit or retire per row, with keys or in bulk on what is shown, and copies or saves the choices as a short text file. Applying it is a separate step, not in this check-in. The format is in docs/curate.md: one line per asset, `keep KIND WARDROBE NAME`, `retire KIND WARDROBE NAME`, or `personal KIND WARDROBE NAME PROJECT`.
The page is src/curate.html, turned into a C array at build time with od and awk, so the release build needs no other tool. Values are written as JSON with markup characters, U+2028 and U+2029 escaped and invalid UTF-8 replaced. The page script has its own test, run under node where node is installed and reported as skipped elsewhere. A new fuzz target covers the front-matter reader and the JSON writer.
Page sizes: 37 KB for the test fixture, 252 KB for 500 assets, 805 KB at the 4096-asset bound.
A new suite, test/curate.sh, with 288 cases, is part of the gate.
2993 unit checks (was 2855), 620 shell cases, 1153 store cases, 846 placement cases, 378 project cases, 236 usage cases and 288 curate cases, under clang, under gcc 16, with no user name set, and under a strict umask, in one run of make gate (66 minutes, on a loaded machine; one earlier run failed only the loaded speed measurement, at 1.06 to 1.11 ms, and this run passed it at 0.99 ms). 100% coverage in all 31 source files. No existing case was changed. (user: dmestas, size: 3332) [annotate] [blame] [check-ins using]
#ifndef SUIT_CURATE_H #define SUIT_CURATE_H #include <stddef.h> #include <stdint.h> // `suit curate` (docs/curate.md): one self-contained HTML page that shows every // skill, agent and command of the wardrobes beside how it is used, and a text // file of the choices made on it. It changes nothing else. constexpr uint32_t CURATE_ASSETS_MAX = 4096; // assets on a page constexpr uint32_t CURATE_PROJECTS_MAX = 64; // projects listed for one asset; the rest are summed constexpr uint32_t CURATE_TOP = 10; // names used that match no asset, listed constexpr size_t CURATE_HEAD_MAX = 16384; // bytes of a file read for its description constexpr size_t CURATE_DESC_KEEP = 300; // bytes of a description kept constexpr uint32_t CURATE_FILES_MAX = 4096; // files of one asset counted for its size constexpr int CURATE_DEPTH_MAX = 16; // folders nested in one asset counted for its size constexpr size_t CURATE_PAGE_MAX = 16777216; // bytes of the page constexpr uint32_t CURATE_RECS_MAX = 600000; // (asset, project) uses and unmatched uses held at once // `suit curate [--since DAYS] [--out FILE]`. ARGV is what follows "curate". // 0; 1 after a message (a file cannot be read or written, a bound is passed); // 2 for bad arguments or a config that cannot be used; EXIT_BUSY. int cmd_curate(int argc, char **argv); // ---- for the tests ---------------------------------------------------------- // The `description` of the front matter in the first LEN bytes of a file, whitespace // collapsed, into OUT (room for LEN + 1 bytes), and its length: 0 when there is no // front matter (a first line "---" and a later one) or no description. size_t curate_front_description(const char *data, size_t len, char *out); // The length of the first MAX bytes of S (LEN bytes) cut so as not to split a UTF-8 character. size_t curate_cut(const char *s, size_t len, size_t max); // A bounded buffer. OVER is set when something did not fit; nothing is then added. typedef struct { char *p; size_t cap; size_t len; bool over; } CurateBuf; // Append the N bytes of S to B, or set OVER if they do not fit. void curate_put(CurateBuf *b, const char *s, size_t n); // Append the LEN bytes of S as a JSON string, quotes included, in which every // "<", ">", "&", U+2028 and U+2029 is a \u escape and every byte that is not // UTF-8 is U+FFFD. void curate_json_string(CurateBuf *b, const char *s, size_t len); // Call CB for the index of each of the N names (sorted, byte order) that the // usage name USAGE (LEN bytes) is an invocation of: it is equal to the name, or // ends with a colon and the name. Returns how many. uint32_t curate_matches(const char *const *names, uint32_t n, const char *usage, size_t len, void (*cb)(void *state, uint32_t index), void *state); // The times, as "YYYY-MM-DDTHH:MM:SS", from which a use counts: in the window of // DAYS, in the last 90 days, and in each of the last four 7-day periods before NOW. typedef struct { char window[20]; char d90[20]; char week[4][20]; } CurateCuts; void curate_cuts(int64_t now, int days, CurateCuts *c); // The period of the time T (at least TALLY_TIME_LEN bytes): 0 the oldest to 3 the // newest, -1 when it is older than 28 days. int curate_week(const CurateCuts *c, const char *t); #endif