diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 09:01:17 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 09:01:17 +0000 |
| commit | 4cb2f4c7b68dceaed8f7ffbd8f0db3cfbf3f1ddc (patch) | |
| tree | 4c7a3fd158b771a413bcbf86d2c70c9a0af577e9 /docs | |
| parent | 2c5a660213ae5f9f6f12d9787c5195e2c2127e6d (diff) | |
| download | aur-build-4cb2f4c7b68dceaed8f7ffbd8f0db3cfbf3f1ddc.tar.gz aur-build-4cb2f4c7b68dceaed8f7ffbd8f0db3cfbf3f1ddc.zip | |
http: SSE log tail, htmx-refreshed builds table, vendored JS budget (§13)
GET /builds/:id/log.stream serves the build log as server-sent events from a
blocking std::io::Read polled by the connection's thread — no async runtime,
no timer wheel. The pipeline appends to a plain file and never learns the
reader exists, so a viewer that hangs up, stalls or never shows up cannot slow
a build by a microsecond. The stream ends when the build reaches a terminal
state instead of holding a connection open forever, and there is a 30-minute
lifetime cap so a wedged build cannot wedge a browser tab indefinitely.
The test proves it is actually live rather than buffered: a producer thread
appends while the stream is open, and the reader must see those bytes before
the build finishes, then see the end event.
The builds table refreshes with hx-trigger="every 3s" against a fragment
endpoint, so htmx swaps one <div> rather than a whole document. Without
JavaScript the same HTML already contains the table — the refresh is an
enhancement, never a requirement.
Static assets are served from include_bytes!, precompressed, with the
Content-Length forced so tiny_http does not chunk a file whose size we know.
Vendoring decision, recorded in docs/DECISIONS.md: the design's '~14 KB htmx'
does not exist — released htmx is 48 KB minified. We vendor 1.9.12 unmodified
and serve the 15.6 KB gzip, and the budget is asserted on served bytes with a
bare-socket test, because an HTTP client would transparently decompress and
hide the number. htmx's SSE extension is deliberately NOT vendored: it swaps
with innerHTML and a build log is untrusted text from someone else's PKGBUILD,
so wiring it up would be an XSS hole opened to make a log scroll by itself.
The review surface still ships no JavaScript at all, asserted by grepping the
rendered page for <script.
Also: styles moved out of base.html into static/app.css, and docs/DECISIONS.md
started with the decisions made so far. 138 tests pass, clippy clean.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/DECISIONS.md | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md new file mode 100644 index 0000000..c681c05 --- /dev/null +++ b/docs/DECISIONS.md @@ -0,0 +1,109 @@ +# 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. + +## `publish_fault`, `shim_fail` and `shim_kill_parent` are test hooks in the config + +Three fields 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. They are inert when +unset, and 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. + +## 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. |
