Artifact f535bd8487bf0721c0075611b2089426ae076ea4420f2a34fdf9a16ed01cbc16:
- File
docs/store.md
— part of check-in
[f96cbc3342]
at
2026-11-13 03:51:02
on branch trunk
— Phase 4a: outfits limited to a machine, and instruction files joined
suit machine shows or sets this machine's name. An outfit worn with machine=NAME applies on that machine and nowhere else, and where it and an unlimited outfit supply the same destination the machine's wins.
A harness has one instruction file per scope. When the unlimited and the machine-limited outfit both supply instructions, suit writes one file with the unlimited text first and the machine's after it, and links the harness to that. It is rewritten when either source changes and removed when no longer needed. This is the one case where an edit in the store reaches a harness only after suit's next run.
The ledger gains an entry for a file suit wrote, so suit off removes the joined file too.
420 unit checks, 227 shell cases, 146 store cases, 612 placement cases, under clang and under gcc 16. 100% coverage in all 16 source files. The no-change run costs about 0.46 ms over an empty program quiet and 0.66 to 0.79 ms loaded.
The checked-in fuzz corpus now includes inputs grown for the ledger reader (61) and more for the stamp reader (108), beside the config parser's 300. The replay tool's input table grew, because fuzzing had filled the old one on the development machine. (user: dmestas, size: 4100) [annotate] [blame] [check-ins using]
The store
A wardrobe's store is a working copy of it in $SUIT_HOME/store/NAME/, backed
by the repository $SUIT_HOME/wardrobes/NAME.fossil. Every file suit writes in
it is written beside the file, synced, and renamed over it, so a reader sees the
old bytes or the new ones.
| Command | Does | Exit codes |
|---|---|---|
suit store open NAME |
Creates the working copy at trunk's tip, or opens the existing one. Safe to repeat. | 0, 1 error, 2 bad name, 15 journal, 16 symlink |
suit store status NAME |
One line per local change: edited PATH, added PATH, deleted PATH. Nothing when clean. Changes nothing. |
0, 1, 15 |
suit commit NAME -m TEXT |
Checks in every local change as the current user. No check-in when clean. | 0, 1, 15, 16 |
suit store update NAME |
Brings the working copy to trunk's tip. | 0, 1, 12 local changes, 13 conflict, 15, 16 |
suit store repair NAME |
Puts the files back after an interrupted update. | 0, 1, 12 |
suit back NAME |
Undoes the last update. | 0, 1, 14 nothing to go back to, 15 |
update lists local changes (exit 12) or conflict PATH lines (exit 13) and
changes nothing in either case; the caller commits first.
The journal and repair
Before an update changes a file it writes $SUIT_HOME/NAME.journal: the version
it is leaving and the version it is going to. It removes the journal when the
update, or the put-back after a failed update, has finished. A journal that is
still there means the update did not finish, because the put-back failed too or
suit was killed. Every command but repair then refuses with exit 15 and says
to run suit store repair NAME.
repair restores every managed file to the version the journal says the update
was leaving. With no journal it restores to the version the working copy
records, and refuses with exit 12, listing the files, when that would throw
local edits away. A second repair has nothing to do. A file the interrupted
update added, which the old version does not have, stays as an untracked file.
Symlinks
Symlinks are not supported, because libfossil's checkout writes a link as a regular file holding its target (docs/evidence.md, "Phase 2"). So, with exit 16 and a message naming each path:
openandupdaterefuse a wardrobe version that holds a symlink, before changing anything.commitrefuses to check in while the store holds a symlink.
The machine's name
$SUIT_HOME/machine holds the name of this machine: one line of 1 to 64 bytes,
letters, digits, -, _ and .. A machine with no such file has no name. A
file that is not a name is an error that names the file.
| Command | Does | Exit codes |
|---|---|---|
suit machine |
Prints the name. | 0, 1 no name set or unreadable file |
suit machine NAME |
Writes the name beside, syncs it and renames it over the file. | 0, 1, 2 not a name |
A [wear user machine=NAME] section applies when NAME is this machine's name,
and is ignored otherwise, and when the machine has no name. suit status says
which sections did not apply and why. suit run notices a change of name,
because the stamp watches the file.
Joined instructions
A harness has one instruction file in the User scope. When the unlimited wear
and the one limited to this machine both supply instructions for it, suit
joins them: it writes $SUIT_HOME/joined/HARNESS, which holds the unlimited
file, a blank line and the machine-limited file, each exactly as in the store,
and the harness's instruction path links to that file. With one supplier the
link goes straight to the store's file.
The joined file is written beside, synced and renamed, and is rewritten when
either source's content differs from what it holds. It is in the ledger as
file PATH, so suit off removes it, and suit apply removes it when the
machine limit stops applying. Each source can be 512 KiB.
This is the one case where an edit in the store is not seen through the
harness's path at once: the joined file is a copy, so it changes when suit
next applies, which suit run does as soon as the stamp sees the edit.