Artifact 885aad2a6ed97a3acad797becc50219b4a43555856fa3f3d81d10e994d6db3b7:
- File
src/upstream.h
— part of check-in
[75c8fde976]
at
2026-11-18 23:06:52
on branch trunk
— Instructions join per harness, and an upstream can be a local folder
A harness's instruction file is now joined from up to four suppliers, ranked: the shared one, the harness's own (an outfit with only = HARNESS), the one limited to this machine, and the machine's own for that harness. Each rank has at most one supplier; more than one rank is joined in that order, each source as it is in the store, separated by a blank line. One supplier still links straight to the store's file. So every harness can read a shared file and one harness an extra one, where an only outfit's instructions used to clash with the shared ones. The same rule holds at personal scope.
An upstream whose url is file:// and an absolute path is a local upstream. suit upstream NAME take with no FOLDER takes from it. The hourly suit tend takes every local upstream whose folder changed since its last take, and accepts it when trust = auto, so a skill whose home is one of the owner's own repositories is placed without a copy kept by hand. Changed is decided by a stamp of the folder kept in suit's home folder (path, size, mtime, inode and executable bit of each entry): an unchanged hour costs one lstat per entry and opens no file of the upstream. As with the no-change run, an edit that keeps a file's size and mtime is not seen until the next one that does not. A missing folder is one attention item that clears when it is back. The take comment names the folder, and the pin when there is one.
Three upstream usage cases changed their expected text, because take no longer needs a FOLDER.
3828 unit checks (was 3792), 625 shell cases, 1258 store cases (was 1153), 1032 placement cases (was 985), 382 project cases (was 378), 237 usage cases (was 236), 288 curate cases, 376 curate-apply cases and 172 https cases, under clang, under gcc 16, with no user name set and umask 002, and under umask 027, in one run of make gate (77 minutes). 100% coverage in all 34 source files. (user: dmestas, size: 3576) [annotate] [blame] [check-ins using]
#ifndef SUIT_UPSTREAM_H #define SUIT_UPSTREAM_H #include "conf.h" #include <stddef.h> #include <stdint.h> // Upstreams (docs/upstreams.md): an upstream's files are taken from a folder // onto the branch upstream-NAME of the wardrobe that defines it, and merged // into trunk when they are accepted. constexpr uint32_t UPSTREAM_FILES_MAX = 4096; constexpr uint64_t UPSTREAM_BYTES_MAX = 64ull * 1024 * 1024; constexpr size_t UPSTREAM_REL_MAX = 512; // a file's path inside its entry's folder constexpr size_t UPSTREAM_NAME_MAX = CONF_INTO_MAX + 1 + UPSTREAM_REL_MAX; // INTO/REL constexpr size_t UPSTREAM_PIN_MAX = 256; // the longest pin constexpr uint32_t UPSTREAM_SETTLE_MAX = 64; // --theirs and --mine in all // The files a take reads, in byte order of name: NAME is the path in the // wardrobe (INTO/ENTRY/...) and the file is ROOT/REL, REL being NAME without // the INTO/ in front. typedef struct { const char *name; uint64_t size; bool exec; } UpstreamFile; typedef struct { uint32_t n; uint64_t bytes; char prefix[CONF_INTO_MAX + 2]; // INTO and a slash size_t into_len; // strlen of prefix char root[4096]; // the folder read uint64_t stamp; // of the names, sizes and times of what was looked at, not its content UpstreamFile f[UPSTREAM_FILES_MAX]; char pool[UPSTREAM_FILES_MAX][UPSTREAM_NAME_MAX + 1]; } UpstreamFiles; // What a take is asked to do, after the config has been read. typedef struct { const char *name; // the upstream const char *pin; // the config's pin: a word const char *into; // where the files land in the wardrobe bool auto_accept; // trust = auto } UpstreamSpec; // The paths `accept` is told to settle: the upstream's version for THEIRS and // trunk's for MINE. typedef struct { uint32_t ntheirs; uint32_t nmine; const char *theirs[UPSTREAM_SETTLE_MAX]; const char *mine[UPSTREAM_SETTLE_MAX]; } UpstreamSettle; // Where an upstream stands. typedef enum { UPSTREAM_NEVER_TAKEN, UPSTREAM_CURRENT, UPSTREAM_WAITING, UPSTREAM_CONFLICT, } UpstreamState; // The folder of the wardrobe that holds upstreams/NAME, the record of what was accepted. constexpr char UPSTREAM_RECORD_DIR[] = "upstreams"; // Read FOLDER, or FOLDER/PATH when PATH is given, for the upstream NAME into F: skip every entry whose // name starts with a dot, refuse a symlink, take regular files, keep the // executable bit. Returns 0; 1 after a message on stderr (a file or folder // that cannot be read, a symlink, a path that is too long, more than // UPSTREAM_FILES_MAX files or UPSTREAM_BYTES_MAX bytes). int upstream_scan(UpstreamFiles *f, const char *name, const char *folder, const char *path, const char *into); // The upstreams whose url is file:///FOLDER, for `suit tend` with no name // (docs/upstreams.md, "Local upstreams"): after the wardrobes are tended, take // each whose folder differs from its stamp, and accept it with trust = auto. A // folder that is missing is an attention item. Says nothing when there is no // local upstream. Returns the worst exit code of a take; a config that cannot be read is said and counts for nothing. int upstream_tend_local(void); // `suit upstream NAME take [FOLDER]`, `accept [--theirs PATH] [--mine PATH]...`, // `diff` and `undo`. ARGV is the whole command line; ARGC is at least 4. int cmd_upstream(int argc, char **argv); // `suit upstreams`. int cmd_upstreams(void); #endif