Artifact b3356eec44d184292501daf848c5570b8ad5e1b3348dbb88af4301551faf2fec:
- File
src/store.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: 2401) [annotate] [blame] [check-ins using]
#ifndef SUIT_STORE_H #define SUIT_STORE_H constexpr int EXIT_LOCAL_CHANGES = 12; constexpr int EXIT_CONFLICT = 13; constexpr int EXIT_NOTHING_TO_UNDO = 14; constexpr int EXIT_NEEDS_REPAIR = 15; constexpr int EXIT_SYMLINK = 16; // The store of wardrobe NAME: a working copy in $SUIT_HOME/store/NAME of the // repository $SUIT_HOME/wardrobes/NAME.fossil. Each command returns an exit // code and reports on stderr (errors) or stdout (what changed). // While an update is in progress, or was interrupted, $SUIT_HOME/NAME.journal // names the version it is leaving and the version it is going to. Every // command but repair refuses with EXIT_NEEDS_REPAIR while it exists. // // Symlinks are not supported: libfossil's checkout writes them as regular // files. open and update refuse a version that holds one and commit refuses to // check one in, each with EXIT_SYMLINK and a message naming the path. // Open the wardrobe and create the working copy at trunk's tip if there is // none. Idempotent. int store_open(const char *name); // One line per local change: "edited PATH", "added PATH" or "deleted PATH". // Nothing when clean. Changes nothing. int store_status(const char *name); // Check in every local change as the current user. Exit 0, and no check-in, // when there are none. int store_commit(const char *name, const char *message); // Bring the working copy to trunk's tip. EXIT_LOCAL_CHANGES, listing the // files, if tracked files have changes. EXIT_CONFLICT, listing "conflict // PATH", if the update would conflict; nothing is changed then. int store_update(const char *name); // Bring every managed file back to the checked-in content of the version the // working copy records, using suit's file writer. EXIT_LOCAL_CHANGES, listing // them, if that would destroy local edits, unless an interrupted update left // a journal: then the files it partly replaced go back to the version it was // leaving. Clears the journal. Nothing to do is not an error. int store_repair(const char *name); // Say which version the working copy is at: "store NAME at UUID12". int store_show_version(const char *name); // EXIT_NEEDS_REPAIR, with a message, if an update of NAME did not finish; else 0. int store_check_journal(const char *name); // Undo the last update. EXIT_NOTHING_TO_UNDO if there is nothing to undo or // the store has moved on since. int store_back(const char *name); #endif