steid

@jamesgill /

steid/plans/progress.md
Markdown185.6 KBRendered·Source·Blame·History·Raw
1# Progress
2
3## This attempt (#3, Topcoat)
4
51,436 tests. Active work in [current.md]current.md.
6
7### 0.8.2 cut · 2026-10-21, not published
8
9Launch phase 2's Steid fixes, as one release: 2.14, decision 4, 2.18 (both halves) and
102.15 with the author's two follow-ups of 2026-10-21. Records below and in
11[releases.md]releases.md.
12
13- **What the cut changed:** `Cargo.toml` and `Cargo.lock`, `install.sh`'s default and
14 its example, and the README's manual-install `VERSION=`, all to 0.8.2; a `RELEASES` row
15 and a `releases.md` row. **No migration**, so the row reuses `RELEASED_0_8_0` and its
16 digest (`6761cb04…`), and `migrations/` is unchanged since 0.8.1's cut.
17- **Also in it:** rustls 0.23.46, rustls-webpki 0.103.16 and webpki-roots 1.0.10, the
18 patch releases for six advisories published from 2026-10-14 (its own commit before the
19 cut).
20- **Not built and not published.** Publishing is the author's: `./release.sh --all`,
21 then `./deploy.sh --publish-s3-only`. The pin moved in the cut, so the publish uploads
22 the matching `install.sh`; uploading it alone first would send fresh installs to a 404.
23- **A rebase had dropped two records.** `594b760` (login CSRF, rebased) deleted the 2.15
24 and DNS-rebinding sections of this file while adding its own; `current.md` linked to
25 both. They were restored from `a13b0b1` before the cut. When rebasing a branch that
26 edits `progress.md`, diff the result's deletions, not only its additions.
27
28### The seed, the installer's quoting, and login CSRF · 0.8.2
29
30Launch phase 2's Steid fixes that a Steid Cloud tenant takes (decisions 4, 9 and 11).
31Built on the `seed-and-login` branch; cut into 0.8.2 on 2026-10-21, which adds no
32migration.
33
34- **2.14: the whole seed is checked before the first write.** `seed_owner` saved the
35 owner, then tried the organisation. A reserved, malformed or taken organisation handle
36 was refused *after* the owner committed: boot one exited 4, systemd restarted it, and
37 boot two found an owner, called the instance claimed (`seed_owner_on_boot`'s
38 `is_claimed` check) and served with no organisation and no home. `check_seed` now runs
39 first: `Email::new` and `Organization::new` for both handles (the validators the writes
40 run, so it cannot pass what they would refuse), equal handles refused, and
41 `find_by_name` for both. A refusal writes nothing, so every boot refuses alike.
42 - **Equal handles answer `AlreadyExists`**, as they did when `create_organization`
43 found the owner's personal organisation one write later, so the message an operator
44 sees is unchanged.
45 - **Still open:** a storage failure *between* the owner's writes and the
46 organisation's can half-seed, because they share no transaction (launch 2.20).
47 - **Proved by failing first:** with the `check_seed` call commented out, the five new
48 unit tests and `a_refused_organisation_is_refused_again_on_the_next_boot` (two boots
49 against one SQLite file) fail; with it, they pass.
50- **Decision 4: `install.sh` writes every `steid.env` value so both readers agree.**
51 systemd reads the file for the service; the Steid Cloud console runs `set -a;
52 . /etc/steid/steid.env` in sh, as root, before every SSM command. `STEID_OWNER_EMAIL`
53 was written bare, so `o'brien@acme.com` (legal in Google Workspace) gave systemd the
54 right address and the console `Syntax error: Unterminated quoted string`. Every console
55 command on that box would have failed while Steid itself ran fine. Now `env_quote`
56 writes all five values (owner email, handle, org, org name, operator token) as
57 `"…"` with `"`, `\`, `$` and backticks backslash-escaped, and `check_env_value`
58 refuses what cannot be written so they agree.
59 - **What the containers proved**, by writing each value four ways and reading it
60 back through sh's `.` and a oneshot unit's `EnvironmentFile=`, byte for byte, on
61 Debian 13 (systemd 257, dash, arm64) and Debian 12 (systemd 252):
62 - escaped double quotes agree on all 26 valid-UTF-8 cases: `'`, `"`, `$HOME`,
63 `${PATH}`, `$(…)`, backticks, one and two backslashes, a trailing backslash, `\n`
64 as text, `#`, `;&|`, `=`, leading and trailing spaces, accents, tab, LF, CR;
65 - bare values break sh on spaces, quotes, `$`, backticks and backslashes, and break
66 systemd on backslashes, padding and line breaks;
67 - plain double quotes (the old `--owner-org-name`) break on `"`, `$`, backticks and
68 backslashes;
69 - `'…'\''…'` breaks systemd on any `'`: after a closing quote it reads `'`
70 literally, giving `o''brien@acme.com'`. So no single-quoted spelling holds a `'`;
71 - **systemd refuses the whole file** over one value that is invalid UTF-8, a
72 surrogate, a noncharacter (U+FDD0–FDEF, U+xFFFE/xFFFF) or past U+10FFFF:
73 "Failed to load environment files", `Result: resources`, so the service never
74 starts. sh reads all of them. glibc's `iconv` catches only invalid UTF-8 and
75 surrogates, hence the byte-pattern `grep` beside it. Tested both ways: the guard
76 refuses exactly those, and accepts emoji, CJK, a mid-string BOM, C1 controls and
77 U+10FFFD, which systemd reads.
78 - **Control characters are refused by choice**, not because the parsers disagree:
79 both read a quoted tab or line break alike, but `set_env_secret`'s `grep -v` and
80 the console's `sed` for `STEID_PUBLIC_URL` read the file line by line.
81 - A comment ending in `\` does **not** continue in systemd 257, so the handle in the
82 `reset-password` comment line is harmless; checked with a handle of `ada\`.
83 - **End to end, on Debian 13:** the real `install.sh` run with an org name holding
84 `'`, `"`, `$(id -u)`, backticks, `${HOME}`, backslashes and padding, and a token
85 holding `$`, `"`, a backtick, `\` and `'`: the console's exact prelude (under
86 `set -eu`) and the service's environment both read all five as given. HEAD's
87 `install.sh` with `o'brien@acme.com` reproduced the console failure. Bad values
88 exit 1, name the flag, never print the value, and write no `steid.env`.
89 - **How it was run, for next time.** Docker Desktop's disk was full, so the container
90 boots from a tmpfs overlay over a read-only image and installs systemd into it, then
91 `exec chroot … /lib/systemd/systemd`. The local `debian:13` image is amd64, and under
92 emulation systemd 257's executor fails every exec (255/EXCEPTION); the arm64 Debian
93 13 image was the control plane's release builder. dbus would not start there, so the
94 probe is a oneshot unit started with `systemctl` (private socket), not `systemd-run`,
95 with `StartLimitIntervalSec=0` or the failures trip the start limit.
96 - **For 2.13**, which will read this file from Rust: `dotenvy` 0.15 accepts `\"`,
97 `\\` and `\$` inside double quotes but rejects `` \` `` with a parse error, and it
98 expands an unescaped `$`. A value holding a backtick would fail loudly there, not
99 silently. Its reader must accept what is written here.
100 - **Not done:** the installer moving into the binary (launch 5.8) is the full cure;
101 this is the cheap guard. Older systemd (Debian 11, Ubuntu 20.04) was not run; its
102 container did not boot here.
103- **2.18, login CSRF: refused by provenance, not by a cookie** (decision 11). Topcoat's
104 `OriginLayer` already refused `Sec-Fetch-Site: same-site`/`cross-site` and a foreign
105 `Origin`, and let a POST carrying *neither* through as a non-browser client. That
106 reasoning (no ambient cookies to forge with) does not hold at sign-in, where the
107 attacker supplies the credentials and steals the browser. `csrf_verified_signed_out`
108 refuses that case with the usual 403 sentence. It runs after `throttled`, before the
109 password is hashed, and `/auth/login` left `EXEMPT`; the scan counts it by name.
110 - **It also runs `verify_origin` itself**, so the check holds if the layer is ever
111 turned off. While the layer is on, that changes nothing.
112 - **Why no pre-session cookie**: it is a second cookie, with its own lifetime and
113 `SameSite` question, for one form; and on the per-boot secret every restart would
114 403 the sign-in form open on someone's screen. In 0008's note.
115 - **The cost:** a bare HTTP client can no longer sign in without adding
116 `Sec-Fetch-Site: same-origin` or its own `Origin`. Nothing in either repository
117 does; `tests/http.rs` now sends it from a `post_form_from_page` helper.
118 - **Tested over HTTP with good credentials each time**, so what is refused is the
119 origin and never the password: neither header 403 with no session cookie;
120 `same-site` 403; `cross-site` 403; a foreign `Origin` 403; the instance's own
121 `Origin` alone 303 to `/`; `same-origin` 303 to `/` with a session. With the call
122 removed, the neither-header case signs in (303) and the test fails.
123 - **Against a running binary** (throwaway database, `STEID_INSECURE_COOKIES` on the
124 command line): `curl` with good credentials and no header 403 and no cookie, with
125 `Sec-Fetch-Site: same-origin` 303 and a session. Headless Chrome submitting the real
126 sign-in form signed in and landed on `/ada`. A forged form on a `data:` page never
127 reached the server, so the browser's cross-site case was not observed; the HTTP
128 test covers it.
129
130### DNS rebinding closed · launch 2.18, for 0.8.2
131
132Launch 2.18's rebinding half ([decision 12]../../plans/launch.md#phase-2-correctness-and-safety).
133Cut into 0.8.2 on 2026-10-21 with 2.14, 2.15 and the login-CSRF half.
134
135- **One list of local names, in `domain::net`.** `names_local_network` holds the names
136 and suffixes `WebhookUrl` already refused (`localhost`, `.local`, `.internal`,
137 `.localdomain`, …), and `ImportSource` now refuses them too: it had refused only
138 `localhost` and `.localhost`, so an mDNS `steid.local` reached the resolver. A trailing
139 dot is ignored, so `localhost.` is refused when it is typed rather than one layer
140 later.
141- **`ImportSource::port()`**, because the pin has to name the port git dials. A written
142 port must be digits, 1 to 65535 — the spelling curl reads. Rust's `u16` parser also
143 takes `+443`, which curl refuses, and a port the two read differently is one the pin
144 would not cover.
145- **Webhooks: the address checked is the address dialled.** `PublicOnly` wraps `ureq`'s
146 `DefaultResolver` and refuses any answer that is not public, through
147 `Agent::with_parts`; `check_resolves_publicly`, the separate lookup before the request,
148 is gone. Nothing is set by hand: `ureq` takes `Host` and the TLS server name from the
149 URL (`ureq-3.3.0/src/tls/rustls.rs:61-66`) and only the socket address from the
150 resolver.
151 - **`.proxy(None)` is load-bearing.** `ureq` reads `ALL_PROXY`, `HTTPS_PROXY` and
152 `HTTP_PROXY` by default (`config.rs:872`), and through a proxy it never calls its
153 resolver (`run.rs:381-387`), so a proxy in the service's environment would have
154 switched the whole check off.
155 - **The resolver is `ureq`'s `unversioned` API**, which may change in a minor release.
156 Not pinned around: a change breaks the build, and the listener tests fail if the
157 resolver stops being the one dialled.
158 - **The tests dial a real socket.** A fake inner resolver answers `127.0.0.1` for
159 `hook.test`, which never resolves: refused, the listener's backlog stays empty;
160 allowed, the listener sees `Host: hook.test:PORT`. The proxy test runs itself again
161 as a child with `HTTPS_PROXY` set, because changing a test's own environment needs
162 `unsafe` in Rust 2024 and the plain assertion passed with or without the setting.
163 Each was checked by breaking the code it guards.
164 - The refusal reads as before on the deliveries page: "`host` resolves to `address`,
165 which is on this machine or its private network", unwrapped from `ureq`'s "other: "
166 prefix.
167- **Imports: the clone is pinned to the checked addresses.** `resolve_public_host` now
168 returns what it checked, and the clone carries `-c http.curloptResolve=host:port:addr[,addr]`
169 built by `pin` (IPv6 in brackets). curl keeps `Host`, SNI and the certificate check on
170 the name and takes only the socket address from the pin, so nothing is set by hand.
171 - **The pin must name the port git dials** — curl applies one only to its exact
172 `host:port` — which is why `ImportSource::port()` exists; the check had always
173 resolved port 443.
174 - **A literal address is not pinned**: no name to rebind, curl never looks one up, and
175 an IPv6 host would need its own spelling in the pin's `host:port`.
176 - **The proxy variables are removed** from every import's git (`http_proxy`,
177 `https_proxy`, `all_proxy`, both cases): through a proxy curl never resolves the name,
178 so the pin would not be what is dialled. `http.proxy` cannot come from a config file,
179 because `git_command` reads no global or system config.
180 - **The git test:** `ls-remote` against `http://pinned.invalid:PORT/` with the pin
181 reaches a loopback listener, `Host` intact. With the key misspelt — what an older git
182 does with it — nothing arrives, which was checked. A pinned `[::1]` and a two-address
183 pin were tried by hand against git 2.50.1.
184- **Imports are refused on git older than 2.37**, the version `http.curloptResolve`
185 arrived in: git's `Documentation/RelNotes/2.37.0.txt` announces it, and 2.36.0's
186 `http.c` and `Documentation/config/http.txt` do not know the key. An older git ignores
187 an unknown key rather than failing, so it would clone unpinned. `GitFeatures` gains
188 `pinned_resolve`, read at boot like `merge_tree`, and `DiskGitImport` takes the
189 features: below the floor the import fails with "Importing needs git 2.37 or newer;
190 this server has 2.34" on the repository's failed-import panel.
191 - **Ubuntu 22.04 ships git 2.34.1**, below both this floor and merge's 2.38, though the
192 README had said 22.04 was fine for merging. It now names Debian 12 (2.39) and Ubuntu
193 24.04 (2.43). Steid Cloud tenants are Debian 13, and the container is bookworm, so
194 neither is affected.
195 - Left open: the import form is still offered on an old git, and `/api/instance` reports
196 `merge_supported` but nothing for imports.
197
198### A backup of a live instance is consistent · launch 2.15
199
200**Cut into 0.8.2** (2026-10-21) with the other Steid fixes. `steid backup` is what Steid
201Cloud's nightly archive runs and what a self-hoster's timer runs, and it copies the data
202directory while pushes and `receive.autogc` carry on. Launch 2.15 found the races by
203reading the code; each is now reproduced with real git by a test that failed on the old
204walk.
205
206- **A push between the objects and the refs.** The walk was sorted, so `objects/` was
207 copied before `packed-refs` and `refs/`. A push landing between them left `main` naming
208 a commit the archive did not hold: `git fsck` on the restore said `invalid sha1
209 pointer`. Only that boundary failed.
210- **A `pack-refs` between `packed-refs` and `refs/`.** `pack-refs` (part of `gc --auto`)
211 writes refs into `packed-refs`, then deletes the loose files. Copied packed-refs-first,
212 one landing in between dropped the branch from the archive entirely. On a repository
213 with no `packed-refs` yet — every repository until its first gc — that was every
214 boundary before `refs/`.
215- **Lock files and the push quarantine.** `*.lock` and `objects/tmp_*` were archived
216 while they existed — a restored `main.lock` refuses every push to `main` — and one that
217 went between the listing and its turn failed the backup with a bare `No such file or
218 directory`, naming nothing.
219- **The fix is git's own reading order** (`walk_order`): inside a bare repository,
220 everything else by name, then `packed-refs`, then `objects`. Git writes objects before
221 it moves a ref, and writes `packed-refs` before it prunes loose refs, so reading refs
222 first, then `packed-refs`, then objects sees every ref with its objects. A ref moved
223 away in between keeps its old commit in the reflog, which gc keeps — reflogs are on in
224 every repository (`init_bare`, imports, and the boot sweep).
225- **The comparator alone was not enough.** A repository is listed before its loose refs
226 are read, so a `pack-refs` in between creates a `packed-refs` the listing never held,
227 and the test still lost `main` at every boundary before `refs/`. `packed-refs` is now
228 looked for at its turn, as git's own reader stats it when it needs it; absent then
229 means no packed refs, which is what git would read.
230- **Repositories are found by Steid's layout**, `{handle}/{name}.git`, as
231 `DiskGitStorage` finds them, never by what a directory holds: inside a repository
232 nothing is re-read as one, because a branch may be called `objects/x`. Quarantined
233 repositories under `orphaned/` are written by nothing and keep plain sorted order.
234- **Never archived: `*.lock` anywhere, `tmp_*` under a repository's `objects/`, and
235 `*.keep` in its `objects/pack/`** (launch decision 10, `is_scratch`; the `.keep` was
236 added by the author on 2026-10-21). Git forbids a refname ending in `.lock`, and git's
237 temporary files become real only by a rename the walk then sees. All three go by name,
238 before any `stat`, so one vanishing cannot fail the backup. Outside `objects/` the
239 `tmp_` rule does not apply, and outside `objects/pack/` the `.keep` rule does not:
240 branches `objects/tmp_x` and `objects/pack/x.keep` are still archived (tested).
241- **A push's `.keep` failed backups for nothing** until 2026-10-21. receive-pack keeps a
242 push of 100 objects or more (`receive.unpackLimit`) as a pack and marks it
243 `objects/pack/pack-<hash>.keep` until the push's refs are in, so a concurrent gc leaves
244 it alone, then deletes the marker. Listed, then gone by its turn, it failed the backup
245 as "vanished". A `.keep` only asks gc not to repack, so leaving one out costs at most a
246 repack after a restore, never an object.
247 - **The test parks a real push** of 150 files in a `reference-transaction` hook: its
248 `committed` call comes after the pack and its `.keep` are out of quarantine and the
249 refs are in, and before the `.keep` goes (git 2.50). The push starts at the
250 `objects/pack` boundary, the walk lists the `.keep`, and the hook is let go just
251 before the walk reaches it. On the old rule the backup failed with "…pack-….keep
252 vanished while the backup was copying it"; now it finishes, without the `.keep` and
253 with the pack it marked.
254- **Anything else that vanishes fails the backup, naming the path** (`unreadable`):
255 "… vanished while the backup was copying it, so the archive would have been missing it
256 and was not finished". Skipping it would let a pack gc replaced mid-walk quietly go
257 missing. Every other read error in the walk names its path too.
258- **A file holds exactly the bytes it held when opened** (`copy_file`, 2026-10-21).
259 tar 0.4.45's `append_file` wrote the size it stat'ed into the header, then copied to
260 EOF (`builder.rs:687-716`), and git appends to reflogs in place. A push appending to
261 `logs/refs/heads/main` mid-copy made the entry longer than its header: nothing failed
262 at backup, and once the extra bytes crossed a 512-byte block the restore read reflog
263 text as the next header. `copy_file` builds the header from the opened file's `fstat`
264 and copies through `take(size)`.
265 - **Grown:** the first `size` bytes are archived. Git changes a file in place only by
266 appending, so they are the file a moment earlier: a reflog without its newest lines.
267 - **Shrunk:** the backup fails, naming the path and both sizes ("… shrank while the
268 backup was copying it, from N bytes to M …"). Git never truncates in place.
269 - **Sparse files are now copied whole**; `append_file` would have skipped their holes.
270 Git writes none. The database snapshot still goes through tar's own path, since
271 nothing writes it.
272 - **Tested with real pushes:** four pushes land after the reflog is opened and before
273 its bytes are copied, growing it from 126 to 630 bytes. The restore holds exactly the
274 first 126 and passes fsck; a reflog cut to half fails the backup. With the copy run to
275 EOF as `append_file` runs it, the restore failed ("numeric field was not a number …
276 when getting cksum for <reflog line>") and the truncated file packed without error.
277- **`pack_with` is the seam.** It calls a hook at two moments: with each path just before
278 the walk reaches it, so a test pushes, packs refs, takes a lock or deletes a pack at
279 one exact boundary, for every boundary the walk has; and with each file once it is
280 open and its size read, so a test grows or cuts it mid-copy. Nothing depends on timing.
281- **Left open** (in [current.md]current.md#operations): the reflog argument does not
282 cover a deleted branch. Accepted for now by the author on 2026-10-21 and recorded there:
283 what the customer would see, how rare it is, and the two cures rejected.
284
285### A rollback boots · 0.8.1
286
287Launch 1.2, Steid's half. **Cut on 2026-10-02 and not published**; the publish and the
288real upgrade-and-rollback proof are open in [current.md]current.md.
289
290- **The cause.** `migrate()` ran sqlx 0.9's `run()` with its default
291 `ignore_missing: false`. A binary started against a database a newer release had
292 migrated exited with `VersionMissing`, and systemd restarted it for ever, so a box
293 upgraded across a migration could never roll back. Expand-only made the old binary
294 *able* to read the newer schema; the default stopped it from trying.
295- **The fix is `set_ignore_missing(true)`, and it only helps a rollback *onto* a binary
296 that carries it.** 0.8.0 → 0.7.0 can still never roll back. Unknown versions are all it
297 excuses: an edited known migration is still `VersionMismatch`. Every path that
298 migrates goes through `migrate()`; `steid backup` migrates nothing.
299- **Tested in process, not against a real binary.**
300 `a_database_one_migration_ahead_still_boots` records a migration one version past the
301 embedded set, checks that sqlx's default refuses that database, then boots. With the fix
302 turned off it fails with `VersionMissing(20260927100001)`. Booting the real previous
303 release needs a Linux binary, so it is launch 5.6's.
304- **Every released migration set is pinned** — `RELEASES` in
305 `database_compat_tests.rs`, 0.5.0 to 0.8.1. Only 0.5.0's had been, and 0.8.0's cut did
306 not move the pin on, so an edit to `instance_settings` would have passed every test and
307 stopped every 0.8.0 box at the next upgrade.
308- **A cut can no longer skip its pin**: `the_version_in_cargo_toml_has_a_releases_row`
309 fails while `Cargo.toml` names a version `RELEASES` has no row for.
310- **A binary is the best evidence of what a release shipped.** `sqlx::migrate!` embeds
311 each migration's SQL and its SHA-384, so hashing each file at a commit and searching the
312 binary for those 48 bytes says exactly which bytes it checks a database against. That
313 settled two open questions for the artefacts in `dist/`: the 0.5.0 ones carry the
314 restored `create_issues` comment, not the edit in the cut commit `b942dad`, and the
315 0.7.0 ones predate `20e5b4e` entirely. Whether the *published* files are those files is
316 one `.sha256` comparison away
317 ([releases.md]releases.md#which-bytes-each-release-shipped).
318- **0.5.0 shipped one new migration, not two.** Its `releases.md` row, and the "two
319 additive migrations" in its record below, counted `create_issues`, whose only change
320 was the comment edit that was reverted.
321
322### Organisations and home · 0.8.0
323
324The first slice of milestone 7, and the first behaviour change 0010 committed to. An
325instance is now *for* somebody, and says so at its root.
326
327**Cut in `bac1a59` (2026-09-27) and published 2026-09-28**, both architectures;
328`install.sh`'s default moved to 0.8.0 in `b0c6058` once the artefacts existed. Shipped:
329the `instance_settings` table and its port; `create_organization`, `home_handle` and
330`set_home`; private by default on the create form, the import form and `import_repo`;
331`/orgs/new`, organisation settings at `/{handle}/settings`, and the root landing on home
332for everyone; setup as three screens (claim, "Who is this Steid for?", done), with
333`?token=` prefilling the claim field so a claim link can carry it; `STEID_OWNER_ORG` /
334`STEID_OWNER_ORG_NAME` on the headless seed and `--owner-org` / `--owner-org-name` on
335`install.sh`; [ADR 0011]decisions/0011-home-is-an-instance-setting.md. Out of scope,
336deliberately: members and roles UI, invitations, registration, token scopes and
337invisible mode — the rest of milestone 7. What it left open is carried in
338[current.md]current.md#open-from-080.
339
340**Done when, verified by hand on 2026-09-27:** a fresh instance can be claimed, told whom
341it is for, and land every visitor there; and a provisioned one arrives that way with no
342wizard at all. Walked as claim → wizard → `/globex` → a repository that defaulted to
343private → `/globex/settings` → an anonymous `curl -I /` answering `307 → /globex`; and a
344second data directory seeded from the environment landing on `/initech`.
345
346- **Home is an instance setting, in a table of its own.** One row, `check (id = 1)`,
347 seeded by the migration so every caller reads rather than upserts. The alternative —
348 a `home_org_id` column on `orgs` — would be null on every row but one, turn a read
349 into a scan, and invite two rows that both claim it. See
350 [0011]decisions/0011-home-is-an-instance-setting.md.
351- **The fallback is what made this shippable.** `home_handle` answers the chosen home,
352 and otherwise the old `sole_owner_handle` rule. Every instance that upgrades into this
353 has no home chosen and keeps exactly the front door it had, so the migration changes
354 nothing until somebody picks. `home_is_set` is the separate question — "did anybody
355 *choose*" — because the wizard and the checkbox want the choice, not the effect.
356- **`set_home` is gated on owning the organisation, not the instance.** The tempting
357 rule is `instance_owner`, and it is wrong: that predicate answers `false` for
358 *everybody* the moment a second user exists (see `access.rs`), which would make the
359 front door unsettable on exactly the instances that most need to set it.
360- **Personal vs organisation is derived, never stored.** An organisation is personal
361 exactly when some user's `personal_org_id` points at it. 0003 wanted an `orgs.kind`
362 column and 0004 dropped it; this is the reason not to bring it back — a derived answer
363 cannot disagree with the foreign key, and a stored one eventually would.
364- **One settings route, two pages.** `/{handle}/settings` branches on that derivation. A
365 second profile form at a URL of its own would be two forms writing one `orgs` row. The
366 Home section is on both pages, not only the organisation's: without it on a person's
367 page there is no way back to "just me" once an organisation has taken the root.
368- **The wizard needs no state of its own.** Claiming signs you in, so
369 `/auth/setup/organisation` reads back the two facts it needs — has a home been chosen,
370 is the actor the sole user — and sends anyone who has already answered to `/`. Three
371 URLs rather than one long form, and a reload cannot strand anybody.
372- **No JavaScript, so the organisation's fields are always visible** rather than
373 revealed by the radio. Steid ships no script of its own, and a `:has()` trick would be
374 the first thing on any page whose behaviour is invisible in the markup.
375- **`orgs` and `organizations` are reserved**, added while nobody held them. Reserving a
376 handle after somebody has it is a breaking change for them — 0004 says so, and this is
377 the first time it has actually bitten.
378- **Private by default** (`Visibility::default()`), read by the create form, the import
379 form and `import_repo` rather than named in each, so it is one edit. Existing rows are
380 untouched; nothing reads a default for a row that has a value.
381- **The root lands on home for everyone**, signed in or not. It used to send a signed-in
382 visitor to their own profile, which was right while an instance was one person and
383 wrong the moment it is a company.
384- **Gotcha, found while verifying by hand.** The header carries a Sign out form, so
385 `document.querySelector('form')` on any signed-in page is *that* form, not the page's.
386 A browser-driven test that clicks `button[type=submit]` signs itself out and looks
387 exactly like a broken redirect. Target the form by its `action`.
388
389### Control plane asks · 0.7.0
390
391Three capabilities the control plane's phase D0 asked for. Nothing here tells Steid it is
392managed; each is a mechanism a self-hoster gets identically.
393
394**Cut in `3f411b5` (2026-09-26) and published 2026-09-27.** `cargo audit` showed no
395vulnerabilities and the three warnings unchanged from 0.6.0 — `bincode` 1.3.3 and
396`yaml-rust` 0.4.5 unmaintained (both via `syntect`) and a yanked `chacha20` 0.10.1 (via
397`topcoat-session`), none with a fix to take. `rustix` came in as a direct dependency for
398`statvfs` and brought no new crate.
399
400**`steid restore --replace` (2026-09-26).** The refusal — "restore only into an unclaimed
401instance" — stays the default, because for a self-hoster it is the one thing standing
402between a mistyped hostname and somebody's site being replaced. A managed instance boots
403*claimed* (the boot-time owner), so it always holds a user, and without a way past the
404refusal the console's restore could never succeed at all.
405
406- **A typed choice, not a `bool`.** `RestoreMode::{OnlyIfEmpty, Replace}`, with
407 `OnlyIfEmpty` the `Default`. `restore(.., true, ..)` at a call site says nothing about
408 what is true, and these two answers are "refuse" and "destroy everything" — the pair
409 least worth guessing at. It is enforced in the application layer, where the refusal
410 already lived, rather than in the command that parses the flag.
411- **`--replace` consents to the first two checks only.** The version check still stands:
412 an archive from a newer Steid may hold a schema this binary cannot read, and no amount
413 of consent makes that work.
414- **Unpack beside, then swap.** The archive extracts into `<workspace>/incoming` first,
415 so a corrupt or truncated archive fails having touched nothing live. Only once the
416 whole extraction has succeeded does the adapter move the data directory's current
417 contents into `<data_dir>/.replaced-<stamp>/` and the staged tree into their place —
418 renames, so no bare repository can be half-copied, and both ends are on one filesystem
419 by construction (the workspace is inside the data directory).
420- **Moved, never deleted**, for the reason `GitStorage::quarantine` exists: the directory
421 may hold the only copy of somebody's objects. A consistent copy of the database that is
422 about to be thrown away is taken *into the same directory*, so the aside holds a whole
423 previous instance rather than half of one. The cost is real and is stated where it will
424 be read — `Restored::replaced` carries the path out and `steid restore` prints it with
425 the `rm -rf` — because the instance now occupies roughly twice what it did.
426- **The dot on `.replaced-` is load-bearing three times**: a handle can never start with
427 one, so the backup packer skips it, `list_repo_dirs` finds no repository under it (its
428 contents are a level deeper than the sweep looks), and the swap itself skips every
429 top-level dot entry — which is what leaves the `.backup` workspace it is running out
430 of, and any earlier replacement, where they are.
431- **The window that is not atomic** is between the swap and installing the database: the
432 repositories are the archive's and the database is still the old one. Recovery is the
433 aside directory plus the archive, both still on disk. Narrowing it further would need
434 the two halves to share a transaction, which they cannot.
435- **A restore into a running process is the operator's problem** and is said so in the
436 doc comment. The console stops the service, restores, starts it; nothing in Steid
437 checks, because there is nothing portable to check with.
438- The flag parses on **either side of the path** — the control plane renders
439 `restore --replace "$ARCHIVE"`; a person types it wherever it falls — and
440 `steid restore --replac a.tar.gz` is a usage error rather than a restore of a file
441 called `--replac`, which needed a guard on the one-argument arm.
442
443**`install.sh --operator-token <token>` (2026-09-26).** Until now cloud-init fetched the
444token from Parameter Store *after* the install, rewrote `steid.env` and restarted Steid —
445so the box served for a few seconds with the operator surface off, and anything asking
446`/api/instance` in that window got the public shape and read it as "no version".
447
448- **The one exception to "written once and left alone".** Every other setting in
449 `steid.env` is written on the first install and never touched again, so an upgrade
450 cannot revert somebody's edit. The operator token is not somebody's edit: it is a
451 machine credential held by whatever provisioned the box, it gets rotated, and a box
452 with the surface off is a box a control plane cannot see. Only a run that *passes the
453 flag* rewrites it; an upgrade without it leaves the line alone.
454- **`set_env_secret` writes the line, not a here-doc**: the replacement goes to
455 `steid.env.new` under `umask 077` and is moved into place, so the token is never
456 briefly world-readable and an interrupted run cannot truncate the env file. The value
457 is emitted with `printf '%s\n'` rather than a here-doc, because a here-doc expands
458 `$…` and backticks and the value is a token somebody else generated.
459- **The value never reaches the terminal, a log or `ps`.** No `echo`, no `say`, no `die`
460 carries it; `say` names the key only. `set -x` is off, and turning it on would print
461 this like anything else.
462- The rewrite strips the previous line *and* the marker comment above it, or a rotation
463 would stack a fresh comment every run.
464- It runs **after** the first-write/keep-existing branch and **before** the unit is
465 written and Steid restarted, which is the whole point of the change.
466- **Verified against a temporary directory**, not a real box: the variable defaults, the
467 argument parser and the whole configuration section were extracted from `install.sh`
468 and run with `CONF_DIR`/`STATE_DIR`/`INSTALL_DIR` pointed at a temp tree and `chown`
469 stubbed — the same stubbed-command approach `--backups daily` was verified with. Six
470 cases: a first install with and without the flag; an upgrade with no flag leaving the
471 file byte-identical; a later run with the flag adding the line and preserving a
472 hand-made edit; a rotation replacing the line rather than stacking one (one key line,
473 one comment, the old value gone, mode 640, no leftover `.new`); and a token full of
474 `$`, backticks, quotes and `%s` written back byte-for-byte and absent from the output.
475 `sh -n install.sh` passes.
476
477**Disk usage on `/api/instance` (2026-09-26).** The operator shape gains `disk`, an
478object of three `u64` byte counts: `data_dir_bytes`, `filesystem_total_bytes`,
479`filesystem_free_bytes`. It closes the "reports no disk, memory or cache numbers" bullet
480for the first of the three.
481
482- **A nested object, not three flat `disk_*` keys**, so the group is present or absent
483 together and a consumer tests one thing. Bytes only — formatting "12 GB of 20 used" is
484 the console's, and a number it can do arithmetic on is what it cannot get back from a
485 formatted string.
486- **Never on the public shape**, and there is a test that serialises the anonymous answer
487 and asserts the string does not contain `disk`. It says how big somebody's machine is.
488- **A seventh narrow port, `DiskUsage`.** A use case may not ask the filesystem anything,
489 and a test must not depend on the size of the disk it runs on. `InMemoryDiskUsage`
490 beside it, including an `unmeasurable()` for the case the report has to survive.
491- **`describe_instance` swallows a disk error into `None`**, deliberately and for the
492 reason `git_version` does: that same response carries `claimed` and the version, which
493 are what a control plane is polling for, and a data directory that cannot be stat'd
494 must not take them down. The reason goes to standard error.
495- **`rustix`, not `libc` or `nix`, for `statvfs`.** `std::fs` cannot answer it at all.
496 `libc::statvfs` needs `unsafe`, and this codebase has none; `nix` is not in the tree.
497 `rustix` already is — `tempfile` and `tar`'s `xattr` both pull it with the `fs` feature
498 — so the direct dependency added **one line to `Cargo.lock` and no crate to the build**,
499 and it is a safe wrapper. `default-features = false`, features `fs` and `std`.
500- **`f_frsize`, not `f_bsize`**: POSIX says the block counts are in fragments, and
501 `f_bsize` is the preferred I/O size, which is not the same number on every filesystem.
502 **`f_bavail`, not `f_bfree`**: the difference is the reserve kept for root, and Steid
503 does not run as root, so `f_bfree` would promise space it cannot have. Stat'd against
504 the *data directory*, not `/`, because state is routinely its own volume.
505- **The walk is the expensive half and is cached for a minute.** Timed on the author's
506 laptop against a synthetic tree of the shape a forge really has — 20 repositories ×
507 1,000 loose objects, 20,000 files, 78 MB — at **115–160 ms**, and a real 4,150-file
508 `.git` at **13 ms** warm (the first cold pass was 148 ms). Uncached, an operator poll
509 every few seconds would be the most expensive thing the instance does. One
510 `WalkingDiskUsage` in app context, or the cache remembers nothing — the same
511 composition-root decision `CatFilePool` and the highlight cache needed.
512- **The walk counts everything under the data directory**, quarantined and `.replaced-…`
513 directories included. It is what the instance is *costing*, not what it is usefully
514 holding, and the gap between the two is exactly what somebody looking at a full volume
515 needs to see.
516- **Apparent size (`len()`), not blocks used** — it matches what a backup of the
517 directory would weigh, which is the comparison somebody sizing a volume makes. Never
518 follows a symlink (`DirEntry::metadata` does not traverse), never fails (an unreadable
519 directory contributes nothing and the walk carries on), and is iterative so a
520 pathological tree cannot overflow the stack of a thread that is only counting bytes.
521- `how_long_the_walk_takes` is an `#[ignore]`d benchmark in the module, driven by
522 `STEID_WALK_BENCH=<dir> cargo test --lib -- --ignored --nocapture`, so the measurement
523 above can be repeated rather than believed.
524- **No `/metrics` gauge.** The consumer is a console showing one instance's storage;
525 putting it on the scrape would mean a walk on the collector's schedule too.
526
527### Releases move to `releases.steid.dev` · done (2026-09-20)
528
5290.6.0 is published from **`https://releases.steid.dev`** — the `steid-releases` bucket
530behind CloudFront — instead of from `jpgill.dev`, which keeps serving the same files as
531a mirror. The reasoning is [decision 0009]decisions/0009-releases-from-releases-steid-dev.md;
532what is worth not rediscovering:
533
534- **The version was not bumped.** `Cargo.toml` and `install.sh` had said 0.6.0 since the
535 boot-time owner landed, and no artefact was ever cut for it — `jpgill.dev` still served
536 0.5.0 as the newest. So 0.6.0 is published as-is. Bumping to 0.6.1 would have burned a
537 number to record a change of URL that nobody had downloaded.
538- **`--publish-s3-only` exists because the mirror needs ssh to a live website.** Cutting
539 a release and touching the author's box are separate decisions, and before this they
540 were one flag. `--no-mirror` is the same separation on a deploy that is also publishing.
541- **Content types are set explicitly on upload** (`--no-guess-mime-type` plus
542 `--content-type`). The CLI's guess labels a `.tar.gz` with `Content-Encoding: gzip`;
543 a browser then decompresses it on download and the `.sha256` beside it no longer
544 matches — a failure that reads as tampering rather than as a header.
545- **The invalidation is waited for, not fired.** CachingOptimized holds objects up to 24
546 hours, `install.sh` is overwritten at a path that already exists, and the script's own
547 HTTPS verification would otherwise happily pass against the previous publish.
548- **The distribution id is looked up by its alias.** An id written into a public
549 repository is a fact about one AWS estate that goes stale silently, and the symptom is
550 a publish that reports success while the host serves the old script.
551- **No credential is in the repository.** The publish uses `--profile
552 ${STEID_AWS_PROFILE:-steid}` by name; no key, no account id, no role ARN. This matters
553 more than it used to: the repository is about to be public.
554
555### The boot-time owner · done (2026-09-13)
556
557`STEID_OWNER_EMAIL` + `STEID_OWNER_HANDLE` create the owner before the first request, so
558a scripted install comes up **already claimed** and there is never a window in which a
559stranger could claim the box. Asked for by the control plane's
560[ADR 0008]../../steid-control-plane/decisions/0008-an-instance-is-born-claimed.md, but
561**Steid knows nothing about a control plane**: this is a capability for any operator who
562wants an unattended install, and a self-hoster gets the same thing by hand. Absent the
563variables, nothing changed.
564
565- **No usable password, and no sentinel type.** The seeded owner's stored hash is a real
566 Argon2 hash of 32 random bytes generated at boot and dropped — the same shape as
567 `login.rs`'s `ABSENT_USER_HASH`. `verify` therefore answers `Ok(false)` through the
568 normal path, in the time any wrong password takes. The alternative, a sentinel value
569 that `login` recognises, would be a second code path through the one function that must
570 not grow one, and the first thing a future change forgets. The cost is that nothing in
571 the database says "this account was seeded"; the benefit is that nothing has to.
572- **Both variables or neither.** One without the other **refuses to start** (exit 4,
573 beside the mail check) with a line naming the missing one. Coming up unclaimed is the
574 exact state this feature exists to prevent, so it cannot also be the fallback for a
575 typo. Likewise a reserved or malformed handle, or a bad email: the refusal is the
576 domain rule's own message, at the one moment an operator is reading the output.
577 `admin` is the case ADR 0008 calls out, and it is a reserved handle.
578- **Inert once claimed, silently.** The variables live in `steid.env` for the life of the
579 instance and are re-read on every boot; a claimed instance says nothing, the way the
580 setup token is already absent once an owner exists. The check is
581 `app::seed_owner_on_boot`'s — the boot *policy* — while `seed_owner` refuses a claimed
582 instance itself, which is the invariant behind it.
583- **`claim_instance` and `seed_owner` share `create_owner`.** The three saves have to
584 happen in org → user → membership order or the foreign keys trip, which attempt #2
585 already had to fix once; a second copy would be a second place to get it wrong. What
586 differs is only what may run it: a token and a claimed check, or a claimed check.
587- **`AppConfig::owner_seed` rather than a check in `main`.** `main` is the one place in
588 the tree nothing can assert against, and the both-or-neither rule is a decision worth a
589 test. It returns `Result<Option<OwnerSeed>, DomainError>`; `main` only prints and exits.
590- **`tests/http.rs` boots a seeded instance through `app::seed_owner_on_boot`**, which is
591 the function `main` calls, so the boot order — seed first, *then* decide whether there
592 is a setup token — is exercised rather than re-implemented in the test.
593- **A page cannot be rendered in `tests/http.rs`.** The empty asset bundle those tests
594 use panics inside Topcoat's catalog the moment a `view!` is built, so the assertions
595 about a claimed instance go through the routes that redirect or answer JSON —
596 `/api/setup`, `POST /auth/setup`, `POST /auth/login`, `POST /auth/reset/{token}` — and
597 never `GET /auth/setup`. That is a standing limit of that harness, not of this feature.
598 The end-to-end proof is the reset flow: mint a link, spend it, sign in with the new
599 password, all over HTTP.
600- **`install.sh --owner-email/--owner-handle`** writes them, refuses one without the
601 other, and — like every other setting there — writes them **only when `steid.env` is
602 first created**; a re-run with them says they were ignored rather than implying a
603 re-seed. The closing message forks: an owned instance is told how to mint a reset link
604 instead of how to find a setup token.
605
606### A security review of the whole surface · done (2026-09-10)
607
608Every `#[page]` and `#[route]`, the git transport, the CLI, the outbound paths and the
609dependency tree. The table, the evidence and the deferred items are in
610[security-2026-09-10.md]security-2026-09-10.md; what follows is what the next session
611would otherwise rediscover.
612
613- **The boundary work held.** No enumeration hole, no authorization gap, no injection.
614 The two 404 bodies for a private repository and an absent one are byte-identical, the
615 git transport gives one 401 for private, absent and mistyped alike, and every `git`
616 argument that could come from a URL is either a resolved object id or sits after `--`.
617 That is worth writing down because six of the seven findings were about something
618 else entirely, and a future reader should not read "seven findings" as "the model was
619 wrong."
620- **Every finding was a resource limit or a library default**, not a rule anyone got
621 wrong. The two that matter: **Topcoat's `Form` and `Json` read the body with
622 `usize::MAX`** and there is no knob for it, and **`ureq` follows ten redirects by
623 default**. Both were assumptions nobody had reason to check, and both are the sort of
624 thing to check first in a framework this new.
625- **One 200 MB POST to `/auth/login` took the process from 20 MB resident to 811 MB.**
626 Measured, not reasoned. `web::body_limit` caps it at a mebibyte in the one layer at
627 `/` — which is now doing three jobs, for the same `.discover()` reason the request
628 counting is there. **The git RPC routes are exempt and the exemption matches the whole
629 four-segment route**: `RepoName` reserves neither `git-upload-pack` nor
630 `git-receive-pack`, so a repository may be called that, and matching on the last
631 segment alone would have exempted its page. The test in the module is what caught it.
632- **A path parameter arrives percent-decoded, and `see_other` panics on a bad
633 `Location`.** `POST /auth/reset/a%0d%0ab` dropped the connection and wrote a panic to
634 the log. The fix is to encode the value on its way into the header rather than to
635 validate its shape — a real token comes back from `encode` unchanged, so there is no
636 second copy of `ResetSecret`'s rules to drift. **Anything from a URL that reaches a
637 redirect wants the same treatment**; the rest of the call sites take a literal or a
638 validated handle.
639- **The SSRF rule was two checks and needed a third.** Resolving a host says nothing
640 about where a `302` sends the next request, and the webhook path made that worse by
641 storing the response body and rendering it on the deliveries page. `max_redirects(0)`
642 for `ureq`, `-c http.followRedirects=false` for the clone. The import cost is real:
643 a repository renamed on its host no longer imports from its old URL.
644- **`git grep` was the last uncapped read on an anonymous page.** `?q=e` over Steid's
645 own source is 5.3 MB of output, all collected before all but a thousand hits were
646 thrown away. `run_capped` already existed for diffs and only had to learn
647 `run_allowing`'s exception — grep's exit 1 means "matched nothing".
648- **`Secret` had one hole and the layer had one gap**: `operator_token` was a bare
649 `String` on a `Debug`-deriving struct, and nothing set `Cache-Control` on anything.
650 Both one line. `private, no-cache` rather than `no-store`, because a response the
651 browser was told not to store cannot answer the archive's `If-None-Match`.
652- **`cargo audit` is clean** — zero vulnerabilities, the same three standing warnings
653 (`bincode`, `yaml-rust`, `chacha20`), all transitive and none an upgrade Steid can
654 make on its own.
655
656### CSRF on every form · done (2026-09-08)
657
658The item `current.md` had carried since the forms first existed, run alone because it
659touches every one of them. The decision and its alternatives are
660[0008]decisions/0008-csrf-double-submit-bound-to-the-session.md; what follows is what
661the next session would otherwise rediscover.
662
663- **Topcoat already ships an origin check, and nothing said so.** `sessions()` installs
664 an `OriginLayer` that refuses any non-safe method whose `Sec-Fetch-Site` is not
665 `same-origin`/`none`, falling back to `Origin` vs `Host` — read in
666 `topcoat-session-0.5.0/src/origin.rs`. So Steid was **not** unprotected before this;
667 it had two defences sharing one deliberate gap, which is that a request carrying
668 neither header passes. That is the gap the token closes, and knowing the layer exists
669 is what turns "we have no CSRF protection" into "we have two and want a third."
670- **The token is `HMAC-SHA-256(per-boot secret, session token hash)`**, so nothing new is
671 stored. `csrf_field()` renders it, `csrf_verified(cx, &form.csrf_token)` checks it in
672 constant time, both in `web/csrf.rs`. **A restart invalidates every open form** — the
673 price of a per-boot secret, and it shows up in development as a 403 on the first
674 submit after a `topcoat dev` rebuild rather than as anything obviously wrong.
675- **A `#[page]` handler cannot return both a status and a view from an error**, because
676 the router only renders its own error types and anything else becomes a 500. So
677 `CsrfRefused` is caught by name in the **root layout**, which renders the 403 page —
678 and that is why `layout.rs` now has a `shell` component the layout renders twice. A
679 `#[route]` handler never reaches a layout, so the two that need the check
680 (`/auth/logout`, `/{handle}/settings/password`) use `csrf_verified_response`, in the
681 `if let Some(response) = …` shape `throttled` already established.
682- **`#[serde(default)]` on every `csrf_token` field is load-bearing.** Without it a
683 submission that omits the field entirely fails deserialization and answers a bare 400
684 instead of the 403 with a sentence. Found by walking the forms with curl; every unit
685 test passed either way.
686- **The two label-assignment forms deserialize as `Vec<(String, String)>`** — a checkbox
687 list has one repeated field name — so `labels::presented_token` picks the token out of
688 the pairs. Any future form of that shape needs the same.
689- **`csrf_scan.rs` reads this directory's source** and fails when a POST route neither
690 calls the check nor is named in `csrf::EXEMPT` with a reason. Textual on purpose: what
691 is being guaranteed is that somebody wrote the line, and a runtime check would need
692 every handler's fixtures. It also enforces the 307 rule, and **found a third instance
693 of it**: `POST /auth/setup` on an already-claimed instance answered `redirect("/")`.
694- **Six handlers had no form body at all** — bare buttons submitting an empty POST:
695 token revoke, import retry, hook delete and redeliver, label delete, and sign out.
696 They take `Form<CsrfGuard>` now. None of them was a link that POSTs; HTML cannot do
697 that, so there was nothing to convert.
698- **Ordering: the check runs before the ownership guard**, so an anonymous POST to an
699 owner-only route answers 403 rather than the guard's 404. Nothing leaks — the answer
700 is the same for every URL, existing or not, because it does not consult the target.
701- **Verified in the running app on :3134**, not only in tests: claimed, signed in, and
702 walked every form through both curl and a real browser — repository create, the five
703 repository settings writes, issues (create, comment, state, edit, labels), labels
704 (add, edit, delete), tokens (issue, revoke), hooks (add, toggle, delete), the profile
705 form, the password change, import, sign-out, and the pull request handlers. Each
706 succeeds with its token and answers 403 without one, and a token tampered with in the
707 browser renders the refusal page inside the normal chrome.
708
709### One access module, one bundle, one sequence, one password rule · done (2026-09-08)
710
711Review steps 5 and 6, plus the password policy `current.md` had been carrying since the
712ops wave. No behaviour change except the password rule, which is named below.
713
714- **`application/access.rs` is now the only place that answers "who may do what."**
715 `readable_repo` and `writable_repo` came out of `issue.rs`, `changeable_repo` out of
716 `repo.rs`, `is_instance_owner` out of `backup.rs`, and `authz.rs`'s two organisation
717 predicates were folded in and the file deleted. The point is milestone 7: graded
718 permissions are a change to six predicate bodies and their signatures, *provided* no
719 use case ever decides authorization inline. The module header says so, in the file
720 someone would have to edit to break it.
721- **`writable_repo` and `changeable_repo` enforce the same rule from opposite ends** —
722 one layered on `readable_repo`, one resolving directly — and nothing checked that they
723 agreed. `access_tests.rs` now walks every actor against a public, a private and a
724 missing repository and asserts both give the same verdict *and* the same kind of
725 refusal. They do. Folding them together is now a safe change rather than a hopeful one.
726- **`application::Stores` replaced the `orgs`/`memberships`/`repos` triple on 56
727 signatures**, and took `#[allow(clippy::too_many_arguments)]` from **63 to 38**. Every
728 remaining allow is a genuinely wide signature rather than port-threading. It is one
729 commit, not one per module: a use case's signature and its callers have to move
730 together.
731 - The transform was scripted, and **the one thing a regex got wrong was inside a string
732 literal** — `format!("{origin}/{handle}/repos/{name}")` became `stores.repos`, which
733 compiled fine and was caught by a webhook payload test. Worth knowing before the next
734 mechanical sweep: exclude string bodies, and lean on a test that asserts a rendered
735 URL.
736 - `Stores` is three references and `Copy`, with hand-written `Clone`/`Copy` impls
737 because `derive` would demand `O: Copy` of the adapters.
738- **`next_number` moved from `IssueRepository` to `RepoRepository`.** The sequence in
739 `repo_sequences` is the repository's — issues and pull requests both draw from it so
740 `#4` means one thing — but it sat on the issue port, so `create_pull` held
741 `IssueRepository` for one line. It no longer does. The in-memory sequence is a map on
742 `InMemoryRepoRepo` under its own lock; the SQLite upsert-returning statement is
743 unchanged, only relocated.
744- **The password rule, and the one behaviour change in the wave.** `domain::Password::new`
745 requires **12 characters and nothing else** — length is the property that measurably
746 helps, and composition rules mostly produce `Password1!` or a sticky note. A 512-byte
747 ceiling bounds Argon2's work for one unauthenticated request. `claim_instance`,
748 `reset_password` and `change_password` all ask it, which closes the actual hole:
749 before, setup had no rule at all, so a password could be *set* at claim time that could
750 never be *changed to*.
751 - **Existing passwords are never re-checked.** `login` does not construct a `Password`,
752 so an account made before the rule keeps signing in and meets the rule the next time
753 its owner changes it.
754 - `Password::RULE` is a constant, printed verbatim by the setup form, the reset page and
755 the settings page — three surfaces that would otherwise drift into three accounts of
756 one rule.
757 - **`POST /api/setup` deliberately says nothing.** A short password gets the same opaque
758 404 as a wrong token, with the reason in the log. Naming the password there would tell
759 a stranger guessing setup tokens that they had guessed one, which is a worse trade
760 than an unhelpful error for a caller that is a script.
761 - The mismatch check runs *before* the length check: "those two are different" is the
762 more useful answer when someone has mistyped, and the pages' refusal codes depend on
763 that order. There is a test for the order, not just for the two refusals.
764
765### The per-file last-commit column — section 1's last gap
766
767Every file and directory in a listing now says what last changed it and when, linking to
768that commit. It is the column 0006 deferred twice, and it is on the landing page and on
769every subdirectory.
770
771- **One `git log --name-only` per listing, not one per entry.** At one fork per entry a
772 twenty-file directory was the ~230ms that made 0006 defer it in the first place. The
773 walk is `--format=%H%x00%ct%x00%s --name-only -z`, narrowed to the directory by a
774 pathspec, capped at **500 commits** — 500 that touched *this directory*, which is deep
775 enough that a real listing is attributed long before it.
776- **Newest first, first mention wins, and a path under a child attributes to the child**:
777 `src/web/page.rs` in a listing of `src` is `web`'s row. The walk stops as soon as every
778 entry has an answer, so the cap is a worst case rather than the usual cost.
779- **An entry the walk never reached shows nothing.** A blank is honest; the oldest commit
780 read is not the answer and would look like one.
781- **`-z` output has no record boundary** — git writes one flat NUL-separated sequence of
782 fields and paths — so a record is recognised by shape: forty hex digits followed by a
783 field that parses as a time. That also survives a merge, which `--name-only` prints
784 with no file list at all.
785
786### A kept-alive `git cat-file` — stage 2 of 0006
787
788**Object reads no longer fork.** `infrastructure/cat_file.rs` keeps two `git cat-file`
789processes per repository — `--batch-check` and `--batch` — in a pool in app context, and
790`DiskGitQuery` writes lines to them instead of spawning. The port is unchanged and its
791whole test suite passed unmodified, which is what "an adapter change behind an unchanged
792contract" was supposed to mean.
793
794The landing page went from **15 processes and 115 ms to 4 and 31 ms**; a tree page from
7953 and 35 ms to 1 and 13 ms. The full table, the reasoning, and what stayed a process are
796in the [third amendment to
7970006](decisions/0006-git-binary-behind-narrow-ports.md#amendment--20260906-stage-2-a-kept-alive-cat-file).
798What is worth not rediscovering:
799
800- **`--batch-command` was rejected on the git version floor, not on shape.** It is the
801 better shape — one process, each line naming its verb — and it needs git 2.36. Ubuntu
802 22.04 ships 2.34 and `install.sh` supports it deliberately. `-z` for NUL-delimited
803 *input* is 2.31 and is used, so a path containing a newline is one spec rather than two
804 requests.
805- **A batch stream is positional, so a misread reply is silent corruption**, not an
806 error: every answer after it shifts by one, and the visible symptom is the wrong file's
807 bytes under the right filename. Hence the desync guard — the `--batch` request carries
808 the id, type and size `--batch-check` already gave, the reply header is *checked*
809 rather than parsed, and any mismatch kills the process. A process that merely died is
810 a different case and is respawned once per request.
811- **The shim technique paid off a second time.** A `git` on `PATH` logging its arguments
812 gave every number in the table in about ten minutes, and it is how the "15 processes"
813 claim was checkable at all.
814- **`ls-tree --long` became two questions.** A tree object carries no sizes, so the
815 listing is the tree object parsed here plus one bulk `--batch-check` for the blob and
816 symlink entries — chunked to 256 specs or 8 KiB, because writing more than a pipe holds
817 without reading deadlocks both ends.
818- **A one-commit log is not a log.** `log(rev, 0, 1)` — the landing page's latest-commit
819 bar — is the revision's own commit object, so it costs no walk and no process. Anything
820 wider still runs `git log`, which is what walking history is.
821- **git's `%s` is the first *paragraph*, folded onto one line, not the first line.** The
822 commit parser reproduces that, and a `gpgsig`'s continuation lines each begin with a
823 space — so the blank-looking ones inside a signature must not be read as the end of the
824 headers.
825
826### How the waves were run
827
828The forge features surveyed on 2026-09-05 were grouped by what they touch rather than
829ordered, because several agents ran at once and the grouping decided what could run
830together. Shared hotspots: `GitQuery` in `port.rs` (every browsing feature appends a
831method), `git_query.rs`, the repo sub-nav, and `plans/` itself. New tables touch
832`sqlite.rs` + `in_memory.rs` and merge one at a time.
833
834Process decisions, answered by the waves rather than left open: agents **do** get
835worktrees and short-lived branches, which is a deliberate bend in the commit-to-main
836rule and worth keeping for a wave; and agents do **not** edit `plans/` — each writes a
837handover the merging session folds in, because five agents appending to `current.md`
838conflict every time. The integration pass afterwards is not optional: it is the only
839place a cross-feature link is ever exercised.
840
841Wave 2 amends one of those: an agent working **alone** — the integration pass is one —
842edits `plans/` in the same commits as the code, as CLAUDE.md asks. The no-`plans/` rule is
843about concurrent agents, not about agents.
844
845### Section 1 wave — read-only browsing · done
846
847**Every read-side `git` process is now bounded at 20 s** (`GIT_TIMEOUT` in
848`git_query.rs`), and the child is `kill_on_drop` so a cancelled request takes git with
849it. Added before blame and grep arrived, because those are the first reads that can
850run long on a big repository, and five agents each adding their own bound would have
851produced five. `GitQueryError::is_timeout()` is how a page tells "asked too much"
852(render a state, offer less) from "git failed" (a 500). Tokio's `time` feature was
853enabled for it.
854
855**Syntax highlighting (merged 2026-09-05).** `syntect` with the pure-Rust `default-fancy`
856engine plus `two-face` (`syntect-fancy` feature) for the grammars the default set lacks —
857TOML, Dockerfile, TypeScript — at +0.59 MiB on the binary. Decisions worth keeping:
858
859- **Classes, never inline colours.** Output is `ClassStyle::SpacedPrefixed { prefix: "hl-" }`
860 and every colour is a `--syntax-*` token in `styles.css`, so the palette follows the
861 theme. `ClassedHTMLGenerator` cannot be used because its spans cross line boundaries
862 and the blob view is one table row per line; `highlight.rs` drives `ParseState` +
863 `ScopeStack` itself, carrying parse state across lines but closing and reopening the
864 markup at each line end.
865- **`hl-` classes are scope atoms, not positional**, so `.hl-function` alone would colour
866 every `meta.function` body. Single-atom selectors only for an atom that leads its scope;
867 the rest are compounds. Rule order in `styles.css` is load-bearing: `.hl-string` is
868 written after `.hl-punctuation` so a quote reads as its string, and the comment rule is
869 last.
870- **The trailing newline is dropped by character, not `trim_end`** — the `_newlines`
871 syntaxes need it fed in, and it comes back escaped inside the output, sometimes before a
872 closing span. Left in, every row renders double-spaced.
873- **Caps are 512 KiB and 10,000 lines**, both, because cost is per byte and per line.
874 Plain text is returned as `Plain` lines, not wrapped in colourless spans.
875- **~87 ms per 1,255-line file in release**, uncached, paid on every view; debug is ~8×
876 slower and not the number to plan against. If it matters: cache per blob object id.
877
878**Branches and tags pages (merged 2026-09-05).** `/branches` and `/tags`, one
879`for-each-ref` each, and the counts beside the switcher and in the sidebar are links.
880
881- **`%(HEAD)` is why the page is one process**: `for-each-ref` marks the default branch,
882 so nothing calls `symbolic-ref` on the happy path, and the compare link's base is read
883 from the pinned row.
884- **Keep empty fields when splitting `for-each-ref` output.** A lightweight tag's
885 `%(*objectname)` is empty; filtering empties shifts its date into the id slot. There is
886 a test for exactly this.
887- **Ordering is git's (`--sort=-committerdate`), pinning is the use case's.** The default
888 branch is a display decision, a stable partition in `list_branches`.
889- **A lightweight tag's `%(contents:subject)` is the commit's subject**, so it is read only
890 when `%(objecttype)` is `tag`. `annotated` is its own field because an annotated tag may
891 carry an empty message. The row shows the peeled `%(*objectname)` so the sha is browsable.
892- **"No tags yet" and "nothing pushed yet" are different sentences**; telling them apart
893 costs one `default_branch` call, only when the list is empty.
894- **`refs.rs::timed_out` is the first web-layer place that renders a timeout as a state**
895 rather than a 500. When a second page wants it, move it to `web::context`.
896
897**Archive download and code search (merged 2026-09-05).** `/archive/{rev}.tar.gz`
898and `.zip` streamed from `git archive`; `/search?q=&rev=` over `git grep -F`.
899
900- **`GitArchive` is a fourth narrow port, not a `GitQuery` method.** `GitQuery`'s contract
901 is capped bytes, collected; an archive is as large as the repository. It lives in
902 `infrastructure/git.rs` beside the protocol server and reuses `web::git::GitBody`, so
903 "one subprocess's stdout becomes a response body" is written once and used twice.
904- **The archive use case is two steps, which is what makes the `ETag` cheap.**
905 `archive_repo` authorizes and resolves into an `ArchiveTarget` nothing else can
906 construct; `open_archive` runs git. A conditional request is answered from step one,
907 so re-downloading a tag costs one `cat-file`. The `ETag` is the resolved commit.
908- **`git grep` is the one command whose exit status is an answer** (1 = no matches).
909 `run_within_allowing` takes an allowed-exit list and `NO_MATCHES` names the exception
910 at the call site, so the module's rule stays visible where it is broken.
911- **`git grep -z` is not optional**: a path may contain colons, so the colon-separated
912 form has no unambiguous reading. The parser walks NULs.
913- **`RepoPath` refuses a colon**, so `a:b.rs` is unsearchable as well as unbrowsable; the
914 parser drops those hits rather than link to a 404. Pinned by a test.
915- **A search timeout is a page state** (`Searched::TimedOut`), the first real consumer of
916 `GitQueryError::is_timeout`.
917- **Archive and search 404 a private repository for a stranger**, matching every other
918 read page rather than 0007's uniform 401, which exists so a git client can offer a
919 credential; a browser link gets no benefit from it.
920- `topcoat dev` in a worktree exited rather than restarting after some source edits and
921 had to be relaunched by hand. Possibly two instances sharing a `target/`. Watch it.
922
923**Commit page and compare view (merged 2026-09-05).** `/commits/{sha}`, `/compare`
924(form) and `/compare/{base}...{head}`, three-dot. Every sha in the log and the
925latest-commit bar links to the commit page.
926
927- **The counts and the patch come from one `git` process**: `diff-tree --numstat -p`
928 writes numstat *first*, so a patch too large to draw still lists every file with real
929 `+a −b`. A second `--numstat` call would be paid on every page for the rare oversized
930 one.
931- **`run_capped` reads through a pipe and kills the child** at `max_bytes + 1`; the exit
932 status is checked only when the cap was not hit, since a killed process says so.
933- **`run_allowing` bends the "non-zero exit is a fault" rule for exactly two commands**
934 whose codes git's manual promises as answers: `grep` (1 = matched nothing) and
935 `merge-base` (1 = no common ancestor, 128 = broken). Both arrived in the same wave with
936 their own copy; the merge kept one. A third caller needs the same scrutiny.
937- **Compare is three-dot** (merge-base to head): two-dot undoes everything base gained
938 since the branch left, a wall of deletions nobody made, and three-dot is what a pull
939 request needs. `...` is unambiguous because `RefName` refuses `..`.
940- **The patch parser tracks hunk line counts**, never matching `diff --git`/`+++`/`---`
941 prefixes anywhere: a patch *of a patch* contains those as content.
942- **Paths come from `---`/`+++`/`rename from`, not the `diff --git` header**, whose
943 `a/<old> b/<new>` has no defined split when names contain spaces. C-quoted names are
944 unquoted.
945- **The compare form GETs to `/compare?base=&head=` and 307s to the path form**, so the
946 shareable URL is always the path one and no JavaScript is needed.
947- **The file header is `sticky`, which is why the diff panel is not `overflow-hidden`**:
948 a hidden overflow makes an ancestor a scroll container and sticky sticks to nothing.
949
950**Blame (merged 2026-09-05).** `/blame/{rev}/-/{path}`, with `Code · Blame · Raw` in the
951file header of both views.
952
953- **The porcelain parser is pure, in `application/blame.rs`.** `git blame --porcelain`
954 writes a commit's header block only the *first* time the commit appears; later runs are
955 a bare sha line looked up from an accumulated map. A code line can look exactly like a
956 header line, and **the leading tab is the only thing that tells them apart**. Both are
957 pinned by tests. `parse_blame` never fails: an unrecognised record is skipped.
958- **`filename` is per commit, not per hunk**, carried on `BlameCommit`; that is what makes
959 the "moved from" marker work.
960- **The use case reads the blob before blaming**, so binary, too-large and not-there are
961 decided by the blob page's rules from the same cap. Blame's own output cannot tell: a
962 binary file blames into garbage rather than reporting itself. Costs one `cat-file`.
963- **The commit cell is one line tall, on purpose**: two lines and blame and blob disagree
964 about where line 400 is. Row height measured at 19.5px in both.
965- **The age tint is linear in time, not rank**, five steps between the file's oldest and
966 newest commit, as `color-mix` of the primary in plain CSS. A file whose history is
967 bunched shows only the end steps; rank quintiles would always look richer and lie about
968 the gaps. A file written in one commit takes the top step.
969- **Blame is 4 processes** (two `batch-check`s asking the same existence question, one
970 from the use case and one inside the adapter). A kept-alive `cat-file --batch`
971 collapses both — the same upgrade 0006 defers.
972- **Headless Chrome writes screenshots to files; the puppeteer MCP tool does not.**
973 `--headless --hide-scrollbars --window-size=W,H --screenshot=path URL`. And `topcoat
974 dev` sometimes keeps printing "no changes; application up to date" while serving the
975 previous binary; `pkill -f "topcoat dev"`, wait for the port, restart.
976
977**The integration pass (2026-09-05).** The five branches merged, run as one app against
978Steid's own history — 9 branches, 2 annotated tags, a public repository and a private
979one — and every link crossing a feature boundary followed in a browser, in dark and in
980light. **Nothing was broken at a seam**, which is the finding: five agents that could
981not see each other agreed on URL shapes because the shapes were written down in
982`ui.md` and in each other's handovers before the code was.
983
984- **A private repository 404s on all eleven read routes anonymously** — landing, log,
985 branches, tags, commit, search, tree, blame, raw, archive, compare. Every use case
986 takes an `Actor` and answers `Ok(None)`, and each page turns that into `not_found()`;
987 the uniformity is the architecture rule paying off rather than eleven separate
988 decisions.
989- **What was walked.** Landing sha → commit page; log sha → commit; commit's "Browse
990 files" → tree at that sha and its parent sha → the parent's page; the counts and the
991 sidebar → branches and tags; a branch row → tree, log and a compare with a real diff (a
992 merged branch correctly says there is nothing to compare); a search hit's line number →
993 `blob#L<n>` with the anchor present and landing; `Code · Blame · Raw` in both
994 directions; blame's sha → the commit page and its line number → the blob anchor; `zip`
995 and `tar.gz` for `main` and for a tag, both extracting under `steid-<rev>/`.
996 Highlighting still rendered after the blame toggle and the anchor edits landed on the
997 same table: Rust and TOML coloured, a plain file not. Screenshots in dark and light in
998 `target/shots/`.
999- **Two gaps found, both entry points rather than breaks.** The About sidebar's Download
1000 links can only ever offer the default branch, because the sidebar renders on the one
1001 repository page that has no `{rev}`. And blame renders its lines unhighlighted while
1002 the blob highlights them, `highlight.rs` and `blame.rs` having shipped on separate
1003 branches. Both were carried in `current.md` and **both are since closed**: the tags page
1004 carries each tag's archives, which is the missing entry point; and blame's code cell
1005 now goes through `source_lines`, the blob's own adapter, so the two views share
1006 classes, caps and plain fallback — both render a file to an identical set of `hl-`
1007 spans and rows stay 19.5px, the only variance being a run's hairline, which is
1008 `border-collapse` splitting that 1px.
1009- **A wave needs a divergent branch to test compare with.** Every feature branch was an
1010 ancestor of `main` after merging, so every branch row's Compare link correctly said
1011 there was nothing to compare and exercised none of the diff. `git commit-tree` makes
1012 one without a working tree.
1013- **Follow-ups the handovers named, done here:** blame's revision switcher (`Switch`
1014 gained a `Blame` arm), `web::context::timed_out` shared by three pages, `.jsx` aliased
1015 onto JavaScript, `token.rs`'s phantom `bg-muted`, and the two exit-status comments
1016 that each claimed to be the only one.
1017
1018**Released as 0.3.0 (2026-09-06)** — the first version carrying the section 1 wave.
1019No migrations between 0.2.0 and 0.3.0, so the two binaries share a database and
1020`deploy.sh`'s rollback is a real one. First Linux release build with `syntect` and
1021`two-face`; both are pure Rust behind the fancy-regex features — the bullseye container
1022build took ~2 minutes and needed no changes. Deployed 2026-09-06 12:07 UTC+1, health
1023check passed first time. Probed live afterwards: landing, branches, tags, search, log,
1024commit and compare all under 0.25 s; the 113 KB `git_query.rs` blob and its blame both
1025~0.65 s (highlighting, uncached, on the Lightsail box); `archive/main.tar.gz` answers with
1026the sha as `ETag`; an unknown repository 404s.
1027
1028### Wave 2 — git features · done
1029
1030**Rename, default branch, archived (merged 2026-09-06).** All on the settings page,
1031which now reads as five sections.
1032
1033- **A rename moves the directory first, then writes the row**, compensating with a move
1034 back if the save fails — the opposite order from delete, because a move is reversible
1035 where a delete is not. `GitStorage::rename` refuses an occupied destination: with no
1036 row naming it, whatever is there is an orphan, and adopting it hands someone else's
1037 objects to this repository. **`fs::rename` silently replaces an empty directory on
1038 Unix**, hence the explicit exists check.
1039- **No redirect from an old name**, single tenant; the form names `git remote set-url`.
1040 Revisit at Milestone 7.
1041- **The default branch has no column.** git holds it in `HEAD`; a SQLite copy would be a
1042 second answer that drifts. The write is `GitStorage::set_default_branch` (on the
1043 storage port, since `GitQuery`'s contract is reading). **`symbolic-ref` accepts a
1044 branch that does not exist**, which would make every page say "nothing pushed yet",
1045 so the use case checks the name against `branches()` first — the same call that
1046 renders the select, so one process for both.
1047- **Archived is a column and not a third visibility.** It says "finished", not "hidden":
1048 clone, browse, search and download keep working, and an archived private repository is
1049 a real, tested state. The push refusal sits in `serve_git` *after* the `Role::Owner`
1050 check, so only someone who could otherwise push ever learns a repository is archived.
1051 `DomainError::Archived` is its own variant: the owner is refused too, and it is the
1052 one refusal the person hitting it can lift. The 403 carries a `text/plain` body so
1053 `git push` shows the sentence behind `remote:`.
1054- **`update_repo` and `rename_repo` carry `archived` across explicitly**, because both
1055 rebuild through `new()`, which resets it.
1056- The `repositories` column-migration test in `sqlite.rs` applies a **list** of
1057 migrations; every future column on that table belongs in it.
1058
1059**Issues (merged 2026-09-06).** Per-repository issues with comments, an Issues tab,
1060and a number sequence pull requests will share.
1061
1062- **The sequence is its own table**, `repo_sequences (repo_id, next_number)`, not a
1063 column on `repositories`: pull requests draw from it too, and allocating a number must
1064 not write the row a push is contending for. **Allocation is one statement**
1065 (`insert … on conflict do update … returning`), so SQLite's writer serialisation is
1066 the whole concurrency story; `unique (repo_id, number)` makes it load-bearing.
1067- **Comments sit behind the issue's port**, one trait for the aggregate, two tables — a
1068 deliberate departure from a literal "every table gets a trait". Same-second comments
1069 tie-break on **insertion order**, not id: ids are random UUIDs and an id tiebreak made
1070 a conversation read backwards, caught by a flaky test.
1071- **`markdown.rs` needed no change**: it writes every tag itself and never passes source
1072 HTML through, so a `<script>` in an issue is inert text. That property is why
1073 user-written markdown can render on the session cookie's origin at all. **Do not
1074 reintroduce HTML passthrough.**
1075- **Third instance of the page-name shadowing trap**: `#[page] async fn comment` would
1076 have shadowed a loop variable; the handler is `add_comment`.
1077- Author handles are resolved once per request (`Handles`); a deleted author renders as
1078 "someone" rather than failing the page.
1079
1080**Import from a URL (merged 2026-09-06).** A second block on the new-repository page
1081mirrors a public `https://` source in the background; the row exists immediately in an
1082`importing` state. Verified against a real GitHub repository: 3,293 commits, 112 tags,
1083`HEAD` following the source, an ordinary repository afterwards.
1084
1085- **`import_state` is nullable and `NULL` is an ordinary repository**, so a page that
1086 forgets about importing gets the behaviour it had. `import_source` outlives the state:
1087 provenance stays true and a retry needs it. State attaches via `with_import(...)` after
1088 construction, like `pinned`, rather than widening `from_trusted`.
1089- **The SSRF check is two halves and both are needed**: `ImportSource::new` refuses the
1090 scheme, userinfo and literal non-public addresses; `DiskGitImport` resolves the host
1091 and checks **every** address immediately before spawning git, because a public name
1092 can resolve to loopback. A host with one public and one private answer is refused.
1093- **`GitImport` is a fifth narrow port**, not a `GitStorage` method: a ten-minute
1094 network transfer that only runs in the background, `kill_on_drop`,
1095 `GIT_TERMINAL_PROMPT=0` — which is load-bearing, since without it a private or
1096 mistyped source hangs git on a username prompt forever. With it, GitHub's 401 for a
1097 missing path reads as "could not read Username", which `import::explain` translates.
1098- **`import_repo` does not touch disk**; `git clone --mirror` creates the directory, so
1099 the two-writes problem moves into `run_import`, which re-reads the row after the clone
1100 because minutes have passed and the repository may have been deleted. The boot sweep
1101 marks stuck `importing` rows failed; it is safe because it runs before anything is
1102 spawned.
1103- **A push during an import is `DomainError::Unavailable` → 409**, after the permission
1104 check so a stranger learns nothing. Clones during an import are still served: git
1105 either finds refs or it does not. The 409 sentence reaches the terminal as a `remote:`
1106 line.
1107- `tokio` gained `net` for `lookup_host`. No new crate.
1108
1109**Push events and webhooks (merged 2026-09-06).** One `push_event` per ref an
1110authorized push moved; webhooks at `/settings/hooks` deliver a signed JSON POST with
1111retries and a delivery log; `REMOTE_USER` reaches the reflog.
1112
1113- **Events are recorded from the application, not a `post-receive` script**: refs are
1114 snapshotted before and after the receive-pack RPC and diffed. A hook script would need
1115 installing on creation and on boot, syncing with the binary, and a channel back; it is
1116 the right answer if per-push cost ever matters, and the only way to a `pre-receive`
1117 refusal. **The recording hangs off the response body's EOF** (`GitBody::on_end`),
1118 because `serve_git` returns while receive-pack still streams; a client that vanishes
1119 mid-transfer records nothing.
1120- **`REMOTE_USER` was inert until `core.logAllRefUpdates` was turned on** — `git init
1121 --bare` leaves bare repos with no reflog. `init_bare` now sets it; **repositories
1122 created before this keep no reflog and there is no migration** (`git config
1123 core.logAllRefUpdates true` in each bare repo). The `(none)` in the reflog identity is
1124 `REMOTE_ADDR`, which Topcoat 0.5 discards.
1125- **A hook's secret is stored in the clear**, unlike a token: an HMAC needs the value,
1126 and a leak forges a payload at one endpoint rather than acting as the owner.
1127- **SSRF in two halves**: `WebhookUrl::new` refuses schemes, credentials, private and
1128 link-local ranges and packed address spellings (`127.1`, `2130706433`); the sender
1129 resolves and checks every answer before dialling. `from_trusted` does not re-run the
1130 rule, so a tightened rule cannot hide a stored hook from the page where it is deleted.
1131 ~~`import` and `webhook` each carry their own `is_public`~~ — **one copy**, in
1132 `domain/net.rs`, and it is the union of the two: each knew a range the other did not.
1133- **`ureq`, not `reqwest`**: already in the tree via Topcoat with rustls, so a feature
1134 flag rather than a second TLS stack; blocking, hence `spawn_blocking`.
1135 `http_status_as_error(false)` because a 4xx is what the delivery row records. New
1136 direct deps `hmac`, `serde_json`, `ureq` were all already compiled transitively.
1137- **`X-Steid-Delivery` carries the push event's id**, the same on every attempt, since
1138 deduplicating on it is the only reason a receiver reads it. Hooks are delivered to
1139 concurrently, events sequentially per hook. The retry schedule is a parameter so tests
1140 prove four attempts without waiting 2.5 minutes.
1141- `GitQuery::ref_snapshot` covers all of `refs/` and reports an annotated tag's own object.
1142- **`deliver_push` takes no `Actor`**: authorization is settled once in `record_push`. It
1143 takes a `Clock` since wave 3.
1144
1145**The wave 2 integration pass (2026-09-06).** The four branches merged and run as one
1146app on port 3111, against Steid's own history with two annotated tags, four repositories
1147imported from GitHub — ripgrep, cargo, clippy, rust-analyzer — and a private one. Unlike
1148section 1's pass, **this one found real breaks**, and both were the same mistake in the
1149same shape.
1150
1151- **A settings save during an import ended the import.** `update_repo` rebuilds through
1152 `Repository::new()` so the description rule lives in one place, and `new()` resets the
1153 import trio; it carried `archived` across for exactly that reason and nobody noticed the
1154 trio. The consequence was not cosmetic: the row said "ordinary repository" while
1155 `git clone --mirror` was still writing into the directory, so the page read as an empty
1156 repository, `refuse_writes` stopped refusing pushes into it, and the provenance was gone
1157 for good. Two imports in the pass's own fixture lost their source before it was spotted.
1158 `rename_repo` had the same shape with a smaller consequence — an imported repository
1159 stops saying where it came from. **The general rule, now in current.md: every use case
1160 that rebuilds through `new()` has to carry what `new()` resets.**
1161- **An imported repository had no reflog.** `git clone` leaves `core.logAllRefUpdates` off
1162 exactly as `git init --bare` does, and an import never goes through `init_bare`. Found
1163 by the new boot sweep reporting six repositories on an instance where every repository
1164 had been created by current code — the six were the imports. `finish_mirror` sets it
1165 now, beside the other two things that turn a mirror into an ordinary repository.
1166
1167What the pass walked, all in a browser or with `git` against a live instance: an import
1168of a real repository while its landing panel, profile badge, issues, settings and hooks
1169pages were read; `git push` into it refused with **409** and the sentence reaching the
1170terminal behind `remote:`, while `git clone` was served; after it landed, branches, tags,
1171a commit, blame, search, compare and both archive formats over 227 tags of imported
1172history. Then archiving: the push refusal in words, reads all still working, an issue
1173opened and commented *after* archiving, and nothing delivered to the hook because no push
1174can happen. Then a rename with a hook, a delivery log and an issue attached: all three
1175followed, and the next push's payload named the **new** repository and URL. A private
1176repository 404s anonymously on every route the wave added — issues, a single issue, new
1177issue, settings, hooks, one hook's deliveries — including while it is importing.
1178
1179- **The end-to-end webhook check is why `STEID_ALLOW_PRIVATE_WEBHOOKS` exists.** A real
1180 push to a real receiver on `127.0.0.1:9099` delivered a signed JSON body with
1181 `X-Steid-Delivery`, `X-Steid-Event` and `X-Steid-Signature-256`, accepted on the first
1182 try in 1 ms, and the deliveries page shows both attempts green. The wave had settled for
1183 a temporary source patch; a flag that warns at boot and is documented beside
1184 `STEID_INSECURE_COOKIES` is the better shape, because a patch is invisible.
1185- **Decisions the pass settled**: issues stay writable on an archived *and* on an
1186 importing repository (archiving says the *code* is finished; a tracker that closed
1187 itself would be the wrong shape for the conversation after a release); rename and
1188 archive are refused while an import lands and the page renders both buttons disabled
1189 with one sentence; hooks may be added during an import, and the description,
1190 visibility and pin form still saves, since none of those touches the directory; delete
1191 stays outside the write guard because it is how a stuck import is cleared; an import
1192 can never land in an archived repository, because a taken name is refused before
1193 anything is cloned. And **an anonymous POST to a private repository's routes answers
1194 400, not 404** — the form parser refuses the body before any use case runs. It is the
1195 same 400 an unknown repository gives, so nothing leaks, but the reasoning is the form
1196 parser's rather than ours.
1197- **The settings page 500'd on an importing repository** before the pass, and not because
1198 of the guard: `branches_of` asks git for the branch list, and against a directory that
1199 is not there yet that is a failed process rather than an empty list. It is skipped
1200 during an import now.
1201- **Screenshots** of the whole walk are in `target/shots/` under `integrate2-`.
1202
1203**The seams closed in the same pass**, each its own commit:
1204
1205- **`Repository::refuse_writes(RepoWrite)`** is the one place a repository says it is
1206 closed for writing. The `RepoWrite` parameter is not decoration: an archived repository
1207 must stay renameable — archived is *finished*, not *frozen* — so archiving cannot be a
1208 blanket refusal. `Contents` refuses archived and importing; `Settings` refuses only
1209 importing.
1210- **One `is_public`**, in `domain/net.rs`, and it is the **union** of the two copies: each
1211 knew a range the other did not (import had `0.0.0.0/8` and the benchmarking range,
1212 webhooks had IETF protocol assignments, documentation and the reserved top of IPv4
1213 space). The url-*text* rules stayed where they were, because only one type wants each.
1214- **The Issues tab counts on every repository page.** It was an optional parameter three
1215 pages passed, so the number appeared and vanished as you moved around. It is now a field
1216 on `RepoView`, which needed the read path split: **`visible_repo`** answers "may this be
1217 seen" for browsing, blame, search, the commit page, the archive endpoint and the summary
1218 read — all of which discarded the view anyway — and **`view_repo`** adds the frame's one
1219 `count(*)`. Five issue pages stopped running a whole issue list purely for that number.
1220 Zero renders as nothing: a mono `0` beside a tab reads as a measurement somebody took.
1221- **An issue's Comment and Close/Reopen share a row**, the Comment button reaching its
1222 form by `form=` id rather than by containment — which is what keeps the textarea out of
1223 the row. **`token.rs`'s Revoke** is ghost and small, like a hook row's Delete.
1224
1225### Wave 3 — the simpler features · done
1226
1227**Paging, everywhere at once (merged 2026-09-06).** Every list that said "this list is
1228not paged" now pages, through one pattern and one control — the whole decision is in
1229[ui.md]ui.md#paging; what is worth not rediscovering:
1230
1231- **Offset (`?page=N`), not a keyset cursor — including for the git lists.** The cursor
1232 is the textbook answer for a log and is wrong here: `git log` walks a date-interleaved
1233 history rather than a chain, so "the commits before `<sha>`" (`git log <sha>^`) is not
1234 the same set as "the rest of this log" once a merge is in it, and the other parent's
1235 line would silently vanish from page 2. `--skip` is git's own answer, is exact, and is
1236 what makes one control serve both the git and the SQLite lists. It costs a count per
1237 page — `rev-list --count`, `count(*)` — which is also what buys "3 of 7".
1238- **Clamp, never refuse.** `?page=400` on a four-page list, `?page=banana`, a link into
1239 a branch that has been force-pushed since: all are the nearest page that exists.
1240 `application::paging::clamp` is the one rule, so `/api` cannot answer differently.
1241 Walked in a browser: a bookmarked page 4 of a branch, force-pushed down to two
1242 commits, renders those two commits and no control rather than a 500.
1243- **Two shapes of "page this", and the difference is not the storage.** A list that
1244 arrives whole anyway is sliced in the use case (`Paged::slice`): branches and tags are
1245 one `for-each-ref` whatever the page asks for, and a profile's repositories must be
1246 cut *after* the visibility filter or page 2 would be short by however many private
1247 repositories page 1 counted. A list a query can narrow gets `limit`/`offset` at the
1248 port (issues, webhook deliveries), with a test per implementation that the second page
1249 starts where the first ended.
1250- **`Option<usize>` where a list has a second caller that wants all of it.**
1251 `list_branches(None)` is the settings form's default-branch `<select>` — an option
1252 missing from it is a branch nobody can choose — and `list_repos(None)` is the profile
1253 overview and `/api`. A page number would have silently truncated both.
1254- **The label-filtered issue list cannot be paged in SQL.** Which labels an issue wears
1255 is a second table `list_issues` already reads whole to render the pills, so the filter
1256 is applied in the use case and the page cut after it; the port's `limit`/`offset`
1257 serve the unfiltered path, which is the one a thousand-issue repository lives in.
1258- **Search pages by file, not by line.** A file's matches are one block under its path,
1259 so a page ends with the last file that fits and may overshoot 200 rather than print
1260 the same heading twice. `SEARCH_LIMIT` (200) became the page and `SEARCH_MAX_MATCHES`
1261 (1,000) the bound on a whole search: `git grep` output is still collected whole, so a
1262 deeper page must not be able to raise what one query costs. **Every page re-runs the
1263 grep** — there is nothing to resume from.
1264- **Redelivery stopped being a 50-row window.** The button can sit on any page now, and
1265 the attempt number it writes counts every attempt the *event* has had — which the
1266 window got wrong as soon as an event aged out of it. The read is unbounded for one
1267 hook; noted in [current.md]current.md.
1268- **The control renders nothing at all on a one-page list**, and so does the sentence
1269 above it. That is why most of these pages look untouched on a small instance.
1270- **A comparison's diff does not page**, only its commit list (100 a page; the log's is
1271 50). The diff is what the whole range changes, so it is the same on page 2 as on page
1272 1, and a range wide enough to need paging still renders one diff capped by
1273 `MAX_RAW_BYTES`.
1274
1275**The paging pass (2026-09-06).** Walked on a real instance on port 3118 holding this
1276repository's own history (182 commits, three branches, two tags) and 62 issues opened
1277through the form:
1278
1279- `/log` at 182 commits: pages 1, 2 and 4 each say `Showing 51–100 of 182 commits` and
1280 the like, `?page=400` and `?page=banana` render page 4 and page 1 rather than an
1281 error, and a branch force-pushed from 182 commits down to 2 answers a bookmarked
1282 `?page=4` with those two commits and no control.
1283- Issues at 62: the state and label filters survive a page (`?label=bug&page=2` says
1284 "Showing 51–59 of 59 open issues labelled bug"), and the Open/Closed links keep the
1285 label while dropping the page.
1286- A comparison of 180 commits pages at 100; search for `let` pages six times over 1,000
1287 matches with uneven pages, which is the file-boundary cut doing its job; a hook with
1288 60 seeded deliveries pages at 50. Branches, tags and the profile's one repository
1289 render no control at all, which is the one-page case.
1290- **Not walked**: a redelivery from page 2 (it would have sent a real request to the
1291 hook's endpoint) — the widened read is covered by tests only; and the deliveries rows
1292 were seeded into SQLite rather than earned by pushes.
1293
1294Screenshots in `target/shots/`, `paging-*`.
1295
1296
1297**Markdown cross-links and highlighted fences (merged 2026-09-06).** `#12` and a bare
1298lowercase 7–40 hex word link to the issue and commit pages; fences with an info string
1299render through `highlight::fenced_lines`.
1300
1301- **References are matched by shape, never checked.** Existence would cost a query or a
1302 `cat-file` per reference per render; the target pages already 404. `deadbeef` links,
1303 deliberately. Uppercase hex does not.
1304- **The boundary rule is the whole trick**: the character before may not be
1305 alphanumeric, `-`, `_`, `.` or `/` (so `src/deadbeef1`, `v1.0-abcdef1` and URL fragments
1306 stay text); after, only alphanumeric, `_` and `-` disqualify, so `#12,` ends cleanly.
1307- **Fences are buffered, not streamed**, because a string can span lines; `Writer`
1308 holds a `Fence` and writes the `<pre>` at `TagEnd::CodeBlock`. `fenced_lines` is
1309 `source_lines`' sibling: an info string is a token, not a filename, and an empty line
1310 inside `<pre>` must stay genuinely empty.
1311- **The "raw HTML never reaches the page" guarantee is intact**: the only unescaped
1312 output shaped by the source is markup `highlight` wrote around text syntect escaped.
1313- `markdown::render` gained `Option<Crossref>`; `None` renders as before, which is what
1314 posts will want until they have a repository to refer to.
1315
1316**Token expiry, last use, and a rate limit on git auth (merged 2026-09-06).** Three of
1317ADR 0007's deliberate omissions closed.
1318
1319- **Expiry is a closed set** (`TokenLifetime`: 30 days, 90, a year, never; 90 the
1320 default), not a date picker; days are 86,400 s with no calendar. An expired token
1321 authenticates exactly like an unknown one — 0007's uniform 401 — and the list is where
1322 a person finds out. Both new columns are null for pre-existing tokens: retroactively
1323 expiring a pasted credential would break a clone with nothing connecting it to an
1324 upgrade.
1325- **`last_used_at` is written at most once a minute**, the comparison in the domain
1326 (`should_record_use`), and a future timestamp never writes, so a clock that went
1327 backwards cannot make every request a write. **`touch_last_used` is its own port
1328 method and `save`'s upsert does not touch the column** — one writer per column, or a
1329 stale save walks the last use backwards. Pinned by a SQLite test.
1330- **The git transport has its own limiter**, `GitAuthLimiter`, 60 per client per minute
1331 (global 600): a clone authenticates two or three times, so sharing the 10/min login
1332 budget would spend a sign-in allowance on one command. Only requests presenting a
1333 credential count; an anonymous clone of a public repository is never throttled. The
1334 429 carries a `text/plain` body git shows behind `remote:`.
1335- `git_actor` returns `Result<Result<Actor, Response>>`: the outer error is a fault, the
1336 inner is the 429 to send.
1337
1338**Atom feeds (merged 2026-09-06).** `commits.atom` and `issues.atom` per repository,
1339`/{handle}/feed.atom` for push activity, autodiscovery links in the head, muted "Feed"
1340links on the log, issues toolbar and profile.
1341
1342- **`/{handle}/feed.atom`, not `/{handle}.atom`**: Topcoat matches whole segments only,
1343 so `{handle}.atom` is refused at registration; the extension must be its own segment.
1344- **Autodiscovery is derived from the request path** in `atom::discovered`, not
1345 contributed by the page: `extensions(cx)` is immutable, only a `#[layer]` may insert,
1346 and `.discover()` forbids a second layer at `/` beside `security_headers`. **If a page
1347 ever needs to contribute to `<head>`** (a per-page `<title>`, which Steid still lacks),
1348 the fix is one shared `#[layer("/")]` owning a request-scoped page-metadata cell with
1349 `security_headers` folded in.
1350- **The activity feed counts no commits**: N would be a git process per entry on an
1351 unauthenticated polled endpoint. Entries say what moved with `before → after` and link
1352 to the compare page. The feed costs zero subprocesses.
1353- **`log_entries` is a second `GitQuery` method** (subject plus body) with its own
1354 parser, because `parse_log` dropped empty fields — safe only while every field is
1355 non-empty; a one-line message has an empty body. **`parse_log` has since been fixed
1356 the same way**, so both parsers keep empty fields and drop only the `-z` terminator.
1357- **One escaper, and C0 controls are dropped, not escaped**: there is no escape for a
1358 NUL and one byte would break the whole document. A feed's `updated` is the newest
1359 entry's own time, never `now`. Entry ids are the alternate URL for commits and issues
1360 and `urn:uuid:` for push events, since two pushes can share a compare URL.
1361- `PushEventRepository::list_recent` takes repository ids so the port answers no
1362 authorization question; SQLite builds `in (?, …)` from the count.
1363
1364**Issue labels (merged 2026-09-06).** `/labels` per repository, pills on issues and
1365list rows, a Labels control on an issue, `?label=` filtering.
1366
1367- **A colour is one of eight palette names, never a hex value**, parsed with `FromStr`
1368 returning `Result`; the eight are `--label-*` token pairs in `styles.css` for both
1369 schemes. The pill CSS is plain CSS because the class is built at render time and
1370 Tailwind never sees it. Adding a ninth is one variant and one token.
1371- **Assignments live behind the labels port** (no fields of their own) and are posted
1372 as the whole ticked set via `Form<Vec<(String, String)>>` — a checkbox list posts one
1373 key many times, which no struct field can hold, and replacing makes a double submit
1374 idempotent. A foreign label id is `NotFound`, not dropped.
1375- **`?label=` narrows the toolbar's open and closed counts too**; a name matching no
1376 label filters everything out rather than widening. **Labelling does not move an
1377 issue's `updated_at`**: that clock marks when what the issue says changed.
1378- **Gotchas**: `#[path_param] struct Label(str)` cannot exist in `web/labels.rs` — the
1379 name snake-cased is the URL parameter and it would shadow the domain type; the route
1380 uses `{id}`, and getting it wrong panics at request time. A list row's disclosure must
1381 not be `<details class="contents">`: the panel becomes a flex sibling and lands beside
1382 the row. The row is the `<summary>` (links inside still navigate).
1383
1384**Wave 2 follow-ups (merged 2026-09-06).** Webhook on/off and Redeliver; import Retry
1385and a two-clone concurrency limit; `zip · tar.gz` on tag rows; a revision switcher on
1386search results; the detected language in the blob header; an orphan-directory sweep.
1387
1388- **A redelivery rebuilds the payload, it does not replay a stored body** (a delivery
1389 row keeps what came back, not what went out); verified byte-identical with the same
1390 signature on a real push. It is awaited in the request — one attempt, no backoff —
1391 and its attempt number continues the event's sequence, taken from the page already
1392 read, so only an attempt within the last 50 can be redelivered. The toggle takes the
1393 wanted state, not "the other one", so a double click is idempotent.
1394- **`MAX_CONCURRENT_IMPORTS = 2`, chosen**: one serialises a small import behind a slow
1395 one; many peak together during `index-pack` on a small box. The permit is taken
1396 inside the spawned task so the form answers at once; the queue records *who* holds a
1397 permit, keyed `{handle}/{name}`, because a semaphore cannot say. `ImportSlot` is a
1398 `Drop` guard: two leaked permits would silently stop every future import.
1399 `retry_import` mutates the loaded row rather than rebuilding through `new()` — the
1400 wave 2 trap — and does not re-validate the stored source.
1401- **Two adjacent bare text nodes are one flex item**: the language label rendered as
1402 `Rust7.3 KB` because `gap-3` separates elements, not text. Same class of silent
1403 failure as `bg-muted`.
1404- **Orphan directories are moved aside, never deleted**, to
1405 `<data_dir>/orphaned/<seconds>-<name>`; the sweep skips that directory, runs after the
1406 import sweep (an interrupted import still has a row), and its decision is a pure
1407 function over strings, not typed names — a directory that does not parse is exactly
1408 what a sweep exists to notice. `GitStorage` gained `list_repo_dirs` and `quarantine`.
1409
1410
1411**The wave 3 integration pass (2026-09-06).** The six branches merged and run as one app
1412on port 3119 against this repository's own history — 190 commits, two branches, four
1413tags, 62 issues opened through the form, 55 of them labelled, one public repository and
1414one private. **One thing was broken at a seam**, and like wave 2's it was two branches
1415meeting rather than either being wrong on its own.
1416
1417- **A feed's cross-links were relative.** `markdown::Crossref` builds `/{handle}/repos/…`
1418 for `#12` and a bare sha, which is right on a page — a relative link survives a
1419 hostname change — and wrong in `issues.atom`, whose content is read in somebody's
1420 reader where a bare path resolves against whatever they last fetched, if at all. The
1421 entry's own `alternate` link, three lines away, was already absolute. `Crossref` gained
1422 an `origin` the feed sets from `public_origin` and every page leaves `None`. Neither
1423 branch could have found this: cross-links shipped before feeds, and feeds reused the
1424 page's renderer, which is exactly the shape a pass exists to catch.
1425- **The rest held.** A `#12` and a sha in an issue body and in the README both land;
1426 `?label=bug&page=2` keeps the filter and the Open/Closed links keep the label while
1427 dropping the page; `/log` clamps `?page=400` and `?page=banana`; the log's Feed link
1428 keeps `?rev=` on a paged revision; a 30-day token clones and pushes and the tokens page
1429 then shows its last use; a tag's `tar.gz` extracts under `steid-<tag>/`; search's
1430 switcher carries the query and drops the page; the blob header names Rust and TOML;
1431 a webhook fired by a real push redelivered byte-identically as `try 2`. **Anonymous on
1432 the private repository 404s on all twelve routes**, feeds and paged URLs included, and
1433 its name appears nowhere in the owner's public activity feed. `commits.atom?rev=older`
1434 is that branch's log. Screenshots in `target/shots/`, `wave3-*`.
1435- **Four seams closed with the pass** rather than found by it: a `Clock` port, so no use
1436 case reads the wall clock out of thin air; `orphaned` reserved as a handle, since the
1437 boot sweep is written never to look inside a directory by that name; a test that reads
1438 `styles.css` and pins it against `LabelColour::ALL` in both directions; and `parse_log`
1439 keeping empty fields, the latent bug the feeds branch named while writing the second
1440 parser.
1441- **Two findings, neither a break.** The Feed link on a filtered issue list offers the
1442 unfiltered feed, and `latest_tag` breaks a same-second tie by refname — only reachable
1443 from a fixture that tags twice in one second. Both in [current.md]current.md.
1444- **The README was rewritten** in the same pass: it still told a visitor that issues,
1445 webhooks and search did not exist. The install path had drifted too — the published
1446 target is `-gnu`, not the `-musl` the manual steps named.
1447
1448**Wave 3 merge note.** The feeds branch rebased cleanly onto the links branch and did not
1449compile: `markdown::render` had gained a parameter. A clean rebase is not a passing
1450build; every merge now runs the tests on main before the docs commit.
1451
1452### Wave 4 — the deeper git features · done
1453
1454**The wave 4 integration pass (2026-09-06).** Six seams between the wave's features,
1455then the whole thing walked as one app on a real instance: this repository pushed with
1456six branches and two tags, plus a purpose-built fixture repository (a rename, a
1457submodule, a markdown file with headings, a conflicting pair of branches) and one
1458private repository. Walked in a browser and with `curl`:
1459
1460- a pull request's **Files changed** shows highlighted diffs, Rust and markdown alike;
1461- the compare page's **Create pull request** carries both branches into the form, which
1462 prefills the title from a one-commit branch and opens a request that **merges**;
1463- a merged request's sha **lands on the commit page**, and the fast-forward merge left
1464 `main` alone because the box was unticked — which is seam 1, seen in a browser;
1465- **`Closes #1`** in a merged request's body closed issue 1 and left a comment naming the
1466 request and the branch it landed on; the `#3` in that comment points at `/issues/3`,
1467 which 303s to `/pulls/3` — the cross-kind redirect doing its job;
1468- a file's **History** follows the rename, and each row's sha reaches a commit page whose
1469 diff is highlighted;
1470- a rendered markdown file's headings carry ids and the README's
1471 `docs/notes.md#the-second-section` **lands on the section** — after the fix below;
1472- a **submodule row** links to `https://github.com/rust-lang/log.git` at its pinned sha;
1473- a **labelled pull request filters**: `?label=bug` narrows the list and all three state
1474 counts follow it, and the labels page counts issues and requests apart;
1475- the tree page's **last-commit column survived `pkill -f 'cat-file --batch'`** — same
1476 page, same 70 ms, two fresh processes;
1477- a **conflicted request** costs one `merge-tree`: 43 ms on the first view, ~18 ms
1478 after, and five more views wrote **no new loose objects**;
1479- **anonymous on a private repository 404s on every route this wave touched** — fourteen
1480 GETs and four POSTs, and the two POSTs that answer 400 answer it identically for a
1481 repository that does not exist, so nothing is leaked.
1482
1483What is worth not rediscovering:
1484
1485- **One thing broke at a seam.** Rendered headings gained ids, and both relative-link
1486 resolvers were still stripping `#fragment` from a link they rewrote — each with a
1487 comment saying the fragment had nothing to find, which had been true an hour earlier.
1488 A feature and the thing that links to it landed in different commits, which is exactly
1489 where an integration pass earns its keep.
1490- **A merge preview is cached per pair of commit ids**, in the adapter rather than the
1491 use case: the port's contract is unchanged, and `merge_preview` is both the expensive
1492 call and the one that writes. Content addressing is what makes the key safe — two
1493 commit ids determine their merge completely, so a remembered answer cannot go stale.
1494 Measured on a conflicted request: 43 ms then ~18 ms, and no new loose objects per view.
1495- **`Closes #n` is a domain parser and reads shape alone.** A bare `#4` stays a
1496 cross-reference; the keyword must start a word and be followed by spaces and then the
1497 reference, so `closes. #4` is two sentences. It runs **after** the branch has moved: a
1498 failure there leaves an issue open, where the reverse would close issues for a merge
1499 that never landed. A `Closes #n` naming a *pull request* closes nothing.
1500- **A followed count is capped at 500**, the last-commit column's number and for the same
1501 reason — `--follow` reads a tree per commit. `CommitCount` carries `capped` beside the
1502 total because "500" and "at least 500" are different statements, and the paging control
1503 offers only the pages that were counted.
1504- **The delete-source checkbox needed the default branch**, which the page did not have.
1505 It is asked for only when the merge box will draw a button at all, so a closed or
1506 merged request costs no extra process.
1507- **Two seam expectations were not met, by prior decision rather than by breakage**: the
1508 last-commit column still names the commit inside a merged branch rather than the merge
1509 (git's own `--name-only` answer), and a merged request's Commits and Files tabs go
1510 blank once the source branch is deleted, because both resolve refs live. Both are
1511 recorded as open in `current.md` with what changing them would cost.
1512
1513**Pull requests carry labels (2026-09-06).** The same labels the issues wear, from the
1514same repository-wide set: pills on the list rows and on the request, a Labels control
1515for the owner, and `?label=` on `/pulls` with all three state counts obeying it.
1516
1517- **A second join table, `pull_request_labels`, not one polymorphic table.** A
1518 `labelled (kind, subject_id, label_id)` would read tidily and would have to give up
1519 both `on delete cascade`s: SQLite cannot point a foreign key at whichever table a
1520 `kind` column names, so deleting a pull request would leave rows behind for the
1521 application to sweep by hand. `IssueId` and `PullRequestId` are different types for
1522 the same reason, and a `kind` column erases that at the boundary. The cost is a
1523 parallel set of four port methods, which is mechanical.
1524- **The labels page stays one page.** Labels are the repository's, not a tracker's, so
1525 there is one place to manage them — and the row now carries **two counts**, because
1526 one total covering both would make "it comes off 3 issues" wrong for whichever kind it
1527 was not counting. The pull request count is drawn only when it is non-zero.
1528- **A pill's destination is a parameter with a default** (`Filtering::Issues`), so the
1529 existing call sites are unchanged and a pill on a pull request leads to the other
1530 requests like it rather than to the issues.
1531- The filtered list is narrowed **in memory**, the issue list's shape and for its reason:
1532 the pairs are already read whole to draw the pills. Filtering costs the other two
1533 states' listings, and only when a filter is applied.
1534
1535**Highlighted diffs and one highlight cache (merged 2026-09-06).** The commit, compare
1536and pull-request diffs are coloured by the file's syntax; blob, blame and README fences
1537share a bounded cache. A 150 KB blob went from 327 ms to 15 ms on second view.
1538
1539- **The cache is keyed by content, so nothing can be stale**: a blob passes its object
1540 id (free), blame and fences a SHA-256 digest. **Blame must not use the blob's id** —
1541 its body is reassembled without a trailing newline and is not byte-identical.
1542 `fenced` is in the key so a fence and a blob cannot collide.
1543- **Bounded by bytes (64 MiB), not entries**; the `lru` crate with default features off
1544 carries the recency half. **The lock is not held across the highlight**: two concurrent
1545 misses both compute and the second insert replaces the first — a wasted parse, never a
1546 wrong answer.
1547- **`highlight::cache()` is a static that main also puts in app context** — the same
1548 `Arc`, because `markdown.rs` renders with no `Cx` in reach and threading a parameter
1549 through four call sites said nothing the static does not.
1550- **Diff hunks are highlighted twice, old side and new side**, never interleaved: an
1551 unterminated string on a removed line would otherwise bleed over the added line
1552 below. A hunk is parsed as if the file began at its first line; the limitation is
1553 asserted by a test. The tints at 12%/20% were already legible under every token;
1554 `styles.css` is unchanged.
1555
1556**File history, rendered markdown, submodules and symlinks (merged 2026-09-06).**
1557`/log/{rev}/-/{path}` follows a file through renames; a `.md` blob is a document by
1558default with `?view=source`; submodule rows link to an `https://` upstream from
1559`.gitmodules`; symlink rows show and follow their target.
1560
1561- **A file is followed, a directory is not**: git refuses `--follow` for a directory
1562 with a fatal exit, so the use case asks what is at the path first — `list_tree`, then
1563 `read_blob` with a **0-byte cap**, which resolves and sizes without reading, so
1564 deciding costs no process. **`rev-list` has no `--follow`**, so a followed count is a
1565 whole `git log --follow` walk, bounded only by the timeout. The count uses the same
1566 `follow` as the listing or the total is smaller than its pages.
1567- **A path not there at the revision is a 404**, not an empty list: those are different
1568 answers.
1569- **`.gitmodules` is read once per listing and only when a submodule is present**;
1570 only `https://` becomes a link (`ssh://`, scp-style and relative URLs stay text with
1571 the pinned sha). Symlink targets are read in bulk through the kept-alive cat-file,
1572 capped at 100 per listing — past the cap none is read, since a half-filled column
1573 says something false about the blanks. `resolve_relative` is shared by symlinks and
1574 markdown and refuses absolute targets and walks out of the tree.
1575- **`render_with_links` declines images** on purpose (a README's images sit at the root
1576 and rewriting trades a 404 for a broken image); the file view uses
1577 `render_with_targets` with `Relative::{Link, Image}`. Resolution happens before the
1578 scheme check, so a resolver cannot hand back `javascript:`.
1579- **`#[component]` drops outer attributes**, so `#[allow(clippy::too_many_arguments)]`
1580 on one does nothing and an inner allow is a parse error: fold parameters into a
1581 struct (`Listing<'a>`). The shadowing trap bit a fourth time (`let history = …`).
1582
1583**Pull requests (merged 2026-09-06).** Branch to branch within a repository, a
1584Pull requests tab, three sub-tabs, a merge box with merge-commit, fast-forward and
1585squash, source deletion, and a push event on merge so webhooks fire.
1586
1587- **A pull request is an issue with two branches and a merge attached**: it shares
1588 `IssueNumber` and the `repo_sequences` allocator, so `#7` names one thing;
1589 `/issues/{n}` and `/pulls/{n}` 303 to each other. **Three states, and merged is
1590 terminal**: `merge` refuses a second call, which is what makes a double-submitted form
1591 land one commit.
1592- **Nothing about the branches is stored while open** — every page resolves both refs
1593 live, so a force-push is simply the new proposal; `merge_commit` is the one exception
1594 because both branches may be gone afterwards. A branch resolves through `refs/heads/`,
1595 never by bare name (`rev-parse spike` would happily answer with a tag).
1596- **`git merge-tree --write-tree` computes the merge in the object database** — the
1597 third exit-status exception in `git_query.rs` (1 = conflicts), and **it writes**
1598 unreferenced objects on every preview. `GitMerge` is its own port (`commit_tree`,
1599 `update_ref`, `delete_ref`), not more `GitStorage` methods: that port's subject is a
1600 repository's lifecycle, and these write inside one. Two verbs and no `merge`, so
1601 fast-forward and squash compose in the use case.
1602- **Every ref move is a compare-and-swap** (`update-ref <ref> <new> <old>`); git's exit
1603 code cannot distinguish a stale old value from a fault, so stderr's "but expected" is
1604 matched. **The six steps' order is the design**: authorize and guard, recompute
1605 mergeability, write the commit (safe to fail, unreachable), move the target guarded,
1606 delete the source guarded, record events and mark merged.
1607- **A merge reaches webhooks through `record_push`** with synthesised snapshots, so a
1608 merge and a push produce the same events. Merging meets the shared write guard
1609 (`RepoWrite::Contents`); opening and commenting stay open on an archived repository.
1610- **git 2.38 detected once at boot** (`GitFeatures`); older git's `merge-tree` succeeds
1611 at the wrong thing (a three-way diff), so the box says so and draws no button. The
1612 install floor is unchanged; README notes the merge requirement.
1613- **Gotchas**: `commit-tree` needs git's `@<seconds> +0000` date form or it refuses `0`;
1614 a `bg-merged` passed through `attrs` onto a Primary badge lost to `bg-primary` by
1615 stylesheet order — hence a `Merged` badge variant. `--merged` is the theme's sixth
1616 semantic colour, purple, git's convention.
1617
1618**Before deploying 0.4.0 (2026-09-06).** A `robots.txt` disallowing the paths that spawn
1619git or pack the repository (archive, search, blame, compare, log, commits) — browsing,
1620issues and feeds stay crawlable, they are what a visitor came for (portfolio framing
1621retired 2026-09-27, ADR 0010) — and an `ArchiveLimiter` at
162210 per client and 60 global per minute, its own budget for the reason the git-auth one
1623is. Chosen over a Caddy rate limit because stock Caddy has none without a plugin, and
1624the limiter already existed. Nobody but the owner can write anything: there is no
1625registration, every write use case requires `Role::Owner`, and the exposure of a public
1626instance is git work on public repositories, not data.
1627
1628**Released as 0.4.0 (2026-09-06)** — waves 2, 3 and 4: import, issues, labels, webhooks,
1629pull requests, feeds, paging, token lifecycle, the kept-alive cat-file, file history,
1630rendered markdown, highlighted diffs and the caches. Thirteen additive migrations since
16310.3.0, so `deploy.sh`'s rollback still restores a database the old binary reads.
1632Merging pull requests needs git 2.38 on the server; the Lightsail box has 2.47.
1633
1634> **Correction, 2026-10-01.** The rollback does not work across a migration, additive or
1635> not. `migrate()` calls sqlx 0.9's `run()` with its default `ignore_missing: false`, so a
1636> binary that finds an applied migration it does not know exits with `VersionMissing`
1637> and systemd restarts it for ever — and `deploy.sh` restores the binary, never the
1638> database. Expand-only migrations make the old binary *able* to read the new schema;
1639> this check stops it from trying. The fix and the first release a rollback can reach
1640> are [launch 1.2]../../plans/launch.md#phase-1-before-anything-else.
1641
1642### The ops step · done (2026-09-08)
1643
1644Prep before the wave: `src/cli.rs` (`steid` serves; `steid backup|restore|reset-password`
1645are subcommands, stubs until their steps land — exit 3, distinct from a usage error's
16462; no argument-parsing crate for three commands), `STEID_OPERATOR_TOKEN` on `AppConfig`,
1647and `web::operator::operator_authorized(cx)`: a constant-time bearer check that is
1648`false` both when no token is configured and when the wrong one is presented, so an
1649instance never given a token advertises no operator surface (404, not 401).
1650
1651**The operator surface (merged 2026-09-08).** `GET /api/instance` and `POST /api/setup`
1652in `web/instance.rs`, JSON only, no layout, no cookie, no session.
1653
1654- **One response struct with optional fields, not two**: anonymous callers get exactly
1655 `{"claimed":false}` (a unit test pins the bytes) and the operator bearer adds version,
1656 git version, merge support, counts and uptime. A wrong operator token gets the public
1657 answer, not a 401 — a 401 would confirm a token exists to guess.
1658- **`POST /api/setup` refuses identically for every reason** — wrong token, already
1659 claimed, bad handle — with the same 404 body from one helper, and both interesting
1660 refusals return before Argon2 runs so timing matches. It issues no session: a control
1661 plane holding a cookie would be a browser.
1662- **`STEID_TRUSTED_PROXY`, off by default, closes the wave-1 question.** Off, the rate
1663 limiters read no header and every caller shares one key (global caps only); on, the
1664 rightmost `X-Forwarded-For` as before. `install.sh` sets it true because it installs
1665 Caddy. `client_key` was split into a testable `key_from(trusted, headers)`.
1666- **`cargo audit` is part of done.** First run found `h2` 0.4.15 (RUSTSEC-2026-0258,
1667 reachable through hyper on every request); fixed by a lock-only bump to 0.4.19. Three
1668 advisories stand with no fix to take: `bincode` and `yaml-rust` unmaintained (via
1669 syntect) and a yanked `chacha20` (via topcoat-session).
1670- `UserRepository::count` and `RepoRepository::count` are instance-wide sizes, not
1671 listings; the repository count includes private ones on purpose. `GitFeatures` now
1672 keeps the version it parsed; `StartedAt` lives in app context as an `Instant`.
1673
1674**A metrics endpoint (merged 2026-09-08).** `/metrics`, operator-bearer only (404
1675otherwise), hand-written Prometheus exposition, one counting line at each site.
1676
1677- **No metrics crate**: counters and four gauges over a closed label set. **Every label
1678 is a slot in a fixed array** indexed by an enum or a `const` table, so cardinality is a
1679 property of the type — a path or handle as a label would make a scrape an unbounded map
1680 an anonymous caller controls. Nothing on the page names a repository. Every series is
1681 emitted from boot including zeroes, or `rate()` reads the first error as a reset.
1682- **Counting lives in infrastructure only.** Webhook outcomes in the sender, import
1683 outcomes in `DiskGitImport::mirror` — because `run_import` answers `Ok(())` for a
1684 failed import (the failure is data on the row). `git::count_spawn(&Command)` derives
1685 the subcommand from the built command past `-C`/`--git-dir`/`-c`, so a call site adds
1686 one line with no label to get wrong.
1687- **Requests are counted in the security-headers layer, and that is not optional**:
1688 `.discover()` allows one layer per path. **A behaviour change came with it, and it is a
1689 fix**: a handler's `Err` was converted to a 404/500 *above* every layer, so until now
1690 **every 404 went out with no CSP, no `X-Frame-Options`, no `Referrer-Policy`**, and the
1691 error half of the site was uncountable. The layer now converts the error itself.
1692- **`/metrics` is rate limited only on the unauthorized path** (30/client/min, 300
1693 global): an authorized scrape never touches the limiter, so guessing from elsewhere
1694 cannot starve a collector — the opposite order from `/auth/login`, where the expensive
1695 work is the hash and must be gated first. Gauges are sampled from their real owners at
1696 scrape time, never mirrored. Two escapers, because help text is not quoted.
1697
1698**Releases served from the instance (merged 2026-09-08) — Milestone 5b's last item.**
1699`https://jpgill.dev/install.sh` and `…/repos/steid/releases/v0.4.0/<artefact>` serve;
1700the stranger's one-liner has now actually run, in clean Debian 12 containers on both
1701architectures, from the real URL. No Rust changed.
1702
1703- **Artefacts live at `/srv/steid-dist`, not `/var/lib/steid/dist`** as the runbook and
1704 `deploy/Caddyfile` said: that directory is the instance's state *and* its backup
1705 surface (`deploy.sh` tars it on every deploy), and it is `750 steid:steid` while Caddy
1706 runs as `caddy`. The URL is unchanged.
1707- **`handle_path`, not `handle`, for the releases block** — `handle` keeps the prefix, so
1708 `file_server` looked under the full URL path and every download 404ed while
1709 `caddy validate` said fine. **The trailing `handle { reverse_proxy }` is load-bearing**:
1710 a bare `reverse_proxy` runs for every request including the static ones.
1711- **`deploy.sh --publish`**, off by default: a publish changes what strangers get under a
1712 version number that can never be re-cut, and would publish only the architecture that
1713 deploy built. It verifies over HTTPS, not on the filesystem. **No `rsync` on the box**
1714 (Debian 13 minimal): `scp` to the login home then `sudo install -m 644`.
1715- **0.4.0's `aarch64` artefact did not exist** and was built from the release commit with
1716 `git archive`, so nothing later leaked into a tarball wearing that version.
1717- **Found by running the download path: a first install kept Caddy's placeholder
1718 Caddyfile**, so the domain served Caddy's welcome page silently. Fixed in `install.sh`.
1719
1720**Backup and restore (merged 2026-09-08).** `steid backup <dest>` writes one `tar.gz`
1721(manifest, `steid.db` via `VACUUM INTO`, the data directory); `steid restore <archive>`
1722refuses a non-empty instance or a newer archive; an owner-only download on the settings
1723page at 2 per hour; `install.sh --backups daily`, off by default.
1724
1725- **`VACUUM INTO`, not a file copy, and it is a port** (`DatabaseSnapshot`): SQLite
1726 writes through a `-wal` sibling, so copying `steid.db` on a serving instance restores a
1727 database that never existed.
1728- **`back_up` takes no `Actor`, `back_up_for` does.** Whoever runs `steid backup` is root
1729 on the box and already holds the files; an `Actor::System` variant would be a value
1730 meaning "skip the check". Only `back_up_for` is reachable from the network.
1731- **"The owner" is the sole user** (`is_instance_owner`), because a backup is every row
1732 and every private repository; it answers `false` for everybody once a second user
1733 exists — Milestone 7 needs an instance-level role.
1734- **Scratch lives at `<data_dir>/.backup`**, never `/tmp`: the dot is load-bearing, since
1735 a handle cannot start with one and the packer skips top-level dot-directories, which is
1736 what keeps a backup from containing the copy it is built from. Verified live.
1737- **The web download unlinks the archive while it is open**, so a client that disconnects
1738 mid-download leaves no copy of the database on disk. The ownership check runs *before*
1739 the limiter, the reverse of every other limited route: a stranger must not be able to
1740 spend the owner's two-an-hour budget.
1741- **Backup opens the database without migrating** (`database::open`), so a control plane
1742 snapshotting a database an older binary still serves applies no schema change; restore
1743 migrates because a fresh install has no file at all. `replace` closes the pool: after
1744 that line the process may only finish restoring and exit.
1745- New deps: `tar`, `flate2`, and `tempfile` promoted from dev.
1746
1747**Password reset with email, change password, and the CLI fallback (merged
17482026-09-08).** `/auth/forgot`, `/auth/reset/{token}`, a password section on settings,
1749`steid reset-password <handle>`, `STEID_SMTP_URL` + `STEID_MAIL_FROM` + `STEID_PUBLIC_URL`.
1750
1751- **The forgot path leaked which way it was *faster*.** Copying login's dummy-hash trick
1752 onto the miss branch made the *hit* the quick one (7 ms vs 234 ms). The verification is
1753 now unconditional, before the branch; measured ~230 ms either way. No test — a timing
1754 assertion is a flaky test — so the guard is the comment. **The residual signal is a
1755 hit's SMTP round trip**; closing it needs a send queue.
1756- **The reset page has its own limiter** (30/client/min): it is a page a person reloads,
1757 and on the sign-in budget six loads locked them out of `/auth/login`. `/auth/forgot`
1758 stays on the sign-in budget because it is an address probe.
1759- **dotenvy needs quotes and fails the rest of the file silently**: an unquoted
1760 `STEID_MAIL_FROM=Steid <x@y>` makes `dotenv()` error, which `main` discards, dropping
1761 every later variable. Quote values with spaces or angle brackets.
1762- **lettre**: `default-features = false` plus `builder`, `smtp-transport`, `tokio1`,
1763 `tokio1-rustls`, `ring`; `rustls-native-certs` so an internal relay with a private CA
1764 works — which makes the Dockerfile's `ca-certificates` line load-bearing. Mail is built
1765 at boot and exits 4 on bad config, so per-request construction cannot fail.
1766- **`steid reset-password` deliberately says whether the handle exists**: whoever runs it
1767 has the SQLite file in front of them, and the one tool a locked-out owner has must be
1768 distinguishable from a typo. It takes no `Actor`, like `claim_instance`.
1769- **A reset ends every session including the asker's; a change ends every *other* one**
1770 and retires outstanding reset links. `delete_by_user(user, except)` is one statement.
1771 Reset rows are marked used, not deleted, so a replayed link can say "already used".
1772
1773### The tidy-up wave · done (2026-09-08)
1774
1775**Review steps 1 and 8 (merged).** The six biggest `mod tests` blocks moved to sibling
1776`<module>_tests.rs` files via `#[path]` — no module-tree change, no widening, not one
1777test touched; `repo.rs` 3,127 → 739, `git_query.rs` 4,958 → 1,293, `sqlite.rs` 4,158 →
17781,791. `git_query`'s parsers now live in `git_query/parse_{refs,log,tree,diff}.rs`, each
1779pure; **a `--format` const lives with the parser that reads it**, not the call site, so
1780the two cannot drift. `#[path]` on a module declared in a non-inline module resolves
1781relative to the declaring file's directory. The convention is in `architecture.md`.
1782
1783**Review step 7 (merged).** `infrastructure/git.rs` (3,746 lines, six ports) is a
1784directory with one file per port — `git/{storage,protocol,archive,import,merge}.rs` —
1785and `InMemoryGitQuery` sits beside `DiskGitQuery` in `git_query/in_memory.rs`. No call
1786site or signature changed; `git_command`, `count_spawn` and `run_git` stay in `git/mod.rs`
1787where every file can see them. Shared test fixtures are a `#[cfg(test)] pub(crate) mod
1788fixture` (sibling test modules cannot see a `pub(super)` item of `git`). Checked by
1789diffing every `fn` name and the sorted bodies before and after. `architecture.md` now
1790names `application/reconcile.rs` as the sweep it said nobody had written and stops
1791crediting `#[memoize]`, which nothing uses.
1792
1793**Review steps 2 and 3 (merged).** One `context::owned_repo`, one `owned_profile` (the
1794review's three "inline copies" were profile guards, a different read), and one
1795`context::write_failure`; eight guards and four mappings deleted. **`pulls.rs` keeps a
1796mapping of its own** for its three genuine arms (archived, unavailable, a raced merge)
1797and delegates the rest — the shape any page with something extra to say should copy.
1798**The one behaviour change**: nine owner-only routes that answered 403 to a stranger now
1799answer 404, wave 5's rule everywhere. Two 403s remain on purpose: the git transport's
1800"authenticated but may not push", and a merge whose session outlived its user.
1801`web/format.rs` and `web/urls.rs` took the formatters and URL builders out of
1802`browse.rs` (1,654 → 1,357; importers 16 → 7); `urls.rs`'s doc carries the one encoding
1803rule — a revision is encoded whole, a path keeps its slashes.
1804
1805### The pre-control-plane wave · done (2026-09-10)
1806
1807**Expand, deploy, contract (merged).** The rule is in `architecture.md` → "Migrations"
1808and enforced by `database_compat_tests.rs`: a lexical guard over the real `migrations/`
1809directory rejects `drop column`, `drop table`, `rename`, and `add column … not null`
1810without a default; a replay test applies 0.4.0's migration set and runs today's reads
1811against it — the reverse direction, proven because `database::open` (backup) opens
1812without migrating. **The forward direction (old binary, new schema) is not tested**; it
1813needs the old tarball and is a CI job. Comments must be stripped before matching —
1814every migration's prose says "drop" and "rename" while doing neither — and string
1815literals kept for execution. `RELEASED_0_4_0` in the test is the authoritative last
1816release set; `plans/releases.md` is the human record, reconstructed from the four
1817release commits; a prefix test keeps them honest and catches a back-dated migration.
1818Every existing migration already complied.
1819
1820**Access, second pass (merged).** `visible_repo` is the bottom of the predicate stack in
1821`access.rs`; `readable_repo` and `changeable_repo` are written in terms of it, so the
1822visibility rule has one body — a read rule and a write rule that disagree fail open, which
1823is why this preceded milestone 7. `is_instance_owner` became `access::instance_owner`
1824and `context::instance_owner(cx)`: the *name* is stable and the *body* is what
1825milestone 7 replaces. It takes `users`, not `Stores`, because instance ownership needs
1826none of the triple. `operator_authorized` stays a machine credential in the web layer;
1827`architecture.md` now says two kinds of caller, two predicates. The milestone 7 shape
1828lives in `access.rs`'s module doc, cited by function name.
1829
1830**The composition root, and the first HTTP tests (merged).** `infrastructure::app::build(
1831config, pool, assets, setup) -> RouterBuilder` holds every `app_context` call and layer;
1832`sweep_on_boot` holds the three sweeps; `main.rs` went 523 → 173 lines with no decision a
1833test would assert. `build` returns the builder so a test can append a fake; takes the
1834`AssetBundle` rather than calling `load()`, which walks up from the *executable* and would
1835make tests depend on `topcoat asset bundle`; clears `setup_token` itself so the running
1836app holds the claim secret only in `SetupState`; prints nothing. **The chain is
1837append-only, written at the top of the module.** `src/cli/{backup,restore,reset_password}.rs`
1838are library functions with eleven tests on real SQLite in a tempdir — the operator's
1839recovery path had none because it lived in a binary. `tests/http.rs` boots `build` on
1840`127.0.0.1:0` with `serve_until` and a `oneshot`, `ureq` in `spawn_blocking` as the
1841client, 0.3 s: security headers on a 200, a 307 and a 404; CSRF 403 with the sentence;
1842`/metrics` 404 byte-identical to an unrouted path; claim through `/api/setup`. **It serves
1843an empty asset bundle, so it must never render a view** — the asset renderer panics on a
1844catalogue miss; the signed-in assertions (303-after-POST, `__Host-` cookie) need the real
1845bundle and a signed-in helper.
1846
1847**Search rate limit, and the plain git read capped (merged).** `SearchLimiter`, 20 per
1848client per minute and 120 globally, its own budget so a crawler walking `?q=` cannot lock
1849the owner out of sign-in; an empty query is free (it never reaches grep); the refusal is
1850a page with the form still filled and `Retry-After` on the response. `run` now goes
1851through the capped reader at `MAX_RUN_BYTES = 32 MiB` and over it is
1852`GitQueryErrorKind::TooLarge`, an *error* rather than a truncation because the reads
1853through `run` are parsed whole — half a ref list is a wrong answer, not a smaller one.
1854Unreachable today (every caller is bounded by its own arguments), which is the point.
1855`Limiter::Search` is on the metrics enum beside the others. `run_allowing` is the one
1856reader still uncapped.
1857
1858**`csrf_scan` walks `web/` recursively (2026-09-10)**, with a test — the second
1859organisation review's step 5, done before any web module became a directory, because a
1860non-recursive scan would silently drop every handler moved into one. The same review's
1861three stale claims in `architecture.md` (a `RegistrationPolicy` that does not exist,
1862"the one place" without its two footnotes, and the test-file count) are corrected there.
1863
1864**Released as 0.5.0 (2026-09-10)** — the ops step, the tidy-up and access refactors,
1865CSRF, both reviews and their fixes, and the pre-control-plane wave. Two additive
1866migrations since 0.4.0. The first release the control plane can provision from:
1867`/api/instance`, `/api/setup`, `steid backup`/`restore`, `/metrics`, password reset.
1868Deploying it breaks every open form once (per-boot CSRF secret) and needs
1869`STEID_OPERATOR_TOKEN` in the box's env for the operator surface.
1870
1871### Milestone 0 — Skeleton · done
1872
1873Topcoat 0.5 app serving pages, `AppConfig` from `STEID_*` env, SQLite pool in app
1874context. Split into a library plus a thin binary — the domain layer had no consumers
1875yet and read as ~30 dead-code warnings in a bare binary, and it unlocks `tests/`.
1876Topcoat's link-time page discovery works from a library; that was checked, not assumed.
1877
1878**Requires rustc ≥ 1.95.** On older toolchains `cargo add topcoat` silently resolves to
1879an empty `topcoat v0.0.0` placeholder instead of failing. Local stable was 1.97.1 at the
1880time.
1881
1882#### Routing findings
1883
1884Moved here from `current.md` on 2026-10-01; durable facts about Topcoat 0.5.
1885
1886- `Router::builder().discover()` collects `#[page]`-annotated items **at link time**,
1887 so pages can live in any module. Layering is our choice, not the framework's.
1888- `module_router!` derives each URL from the module tree rather than a path string.
1889 Still deferred. Application routes now group cleanly (`auth/login`, `api/me`), but
1890 handles sit at the root ([0004]decisions/0004-root-handles-grouped-routes.md), so a
1891 parameterised root segment still has to coexist with static ones. Worth checking how
1892 `module_router!` handles that before committing to it.
1893- Path and query params are read from `Cx` via `path_param!` / `#[query_params]`, not
1894 injected as handler arguments. Parses are memoized per request.
1895- Layouts wrap by path prefix and nest outermost-first, and a layout can catch a page's
1896 `NotFoundError` to render a branded 404.
1897- `HOST` / `PORT` configure the bind address, so `STEID_LISTEN_ADDR` is gone.
1898- `Body` is a boxed `http_body::Body` used for both requests and responses, with
1899 `into_data_stream()` to read and `Body::new()` to wrap a stream — pack data can
1900 stream both directions without buffering. This is what makes Milestone 4 viable.
1901
1902### Milestone 1 — Identity, thin · done
1903
1904**Domain.** Typed IDs, `Email`, `PasswordHash`, `OrgName`, `Organization`, `User`,
1905`Membership`, `Role`, `Actor`, `Session`, `SetupToken`, `DomainError`. Value objects
1906pair `new()` (validates) with `from_trusted()` (skips, for rows already validated).
1907
1908**Application.** `claim_instance`, `login`, `resolve_actor`, `record_session`,
1909`end_session`, `sweep_expired`. `PasswordHasher` port with Argon2 and a stub.
1910
1911**Infrastructure.** Migrations for orgs, users, memberships, sessions. In-memory and
1912SQLite implementations of every port. Root layout, `/setup`, `/login`, `/logout`, home,
1913and `/api/me`.
1914
1915`describe_identity` is the first use case with two consumers — the home page and
1916`/api/me` both read through it. Until that existed, "the application layer is
1917transport-neutral" was an assertion with one caller behind it.
1918
1919**Verified in a browser and by curl:** wrong token refused with nothing written;
1920correct token creates org + user + owner membership and signs the owner in; session
1921authenticates; logout clears cookie and row; wrong password bounces; right one signs
1922in; re-claiming a claimed instance is refused.
1923
1924#### Decisions worth remembering
1925
1926- **`Actor` is an enum with an explicit `Anonymous`**, not `Option<UserId>`. Attempt #2
1927 used a placeholder `UserId("ssh-anonymous")` and it became a security hole. A variant
1928 can't be forgotten the way a sentinel can.
1929- **`login` verifies a dummy hash when no user matched.** Returning early on the
1930 unknown-email path makes it measurably faster and leaks which addresses have
1931 accounts. A test pins that the dummy stays parseable — if it stops being, `verify`
1932 bails early and the defence dies silently.
1933- **`SetupToken` compares in constant time.** An early-return comparison leaks how much
1934 of the token is right, which recovers it a character at a time.
1935- **The setup token is only in app context while unclaimed**, so a claimed instance has
1936 nothing for a claim attempt to match.
1937- **SQLite ignores foreign keys unless asked**, per connection. `foreign_keys(true)`
1938 plus a test that a user pointing at a missing org is refused.
1939- **`sqlx migrate add` stamps versions to the second** — three calls in one second
1940 collide, leaving apply order ambiguous between tables that reference each other.
1941- **An unparseable role surfaces as an error**, never as "no membership". The latter
1942 silently downgrades an owner to no access.
1943- **`Secure` session cookies over plain-HTTP localhost fail silently.** See
1944 [runbook.md]runbook.md#steid_insecure_cookies--development-only. This one actually
1945 bit, and it looked exactly like broken auth logic.
1946
1947### Milestone 2 — Profile page · done
1948
1949`/{handle}` is the real profile page: label, handle, bio, and the section frame for
1950repositories, writing, and projects. Public, renders signed out, 404s on an unknown
1951handle, and resolves regardless of casing. `/` forwards a signed-in owner to their own
1952profile. `/api/users/{handle}` serves the same read model as JSON.
1953
1954URLs settled as root handles with grouped application routes
1955([0004]decisions/0004-root-handles-grouped-routes.md), superseding
1956[0003]decisions/0003-scoped-urls.md the same day. A twenty-word reserved list in
1957`OrgName::new` keeps handles from shadowing routes.
1958
1959#### Decisions worth remembering
1960
1961- **`PublicProfile` has no email field, deliberately.** `Identity` does, and `/api/me`
1962 returns it, because that endpoint describes the caller to themselves. Giving the type
1963 that reaches the page nowhere to put an email makes the leak impossible rather than
1964 merely avoided.
1965- **`viewer_is_owner` is decided in the use case**, so the web form and `/api` cannot
1966 disagree about who may edit. Tested for a signed-in stranger and a non-owner member —
1967 "signed in" quietly becoming "allowed" is the usual failure.
1968- **`Organization::update_profile` clears on blank input** rather than storing
1969 whitespace, so cleared and never-set are one state and the page renders one case. A
1970 rejected edit applies nothing.
1971- **Bio length counts characters, not bytes.** A byte check would reject a bio of
1972 accented text well under the limit.
1973- **`path_param` is an attribute macro in 0.5**, not function-like. The vendored crate
1974 is the authority for the pinned version, not the docs on `main`.
1975- **Components are invoked bare inside `view!`**, and `if`/`match`/`for`/`let` are
1976 native to the macro.
1977- **`#[query_params]` needs `error = …`** to work with `?`; otherwise the error borrows
1978 from `cx` and escapes the handler.
1979- **Forms re-render on failure and redirect on success.** Redirecting after a
1980 validation error throws away what was typed and hides the reason.
1981- **Styling is Tailwind via Topcoat's build script**, with registry components copied
1982 in rather than depended on ([0005]decisions/0005-tailwind-and-copied-components.md).
1983 Components reference theme tokens, never raw colours.
1984
1985### Milestone 3 — Repo model · done
1986
1987Repositories exist as records and as bare repos on disk, and they appear on the
1988profile. Domain, both persistence adapters, `GitStorage` with `DiskGitStorage` behind
1989it, `create_repo` / `view_repo` / `list_repos`, the `/{handle}/repos/new` form and
1990`/{handle}/repos/{name}` page, the profile's Repositories section, and
1991`/api/users/{handle}/repos`. How git is invoked is recorded in
1992[0006]decisions/0006-git-binary-behind-narrow-ports.md.
1993
1994**Verified in a browser and by curl:** the owner creates a repo through the form, a
1995bare repo appears at `{data_dir}/{handle}/{name}.git`, and it lists on the profile; a
1996private repo is absent for a signed-out visitor on both the page and `/api`; an unknown
1997handle 404s rather than answering `[]`. `git clone` does not work yet — Milestone 4.
1998
1999#### Decisions worth remembering
2000
2001- **`git init` on an existing repository exits 0 and re-initialises in silence.**
2002 Measured, not assumed. So `AlreadyExists` has to be our own `path.exists()` check —
2003 there is no exit code to key off. Refusing rather than adopting matters because a
2004 directory with no matching row is an orphan from a crashed create, and re-initialising
2005 it would resurface a private repository's objects under a fresh record.
2006- **`git init` creates missing parent directories itself**, so there is no
2007 `create_dir_all` before it. This was in the plan and the probe removed it.
2008- **`--template=` takes a new bare repo from 18 files to 2.** The default seeds sixteen
2009 `.sample` hooks. Timed at 15.2ms against 13.1ms across 20 runs — so the ~2ms is not
2010 the reason; Steid installs its own hooks later and the samples would be noise to work
2011 around.
2012- **`--initial-branch=main` is explicit** so the host's `init.defaultBranch` cannot
2013 decide it. This machine's git already says `main`, which is precisely why a drift
2014 would go unnoticed — hence the test.
2015- **`GIT_CONFIG_GLOBAL` and `GIT_CONFIG_SYSTEM` are pointed at `/dev/null`**, and the
2016 five `GIT_*` variables that redirect object storage are removed from the child
2017 environment. `GIT_DIR` was checked and does *not* override an explicit path argument,
2018 but `GIT_OBJECT_DIRECTORY` does redirect where objects land, and the failure is
2019 silent — the repository just looks empty.
2020- **One `run_git` owns the invocation.** With a single caller this looks premature; it
2021 is a private function rather than a public abstraction for that reason. The point is
2022 that Milestone 4's `http-backend` spawn cannot quietly disagree about isolation.
2023- **`tokio::process` and `tokio::fs`, never the `std` equivalents.** `init_bare` is not
2024 hot — ~13ms, once per repository — but `remove_dir_all` on a repo with real history
2025 walks every loose object and would stall a runtime worker. The performance that
2026 matters is Milestone 4's per-request spawn, not this.
2027- **`tempfile` for test fixtures, not `target/`.** Parallel-safe by construction and
2028 self-cleaning on panic. Debris under `target/` would be actively harmful here, since
2029 `init_bare` refuses a path that already exists.
2030- **Membership is resolved once per listing, not once per row.** Obvious in hindsight;
2031 the shape that invites the mistake is filtering inside a loop that can `await`.
2032- **One empty state serves "no repositories" and "none you may see".** A distinct
2033 message for the second — or any count — leaks that private repositories exist and how
2034 many. Tested, because it is the kind of thing a later "helpful" tweak would undo.
2035- **`redirect()` is a 307, and 307 preserves the method.** Post/redirect/get needs a
2036 303, or the browser re-POSTs the form to its redirect target. Milestone 2's settings
2037 form shipped with this and nothing caught it — every test passed, because the tests
2038 are on the use case and the bug is in the reply. Found by following the redirect with
2039 curl. The fix is a `StatusCode::SEE_OTHER` plus a `Location` pair inside `view!`,
2040 wrapped as `web::context::location`, because `see_other()` is a response type and
2041 `#[page]` must return a view for the layout to wrap the failure re-render.
2042 `RedirectError::new` is private, so a 303 cannot be built as an error, and the
2043 error-to-response path only downcasts topcoat's own error types — a custom one
2044 becomes a 500.
2045- **`#[page]` returns a view; `#[route]` returns a response.** That is the whole reason
2046 the redirect is spelled awkwardly: a form handler needs both a redirect and a
2047 full-page re-render, and only the view path gets the layout.
2048- **Boolean HTML attributes take an explicit value in `view!`** — `required=(true)`, not
2049 bare `required`, which fails to parse. `false` omits the attribute entirely, so
2050 `selected=(bool)` on an `<option>` is correct rather than rendering `selected="false"`.
2051- **`topcoat ui add select` needs the `icon-iconify` feature and a staged icon set.**
2052 The chevron comes from `feather`, staged in `build.rs`. No new crates, but the build
2053 fails with a clear message until the set is staged.
2054- **`is_org_owner` moved to `application/authz.rs`** on its second caller. Owner-ness
2055 gates the profile edit, repo creation, and later PATs and push; two copies of an
2056 authorization predicate drift, and the direction they drift is open.
2057- **The compensating transaction is safe to do by path.** `remove` after a failed save
2058 can only ever delete what `init_bare` just created, because the loser of a concurrent
2059 create never gets past `init_bare`. Non-obvious enough that it is commented in the
2060 code as well as here.
2061- **Compensation is best-effort.** If the removal also fails, the caller still gets the
2062 error that started it — an orphaned directory is the documented failure mode, and
2063 replacing the real error with the cleanup's error would hide the cause.
2064- **`InMemoryGitStorage` enforces `AlreadyExists` too.** A permissive fake would let
2065 `create_repo` pass while the real adapter refused. The fake mirroring the rule is the
2066 point of having two implementations.
2067- **`/api` resolves the handle without loading a profile.** `handle_param` split out
2068 of `profile_for` so the repo listing route 404s on `list_repos`' own `None`. Routing
2069 it through the profile would have made that `None` unreachable and left the page and
2070 `/api` disagreeing about what an empty repository list means (portfolio framing
2071 retired 2026-09-27, ADR 0010) — the exact duplication
2072 `architecture.md` says to watch for.
2073- **The `/api` listing is a bare array, not an envelope.** Matches `/api/users/{handle}`
2074 returning a bare object. Pagination later means a wrapper and a breaking change; taken
2075 knowingly, since one owner means a handful of repositories (personal-first framing
2076 retired 2026-09-27, ADR 0010) and there are no
2077 consumers yet.
2078- **`Repository::description` stays.** Added unrequested and flagged; kept on review
2079 because this milestone's own "Done when" puts repositories on the profile, which
2080 makes it a consumer inside the milestone rather than speculation. Worth noting the
2081 window that closed: the repositories migration had not yet been applied to the dev
2082 database, so removing the column would have been a free in-place edit rather than a
2083 second migration.
2084
2085### Milestone 4a — Clone over HTTP · done
2086
2087`git clone` works against a public repository, for anyone, with no credentials.
2088`GitProtocolServer` (CGI-shaped) with `GitHttpBackend` behind it, the `serve_git` use
2089case, and three routes under `/{handle}/repos/{name}.git/`. Bodies stream both
2090directions.
2091
2092**Verified against a real client**, not only by unit test: an anonymous `git clone` of a
2093201-ref repository returns 201 commits and 203 refs with `HEAD` matching the origin, on
2094protocol v2 and on v0; a private repository answers 404 to an anonymous clone but 200 to
2095its owner's browser session; `git push` is refused with 403; and unknown repo, unknown
2096handle, missing `service`, an unknown service, a missing `.git` suffix, and a
2097dumb-protocol object path all answer 404 while the repository page still answers 200.
2098
2099`git http-backend`'s contract, probed against git 2.50.1 by driving the CGI from a
2100throwaway server and cloning through it. Everything below is measured, not read.
2101
2102#### The contract
2103
2104- **`HTTP_CONTENT_ENCODING`, not `CONTENT_ENCODING`.** CGI gives only `Content-Type` and
2105 `Content-Length` unprefixed names; every other request header is `HTTP_`-prefixed, and
2106 `http-backend` looks for the prefixed one. **This is the finding that would have cost a
2107 day.** With the wrong name, `http-backend` hands the still-compressed body to
2108 `upload-pack`, which dies with `bad line length character` and the client reports
2109 `fatal: expected 'packfile'` — nothing names gzip, or the environment, anywhere in the
2110 failure. And it only happens once a repository has enough refs for the client to bother
2111 compressing: a one-ref test repo passes.
2112- **`HTTP_GIT_PROTOCOL`** carries `version=2` through to `upload-pack`. Clones verified
2113 on v2 and on `protocol.version=0`, both 201 commits, both gzipped.
2114- **`GIT_PROJECT_ROOT` plus `PATH_INFO`**, where `PATH_INFO` is the on-disk path relative
2115 to the root. Steid's URL and its storage layout differ — `/{handle}/repos/{name}.git/…`
2116 against `{data_dir}/{handle}/{name}.git` — so the adapter rewrites the middle segment
2117 out. `GIT_PROJECT_ROOT` is the data directory.
2118- **`GIT_HTTP_EXPORT_ALL=1` is required.** Without it every repository answers `Status:
2119 404 Not Found` and `Repository not exported`, unless a `git-daemon-export-ok` marker
2120 file sits in the bare repo (confirmed: dropping that file in re-enables it).
2121- **Headers are CRLF-terminated and end at `\r\n\r\n`.** No bare-LF variant was
2122 observed, but the adapter should accept one rather than hang.
2123- **`Status:` appears only on failure.** Its absence means 200, and it must be
2124 translated, not forwarded as a header.
2125- **`http-backend` sets its own `Content-Type` and cache headers** — `Expires: Fri, 01
2126 Jan 1980`, `Pragma: no-cache`, `Cache-Control: no-cache, max-age=0, must-revalidate`.
2127 Steid forwards them rather than inventing its own.
2128
2129#### Decisions worth remembering
2130
2131- **`GIT_HTTP_EXPORT_ALL`, never `git-daemon-export-ok`.** The marker file is git's own
2132 visibility mechanism and it looks tempting, but visibility lives in the `repositories`
2133 table and the use case is what enforces it. A marker file would be a second source of
2134 truth for the same question, free to drift from the first, and the drift direction is
2135 "private repository still clonable". Steid decides; git is told to stop asking.
2136- **`receive-pack` is refused by default** — `Status: 403 Forbidden`, `Service not
2137 enabled: 'receive-pack'`, without any configuration. Convenient for 4a, but the routes
2138 still refuse writes explicitly rather than leaning on it: a default that helpfully
2139 changes is not an authorization decision.
2140- **A non-zero exit can arrive after the headers are already out.** The gzip failure
2141 exited 1 having emitted a complete, successful-looking header block. So the exit code
2142 cannot gate the response — by the time it is known, the status is sent. It belongs in
2143 the log.
2144- **A missing repository is `Status: 404` with exit 0.** Failure is reported in the
2145 CGI stream, not the exit code, and the two disagree in both directions.
2146- **The router is the allowlist.** Only `info/refs`, `git-upload-pack` and
2147 `git-receive-pack` are routed. Handed any other path, `http-backend` serves
2148 dumb-protocol object files straight off disk — a read of a repository nothing
2149 authorized. Verified: `/…​.git/objects/info/packs` answers 404.
2150- **The endpoint is named by the route, not parsed from the path.** Three routes, three
2151 literal `GitEndpoint` values, and `serve_git` rebuilds `path_info` from the validated
2152 handle and name. The string that decides authorization and the string handed to git
2153 are therefore the same string.
2154- **Existence is settled before permission.** A push to a repository the actor cannot
2155 see answers 404, not 403 — a 403 would confirm a private repository by that name
2156 exists. Costs nothing to get right at the start and is invisible to test later.
2157- **`BufReader` is what makes the header/body split safe.** The reader keeps whatever it
2158 read past the blank line, so handing the reader itself back as the response body
2159 carries the already-buffered first bytes of the pack with it. Parsing headers into a
2160 separate buffer and then streaming the rest would silently drop them.
2161- **The child's exit code cannot gate the response.** A protocol failure exits non-zero
2162 *after* a complete, successful-looking header block has been written. By the time the
2163 status is known it has been sent, so the exit code goes to the log and nowhere else.
2164- **Stderr must be drained, not merely piped.** An unread pipe fills and blocks the
2165 backend mid-transfer. It is read in the same task that reaps the child.
2166- **`body_limit` does not exist** in `topcoat-router` 0.5.0 — the warning carried from
2167 [0001]decisions/0001-git-over-http-not-ssh.md is stale. Bodies are read by the
2168 handler with a caller-chosen limit via `to_bytes`, and the git routes take `Body`
2169 unbuffered so no limit applies at all.
2170- **`impl<B> IntoResponse for http::Response<B>`** means a handler can return its own
2171 `http_body::Body` and Topcoat re-bodies it. That is what lets the pack stream without
2172 a framework-specific body type.
2173
2174### Milestone 4b — Push and tokens · done
2175
2176`git push` works over HTTP for the owner, and a private repository is clonable by
2177someone holding a token for it. `PersonalAccessToken` with both storage adapters,
2178`issue_token` / `list_tokens` / `revoke_token` / `authenticate_token`, HTTP Basic on the
2179git routes, and token management at `/{handle}/settings/tokens`. Decisions recorded in
2180[0007]decisions/0007-tokens-over-http-basic.md.
2181
2182**Verified end to end**, issuing the token through the UI rather than seeding one:
2183push of 201 refs to a public repo and to a private one; clone of the private repo
2184returning 201 commits; anonymous clone of the public repo still open with no prompt;
2185401 with `WWW-Authenticate: Basic` for a private repo, a **nonexistent** repo, an
2186unknown handle and a push advertisement alike; a wrong token challenged rather than
2187accepted; and after revoking, both clone and push answer 401 while the public repo stays
2188open. The token is shown once and never again on reload, the revoke button disappears
2189from the list, and the page is 403 for anyone else.
2190
2191#### Decisions worth remembering
2192
2193- **`http-backend` refuses `receive-pack` by default, and Steid authorizing the push is
2194 not enough.** The symptom is a 403 that looks like Steid's own refusal but is git's:
2195 `Service not enabled: 'receive-pack'`. It needs `-c http.receivepack=true` **before**
2196 the subcommand. That flag is set from a `GitRequest` field the use case turns on only
2197 after the authorization check passes, so git remains a second refusal behind Steid's
2198 rather than being switched on wholesale — if the rules are ever wrong, git still says
2199 no.
2200- **The uniform 401 is what makes authenticated cloning possible at all.** A git client
2201 offers a credential only after a 401, so the 4a behaviour of answering 404 for a
2202 private repository made an authenticated private clone unreachable. Extending the 401
2203 to repositories that do not exist is what keeps it from leaking which private names
2204 are real.
2205- **A bad credential falls through to anonymous rather than failing.** The caller then
2206 gets the same challenge as someone who presented nothing and can try again, which is
2207 also how a stale session cookie behaves.
2208- **Basic accepts the token in the password field, or in the username with no password.**
2209 Git puts it in the password; people paste it into the username. The alternative is an
2210 authentication failure with nothing to explain it.
2211- **Issuing a token deliberately does not redirect**, unlike every other form here. The
2212 secret exists only in that response, and surviving a redirect would mean putting a live
2213 credential in a URL — browser history, logs, referrers. Reloading issues a second
2214 token, which is harmless and visible in the list.
2215- **Revoking someone else's token is `NotFound`, not `Forbidden`.** That a token id
2216 exists but belongs to another user is not a fact worth confirming.
2217- **Tokens do not expire.** A credential pasted into a machine and forgotten is worth
2218 less if it stops working silently; revocation is the control that matters.
2219- **`in_memory.rs` keeps `mod tests` in the middle of the file**, like `sqlite.rs`.
2220 Appending an implementation to the end lands it inside a later impl block.
2221
2222#### Measured, for Milestone 5
2223
2224Taken at the end of 4b, on a 201-commit repository, 50 runs averaged per command:
2225
2226| Command | Per call |
2227|---|---|
2228| `git rev-parse HEAD` | 11.2 ms |
2229| `git ls-tree -l HEAD` | 11.7 ms |
2230| `git cat-file -p HEAD:` | 11.6 ms |
2231| `git log -20 --format=…` | 11.8 ms |
2232| `git for-each-ref` | 14.4 ms |
2233
2234**The cost is starting git, not the query** — every command lands in the same band
2235regardless of the work it does, matching the ~13ms `git init --bare` from Milestone 3.
2236A three-call page is therefore ~35ms of pure overhead, and a per-file last-commit column
2237at one call per entry would be ~230ms for twenty files. This is the input
2238[0006]decisions/0006-git-binary-behind-narrow-ports.md asked for before reconsidering
2239`gix` on the read path.
2240
2241### Milestone 5 — Repo browsing · done
2242
2243A repository is readable on the web: the file tree at a revision, a file's contents with
2244line numbers, and the commit log. `ObjectId` / `RefName` / `RepoPath` / `EntryKind` /
2245`TreeEntry` / `CommitSummary` in the domain, a `GitQuery` port with `DiskGitQuery` and an
2246in-memory fake behind it, `browse_repo` and `repo_log` read models, and pages at
2247`/{handle}/repos/{name}`, `/tree/{rev}`, `/tree/{rev}/-/{path}`, `/log` and `/log/{rev}`.
2248The read-path decision and its upgrade ladder are in
2249[0006]decisions/0006-git-binary-behind-narrow-ports.md#amendment--20260829-the-milestone-5-read-path.
2250
2251**Verified against Steid's own repository, hosted on Steid.** A freshly created repo
2252shows push instructions; after pushing 57 commits the page lists the tree; directories
2253descend and breadcrumb back; `src/domain/session.rs` renders with line numbers and
2254correct HTML escaping; the log shows 50 commits with author and relative time. Unknown
2255revision, unknown path, `../etc/passwd`, unknown repo and unknown handle all 404, clone
2256still works, and a private repository answers 404 to an anonymous visitor on **every**
2257browse route while its owner sees it.
2258
2259#### Decisions worth remembering
2260
2261- **`cat-file --batch-check` with the spec on stdin is the lookup primitive.** It exits
2262 **0** and prints `<spec> missing` for anything unresolvable, which is what makes "not
2263 found" a *value read off stdout* rather than an exit code to interpret. The rule the
2264 adapter follows: **a non-zero exit is always an error; absence is a marker in the
2265 output** (`missing`, `ambiguous`, `dangling`, `notdir`). The obvious alternatives are
2266 worse — `rev-parse --verify --quiet` returns 1 for an unknown ref but 128 for a missing
2267 repository, and `ls-tree` pointed at a blob is a `fatal:` for what is, to a visitor, a
2268 404. Passing the spec on **stdin** also means no revision or path can ever be read as a
2269 flag, whatever validation upstream does or stops doing.
2270- **`git log` in a repository with no commits is a fatal error, not empty output**, hence
2271 resolving the revision first. An extra fork, in exchange for not reading meaning out of
2272 a localised stderr string.
2273- **`%s` is git's *subject*, not the first line** — with no blank line in the message it
2274 joins the whole first paragraph with spaces. The adapter takes `.lines().next()` rather
2275 than trusting that.
2276- **Negative `%ct` exists** in imported histories and would panic `UNIX_EPOCH + Duration`.
2277- **A symlink is indistinguishable from a file in the object store** — both are blobs — so
2278 `read_blob` returns a symlink's target path as its content. Deliberate; making it
2279 `Ok(None)` would cost an extra `ls-tree` of the parent.
2280- **The empty repository is a first-class state, not an error.** Steid creates
2281 repositories empty and Milestone 4 made it easy to have one never pushed to, so
2282 `default_branch` returning `None` means "no commits" and the page offers the three
2283 commands to push rather than a broken listing.
2284- **`%2F` in a revision segment survives routing.** Topcoat matches on the raw path and
2285 percent-decodes after, so a slashed branch works as a single segment — which is what
2286 makes the `/-/` separator sufficient without a ref lookup.
2287- **Three agents worked in parallel on disjoint files**, with the port, the fake and a
2288 non-panicking stub adapter written first so neither branch could break the other's
2289 build. The stub answering "nothing there" rather than `todo!()` is what let the pages
2290 be developed and run before the adapter existed.
2291
2292### Milestone 5b — Deployable by anyone · done
2293
2294Distributed as a binary plus its `assets/` directory, installed by one command, behind
2295Caddy for automatic HTTPS. `release.sh`, `install.sh`, `deploy/`, a `README.md`, and the
2296operability the service needs: `/healthz`, `STEID_SETUP_TOKEN`, and rate limiting.
2297
2298#### Topcoat findings, both load-bearing
2299
2300- **`topcoat::start()` already handles SIGTERM.** `serve()` calls `serve_until(…,
2301 shutdown_signal())`, and that selects on Ctrl+C *and* SIGTERM on Unix: it stops
2302 accepting, drops the listener so a replacement process can bind the port, and drains
2303 in-flight requests up to `shutdown_timeout`. So systemd stop/restart does not cut a
2304 clone mid-pack, and **no wiring was needed** — the work was finding this out rather
2305 than building it.
2306- **The peer socket address is not reachable from a handler.** `internal_serve` discards
2307 it at accept time (`let (stream, _remote) = accepted?;`) and never puts it on the
2308 request extensions; the context exposes only parts, method, uri, headers and
2309 extensions. **Any IP-based decision in Steid is therefore header-based by necessity**,
2310 not by choice, and closing that would take an upstream change.
2311
2312#### Decisions worth remembering
2313
2314- **The rate limiter keys on the *rightmost* `X-Forwarded-For` entry.** A proxy
2315 *appends* the address it accepted from, so the last entry is the one the nearest proxy
2316 wrote and the only one a client cannot forge. The leftmost — what "the real client IP"
2317 usually means — is exactly the attacker-controlled one. Two proxy hops collapse clients
2318 onto the inner proxy's address, which is stricter, so being wrong that way is safe.
2319- **A global cap backs the per-key one**, because without a peer address a forged key
2320 cannot be disproved. It turns key forgery from a total bypass into a modest speed-up.
2321 The cost is that a flood can lock the login form for a minute — a recoverable denial
2322 against an unrecoverable guessed password.
2323- **The limiter's map is bounded.** An unbounded map keyed by attacker-controlled values
2324 is itself the denial of service; at the cap it sweeps expired entries and otherwise
2325 falls through to the global window, which is stricter rather than permissive.
2326- **glibc on bullseye, not static musl.** musl failed on `ring` (Debian's `musl-gcc`
2327 rejects `-m64`), but the decisive argument is that **musl buys a dependency-free binary
2328 and Steid hard-requires `git` on PATH** — the portability is unusable. Bullseye pins the
2329 glibc floor at 2.31, covering Debian 11+ and Ubuntu 20.04+; bookworm would need 2.36
2330 and silently exclude Ubuntu 22.04.
2331- **Licensed AGPL-3.0** (`607da17`, 2026-09-05). `current.md` had carried "a licence" as
2332 open; the reasoning — section 13, and what it does not stop — is README's Licence
2333 section.
2334- **The runtime binary links a TLS stack it never uses.** `ring` ← `rustls` ← `ureq` ←
2335 Topcoat's `icon-iconify`/`tailwind`, whose `ureq` downloads the Tailwind CLI *at build
2336 time*. Those features are on the normal dependency as well as the build one, so the
2337 crypto ships too. Moving them would shrink the binary and drop an unused dependency
2338 from the attack surface. Not attempted; it is also what made the musl build fail where
2339 it did.
2340- **`STEID_SETUP_TOKEN` does not undermine [0002]decisions/0002-first-run-claim-not-config-bootstrap.md.**
2341 What that ADR refused to put in configuration was the owner's *password* — long-lived,
2342 goes stale, ends up in a repository. This is the one-time claim secret the operator was
2343 already copying out of a log line. It is validated for strength, never printed, and
2344 ignored entirely once claimed.
2345
2346### Gap-filling while 5b was blocked on DNS · done
2347
2348Built while the domain transfer was in flight, so none of it belongs to a milestone.
2349Three things: repository settings, browse usability, and README rendering — the last of
2350which is Milestone 6's markdown pipeline arriving early because a repository page needed
2351it.
2352
2353#### Repository settings — a hole, not a feature
2354
2355Repositories were **create-only**. No edit, no delete, and therefore **no way to
2356un-publish something published by accident**. Now: description and visibility are
2357editable, and a repository can be deleted behind a type-the-name confirmation.
2358
2359- **Delete writes the row first, then the directory best-effort.** An orphaned directory
2360 only blocks reusing that name and is already `create_repo`'s documented failure mode;
2361 an orphaned row is a repository that lists on the profile and 404s when clicked. The
2362 visible failure is the worse one, so the ordering avoids it.
2363- **Two different refusals, deliberately.** A repository the actor may not *see* is
2364 `NotFound` (a 403 would confirm a private repo by that name exists); one they can see
2365 but do not own is `Forbidden`, matching `create_repo`, because the resource is public
2366 anyway. The page collapses both to 404.
2367- **Renaming is still impossible, now with a comment saying why.** The bare repo lives at
2368 `{data_dir}/{handle}/{name}.git`, so a rename is a directory move that breaks every
2369 existing clone — and doing the row half only breaks them silently.
2370
2371#### Markdown — raw HTML is structurally impossible, not merely disabled
2372
2373- **`pulldown-cmark` does not sanitise URLs.** Its `escape_href` only percent-escapes, so
2374 `javascript:` would have survived into a rendered README. The renderer uses a scheme
2375 **allowlist** (`http`, `https`, `mailto`, `ftp`, `ftps`, `tel`) and strips ASCII control
2376 characters *before* the check as well as on output, because browsers strip them too and
2377 `java&#9;script:` is otherwise a live bypass.
2378- **Adding the crate with `default-features = false` turned off its `html` feature**, so
2379 `push_html` does not exist in this build. The renderer therefore walks the event stream
2380 and writes every tag itself. Forced rather than chosen, and better: the emittable tag
2381 set is exactly what the writer spells out, so raw HTML cannot pass through by
2382 construction. `Event::Html` is written as *text*, so `<script>` is visible and inert
2383 rather than silently vanishing.
2384- **Escaping goes through `topcoat::view::HtmlContext`**, the same escaper `view!` uses —
2385 not a hand-rolled one.
2386- **Smart punctuation is off**: it rewrites `--flag` to an en dash, quietly corrupting CLI
2387 flags in README prose.
2388- Relative *links* are rewritten into tree URLs; relative *images* are deliberately left
2389 alone, because a tree URL serves a page and rewriting would swap a 404 for a broken
2390 image. Pointing them at `/raw/` is the obvious follow-up now that route exists.
2391
2392#### Browse — the switcher and raw files
2393
2394- **`for-each-ref` asks only for `%(refname)`.** `%(objecttype)` is `commit` for both a
2395 branch and a lightweight tag, so the *namespace* is the only thing that answers
2396 branch-versus-tag.
2397- **Raw files are served as `application/octet-stream`, always** — never the file's own
2398 type and never guessed from an extension — with `nosniff`, `Content-Disposition:
2399 attachment` and `default-src 'none'; sandbox`. A repository-supplied `.html` or `.svg`
2400 served as its real type on this origin is stored XSS against the viewer's session.
2401 `text/plain` was rejected because browsers render it and have been talked into sniffing
2402 it as HTML. The filename is repository content arriving in a header, so it is reduced to
2403 `[A-Za-z0-9._-]` against header injection.
2404- **The switcher costs one more fork (~13ms) on tree and log pages**, measured
2405 interleaved against `ls-tree` to cancel out load — same band, confirming again that the
2406 fork is the cost. It is not called on the repository page or an empty repository.
2407
2408#### Verified
2409
2410Against a running instance with a deliberately hostile README: **zero real `<script>` or
2411`<img>` tags in the output**, the markup present once as escaped inert text, the
2412`javascript:` link stripped of its `href` while `https://example.com` survived, the table
2413rendered, raw bytes SHA-256 identical with the headers above, the switcher listing a
2414branch and a tag, and the Settings link visible to the owner and absent for anonymous.
2415
2416### The profile page, rebuilt · done
2417
2418Flat navigation, per [ui.md]ui.md#the-profile-page. Tabs instead of stacked sections,
2419one lead item distinguished by weight and space rather than size, hairlines instead of
2420boxes, and a `/{handle}/repos` index for the tab to point at.
2421
2422#### Decisions worth remembering
2423
2424- **Existing rows were stamped with the migration time, not left at 0.** A repository
2425 pushed to for months would otherwise read "updated 56 years ago" on the very page the
2426 column exists to order. Wrong by a bounded amount and self-correcting on the first
2427 push, against wrong forever and looking broken.
2428- **The single-pin invariant lives in the use case, not in a constraint.** The rule is
2429 "pinning this unpins that", and a unique index can only *refuse*, never unpin. The two
2430 writes are not one transaction; a crash between them leaves nothing pinned, which is
2431 the harmless direction.
2432- **`updated_at` is touched on the authorized write path**, before the protocol is
2433 reached — so a clone never moves it and neither does a refused push. It records that a
2434 push was *authorized*, not that it succeeded; waiting for the subprocess would be a
2435 much larger change for a small gain. A failed touch is logged and does not fail the
2436 push.
2437- **The lead is picked out of the listing**, not fetched separately, so the lead and the
2438 list cannot disagree about which repository is pinned.
2439- **Ordering changed from name to recency**, and two existing tests had been passing by
2440 accident: everything created inside one second tied and fell back to the alphabet.
2441
2442#### Two Topcoat traps, both silent
2443
2444- **`let profile = …` in a module with `#[page] async fn profile` is a unit-struct
2445 pattern, not a binding.** The page's name is a unit struct in module scope. The error
2446 points at neither the page nor the shadowing.
2447- **Forgetting `topcoat asset bundle` after `cargo build` produces a broken-looking
2448 page, not an error.** New utility classes are simply absent, so gaps collapse and type
2449 falls back to browser defaults — it reads as a design mistake. Cost one confused
2450 screenshot.
2451
2452### Security review before going public · done
2453
2454Attempted with three blind reviewer agents; all three died to the machine sleeping, so
2455the review was done directly instead. **Findings were verified by attacking a running
2456instance, not by reading comments** — the codebase argues confidently for its own
2457safety and those arguments are exactly what needed testing.
2458
2459#### What held, demonstrated rather than assumed
2460
2461| Probe | Result |
2462|---|---|
2463| Private repo: page, tree, log, settings, raw, `/api` | 404 on every surface; `/api` does not leak the name |
2464| `rev=--upload-pack=touch /tmp/pwned` and five other injections | 404, no execution |
2465| Four path-traversal spellings incl. `%2e%2e` and `....//` | 404 |
2466| Login brute force | 10 attempts then 429 |
2467| Error bodies | bare "not found", nothing internal |
2468| Raw `.html` and `.svg` from a repo | `octet-stream` + `nosniff` + `attachment` + sandbox CSP |
2469| Filename `ev"il; drop.txt` in a header | sanitised to `ev_il__drop.txt`, no header injection |
2470| `<script>` in a viewed file | escaped, zero live tags |
2471
2472**The production cookie is `__Host-session; HttpOnly; Secure; SameSite=Lax; Path=/`** —
2473the strictest cookie form available, and it forbids a `Domain` attribute so a
2474compromised subdomain cannot inject one.
2475
2476**A near-miss worth recording:** the first check appeared to show production serving
2477`steid-dev-session` with no `Secure`. It was a testing error — **`dotenvy` reads `.env`
2478from the working directory**, and running the binary from the repo root picked up the
2479gitignored dev `.env`. Verify from a neutral directory, and note the same trap applies
2480to the deployment: the systemd unit's `WorkingDirectory=/opt/steid` means a stray `.env`
2481there would silently override the environment file.
2482
2483#### The one real finding: no security headers on HTML
2484
2485Fixed with a layer, deliberately a layer rather than a per-handler concern — a page
2486added without them would simply not have them and nothing would fail.
2487
2488- **Steid renders no JavaScript at all**, not a script tag on any page, so
2489 `default-src 'none'` is a policy the product can genuinely keep. That is far stricter
2490 than a typical CSP and worth defending: if a feature ever needs script, weakening it
2491 should be a deliberate decision.
2492- `'unsafe-inline'` is granted for **styles only**, and only because Topcoat's icon
2493 macro emits `style="vertical-align: -0.125em"`. A framework constraint, not a choice.
2494- **`Referrer-Policy: no-referrer`**, not the usual `strict-origin-when-cross-origin`: a
2495 private repository's URL contains its name, and a README may link anywhere, so a
2496 referrer would hand that name to whatever the visitor clicked.
2497- Headers are set with `entry().or_insert()`, never `insert()` — the raw endpoint's own
2498 stricter `default-src 'none'; sandbox` must not be relaxed by a blanket overwrite.
2499 Verified that it survives.
2500
2501#### Not covered, and why
2502
2503- **The member-but-not-owner path could not be demonstrated.** There is no registration,
2504 so a second account cannot exist until Milestone 7. It is covered by use-case tests and
2505 nothing else — re-verify for real the moment a second account is possible.
2506- **No automated test asserts the headers.** There is no HTTP-level test harness in this
2507 project, so a regression here would be silent. That is a gap, not a decision.
2508- No dependency audit (`cargo audit` was not run), and no review of the deployment
2509 scripts beyond the earlier container dry-run.
2510
2511### Deployed · jpgill.dev, 2026-09-04
2512
2513Steid runs on the public internet at **https://jpgill.dev**, on AWS Lightsail (Debian 13,
2514x86_64, 1 GB), behind Caddy with a Let's Encrypt certificate, hosting its own source.
2515Installed with `install.sh --tarball`, since the instance that will serve the releases is
2516the one being installed.
2517
2518#### What the first real deployment taught
2519
2520- **A domain transfer moves the registrar, not the nameservers.** The transfer to Amazon
2521 Registrar completed, the Route 53 zone held the right records, and every public resolver
2522 returned nothing — because the `.dev` registry still delegated to the old provider's
2523 nameservers. Diagnosed with `dig +trace`, which shows the delegation the world actually
2524 follows rather than the zone you are looking at.
2525- **The domain was `jpgill.dev`, not `jpgilldev.com`.** Inferred from an email address and
2526 never confirmed, and by then it was baked into `install.sh`'s release URL and the
2527 systemd unit. Ask what the domain is.
2528- **`.dev` is HSTS-preloaded.** Browsers refuse plain HTTP with no click-through, so the
2529 certificate is not optional — until Caddy has one the site is simply unreachable.
2530- **The uniform 401 cost real time.** Pushing to a mistyped handle answered
2531 `Authentication failed` rather than "no such repository", because
2532 [0007]decisions/0007-tokens-over-http-basic.md deliberately makes an absent repository
2533 indistinguishable from a private one. That trade was recorded as costing "a prompt on a
2534 typo"; in practice it cost ten minutes and a confident wrong diagnosis, with someone
2535 watching who knew the design. A stranger has nobody to ask.
2536- **An upgrade silently discarded the operator's Caddyfile.** `install.sh` kept
2537 `steid.env` across a re-run but rewrote the Caddyfile unconditionally, so a hand-added
2538 `www` redirect vanished on the next upgrade and took the hostname with it. Now written
2539 on first install only, with `--force-caddyfile` and `--www`. Found by testing the
2540 upgrade path rather than waiting for it to happen.
2541- **The upgrade path works and is verified**: claim, database, repositories, `steid.env`
2542 and Caddyfile all survive `install.sh` re-run against a newer tarball.
2543
2544#### Renaming a handle, done by hand
2545
2546`current.md` recorded a rename as "a directory move, not a row update". That was exercised
2547for real, renaming `jpgilldev` to `jamesgill` on the live instance: **one `UPDATE orgs SET
2548name` and one `mv` of `{data_dir}/{handle}/`**. Everything else — users, repositories,
2549tokens, sessions — keys off ids, so nothing else moved, and the account, password and
2550access token all survived.
2551
2552So a rename feature is genuinely two writes. What makes it more than that is the
2553consequence: every existing clone URL breaks, and there is no redirect from the old
2554handle. That is the part to design, not the mechanics.
2555
2556### The shell: top bar and per-page widths · done (2026-09-05)
2557
2558The root layout gained a slim global top bar — wordmark to `/`, and either "Sign in"
2559or `@handle` / Settings / Sign out — and stopped imposing a width. Pages now choose
2560their own column via two components in `layout.rs`: `narrow` (48rem — profile, forms,
2561settings) and `wide` (80rem — tree, blob, log, the repo page). Verified in the
2562browser across visitor and owner states, including sign-out.
2563
2564#### Decisions worth remembering
2565
2566- **A slim bar plus contextual tabs, deliberately not an app shell.** The reasoning
2567 lives in [ui.md]ui.md#the-shell; the short form is that Steid's first audience is
2568 an anonymous reader of someone's site, and GitLab-style rail chrome tells that
2569 visitor they've landed in an admin tool.
2570- **A `#[layout]` may take `cx: &Cx`** alongside `slot` — both recognized by name, no
2571 other parameters. Documented in the vendored `topcoat-router-macro` docs, not
2572 obvious from the README example.
2573- **The layout imposes no width; pages wrap themselves.** Same philosophy as request
2574 helpers being functions: a page that forgets a container renders full-bleed, which
2575 is immediately visible, rather than silently inheriting a wrong one.
2576- **The top bar costs an identity lookup on every page render** (session hash plus a
2577 user row). Fine over local SQLite; worth remembering if page queries are ever
2578 counted.
2579
2580### The repository landing page · done (2026-09-05)
2581
2582`/{handle}/repos/{name}` became two columns — the file list and README on the left, an
2583About sidebar on the right — and every repository page (tree, blob, log) picked up the
2584same header and `Code` / `Commits` tab strip. New: a toolbar row carrying the revision
2585switcher and branch/tag counts, a latest-commit bar, an About block with the
2586description and detected licence, a facts list (commits, branches, tags, latest tag,
2587pushed), and the clone URL moved into the sidebar.
2588
2589The layout and the map of where the next features slot in are in
2590[ui.md]ui.md#the-repository-page. What is here is what the next session should not
2591have to rediscover.
2592
2593**Verified** with the app running from a worktree on port 3100: this repository's own
2594history pushed into it with two annotated tags and three branches, plus an empty
2595repository and one with no README and no licence. Screenshots taken headless at 1280px
2596and 800px, in both colour schemes, of the landing page, the empty and sparse states, a
2597tree subpath, a blob and the log; the owner's view (with the Settings button) checked
2598signed in. `cargo test` 467 passing, clippy clean.
2599
2600#### Decisions worth remembering
2601
2602- **The subprocess count was measured, not estimated.** A `git` shim on `PATH` logging
2603 every invocation: **15 processes** for a repository with a README and a licence, **10**
2604 without them, **1** for an empty one — up from 7. Worth repeating the trick; it took
2605 two minutes and contradicted a careful hand-count.
2606- **The description has exactly one home, and it is the sidebar.** Putting it in the
2607 header too makes the header tallest on the repositories with the most to say, which
2608 pushes the code below the fold on exactly the pages that deserve it least.
2609- **`repo_summary` takes the revision and the root listing the page already read.** A
2610 self-contained use case would have spent two more processes re-reading what the caller
2611 had in hand. The five calls it does make run under one `tokio::try_join!`.
2612- **`organise_refs` was split out of `list_refs`** so the landing page gets the counts
2613 and the switcher's list from one `for-each-ref`. Two places deciding ref order is two
2614 places to change it.
2615- **A `#[component]`'s name is a unit struct in module scope, and the copied-in
2616 components are in that scope too.** A parameter named `label` inside `repo.rs` does
2617 not bind — it parses as the `label` component's unit struct, and the error says
2618 "expected `str`, found `label`" without naming the component. The fix was renaming the
2619 parameter to `term`. This is the same trap `CLAUDE.md` records for pages; registry
2620 components widen it to every file that imports one.
2621- **`bg-muted` is not a token.** Three `<pre>` blocks have been rendering with no
2622 background since they were written, silently — the exact failure `ui.md` describes for
2623 Tailwind classes the build never ships. `bg-surface` is the token. Two were fixed here;
2624 `token.rs` still has one.
2625- **The clone URL wraps rather than scrolls.** In an 18rem column an `overflow-x-auto`
2626 URL looks like a truncated one, and the part hidden is the repository's own name.
2627- **The licence sniffer reads 1 KiB, not the 200 bytes first sketched.** BSD-2 and
2628 BSD-3 differ only by a third clause about 900 bytes in. `LICENSE-MIT` and other
2629 suffixed spellings are not detected: the filename list is deliberately short, because
2630 every extra candidate is another speculative blob read.
2631- **Light mode was checked by flipping the layout's `class="dark"` and rebuilding**,
2632 because there is no toggle. Nothing was wrong on these pages. That is the cheapest way
2633 to check it until a toggle exists, and it is worth doing before each UI step rather
2634 than after several.
2635
2636---
2637
2638## Reference: what attempt #2 proved
2639
2640Not this repo's progress. This is a catalogue of what was built and **verified working**
2641in `steid-backup-2026-07-31`, so the rebuild can crib rather than rediscover.
2642
2643Final state: single crate, ~4,200 LOC, 60 passing tests, five milestones.
2644
2645### Identity
2646
2647Domain model (User, Organization, Membership, Actor, Role), `Email` and
2648`PasswordHash` value objects, typed IDs, `DomainError`, four repository ports with
2649in-memory and SQLite implementations each. `RegistrationPolicy` (Personal / Invite /
2650Open) driving which routes exist. Argon2 hashing behind a `PasswordHasher` port with a
2651stub for tests. Use cases: `bootstrap_owner`, `register_user`, `login`, `create_invite`.
2652Signed-cookie sessions via an `AuthUser` extractor.
2653
2654**Gotcha:** organizations must be saved before users — the FK runs that direction.
2655Both `bootstrap_owner` and `register_user` had to be fixed for this.
2656
2657### Repo model
2658
2659`Repository` entity, `RepoId`, `Visibility` (Public/Private), `RepoRepository` port,
2660migration `006_create_repositories.sql`. `create_repo` use case validates the name,
2661rejects duplicates, and initialises the bare repo on disk in the same call. Bare repos
2662live at `{data_dir}/{org}/{repo}.git`, `data_dir` defaulting to `./data`. Repos are
2663created empty, no initial commit, like GitHub.
2664
2665### Git over SSH
2666
2667`GitStorage` port (`init_bare`, `repo_path`) with `DiskGitStorage` shelling out to
2668`git init --bare`. `GitProtocolServer` port (`upload_pack`, `receive_pack`) with
2669`GitBinary` spawning `git upload-pack` / `git receive-pack` via
2670`tokio::process::Command` and pumping stdio with `tokio::io::copy`.
2671
2672`serve_clone` and `serve_push` use cases enforce visibility and actor checks **before
2673any protocol byte flows** — that ordering is the whole point of putting them in the
2674application layer.
2675
2676#### SSH channel bridging
2677
2678The fiddly part, and worth re-reading if SSH ever returns as a transport
2679(milestone 8+ — [0001]decisions/0001-git-over-http-not-ssh.md chose HTTP):
2680
2681- Store `Channel<Msg>` per `ChannelId` in the handler's map on `channel_open_session`
2682- On `exec_request`, take the channel, split it with `into_stream()` +
2683 `tokio::io::split`
2684- Take stderr via `make_writer_ext(Some(1))` **before** `into_stream()` — that call
2685 consumes the channel, so the order is not optional
2686- No `data()` or `channel_eof()` handlers needed once the streams are split
2687
2688An earlier iteration used mpsc channels, custom `ChannelReader`/`ChannelWriter`, and a
2689`spawn_blocking` thread. All of it was deleted and the result was simpler.
2690
2691### SSH key auth and authorization
2692
2693`SshKey { id, user_id, name, fingerprint, openssh }` + port, migration
2694`007_create_ssh_keys.sql` (`fingerprint` UNIQUE). Fingerprints are SHA256 via
2695`russh::keys::ssh_key::PublicKey::fingerprint(HashAlg::Sha256)`, stored as `SHA256:…`.
2696`add_ssh_key` parses the openssh blob, dedupes on fingerprint, and re-encodes to a
2697canonical form before storing.
2698
2699`auth_none` rejects. `auth_publickey` fingerprints the offered key, looks it up, and
2700on a match stores `user_id` on the handler; `exec_request` builds the real `Actor`
2701from it.
2702
2703Authorization rules as shipped:
2704
2705| Operation | Requirement |
2706|---|---|
2707| Clone, public repo | open |
2708| Clone, private repo | any membership in the repo's org |
2709| Push | `Role::Owner` membership in the repo's org |
2710
2711Web UI at `/{owner}/keys` — owner-only, lists fingerprints, accepts openssh via
2712textarea, revokes per-row.
2713
2714**Verified end-to-end:** clone with an unregistered key → `Permission denied` (exit
2715128); register via web UI → clone and push both succeed; second unregistered key →
2716rejected at auth; revoke via web UI → subsequent clone rejected at auth.
2717
2718### Security notes
2719
2720Attempt #2 ran with a **named, deliberate backdoor** between milestones: SSH accepted
2721any connection and passed a placeholder `Actor` (`UserId("ssh-anonymous")`), leaving
2722push open to anyone who could reach the port. It was recorded with an explicit
2723tightening point (`ssh.rs::exec_request`) and a closing milestone, and it did close.
2724
2725That practice is worth keeping. When this attempt opens a hole to make progress, name
2726it, name the line that closes it, and name the milestone.
2727
2728### Never built
2729
2730Repo browsing (tree/blob/log), HTTP smart protocol, personal access tokens, flash
2731messages, issues, PRs, blogs, pages, project showcases. Milestones 5–8 in
2732[ROADMAP.md]ROADMAP.md are all greenfield.