Artifact 78dfe5b1cd3954c763e770876c34db3f0870875169845271c87a4de4127673eb:
- File
src/attention.h
— part of check-in
[3598f9d78d]
at
2026-11-14 13:15:53
on branch trunk
— Phase 8a: needs are checked, listed, and shown until they are done
A need is a step a harness must do for itself, such as registering a slot in its own settings. suit never edits those settings; it says what is needed and can tell when it has been done.
The done test has two forms and nothing else: PATH exists, and PATH contains "TEXT". suit needs lists every need as done, not done or cannot tell, and changes nothing. suit need HARNESS NAME prints the prompt's exact bytes so it can be handed to the harness.
After each apply the attention file holds one item for each need not done and none for those that are. Other kinds of item are left alone and keep their order, and nothing is written when nothing changed. If that update fails, apply writes no stamp, so the next run tries again. A bad need stops apply before it places anything. suit off removes the items.
suit-run is untouched and the speed budget still passes.
An eighth fuzz target covers the done-test parser.
1355 unit checks, 479 shell cases, 669 store cases, 745 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 24 source files. No suite has fewer cases than at the last check-in. (user: dmestas, size: 2070) [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); #endif