Artifact 772cee126d09c4d9eb96c7a2ca70106e635748b1799941aa72939f993d944bca:
- File
docs/store.md
— part of check-in
[27d847f693]
at
2026-11-18 16:19:19
on branch trunk
— suit syncs and clones over https
suit sync, suit clone and suit tend now work with https:// remotes. http:// and file:// keep libfossil's built-in channel.
libfossil is the private byot build 2f20f44ba4 in place of trunk f2983dcd78, approved while suit is being proven; only libfossil.c and libfossil.h differ from trunk's files. Its stream channel does all of the HTTP: request headers, Content-Length, chunked and close-delimited replies (the last only after a clean close), the reply-size limit and the timeout. suit supplies the transport: src/tls.c, over non-blocking TCP and BearSSL 0.6, now vendored.
- TLS 1.2 only, ECDHE key exchange, AES-GCM or ChaCha20-Poly1305. A server offering only TLS 1.3, RSA key exchange or CBC is refused. - The chain is verified against trust anchors and the host name against the certificate. Anchors come from the system's PEM bundle read at run time (SSL_CERT_FILE, then the usual macOS and Linux paths), or from a per-wardrobe CA file set with --ca, which replaces the bundle. No roots are compiled in and there is no way to trust anything. - A certificate file must be a regular file owned by the user or root, writable by no one else, in a folder that passes the same check; --ca refuses a symlink, and a FIFO is refused at once. - Redirects are refused, never followed, and the message names the new address. No proxy support. - Nothing is sent before the handshake has verified. The login goes out only as libfossil's login card. Commands that read the sync secret turn core files off first. - Every connect, read, write and name lookup waits in poll with a 30 s idle limit, and a whole command stops after 10 minutes. getaddrinfo has no deadline, so it runs in a forked child that is killed and reaped. - BearSSL makes no system call of its own: it is built without its own randomness or clock, and suit seeds it and gives it the time through its fault wrappers. - Exit 18 now means the secure connection failed (handshake, certificate, host name). 17 stays the network and 19 a refused login.
A per-wardrobe CA file is kept in cafiles in suit's home folder, one NAME PATH line each. suit-run is built without the network code and is unchanged at 35496 bytes; the speed budget passes. Release suit went from 2291288 to 2490024 bytes.
An independent security review found no critical or high issues. Its one medium finding, a CA file trusted without checking its owner, mode or type, is fixed here, as are its low ones: separate storage for each set of anchors, core files off, and the release check now covering every test-only switch.
Checked against a real server: an anonymous clone of this repository over https from its forge, 8.4 s, verified with stock fossil.
A new suite, test/https.sh, with 170 cases, runs local servers with test certificates made at test time, including servers that misbehave on purpose. It prints skip lines where openssl or nc is missing. A new fuzz target covers the bundle reader.
3788 unit checks (was 3669), 625 shell cases, 1153 store cases, 985 placement cases, 378 project cases, 236 usage cases, 288 curate cases, 376 curate-apply cases and 170 https cases, under clang, under gcc 16, with no user name set, and under a strict umask, in one run of make gate (76 minutes, on a loaded machine). 100% coverage in all 34 source files. Three store cases that expected "cannot use https yet" now expect the refusal for a missing certificate bundle. (user: dmestas, size: 20115) [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`. You may have several; placing takes every one whose store holds a `suit.conf` and merges them ([conf-format.md](conf-format.md), "More than one wardrobe"). The no-change run watches the folder `$SUIT_HOME/store` itself and each folder in it, so a wardrobe that appears or goes is noticed, and in each store what apply acts on: its `suit.conf`, its `skills`, `agents` and `commands` folders and the paths its config names, not the files a placed link already shows ([decisions.md](decisions.md), 2026-11-17). 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 lint NAME` | Runs the lint on the local changes. Changes nothing. | 0 clean, 1, 3 problems, 15 | | `suit commit NAME -m TEXT [--confirm-deletions]` | Runs the lint, then checks in every local change as the current user. No check-in when clean. | 0, 1, 3 problems, 4 held, 15 | | `suit tend NAME` | What a timer calls once an hour: checks in, or leaves what needs you in the attention file, then runs `suit sync`. | 0, 1, 3 problems, 4 held, 12, 13, 15, 17, 18, 19 | | `suit tend` | Tends every wardrobe on this machine, in name order. | 0 all clean, else the highest code any returned | | `suit clone NAME URL [--ca FILE]` | Makes the wardrobe NAME here from the remote at URL, records it (and FILE) as NAME's remote and opens the store. | 0, 1, 2 bad name, address or CA file, 17 network, 18 secure connection failed, 19 refused, 20 NAME exists | | `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 remote NAME [URL [--ca FILE]\|--none]` | Shows, sets or clears the wardrobe's remote address and its CA file. | 0, 1 none set or error, 2 bad address or CA file | | `suit login NAME USER` | Reads the secret from standard input and keeps it in `credentials`. | 0, 1, 2 | | `suit logout NAME` | Removes the login. | 0, 1, 2 | | `suit sync NAME` | Pulls, brings the working copy forward, merges a fork, pushes. | 0, 1, 12 local changes, 13 conflict, 15, 16, 17 network, 18 secure connection failed, 19 refused | | `suit back NAME` | Undoes the last update. | 0, 1, 14 nothing to go back to, 15 | | `suit upstream NAME take\|diff\|accept\|undo` | An upstream's branch of the wardrobe that defines it: take files from a folder, show what merging would change, merge, or reverse the newest accept by a new check-in. See [upstreams.md](upstreams.md). | 0, 1, 2, 3, 12, 13, 15 | | `suit upstreams` | Where each upstream stands. | 0, 1, 2, 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: - `open` and `update` refuse a wardrobe version that holds a symlink, before changing anything. - The lint reports every symlink in the store (`PATH: symlink, not supported`), so `commit` and `tend` check nothing in while one exists. ## The lint The lint reads the files that would be checked in: the new and edited files of the working copy, never the deleted ones. It reports each problem as `PATH:LINE: what` on stderr, or `PATH: what` when it concerns a whole file, and it never changes a file. `suit lint`, `suit commit` and `suit tend` run it; a commit or a tend with a problem checks nothing in (exit 3). 1. Token-shaped values. A line holding any of: `-----BEGIN` followed on the same line by `PRIVATE KEY-----`; `AKIA` and 16 capital letters or digits; `ghp_`, `gho_`, `ghs_` or `github_pat_` and at least 20 letters, digits or `_`; `sk-` and at least 20 letters, digits, `-` or `_`; `xoxb-`, `xoxp-` or `xoxa-` and at least 10 such characters; or a word holding `token`, `secret`, `password`, `passwd`, `api_key`, `apikey` or `api-key` (any letter case), then spaces and quotes, `=` or `:`, spaces and quotes, and at least 24 letters, digits, `+`, `/`, `=`, `-` or `_` with no space. A value that starts with `$`, `<` or `{{`, or is one character repeated, is a reference and is allowed. 2. Attribution text. A line holding `co-authored-by:`, `generated with`, `generated by ai`, `claude-session:`, `written by ai` or `assisted by ai`, in any letter case. 3. Symlinks. 4. A skill folder (`skills/NAME/...`) with no `SKILL.md` (`skills/NAME: no SKILL.md`), or a `SKILL.md` whose first line is not `---` (`skills/NAME/SKILL.md:1: no header`). Folders removed whole are not looked at. 5. A file larger than 4 MiB is refused by name and not scanned; a line longer than 64 KiB is refused. A file with a NUL byte in its first 8 KiB is binary, and rules 1 and 2 skip it. `suit.lint`, at the wardrobe's top, adjusts rules 1 and 2. Each line is `allow PATH` (that file is exempt) or `forbid TEXT` (an extra literal, any letter case, up to 200 bytes). Paths are relative to the top, with no `.`, `..` or empty part. There are no blank lines or comments; a line that is neither is a problem reported as `suit.lint:LINE: ...`. `suit.lint` is not scanned for its own forbidden text. ## suit tend `suit tend NAME` is what a timer calls once an hour. With no local changes it does nothing and writes nothing. With changes it runs the lint. If that is clean it checks the changes in with the message `Edits on MACHINE: N files` (`this machine` when the machine has no name). If not, it checks nothing in, prints the report and exits 3. A check-in that deletes more than 5 files and more than a fifth of the files the wardrobe tracks is held: `tend` and plain `commit` check nothing in, say `held NAME: N of M files deleted` and exit 4. M counts the files of the version the working copy is at. `suit commit NAME -m TEXT --confirm-deletions` checks such a change in on purpose. ## The remote and the login `$SUIT_HOME/remotes` holds one line per wardrobe, `NAME URL`. The address is `file://ABSOLUTE/PATH`, `http://HOST[:PORT]/PATH` or `https://HOST[:PORT]/PATH`, and carries no user name or password: `suit remote` refuses one and never repeats what it was given. `suit remote NAME` prints the address (exit 1 when none is set); `suit remote NAME --none` clears it. The file is parsed strictly (256 lines, 1280 bytes a line, 64 KiB), written beside and renamed. An https remote may have a CA file of its own, for a self-hosted server whose certificate no public CA signed: `suit remote NAME URL --ca FILE` (or `suit clone NAME URL --ca FILE`). `$SUIT_HOME/cafiles` holds one line per wardrobe that has one, `NAME PATH`, PATH absolute, printable, no space, at most 1024 bytes; it is parsed as strictly as `remotes` and written beside and renamed. The file is read when it is set, and refused (exit 2) if it holds no certificate suit can use; `--ca` with an address that is not `https://` is refused too. Setting the remote again without `--ca`, or `--none`, forgets the CA file. `suit remote NAME` prints the address and, when there is one, a second line `ca PATH`. Before reading a secret (`login`, `logout`, `sync`, `clone`, `tend`) suit turns off core files for itself (`RLIMIT_CORE` 0), so a crash cannot leave the secret on disk; if it cannot, it stops with exit 1. `suit login NAME USER` reads one line from standard input, 1 to 256 printable characters with no space, and writes `$SUIT_HOME/credentials`, one line `NAME USER SECRET`, mode 0600. The secret lives there and nowhere else: it is not in an address, an error message, the remotes file, the attention file or a log, and it is wiped from memory after use. Suit refuses to read or write the file when any group or other permission bit is set (`chmod 600` it). `suit logout NAME` removes the line. A `file://` remote needs no login. ## suit sync `suit sync NAME` uses libfossil's own sync client, over `file://` (which runs stock `fossil test-http`, so `fossil` must be on the path), `http://` or `https://` (see "https" below). 1. No remote set: nothing is done, exit 0. 2. Pull. A failed pull leaves the store as it was, says `sync NAME: HOST failed: ...` and exits 17 (18 when the secure connection failed, 19 when the remote refuses the login). Nothing goes in the attention file for a first failure. 3. Local changes in the working copy: nothing is updated, the message is `local changes: run suit commit or wait for suit tend`, exit 12. The pull is kept; nothing is pushed. 4. Trunk moved and the working copy is clean: the safe update (dry run, suit's file writer, the journal). 5. A fork (another open trunk leaf that this working copy has neither built on nor merged) is tried as a dry run. A file changed on both sides, a binary or symlink both sides touched, a file added over an untracked file, and a file one side changed and the other deleted all count as conflicts. With none, the merge is made and checked in as `Merge edits from MACHINE`. With any, no file changes, no conflict marker is written, the attention file gets `conflict NAME: N files changed both here and on the remote` and the exit is 13; the local check-ins are still pushed, since a fork on the remote loses nothing. A merge that changes no file cannot be checked in through libfossil; the fork then stays open. 6. Push. Every branch of the repository travels: sync and clone are of the whole repository, so the branches `upstream-NAME` ([upstreams.md](upstreams.md)) go to the remote and come back on the other machines. The fork in step 5 is only another open leaf of *trunk*, so an upstream's branch, whose check-ins are tagged with their own branch name, is never taken for one. An accept records itself in the tracked file `upstreams/NAME` of its merge check-in, so that check-in is never empty, and merges against the check-in that file names, not the newest common ancestor (upstreams.md, "The record"). The fork merge here keeps libfossil's own choice of ancestor. `tend` runs the sync after its check-in or when there was nothing to check in; a lint failure or a held deletion stops it first. ## https `sync`, `clone` and `tend` speak https themselves: libfossil does the HTTP and suit supplies the connection (`src/tls.c`), with BearSSL compiled in. Nothing else is needed on the machine but a certificate bundle. - TLS 1.2 only, ECDHE key exchange only, AES-GCM or ChaCha20-Poly1305 only: no RSA key exchange, no CBC. A server that offers nothing else is refused with exit 18 and `TLS alert 40`. BearSSL has no TLS 1.3; a server that speaks only TLS 1.3 answers with alert 70, and the message says that it may offer only TLS 1.3. - The certificate chain, its dates and the host name are checked before libfossil writes a byte of the request, so the login goes only to the server the address names. There is no way to skip the check. - Trusted certificates are read at the start of each transfer, never compiled in: the remote's own CA file when it has one (in place of the bundle, not added to it), else the first of these that exists: the file named by `SSL_CERT_FILE`, `/etc/ssl/cert.pem`, `/etc/ssl/certs/ca-certificates.crt`, `/etc/pki/tls/certs/ca-bundle.crt`, `/etc/ssl/ca-bundle.pem`. A file is PEM, at most 1 MiB and 512 certificates; objects that are not certificates are skipped, and so is a certificate BearSSL cannot use (an unsupported key type). With none of them there, or one that holds no usable certificate, the transfer stops with exit 18 and a message naming the files it tried. - A certificate file decides whom suit trusts, so it must be one nobody else could have changed: a regular file (not a FIFO, a device or a folder), owned by you or root, that group and others cannot write, in a folder that passes the same test (so nothing in `/tmp` or another shared folder). A remote's CA file may not be a symbolic link; `SSL_CERT_FILE` and the system's bundles may, since systems ship them as links. Its path is absolute. A file that fails is refused with exit 18 at a sync, and with exit 2 when `--ca` sets it. - Exit 18 is a failed secure connection: no usable certificates, the handshake, a certificate that is untrusted, expired or for another host, or a TLS protocol error. Exit 17 is the network: no name, refused, unreachable, dropped, timed out, a reply cut short, an HTTP error. Exit 19 is a refused login. - Limits: a name lookup, a connect, a read or a write that makes no progress for 30 seconds fails, and the whole command (a sync's pull and push together) fails after 10 minutes. The name lookup runs in a child process, so that it too has a time limit; the child is killed when it is up. - A redirect is refused, never followed: it could take the login to another host. The message names the address it points to and says to set it with `suit remote NAME URL` if you trust it. - Replies with a Content-Length, chunked replies and replies that end where the connection ends are read; the last kind only after the server's TLS close_notify, since without it the reply may be cut short. - Not supported: proxies (`https_proxy` and `HTTPS_PROXY` are ignored), client certificates, TLS 1.3, IPv6 address literals, and certificates issued to an IP address rather than a host name (BearSSL matches host names only). ## suit clone `suit clone NAME URL` gets a wardrobe onto a machine that has none of it. It clones the repository at URL with libfossil (`fsl_clone`, over `file://` or `http://`, using the login saved for NAME if there is one, so a private wardrobe can be cloned), into `$SUIT_HOME/wardrobes/NAME.fossil.clone`, and renames it to `NAME.fossil` only when it is complete. Then it opens the store at trunk's tip, as `suit store open NAME` does, and records URL as NAME's remote. It refuses, changing nothing: exit 20 when NAME is already a wardrobe or a store here (it never overwrites); exit 2 for a name that is not one, or an address `suit remote` would refuse (one carrying a user name or password); exit 18 when the secure connection fails and 2 for a `--ca` that is not an absolute path or goes with an address that is not `https://`; exit 17 when the remote is missing, is not a repository or cannot be reached, and 19 when it refuses the login. A failure at any later step removes the repository file, the store and any partial clone, and writes no remotes line. ## suit tend with no name `suit tend` with no NAME tends each wardrobe in `$SUIT_HOME/wardrobes` (a file `NAME.fossil` with a valid name), in name order, one after another: for each, the same tend as `suit tend NAME`. One wardrobe's failure does not stop the others. For each that did not end clean it prints `suit: tend NAME: did not end clean, exit CODE`, after what that tend printed. The exit is 0 when all were clean, else the highest code any returned. With no wardrobes it prints nothing and exits 0. More than 1024 wardrobes is an error (exit 1) and nothing is tended. After the last wardrobe it runs the usage scan once ([usage.md](usage.md)), if a harness in the wardrobes' configs has `sessions`, and prints its one line. The scan does not change the exit status: a failure is reported (`suit: tend: the usage scan did not finish, exit N`) and nothing else is affected. With no harness that has `sessions`, and with no wardrobe config, it prints nothing. `suit-run`, the per-minute program, does not scan. ## Repeated sync failures `suit tend NAME` counts the syncs that fail to use the remote (exit 17, 18 or 19) in `$SUIT_HOME/NAME.syncfail`: 1 to 6 digits and a newline, parsed strictly (a file that is not that is an error naming it) and rewritten beside and renamed. At 3 failures in a row it writes `sync NAME: failing since N tries: HOST` to the attention file, with N growing on every further failure (it stops counting at 999999). HOST is the address's host and port, or for `file://` the path; never a secret, and never the rest of an `http://` address. Any other result of the sync, including a pull that ended at local changes or a conflict, clears the count and removes the line. ## The attention file `$SUIT_HOME/attention` holds what needs you. An item is a header line, then the lines that belong to it indented by two spaces: `lint NAME` with one problem per line under it, `held NAME: N of M files deleted`, or, for an upstream, `upstream NAME: update waiting for review` or `upstream NAME: N files conflict` ([upstreams.md](upstreams.md)). The first word is the item's kind; `tend` only replaces and removes the items of a wardrobe, never an `upstream` item that has the wardrobe's name. `tend` writes it beside, syncs it and renames it, replaces the item of the same kind and name, and keeps other wardrobes' items. When a later `tend` checks in, or finds nothing to do, it removes that wardrobe's items, and removes the file when it is empty. `suit status` prints the lines under `needs you:`. ## 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.