Artifact 094826c3995b4521e2064409dff4e24e952827a8c30765ad2ed769d0b2eb701f:
- File
src/attention.h
— part of check-in
[3cb21b0428]
at
2026-11-16 08:11:34
on branch trunk
— Phase 8c-1: an upstream is taken from a folder, reviewed, and merged
suit upstream NAME take FOLDER checks the upstream's files in on the branch upstream-NAME of the wardrobe that defines it, at INTO/ENTRY, with the comment upstream NAME at PIN. The check-in is built as a deck on a repository opened with no checkout, so the working copy is not touched. Its first parent is trunk's first check-in, so a later merge is three-way. Dot entries are skipped, links are refused, the lint runs, and a file that something else supplies is a clash. into is a new key, default skills; trust defaults to review.
With trust = review the update waits: the attention file says so, suit upstreams lists each upstream as never taken, current, waiting for review or conflict, and suit upstream NAME diff lists what accept would add, change, remove or conflict on. suit upstream NAME accept merges the branch into trunk after a dry run. A conflict changes no file and writes no marker; --mine PATH and --theirs PATH settle one. With trust = auto a clean take is accepted at once.
Every accept writes the tracked file upstreams/NAME, holding the hash and pin it accepted, into its merge check-in. So a merge that changes no other file can still be checked in, and keeping your version of the only conflict ends as current.
The proof: a local fix to a taken file survives an update that changes another line, and an update that rewrites the same line waits as a conflict with trunk byte-identical to before.
Limits, all in docs/upstreams.md. suit back after an accept refuses, as after any check-in, and no command undoes an accept. diff prints the list of files, not their text. After --mine, a later take that touches the same lines can conflict again, because the library leaves the merge parent off that check-in. Accept works only at trunk's tip. A wardrobe and an upstream of one name share an attention item. Fetching over the network is part two and is not built.
1473 unit checks (was 1431), 620 shell cases (was 612), 968 store cases (was 669), 846 placement cases 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 (34 minutes). 100% coverage in all 26 source files. The speed budget still passes. No existing case was changed. (user: dmestas, size: 2342) [annotate] [blame] [check-ins using]
#ifndef SUIT_ATTENTION_H #define SUIT_ATTENTION_H #include <stdbool.h> #include <stddef.h> // $SUIT_HOME/attention: what needs the user. An item is a line, "KIND NAME" // or "KIND NAME: what", and the lines indented by two spaces after it, which // belong to it. The file is written beside, synced and renamed, and is removed // when it would be empty. Each returns 0, or 1 after saying what failed. constexpr size_t ATTENTION_FILE_MAX = 131072; // Take out the items of NAME, of kind KIND (every kind if null). Writes // nothing when there is none. int attention_remove(const char *path, const char *kind, const char *name); // Replace the item KIND NAME with HEADER and DETAILS: lines, each ending in a // newline, kept under it indented (null for none). Writes nothing when the // file would not change. int attention_add(const char *path, const char *kind, const char *name, const char *header, const char *details); // Make the items of kind KIND be exactly the N given: HEADERS[i] (a line with // no newline) under NAMES[i]. An item already there with its header as given // stays where it is; one that is not wanted, or whose header differs, is // taken out; one missing is added at the end. Items of other kinds are not // touched. Writes nothing when the file would not change, and removes it when // it would be empty. N is at most ATTENTION_SYNC_MAX. constexpr size_t ATTENTION_SYNC_MAX = 256; int attention_sync(const char *path, const char *kind, size_t n, const char *const *names, const char *const *headers); // Print "needs you:" and the file's lines, or nothing when there are none. int attention_print(const char *path); // How many items the file holds: its lines that are not indented. 0 in *COUNT // when it is not there. Returns 0, or 1 after saying what failed. int attention_count(const char *path, unsigned *count); // Whether the item KIND NAME is in the file: false in *HAS when it is not // there. Returns 0, or 1 after saying what failed. int attention_has(const char *path, const char *kind, const char *name, bool *has); // The header line of the item KIND NAME, copied to HEADER (CAP bytes, cut if // longer): empty when there is no such item. Returns 0, or 1 after saying // what failed. int attention_header(const char *path, const char *kind, const char *name, char *header, size_t cap); #endif