Artifact 93e94302a8cbcc2ac8b6484751197d0ed212dc4290af4393ce6d7880f6e16af2:
- File
docs/upstreams.md
— 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: 12892) [annotate] [blame] [check-ins using]
Upstreams
An upstream is a source of assets that someone else maintains (vocabulary.md). Its files come into a wardrobe from a folder on disk, wait there for review, and are merged into trunk. A local fix survives an update, and an update that would overwrite one waits for you.
This page is part one (phase 8c-1): taking from a folder. Fetching an archive over HTTPS is part two and is not built.
The model
- Each upstream has a branch of its own,
upstream-NAME, in the repository of the wardrobe whosesuit.confdefines it (conf-format.md, "More than one wardrobe"). Branches travel with the wardrobe:suit sync,suit tendandsuit clonecarry every branch, so a take on one machine is seen on the others. - The branch holds only that upstream's files, at
INTO/ENTRY/...for each entry (file or folder) of the folder read. Its first check-in has trunk's first check-in, the empty one every wardrobe starts with, as its parent, so trunk and the branch share an ancestor and a later merge is three-way. Each take after that is one check-in on top of the branch's tip. - Updates merge into trunk, in the working copy, after a dry run. A file you edited and the upstream changed on a different line merges; the same line is a conflict, and nothing is changed.
- An update waits for review unless the upstream says
trust = auto. - Taking never touches the working copy. The check-in is built from a deck
(libfossil's own calls,
fsl_deck_save) in the wardrobe's repository, with no checkout, so your edits, new files and the files suit placed stay as they are. Every byte of a file that suit writes into the working copy goes through suit's file writer, as for an update.
The config
[upstream mattpocock]
url = https://github.com/mattpocock/skills
pin = de4f182c30876a2460ca307e2f601b9b892527e5
path = skills/engineering
into = skills
trust = review
| Key | Meaning | Default |
|---|---|---|
url |
Where part two will fetch from. Not used by take. |
none |
pin |
A word naming the version. Required by take, at most 256 bytes. It is a label: suit cannot check that a folder matches it. It is written into the check-in's comment. |
none |
path |
The folder of the upstream to read, relative to FOLDER, with no .. part. |
the folder's top |
into |
Where the files land in the wardrobe: a relative path of names, at most 256 bytes, no empty, . or .. part and no part that starts with a dot. |
skills |
trust |
review or auto. |
review |
An upstream that carries two kinds of asset is written as two sections that
share url and pin, one for each into.
Commands
| Command | Does | Exit codes |
|---|---|---|
suit upstream NAME take FOLDER |
Checks the files of FOLDER in on the branch. With trust = review leaves an item in the attention file. With trust = auto goes on as accept does. |
0, 1, 2, 3 lint, 12, 13, 15 |
suit upstream NAME diff |
Prints what accept would change in trunk. Changes nothing. |
0, 1, 2, 12, 15 |
suit upstream NAME accept [--theirs PATH] [--mine PATH]... |
Merges the branch's tip into trunk. | 0, 1, 2, 12, 13, 15 |
suit upstreams |
One line for each upstream of every wardrobe. Changes nothing. | 0, 1, 2, 15 |
Exit 2 is a usage or config error: an upstream the config does not define
(the message names it), a missing pin, a path with a .. part or an
absolute one, a --theirs or --mine path that is not a conflict it can
settle. Exit 1 is any other error (a folder that cannot be read, a symlink, a
limit, a clash). Exit 3 is a lint finding, 12 is local changes in the working
copy, 13 is a conflict, 15 is an unfinished update (store.md, "The
journal and repair").
take
FOLDER is a folder on disk. With path set, the folder read is
FOLDER/PATH, which must exist and be a folder.
- Names that start with
.are skipped at any depth, so.gitnever comes in. - A symlink is refused: the take fails, naming the link. Only regular files and folders are taken; a fifo or a socket is refused the same way. The executable bit of a file is kept.
- At most 4096 files and 64 MiB in all (
UPSTREAM_FILES_MAX,UPSTREAM_BYTES_MAX). Over either, nothing is checked in and the message says which. A path is at most 512 bytes insideINTO, and folders nest at most 32 levels, counting the folder read as the first; over either, the take fails. - A folder that holds no file to take (nothing, or only names that start with a dot) is refused.
- The lint that runs at check-in runs on the files to be taken, with the rules
of the wardrobe's
suit.lint(store.md, "The lint"), and the skill folder rule applies to what lands underskills/. A finding stops the take, listed as the lint lists it, with exit 3. - A file the take would add at
INTO/...that trunk already has, and that is not in the tree of the last check-in on this branch, is a clash: the take fails naming the file, with exit 1. If another upstream's branch holds the file the message names that upstream. Two upstreams may not supply the same path. Nothing is changed. - If the files, their modes and their content, are the branch tip's, nothing
is checked in:
upstream NAME: no change, exit 0. - Otherwise one check-in on
upstream-NAMEwith the commentupstream NAME at PIN. Files the upstream no longer has are removed on the branch. - With
trust = review:upstream NAME: update waiting for review, once in the attention file for the upstream (replaced, never repeated), and on standard output. Withtrust = auto: the same item is written, then the take goes on asacceptand removes it when that merges; a conflict leaves the item described below and exits 13.
The take is one transaction. A lint finding, a clash, or a failed write leaves the repository, the working copy and the attention file as they were.
accept
Merges the tip of upstream-NAME into trunk, in the working copy of the
wardrobe that defines it, with the discipline of the fork merge in
suit sync (store.md).
- Nothing taken yet: exit 1. The working copy is not at trunk's tip: exit 1,
run
suit store update NAME; the merge is made at trunk's tip so that its check-in builds on trunk and never forks it. - The working copy's
upstreams/NAMEalready names the branch's tip:upstream NAME: nothing to accept, exit 0. A stale attention item for the upstream is dropped. - Local changes in the working copy stop it:
local changes: run suit commit or wait for suit tend, exit 12. - A dry run. A file changed on both sides merges when the changes do not overlap (a line-level three-way merge, as libfossil does it) and is a conflict when they do. Also conflicts: a binary file both sides changed, a file one side changed and the other deleted, and a file added over an untracked file.
- No conflict: the merge is made through suit's file writer and the journal,
the record
upstreams/NAMEis written (below), and the merge is checked in asMerge upstream NAME at PIN, where PIN is the pin the branch was taken at. The attention item is removed. - Any conflict: no file changes, no conflict marker is written anywhere, the
attention item becomes
upstream NAME: N files conflict,conflict PATHis printed for each, in byte order of path, and the exit is 13. --theirs PATHtakes the upstream's version of a conflicting file and--mine PATHkeeps trunk's. Each can be given more than once, up to 64 paths for each, and the rest is merged. It succeeds only if every conflict is named. With conflicts left, those are listed and counted and nothing changes. A PATH that is not a conflict it can settle (not in conflict at all, or a file added over an untracked file, which the merge would overwrite) is an error, exit 2, and a PATH named by both is a usage error.
--theirs and --mine first let the merge write the files, with markers in
the ones that overlap, then replace each settled file with the chosen
version. The journal covers a stop part way, as for an update.
diff
One line for each file accept would change in trunk, in byte order of path:
add PATH, change PATH, remove PATH or conflict PATH. It prints the list
only. A unified diff of trunk's version against the merged result is not
printed: libfossil can merge and diff text, but a merged result only exists
once the merge has written files, and diff changes nothing. The exit is 0
even when there are conflicts, since the lines say so. The same checks as
accept apply first (nothing taken, not at trunk's tip, nothing to accept,
local changes).
upstreams
One line for each upstream of every wardrobe, in byte order of name:
NAME: STATE (taken PIN_TAKEN, config PIN)
PIN_TAKEN is read from the comment of the branch's tip and PIN is the
config's (none when it has none). STATE is one of:
never taken: no branch yet (the line isNAME: never taken (config PIN)).current: the working copy'supstreams/NAMEnames the branch's tip.waiting for review: it does not, or there is no such file or it is malformed.conflict: it is not, and the attention file holdsupstream NAME: N files conflict.
The record
Every accept that succeeds writes one small tracked file in the wardrobe,
upstreams/NAME: the full hash of the upstream-NAME check-in that was
accepted, a space, its pin and a newline. It is written through suit's file
writer after the merge and any settling are applied and before the check-in, and
is part of the merge check-in, so that check-in always changes at least that
file and libfossil's refusal of an empty check-in cannot arise. It is how suit
knows an upstream is current: the file names the branch's tip, whatever the
merge did, and it travels with the wardrobe, so another machine sees it after
suit sync. It is not decided by asking libfossil whether the tip is an
ancestor, because a merge settled with --mine can be checked in without a
merge parent (observed in the library's plink table), which would leave the
upstream waiting for ever. A missing or malformed file means never accepted;
the next accept rewrites it. The lint passes it, a take does not treat it as a
clash (it is in no upstream's into unless you point into at upstreams),
and placing reads only the skills, agents and commands folders, so it is
never placed. diff does not list it.
The attention file
One item for each upstream, replaced and never repeated (store.md, "The attention file"):
upstream NAME: update waiting for review, from a take.upstream NAME: N files conflict, from anacceptthat found conflicts. N counts the ones left after--theirsand--mine.
A clean accept removes it. The item belongs to the machine that took: another
machine sees the update through suit upstreams, and a machine whose item is
stale after an accept elsewhere clears it with suit upstream NAME accept
(nothing to accept). An upstream and a wardrobe that share a name share an
item key, so suit tend of that wardrobe also drops the item; the next take or
accept writes it again.
Going back
There is no command that undoes an accepted update yet. suit back undoes an
update by the undo record libfossil keeps for a merge, and that record ends when
the merge is checked in, so after an accept, as after any suit commit,
suit back NAME says it cannot go back (exit 14) and changes nothing. Today an
accepted update is undone by editing the files (or restoring them from an older
version of the wardrobe) and committing; the record keeps naming the accepted
tip, so the upstream stays current until a newer take is accepted.
Limits of the library
- A file one side deleted and the other changed is not reported by libfossil's
merge: it drops the file the upstream deleted even if you changed it, and
leaves out one you deleted and the upstream changed. Suit finds both by
comparing the common ancestor's files with each side's, and counts them as
conflicts.
--mineand--theirssettle them. - A merge settled with
--minecan be checked in with no merge parent, so a later take is merged against the older common ancestor and may conflict again on the same lines. Settle it again, or edit the file to match.
Part two
Not built, and waiting on HTTPS (the same transport as suit sync to an
https:// remote): suit upstream NAME fetch will download the archive at
url for the pinned version, check it against a checksum kept in a second key,
unpack it and take it as take does, and suit tend will look for new
versions by itself. Everything on this page works the same on what it takes.