1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
# Decisions
Choices made where DESIGN.md left an opening (§19), or where following the letter
of the design would have been worse than following its intent. Each entry states
the pressure, the choice, and what it costs.
---
## Vendored JavaScript: htmx 1.9.12, served precompressed
The design budgets "vendored htmx (~14 KB)". Real htmx is not that size: 1.9.12
is 48 KB minified, and no released build of htmx is under 20 KB. The budget was
an estimate, not a constraint with a reason attached to it, and the reason it
was written — do not let a build step and a JavaScript dependency creep in — is
fully satisfied by vendoring one unmodified upstream file.
**Choice.** Vendor `htmx.min.js` unmodified, plus a precompressed `.gz` beside
it, and serve the gzip to clients that accept it. The budget is enforced on
**served bytes**, which is what a browser actually downloads: 15.6 KB, asserted
by a test that reads the wire with a bare socket rather than an HTTP client that
would transparently decompress and hide the number.
**Cost.** Two copies of one file in the repo, and a budget that has to be stated
as "on the wire" rather than "on disk". A reviewer who wants to audit the JS can
read the upstream file; the test asserts the served copy decompresses to it.
## No JavaScript on the review surface, and no SSE extension
htmx ships an SSE extension, and the obvious move was to wire the build log
stream into the page with it. Not done, for two reasons:
- It swaps with `innerHTML`, and a build log is untrusted text produced by a
PKGBUILD someone else wrote. Wiring it up would be an XSS hole opened
specifically to make a log scroll by itself.
- It would add 3 KB gzipped to a budget the base library already nearly spends.
**Choice.** The review flow ships no JavaScript at all — asserted by a test that
greps the rendered review page for `<script`. The log tail is a real endpoint
(`/builds/:id/log.stream`, server-sent events, tested end to end) and the page
links to it; the builds table refreshes by htmx polling, which degrades to "press
reload".
## `identity_hash` is a digest, not the canonical JSON
`Identity::hash()` originally returned the canonical JSON of the identity tuple.
That is an identity token, but it is not a hash, it is large, and it contains
quotes — so it could not survive an HTML attribute round-trip, which is exactly
what the approve form needs (§7.1a requires the form to carry it back).
**Choice.** `hash()` returns `sha256:<hex of the canonical JSON>`. The JSON stays
internal; the token is what a form can carry and what a comparison can be made
on.
## The reaper reaps `running`, not only `leased`
§8.2 writes the reaper as
`UPDATE build SET state='queued' WHERE state='leased' AND lease_expires_at < now()`.
A worker sets `state='running'` the moment it starts a step, so a process that
dies mid-step leaves a `running` row — and following the design literally would
strand every real crash forever. Found by the SIGKILL test in `tests/crash.rs`.
**Choice.** The reaper matches `state IN ('leased','running')`.
## Paused subscriptions are not observed at all
The design has `paused` as a subscription state but does not say what the watcher
does with it. Polling a package nobody will act on wastes requests and keeps
opening reviews nobody will read.
**Choice.** `check_pkgbase` returns `Outcome::Paused` before it touches the
network. Pausing is a statement that we are not looking.
## Staleness is computed on read, never stored
§10.2 asks for this and the code follows it exactly: there is no `stale` column.
A stored flag goes wrong the moment anything else is published, and something else
is always being published. Deriving it from the recorded world snapshots against
the live index means it cannot lie, at the cost of a query per page view.
## Downgrades are an announcement, not a build request
When AUR offers a lower version than we serve, nothing should be rebuilt and
nothing should be withdrawn automatically — a human has to decide whether the
mirror or the upstream is wrong. The row appears on Attention with both versions
and no action button.
## The test hooks are a gated submodule, not fields on `Config`
`publish_fault`, `shim_fail`, `shim_kill_parent` and their siblings exist only so
the harness can reproduce failures it cannot otherwise cause: a crash between the
rename and the signature, a tool that exits non-zero, and a process killed
mid-step with a signal it cannot catch. The alternative — an in-process
simulation of a crash — can be caught and cleaned up by accident, which is
precisely what I5 must not allow.
They are no longer seven `Option` fields on the production `Config`, and the
branches that consult them are no longer compiled into the binary at all. Under
the default features there is a `TestHooks` type with no fields, the shims and
their binaries do not exist, and `Config::child_env` exports nothing; the fault
branches in `publish` are `#[cfg]`-ed away rather than guarded by a runtime
`if`. A production binary that carries its own fault injection is a binary in
which someone will eventually ask whether a fault can be triggered from the
network, and the honest answer will be "not today".
**Cost.** The test harness depends on the crate with `features = ["test-support"]`,
so `cargo test` and `cargo build` compile slightly different libraries — which is
the point, and is why `production_surface.rs` asserts the default build is clean.
## CAS baseline comes from the candidate, not from the live pointer
At publish time the compare-and-swap compares against the `base_release_id`
recorded on the candidate, not against `pkgbase.current_accepted_release_id` as
it reads it then. If they differ, someone accepted a newer version while this
build was running, and publishing over it would silently drop a human decision.
## One publisher lock per process, not a queue
§8.2 says the publish step goes through the publisher's single-thread channel.
With `max_concurrent_builds > 1` two workers could otherwise interleave the index
rewrite. A `static Mutex` around `publish()` gives the same guarantee with less
machinery; the critical section is the db file rewrite, never a build. The lock
poison is cleared deliberately: atomic publish means a panic cannot have left a
half-written db, so wedging the queue would be worse than continuing.
There is now exactly one such lock, `REPO_LOCK`, taken at the top of `publish()`
for the whole sequence — file rewrite, signature, index update — and by
`withdraw_package`, which rewrites the same files. There used to be a second one
(`PUBLISH_LOCK`) covering a shorter span inside the first, which gave the
appearance of a second serialization point and would have been the natural place
for the next writer to acquire the wrong one. A test fails if a second lock
guarding the served index appears.
## The session id is the credential, not a cookie the client controls
Login used to set `auth=1`, so the secret was the *name* of a cookie and anyone
who could type `Cookie: auth=1` was the reviewer. Sessions are now a map the
server owns — a random sid minted at login, marked authenticated only in the
server's table — and the cookie carries the sid and nothing else. Logging in
rotates the sid, so a session id that a previous identity might have leaked is
useless after a re-login; logging out deletes the entry, so the id stops working
rather than being re-interpreted.
**Cost.** Sessions are per-process and lost on restart, so a server restart signs
everyone out. For a single-operator tool that is a feature: the same restart that
reloads the binary also revokes every session it was running under.
## `db/` is a boundary, and the writer does not hand out connections
Every SQL statement in the crate lives in `db/`. `Writer::call`, `tx` and `send`
are `pub(crate)`, and the raw door the test harness needs exists only under
`test-support`. A module that needs the database asks `db/` for a typed query;
if the query does not exist, writing it is the change to make.
**Cost.** `db/` is large, and a one-off ad-hoc query now costs a function instead
of a line. That is the trade: the schema's shape is knowable from one directory,
and a grep for a table name finds every reader of it.
## A stale review and a broken database are different answers
`approve()` used to return an `Approval` with `id: 0` when the transaction
failed, which the UI then rendered as "someone else got there first" — telling a
reviewer their click lost a race it did not lose, and hiding an I/O error behind
a message that invites them to retry. It returns `Result<Approval, ApproveError>`
now, with `Stale` (the review moved: 409, re-render the current diff) kept apart
from `System` (the database failed: 500, name the cause). `bulk()` answers the
same way, per row.
## The shims are test-only, and the real `.PKGINFO` parser is the only one
The publish path used to read a package's name out of the archive with a
simplified parser that the shim harness also had a copy of, which meant
production was tested against a model of the format rather than the format. There
is one parser (`pkginfo::parse_pkginfo`), the shims are behind `test-support`,
and the shim binaries are not built by default.
## States are enums, and writing one is a compare-and-swap
`build.state`, `candidate.state`, `step.state`, `release.state` and
`subscription.state` were free text, and `current_state` returned `""` for a
build that did not exist. They are five enums now, parsed at the row boundary — a
state the code does not define is an error, not a default — and every transition
is a conditional update (`WHERE state IN (…)`), so a worker whose lease expired
finds its write refused instead of quietly overwriting the state of the build
somebody else now owns. A zombie finishing a live build is the failure mode this
prevents, and it is silent in the old shape.
**Cost.** The transition table is real code that has to be kept honest with the
schema, and `failed → running` is legal (I5 says a failed build resumes on its
own row), which is not obvious and is commented where it is defined.
## A row that cannot be read fails the query
`filter_map(|r| r.ok())` was used in some queries and not others, so a row that
failed to deserialize was sometimes skipped and sometimes an error — and the
skips were invisible. The policy is now uniform: if a row cannot be read, the
query fails. A silently missing package is worse than a failed page, because the
missing package looks like an absent one. `setting_i64` is the one documented
exception, because a *setting* falling back to its default is the designed
behaviour, not a lost row.
## Only momentary I/O is transient
`is_transient` classified every `Io` error as retryable, so ENOSPC and EACCES
were retried with the same backoff as a connection reset — a full disk produced a
build that retried until it gave up, blaming a network that was fine. Retryable
now means the kinds that can genuinely pass on the next attempt: would-block,
timed out, interrupted, broken pipe, connection reset/refused/aborted.
## The pipeline refuses symlinks in the srcdir, even though a chroot should make that moot
`collect` scans the build's srcdir for `*.pkg.tar.zst`, and `ingest` copies
whatever those paths resolve to into the content-addressed store — from where
the bytes are served from our repo and signed with our key. The paths are ours
(the scan generates them) but their *targets* are not: a PKGBUILD that drops a
symlink named `evil.pkg.tar.zst` pointing at the signing keyring, the database,
or anyone's home directory would have its target copied in and published.
**Choice.** `collect` rejects any entry that is a symlink, and any entry whose
canonicalized target escapes the build's own staging directory. The build fails
closed with the path in the message. `tests/invariants.rs::i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir`
acts the attack out through a shim hook rather than arguing it is unlikely.
**Cost.** A legitimate build that stages a package outside its srcdir and
symlinks it in now fails. That is a build we want to fail: it is telling us the
recipe does something we cannot see the whole of.
**Why this is not a substitute for the chroot.** I9's real enforcement is
isolation, and that tier is gated. This is the narrower claim that the control
plane does not *depend* on isolation for its own secrets — the layers should not
be load-bearing on each other.
## Metrics are served without a session
Everything else in the UI is behind a password. `/metrics` is not, because a
Prometheus scraper has no session to present, and the alternative — teaching the
scraper to log in and hold a cookie — puts a credential in a monitoring config
to protect numbers.
**Choice.** `/metrics` returns counts only: queue depth, review debt and its age
histogram, build success rate, WAL size, index size, stale counts by reason,
staging usage. No package names, no versions, no audit detail, no paths. The
bind address is loopback by default, which is where that is safe; anyone exposing
it further is exposing their own choice of numbers, not their recipe history.
**Cost.** A visitor on the host can see how busy the server is. If that ever
matters, the fix is a scrape token, not a session.
## Retention records a purge instead of deleting the row
The schema exists so that "which bytes produced this installed package" stays
answerable years later (§11a). Disk cannot be kept forever, so something has to
give, and the honest option is to let the *bytes* go while the *record* stays.
**Choice.** Eviction deletes the package, signature, build log and cached
sources of releases beyond the keep window — as a unit, because a package whose
log is gone but whose bytes remain is full price for no explanation — and sets
`purged_at` on the release and its artifact rows. The digest and size survive, so
the database says "these bytes existed, hashed to this, and were dropped at T"
rather than continuing to claim a file that is no longer there. Shared
content-addressed files are reference-checked against every *retained* release
first: two releases built from the same source share one cached archive, and
aging one out must not corrupt the other.
**Cost.** A `purged_at` column on two tables, and a UI that has to say "bytes no
longer held" rather than offering a download that 404s.
## The real-chroot tier: what was actually run, and where it stopped
§16a gates the tier that needs root, network and devtools. It was not skipped
for lack of trying; it was run on a host with all three, and here is how far it
got.
**What passed with the real tools.** Real `gpg` (a generated 2048-bit RSA key)
detached-signed the artifact the pipeline produced, and `gpg --verify` reported a
good signature. Real `repo-add -s -k` built a pacman database over that artifact
and signed it, and that signature verified too. So the claim "both the packages
and the `.db` are signed" is checked against real crypto, not the shim's fake
key.
**What the attempt caught.** `mkarchroot` has no `-N` flag. The pipeline was
calling `mkarchroot -N <seed>`, which the shim accepted (it ignores unknown
flags) and the real tool rejected with a usage error — so the first real chroot
build would have died on its very first step, in a code path no shim test could
ever have caught. The seed's package list is now configuration
(`mkarchroot_args`, default `base`) and the call follows the real usage,
`mkarchroot <working-dir> <packages...>`.
**Where it still stops.** `mkarchroot <dir> base` against a live mirror
downloaded and installed the base set into the chroot (437 MB, 14 packages,
install scripts ran), then failed in devtools' init stage with
`Failed to parse --bind(-ro)= argument : Invalid argument` from
`systemd-nspawn` 262, and with `etc/pacman.conf` unreadable inside the root.
That is a devtools/nspawn interaction inside an unprivileged container, not
something this codebase controls.
**What therefore remains unverified by execution:** `makechrootpkg`'s
copy-on-write snapshot semantics, `systemd-nspawn` isolation behaviour, and GPG
passphrase handling through a real agent. The shim tier drives the *unmodified*
pipeline against fake tools that produce real archives, and the crash tests kill
real processes with real signals, so the step machine, the checkpoints and the
publish path are all exercised for real — it is the chroot boundary itself that
is modelled rather than crossed.
**How to run it properly.** A privileged Arch host (or a container with the
nspawn capabilities devtools expects), devtools installed, a real signing key,
`signing_key_id` set, `path_prepend` left unset so the real tools are found, then
subscribe to a real pkgbase and drive it through `aur-build serve`.
|