summaryrefslogtreecommitdiffstats
path: root/src/pipeline
Commit message (Collapse)AuthorAgeFilesLines
* src: close the items the stricter detector surfacedaur-build11 days1-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The auditor's two counterexamples were real, and fixing the detector exposed seventeen more items it had never listed. Each was checked individually rather than dispositioned in bulk, and the check changed what the right answer was: - `review::approve::withdraw` — gated. The CLI and the web UI both go through `usecase::withdraw_package`; nothing invokes this. tests/pipeline.rs pins its invariants, so it is gated rather than deleted: the test is the cover for an operation production has not grown yet. - `pipeline::dispatch::Pool::shutdown` — gated. Production runs the pool until the process exits; a test needs the join to assert on effects after the threads stop. Its two fields now carry a matching `cfg_attr(allow(dead_code))` because in a release build they are stored and never read. - `shims::{mkarchroot,makechrootpkg,makepkg,gpg,pacman,record}` — plain `pub(crate)`. `run` dispatches to them by tool name; no module outside `shims` names them and no test calls them. The tool names appear in test *strings*, which is not a caller. - `db::Writer::start`, `fetch::open`, `http::Req::form`, `http::Page::new`, `http::Panel::new`, `http::render::BuildRow` — plain `pub(crate)`, same reason: used only from inside their own module. - `db::AuditEntry::system` — deleted. `audit_system` builds the row through the free `audit()`; nothing ever called the constructor, production or otherwise. - `pkgver::Version::display` — deleted, a wrapper around `to_string` with no callers. - `http::Server`, `watch::Stale`, `pkgver::Version` — private inner module with a gated alias. `Server` is what `spawn` hands back and `main` holds without naming; `Stale` is what `stale_rows` returns to `http` and `ops`; `Version` is what `parse` returns. All three must stay nameable to those callers in shape but not in name, which is exactly what the inner-module alias gives. Measured on the release build's public surface: 466 reachable public names at the start of this goal, 402 now, newly-public set empty.
* sandbox: keep `Exit` out of the release buildaur-build11 days3-0/+70
| | | | | | | | | | | | | | | `Exit` is the result of running a command in a sandbox. `pipeline` consumes it through `Sandbox::run` — `.success()`, `.stderr` — without ever writing the name, which is why the census called it dead outside `sandbox`. The type now lives in a private `mod exit` and reaches the world through an alias that is `pub` only under `test-support` and `pub(crate)` otherwise. A `pub` definition inside a private module is not a nameable path from outside, but it is visible enough to appear in a public trait signature, which is what makes this possible where a plain `pub(crate) struct` is not. Verified with an external crate: naming `aur_build::sandbox::Exit` in a release build is `error[E0603]: struct Exit is private`; with `test-support` it compiles.
* error: give the six variants behavior carries a shape, not a sentencedev11 days2-16/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Error::NotFound("no repo row; run `aur-build init`")` and `Error::NotFound("pkgbase linux")` were the same variant. One is "the install was never initialised, every page is wrong"; the other is "that page does not exist, answer 404". The difference lived inside a string, so the only way to act on it was to re-parse text the same process had written moments earlier. Six variants now carry structure: Missing pkgbase / candidate / release / build / snapshot / mirror path / repo row Refused IllegalTransition / WrongState / PointerMoved / Other Guard HashMismatch / DigestMismatch / Invariant WorldGap MissingPin / Other PoolFull Backend{backend} / Other TransientCause Upstream / Command / Other `Refused` distinguishes the three refusals that were indistinguishable: a transition no edge permits (caller bug), a row in the wrong state (stale view), and the accepted pointer moving under a build (a lost race, and the one a client may safely retry). `PoolFull::Backend` names which pool, because a kata quota needs an operator and a local cap clears when a build exits. `is_transient` and `is_pool_exhausted` already matched on variants rather than strings, so they are unchanged — the typing is what lets the *next* branch be a match instead of a `contains`. No test assertion was edited. Where a message is load-bearing the Display was written to reproduce it: `recipe_hash mismatch: approved X, materialized Y`, `no release 4`, `illegal candidate transition approved → rejected`, `sandbox world is missing plain-make-1.0-1 after installing the lease set` and kata's `never dialed in` all come out of the new types byte-identical. Five messages did change wording, none asserted anywhere: release N is X, not published: nothing to withdraw -> release N is X, not published (Refused::WrongState's shape) illegal candidate transition a → b for review 7 -> ... for candidate 7 (it is a candidate id; "review" was misleading) no candidate 7 to resolve -> candidate 7 (Missing::Candidate's shape) lease artifact n-v: store bytes hash to A but the index says B -> source n-v hashed to A but the candidate recorded B (shares Guard::DigestMismatch with the source-cache check) vcs_cache clone URL: err -> upstream: vcs_cache clone URL: err (TransientCause::Upstream tag) error.pub 15->21 is the six payload enums, which is the point of the task rather than a widening to apologise for. watch.dead/test each rose by one for a subtler reason: `watch::upstream::resolve` looked live only because an unrelated db message ended "... to resolve", and rewording that string removed the phantom mention. The census now documents that a clean count is not always an answer, since mentions are matched over raw source including string literals. 281 passed / 0 failed (277 plus four new typing tests in src/error.rs), clippy -D warnings clean, release build clean.
* sandbox, pipeline: close what only your own module was ever meant to namedev11 days3-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sandbox exported 35 items and 8 of them were named by nobody at all — not by a caller, not by a test. `Frame`, `read_frame`, `write_frame`, `hex_bytes`, `unhex` and `MAX_FRAME_BYTES` are the wire protocol, and the protocol is sandbox's: the agent, the remote client and the loopback all speak it from inside. Exporting it advertised a second way in that nothing used and everything would have had to keep compatible. `LoopbackSandbox` and `RemoteSandbox` are the same story — handles handed out by a constructor nobody calls by name. Pipeline exported its step machine. `run_step`, `log_line`, `sweep_render_dirs`, `from_candidate`, `from_release` and the four types they pass around (`Collect`, `CollectedPkg`, `SourceIdentity`, `StepResult`) were all internal plumbing reachable from `main`, which only ever wanted `run`, `Outcome`, `enqueue_for_candidate`, `enqueue_manual_rebuild`, `publish::reconcile` and `dispatch::Pool::spawn`. sandbox.pub 35->27, pipeline.pub 30->21, and both modules now have zero items named by nobody: what is left public is public because a test names it, which is the allowlist the budget records rather than a hole in it. Clippy caught what the tests did not: `Ctx::src` was a `pub` field of the newly private `SourceIdentity`, a public face on a private type. The field narrowed with the type. Re-widening `SourceIdentity` to silence it would have undone the point. The diff is visibility keywords only — no step id literal, no frame variant, no wire byte changed. 277 passed / 0 failed across 36 binaries, including remote_agent, failure_modes and the kata tier; clippy -D warnings clean.
* watch: one source interface, and the fail-closed check lives with the sourcedev11 days1-13/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The step machine reached into two of watch's internals and reassembled the rules itself: `mirror::read_tree` then `Tree::recipe_hash` to re-derive the hash a reviewer approved, and `digests::cached_path` then `digests::download_and_cache` then its own comparison to check a payload. The comparison is the part that must never be skipped, and it was sitting in whichever step happened to want a file — a step could have forgotten it and nothing would have noticed. `watch::sources` is the interface now: what a tree hashes to, and a guarantee that a cached source is the bytes its name claims. `verify_cached` owns the fail-closed test and its message verbatim. `download_and_cache` and `cached_path` are `pub(crate)` again, so the cache layout is watch's business again; `watch/mod.rs` no longer re-exports them. `src/pipeline` now names exactly one watch path. Detection is untouched by construction — no git-invoking function changed — and the census agrees: 264 successful git execs on the detect binary before and after. (An initial reading of 1320 vs 264 was PATH-probe ENOENTs from a differing shell PATH, not git work; counted with suite-cost.py's own rule of successful execve only, the two runs are identical.) watch.pub 31->30. `read_tree` moved into the test-only column: the pipeline stopped naming it, and what remains are watch's own calls plus the two tests that exercise its one-batch-read contract directly. 277 passed / 0 failed, clippy -D warnings clean.
* review: one call to record a candidate, and one way to read onedev11 days2-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `watch::detect` was performing review's write protocol by hand: look up the accepted release, upsert the candidate, assess the risk, store the risk, work out the missing dependencies, store those. Six calls that only make sense in that order, issued from a module whose job is noticing that an upstream moved. Get the order wrong and nothing complains — the candidate just quietly has no risk score, and the reviewer approves it without one. `review::intake::record` is the protocol now. The watcher hands over what it observed and review decides what it means. `missing_deps` moved with it: it computes a risk signal, which is a review question that happened to be living in the watcher. `accepted_for` was not a review question either. It reads a pointer column off the pkgbase row, so it is now `db::accepted_release_for` — the watcher asks persistence what is currently accepted, rather than asking review as a favour. With intake owning the write path, three things became internal and closed: `upsert_candidate`, `risk::assess`, and the risk/missing-deps column setters. `approve::approval_for` was a pass-through to db that only the pipeline called; it is gone, and the pipeline now asks `review::reads::{candidate, approval}` — two named facts instead of a re-export of review's storage layout. The budget rose in two places and both are moves, not growth: db.pub 201->202 is `accepted_release_for` arriving from review, and review.test 4->5 is `set_risk_for_tests`, the one place a fixture still needs to force a score. review.pub itself is unchanged at 29 — four names added, four removed. `priv` was also dropped from the budget keys. Counting `pub(crate)` items against a ceiling was backwards: closing an interface raises that number, so a budget that punishes it punishes the work. The Rust test never checked it. 277 passed / 0 failed, clippy -D warnings clean, and every detect, approve and staleness assertion intact.
* time: a wait seam the control loops call throughaur-build12 days1-6/+8
| | | | | | | | | | The dispatcher tick, watcher tick, SSE poll, agent watchdog and remote keepalive each slept on the wall clock in their own slice loop, so every test that wanted a tick waited for real time. They call crate::time::wait/sleep now, which is the same real sleep in a production build and a virtual clock advance under test-support: a test that takes the clock owns it, and threads it spawns inherit it. production_surface checks the virtual path is compiled out and that no control loop went back to std::thread::sleep.
* fix: drop the doubled semicolons the comment strip left behindaur-build12 days1-1/+1
|
* docs: drop the citations the deleted docs left behindaur-build12 days1-2/+2
| | | | | | | | The §n, I-n, M-n and m-n references survived in string literals the comment strip never touched: migration SQL comments, assertion messages, runtime error text, Cargo.toml, a CSS and template note, and one corpus manifest. They named sections of files that no longer exist, so the prose stays and the citation goes.
* comments: keep only what the code cannot showaur-build12 days4-196/+4
| | | | | | | | | | | Stripped every comment that described what an item does, documented its arguments or fields, or cited the design docs (§n, I-n, m-n, decision n). 2247 comments down to 83. What survives: the section dividers that segment the large modules, the secret-handling warnings, the agent wire-frame directions, and the few notes without which the code they attach to reads as redundant, reorderable, or unsound.
* comments: say why, not whataur-build12 days4-221/+98
| | | | | | | | | | | | | | Every module-level `//!` header is gone, and the comments that remained either re-explained the line below them or had grown into paragraphs. Density went from one comment line per 6.7 lines of code to one per 10. 827 insertions against 2194 deletions across 86 files. What survived: the invariants (I1-I12), the design cross-references into DESIGN.md, and the notes recording a bug that was found and fixed — those are the comments that carry weight, because they answer a question the code cannot answer about itself. What did not: restating a function signature in prose, and narration of the statement underneath.
* sandbox: the agent listener belongs to the process, not to a buildaur-build12 days1-27/+1
| | | | | | | | | | | | | | | | | | | | | | | | `Ctx::new` constructed a backend for every build, and constructing a remote backend bound the agent listener. With a fixed `listen` — which is what any real deployment configures, since the operator has to tell the agents where to dial — the second concurrent build died of EADDRINUSE. A build failing for a reason that had nothing to do with its package is the worst kind of flake: it looks like the package's fault. `RemoteBackend::bind` now shares one bound listener per `(address, token)` for the life of the process, and hands each backend a clone of the dial-in queue. That is also what `remote` already meant: an agent dials in when the operator boots one and whichever build is waiting takes it. The token is part of the key deliberately — two tokens cannot share a listener, and quietly reusing the first one's would be a fail-open surprise, so the second bind is attempted and fails loudly instead. Backend construction moved out of `Ctx` into `sandbox::backend_for`, so "which backend" has exactly one answer and the validation guard travels with it. Tests cover the shared listener, the shared queue (the *second* backend takes the dial-in), the two-token refusal, and two concurrent `Ctx`es on one address — with an assertion that a raw second bind still fails, so the test cannot rot into proving nothing.
* config: refuse a sandbox configuration that cannot work, at startupaur-build12 days1-0/+4
| | | | | | | | | | | | | | | | | | | | | The enum makes the impossible unrepresentable, but two things survive any type: a field that is present and empty, and an assertion the type leaves defaulted on purpose. `Config::validate` catches both, and it runs at startup — before the watcher, the dispatcher or the UI are up and looking healthy — and again where a backend is constructed, so nothing that builds one can skip it. The one that matters is the workspace. `Run` frames carry a hub-side working directory and the srcdir is never shipped to the sandbox, so a `remote` backend on a machine that does not share the hub's filesystem would fail in `makepkg` with a missing directory — and, worse, would *succeed* in the case nobody wants: quietly building untrusted code on the hub. So a remote or agent-sandbox config must say `"shared_workspace": true`, and the refusal says why rather than just naming the field. Loopback needs no assertion because it shares the filesystem by construction, which is also why it stays the zero-config default. Empty `listen`, `token`, `api`, `namespace`, `bearer` and `image` are each refused by name. Two tests drive the compiled binary rather than the library, because a guard that only exists as a callable function is a guard the CLI can walk past.
* config: the sandbox backend is an enum, not a string with a fallthroughaur-build12 days1-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | `sandbox_backend` was a free-form string and `backend_for` matched it with `_ => loopback`. So `sandbox_backend = "kata"` — a real, intended backend, documented in the design — meant "run the untrusted PKGBUILD as the hub's own user", and nothing anywhere said so. There was also no validation of any kind in the crate: an empty `agent_token` with a remote backend, or a missing listen address, parsed fine and failed later as something else. The four flat fields become one tagged `sandbox` object with three kinds: `loopback` (needs nothing, still the default, so every config on disk keeps working), `remote` (listen + token), and `agent-sandbox` (api, namespace, bearer, image, listen, token). Required fields are required by the type, an unknown kind is a parse error naming the valid set, and `deny_unknown_fields` means a misspelled field is named rather than read as absent. `agent-sandbox` parses and is refused at backend construction until it is wired up — a valid kind that is not implemented is an error, never a substitution. Retired keys are refused when they carry intent: a config saying `sandbox_backend: "remote"` errors and names the replacement shape, because quietly reinterpreting it as loopback is the bug being removed. A config saying `"loopback"` with the empty strings `init` wrote is noise, not intent, and loads unchanged. The token and the cluster bearer are redacted in `Debug`, so a config that reaches a log line cannot leak them.
* publish: repo-add decides the database filenameaur-build12 days1-34/+113
| | | | | | | | | | | | | | | | | | | | | | | | Publishing renders the index before the DB commits and renames it into place after, so a crash between the two leaves the old index serving (I4). The way that was written did it at `<db>.tar.gz.tmp` beside the live file — a filename real repo-add refuses, because its database argument has to be a name pacman would accept. Every publish test passed; the first real package anyone tried to publish died at the last step with the release already committed. `render_db` now renders into a scratch directory under the served directory, under the name a consumer will download. Same filesystem, so the rename is still the atomic swap, and the live database is never the file repo-add is writing into. `publish`, `reconcile` and `withdraw_package` all had the bug and all share the helper now; `reconcile` sweeps scratch directories a crash left behind. `run_repo_add` drops `-s` too: repo-add would sign into scratch space that is about to be deleted, and `publish::sign` already signs the renamed file. The reason 238 tests missed this is that the shim would write the database anywhere it was told. It now enforces the accepted set — measured against `repo-add (pacman) 7.1.0`, not read out of its docs — with the real tool's wording and exit status, and a gated test re-derives the set against the installed tool, in the shape of the vercmp oracle. A shim that is more permissive than its tool is not a test of the tool.
* sandbox: failure-mode tier — a FakeBackend that breaks on purposeaur-build12 days1-4/+29
| | | | | | | | | | | | | | | | | | | The recovery paths a remote pool makes newly reachable are now executed, not described. A decorator over the loopback backend injects the four faults that matter: a sandbox that vanishes mid-run (the step fails, the lease expires, the reaper requeues, a healthy pool finishes from the checkpoints — I5 across the sandbox boundary); a TTL that bites mid-build (a failed step, not a retry-burned one); a pool at quota (the build blocks on sandbox-pool using the same blocked machinery as missing deps, rather than failing on an infrastructure fact); and a sandbox whose pacman -Q lies about the installed world (provisioning refuses with a dedicated world-mismatch class, so 'the sandbox lied' never reads as 'the sandbox broke'). Two error classes carry that vocabulary: PoolExhausted — capacity, so wait, never retry — and WorldMismatch — fail-closed, never retried. The remote and kata acquire timeouts now speak the first, which is what makes a full pool a queue fact instead of a build failure.
* sandbox: ephemeral agent, wire protocol, and the hub's remote backendaur-build12 days1-1/+16
| | | | | | | | | | | | | | | | | | | | | | | The seam from the previous commits only had one body. This adds the other one: a sandbox-agent binary that dials the hub (outbound rendezvous — the hub never needs a route into an untrusted box), serves Run/Put/Get frames over length-prefixed JSON, streams the child's stdout/stderr as they fill, and dies — taking its child with it — when the connection drops or its TTL expires. The TTL watchdog is the backstop under every leak: hub crash, partition, a forgotten destroy. Hub side, RemoteBackend implements the same SandboxBackend: acquire waits for a dial-in and verifies the shared token and profile before a lease exists; a vanished sandbox fails the step, which is already the shape of an expired lease (I5), so the remote path adds no new failure vocabulary. Run frames carry the hub's child environment, so the §16a shim protocol reaches remote children exactly as local ones — which is what makes the end-to-end test honest: a real build, real frames, real log streaming into the SSE-tailed file, no root and no container. Workspace sync over the wire is deliberately not here: Run carries a hub-side cwd, honest for loopback-shaped deployments and this test tier, and the module says so rather than pretending.
* pipeline: replace the devtools chroot with pinned pacman -U provisioningaur-build12 days1-32/+115
| | | | | | | | | | | | | | | | | | | | | | | The chroot step existed to run mkarchroot/makechrootpkg, whose sudo requirement was the whole reason a build had to run on the hub under root-adjacent rules. The sandbox model makes the chroot redundant: the sandbox boots from a base that already carries the official packages, and step 2 now provisions it with a lease manifest instead — every dependency we publish, pinned to the exact version and digest of the artifact the index serves. The hub re-hashes every blob before staging it, installs with pacman -U (no -Sy, no live resolution, no mirror at build time), and the sandbox's own pacman -Q must confirm the pinned world landed before a build may start. A byte that hashes differently, or a world that drifted, fails closed. The build step is now plain makepkg -c -f: no -s (dependencies arrive installed; resolving at build time is what the pinning model forbids) and no -si (ingest signs). mkarchroot/makechrootpkg are gone from the pipeline and the config; their shims stay as stand-ins for the real devtools so the shim protocol itself remains exercised. The shim pacman grew a real fake installed-database: -U refuses bytes that do not hash to the digest their name claims, -Q reports what landed, so the world check is a test and not a no-op.
* pipeline: signing moves from the build step to hub-side ingestaur-build13 days2-16/+29
| | | | | | | | | | | | | The build step used to pass -si<key> through makechrootpkg, which meant whatever machine ran the build had to hold the signing key - fine for a chroot on the hub, disqualifying for a remote sandbox. The build now produces unsigned bytes; ingest signs the exact bytes that entered the store, with the same key and code path that signs the database, and a gpg failure fails the build closed. verify() no longer checks for a build-made signature: the meaningful guarantee moved to 'ingest produced one or the build failed'. The shim makechrootpkg now only emits .sig when -si is passed, like the real tool, so the suite cannot accidentally test a signing path that no longer exists.
* sandbox: the seam between the pipeline and where build code runsaur-build13 days2-24/+55
| | | | | | | | | | | | The step machine spawned its own subprocesses, which quietly made "build code runs on this machine, inside a devtools chroot, under §14's sudo rules" a pipeline fact rather than a deployment fact. Every build subprocess now goes through SandboxBackend: acquire a lease, run argv shaped commands (never a shell string), move content-addressed blobs, destroy. The loopback backend is today's behavior wearing the interface - same child_env shim protocol, same captured output - which is why the shim suite passes untouched: a step that cannot tell loopback from a remote sandbox is the property under test.
* pipeline, watch: a source identity that is complete when it existsaur-build13 days1-12/+19
| | | | | | | | | | | | | | | | | | | n-1. `SourceIdentity::from_candidate` returned a value with `aur_commit` and `recipe_hash` set to empty strings, which `Ctx::new` overwrote afterwards if it found the snapshot row. So the type had two meanings for "" — not filled in yet, and genuinely absent — and the second half of the construction was a convention rather than a requirement: a new call site could produce a build that recorded empty provenance and never noticed. The snapshot is an argument now, a candidate without its snapshot is an error rather than a quieter build, and the field `identity_hash`, which nothing ever read, is gone. n-2. `detect::Outcome` mirrors four of `candidates::Upsert`'s variants. Kept, with the reason in the code: `Upsert` answers "what did the candidate write do" and `Outcome` answers "what should the watcher do next", including the outcomes that never reach the candidate table (paused, gone, blocked, notice). Merging them would move watcher concerns into the review module and put storage vocabulary in the scheduler's matches. The converter is total and compiler-checked, which is what makes the mirror safe.
* http, pipeline: form pairs parsed once, and a rebuild identity in the real ↵aur-build13 days1-4/+20
| | | | | | | | | | | | | | | | | | | | | format n-3. `Req::form_get` called `form()`, which re-parsed the entire request body every time. The approve handler asks five times — two hashes, a note, a CSRF token, and a confirm flag — so a single POST parsed its own body five times. The pairs are parsed once at decode, next to the query pairs, and `form()` returns the stored slice. n-5. `enqueue_manual_rebuild` invented its own identity format, `hex("{aur_commit}|{recipe_hash}|manual")`, while every other identity in the system is a `sha256:` over the canonical JSON of the identity tuple (§3). Two formats for one concept is how a comparison quietly stops meaning anything, and the ad-hoc one had a delimiter that can appear inside a URL-shaped value and ignored the pins and digests that are the whole point of an identity. A rebuild is now identified by the canonical-JSON hash of the release's actual commit, recipe, pins and digests plus a `requested: manual_rebuild` marker — the marker being what keeps a rebuild a distinct build from the one that landed, while staying deterministic so that clicking rebuild twice is one build, not two.
* watch, review, config: the clarity minors — no-ops, dead params, one error ↵aur-build13 days2-17/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | type m-5. `mark_approved_but_unbuilt` was a function that did nothing, called from the failure path with a comment explaining that it did nothing. The mechanism is real — a failed build leaves the accepted pointer alone, and "approved, build failed, index still serving the old version" is what the derived query reads back — but a no-op in the failure path is a trap for whoever traces a build failure at 3am. Deleted; the explanation moved to the call site that needs it. m-6. The step loop extended the lease by a hardcoded 90 seconds while `Config` carried `lease_secs`, so an operator who raised the lease got leases that were silently reset to 90s after the first step. m-8. Dead parameters and `let _ =` debris: `upstream::run` took a `Db` it never used (and a `let _ = local;` after the value's only use), `risk::assess` took a `Pkgbase` it never used, `accepted_pins` took a `Db`, `detect::schedule_next` took a `Pkgbase` it discarded, `diff::version_delta` computed a `vercmp` and threw the answer away, and two HTTP handlers took arguments they ignored. All gone, with the callers following. m-11. `schedule_next` re-queried the subscription for `poll_interval_secs` that its caller had read moments earlier to decide whether the pkgbase was paused — two queries, and two chances to get different answers. The interval is now an argument, and the scheduler's own tick (which already holds the row) was already doing it the right way. m-15. `Config::load`/`save`/`ensure_dirs` returned `anyhow::Result` while the rest of the crate returns `error::Error`, which put two vocabularies on either side of one boundary and turned "there is no config yet, run init" — the one thing a caller can branch on — into an opaque string. They return the crate's error now; `main` keeps `anyhow` at the CLI edge, where it belongs. m-19. `skip_declared` was hardcoded `true` for VCS entries, so the field that means "the recipe gave us no checksum to trust" also meant "this is a git source", and a new `-git` source was rendered to a reviewer as `sha256sums=SKIP` — a warning about a recipe that had done nothing wrong. The field now means one thing everywhere, `SourceDigest::is_vcs()` says which integrity mechanism protects an entry, and the diff panel prints "pinned commit" for those. n-6. `recipe_at` was `pub` for no reason; it is `pub(crate)`.
* pipeline, db: the correctness minors — fsync, withdrawal, orphans, retry classaur-build13 days1-52/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | m-7. `fsync_file` and `fsync_dir` opened, ignored every error, and returned Ok, in the module whose entire guarantee is "fsync, then rename". A filesystem that refused the sync — full, read-only, a network mount that had dropped — still produced a successful publish whose database might not be on disk. They propagate now, with the path and the cause. m-10. `withdraw_release_in` set `state='withdrawn'` unconditionally, so withdrawing twice reported success the second time while changing nothing, and withdrawing a release that had never been live did the same. The write is a compare-and-swap on `state='published'`, and a refusal names the state that was actually there ("release 1 is withdrawn, not published: nothing to withdraw"). m-16. Artifacts are copied into the served tree before the DB commit, and when the commit refused they stayed: files no index names, sitting in the directory consumers download from. `publish` now tracks which files it created (a file that already existed belongs to the release still being served and is never touched) and removes them if the publish does not land. m-14. `is_transient` treated every `Error::Io` as retryable, which made ENOSPC and EACCES — plain `Io` — into three identical failures and a silent build. Only the kinds that mean "ask again in a moment" retry now. This turned a test that had been asserting the bug: it simulated a transient failure by pointing `makechrootpkg` at a nonexistent path, which is a missing binary, not a flaky network. That test now asserts the opposite (one attempt, no retries), and a new one produces a genuinely transient failure the way production does — a `SKIP` source whose bytes go unreachable after detection, cache dropped, so the `sources` step fails over the fetch path and retries to the cap. m-13. `random_hex` read `/dev/urandom` into a zeroed buffer, ignored every error, and hashed it anyway. Since C-1 the session id is the whole credential, so a failed read is now a refusal: `new_session()` returns `Option`, and the two call sites answer 500 rather than mint a token derivable from the clock and a counter. m-9. The row-error policy is decided and applied: a row that cannot be read fails the query instead of vanishing from the result (six `filter_map(|r| r.ok())` sites, including the reaper's and the claimer's), and `setting_i64` documents its own policy — absent means default, nonsense means default *and a complaint*, because a typo that silently does nothing is worse than a knob that refuses to apply.
* config: the test hooks are a gated submodule, not the production surfaceaur-build13 days1-2/+5
| | | | | | | | | | | | | | | | | | | | | | | Seven fields sat on `Config` next to `signing_key_id` and `bind`: a PATH override, three shim protocol variables, a fault-injection point in the middle of `publish()`, and two more shims could obey. m-9's complaint was not that they exist — the shims are how I4, I5 and I9 are tested for real, and a mock would have asserted the mock's own behaviour — but that nothing said which of these was production and which was scaffolding, and the publish path carried a test branch on every real publish. They are one `TestHooks` submodule now, documented as what it is, and the whole submodule is `#[cfg(feature = "test-support")]` — the same feature that already gates the shims and the raw SQL escape hatch, and which only this crate's own dev-dependency turns on. A production build has no `hooks` field, no shim protocol in `child_env`, and no fault-injection branch in `publish()`; the serialized config skips the section entirely when nothing is hooked, so a real `config.json` never mentions any of it. `TestHooks::is_empty()` names the state a real process runs in, and three tests hold the line: the hook fields may be declared exactly once and only inside `TestHooks`, every `publish_fault` read in `publish.rs` must sit behind the feature gate, and a default config serializes without a trace of hooks.
* db: the review, step, release and subscription states are enums tooaur-build13 days2-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | M-8 named four more machines after `build_state`, and each had the same defect in miniature: `&str` constants, a writer that took any `&str`, and a rule that lived only in the caller's discipline. They are `CandidateState`, `StepState`, `ReleaseState` and `SubscriptionState` now, all parsed through one `db::state_col` at the row boundary — a column value the code cannot name fails the read rather than becoming a state it did not ask for. The one that mattered is the review machine. `resolve_in(tx, id, &str)` would move a candidate to any state from any state, so an approval racing a rejection, or a stale worker resolving a review that had already been superseded, silently overwrote what a human had decided — the direct route to breaking I2 and I3 with no symptom anywhere. It is a compare-and-swap on `CandidateState` now: a decided review is only ever frozen, never re-decided, and a refusal names both states. `supersede_in` goes through it, so the freeze cannot resurrect a superseded review either. `StepState` gives I5 teeth. `begin_step` upserted over any existing checkpoint, including one recorded `succeeded`, so a resume that asked to re-run a finished step could rewrite the very row that told it to skip; the upsert now refuses to touch a done checkpoint and `finish_step` is a CAS. The blocked path (`running → pending`) and the reaper's `running → interrupted` are unchanged, and both are in the table. Two behaviour changes, both for the better and both tested: the UI's pause button now says "orphaned: nothing to pause" instead of rewriting an orphaned subscription back to a pausable state, and a step checkpoint that is already done makes `begin_step` an error rather than a quiet overwrite. Five tests in `tests/state_machine.rs` cover the review CAS in both directions, the frozen checkpoint, the interrupted/blocked transitions, and the unknown value in a candidate and a step row.
* db: the build state machine is an enum, and a state write is a compare-and-swapaur-build13 days1-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `build_state` was seven `&str` constants and `set_state(&str)` would write any string a caller invented, so the machine existed only as `WHERE state IN (...)` clauses scattered across six modules and nothing could say that `succeeded → running` is nonsense. It is `db::model::BuildState` now: parsed where a row is read (a state the code cannot name is an error, not an empty string — which also retires m-12's `current_state` returning `""`), and `set_state` takes the variant and writes only if the row's current state is one of `to`'s legal predecessors. A refused transition writes nothing and says why. Writing the machine down surfaced three things that were true of the flows but of nobody's documentation. The step loop re-asserts `Running` at every step boundary, so a self-write is a no-op and not a move — every state accepts its own name. A failed build is resumed *on its own row* (I5: the step checkpoints say where to continue), so `failed → running` is a real transition. And `builds::retry` — the UI's requeue button — moved any row to `queued` unconditionally, including one that had already published, re-queueing a build whose every step was checkpointed as done; it goes through the machine now and is refused with a reason. `requeue_transient` likewise. What the CAS buys is the zombie case, which no test covered: a worker's lease expires mid-step, the reaper returns the build to the queue, and the original worker — still running — comes back and writes `succeeded` over whatever the new owner has since done. That write now fails loudly and the queue keeps ownership. `builds_for_pkgbase` had a second, hand-copied row mapper that dropped unreadable rows with `filter_map(|r| r.ok())`; it shares `row_to_build` now and a bad row fails the query instead of vanishing from the package page (m-9's policy, applied where it bit). `tests/state_machine.rs` pins the whole table, the zombie refusal, the unknown state, the terminal build that does not move, and the requeue-of-a-published- build refusal. `tests/live.rs` walks a build through `running` before succeeding instead of teleporting it.
* pipeline: one lock guards the served index, and it says so onceaur-build13 days1-21/+33
| | | | | | | | | | | | | | | | | | | | | | | | | `publish.rs` had two static mutexes, each documented as *the* "one publish per repo" guarantee — `PUBLISH_LOCK` taken at the top of `publish()`, `REPO_LOCK` taken partway through and by `withdraw_package`. Either the second was redundant or the guarantee was incomplete, and a reader could not tell which, which is worse than either answer: the comment on `REPO_LOCK` claimed a single-writer property that its own position in the function did not provide (artifacts were already staged by then), and the comment on `PUBLISH_LOCK` claimed it for a section that did not include the rename. There is one lock now. `REPO_LOCK` is taken at the top of `publish()` and held for the whole of it — staging, render, DB commit, rename, sign — which is the sequence that must not interleave, and `withdraw_package` takes the same lock for the same reason. The poison-recovery rule that belonged to both is stated once, on the lock. `reconcile` is documented as the one rewriter that does not take it, because it runs at startup before the dispatcher exists. M-5 is a clarity defect rather than a live misbehaviour, so the guard is structural: `tests/production_surface.rs` fails if `publish.rs` declares a second serialization mutex, if `PUBLISH_LOCK` comes back, or if either index writer stops taking the one that remains. A timing-based test would have been the flaky kind and would not have proven anything the I4 and I8 crash tests do not already prove.
* pipeline: the name we publish comes from the real .PKGINFO parser, and the ↵aur-build13 days1-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | shims are test-only `publish.rs::package_name` — the function that decides which package a built artifact is, and therefore what the index says — called into the test harness (`shims::read_pkginfo`) to read it. Worse, the shim module carried its own `.PKGINFO` field parser alongside the real one in `pkginfo.rs`. Two parsers that can drift is a supply-chain-shaped foot-gun in a system whose whole job is provenance: the bytes we sign and the bytes the tests believed in would be interpreted by different code, and a green shim test would not have meant the pipeline read the package the same way. There is now one parser. `package_name` uses `pkginfo::pkginfo_text` and `pkginfo::parse_pkginfo`; the shim's `repo-add` renders its `DESC` entry from the same `PkgInfo` the production code parses, so the fake tool and the real pipeline cannot disagree about what a package calls itself. The duplicate parser and the two wrapper functions are deleted, and the harness test reads its artifact with `pkginfo` too. The module itself is now test-only in the way the review asked for. `pub(crate)` was not available — the shim binaries are separate crates that link the library — so the equivalent enforcement is used instead: `shims` is compiled out unless the `test-support` feature is on, and every shim binary declares `required-features = ["test-support"]`. A production `cargo build --release` neither builds the fakes nor links their code; `cargo build --bin makepkg` says so out loud. `tests/production_surface.rs` covers the half the compiler cannot see: no module in `src/` outside the harness may name `shims::`, and the binaries must keep declaring the feature.
* db: the schema gets an owner — every statement moves into db/, and the ↵aur-build13 days3-77/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | writer stops handing out connections Twelve modules outside `db/` contained hand-rolled SQL — 22 statements in `ops.rs`, 17 in `approve.rs`, 15 in `candidates.rs`, 11 in `publish.rs`, and a dozen more scattered through `watch`, `pipeline`, `http` — which meant the blast radius of a schema change was "any module", and `db/` was a directory rather than a boundary. The audit trail alone was defined in four places with three different detail payloads. Every statement now lives in `db/`. New modules `db::candidates` and `db::approvals` own their tables (including the 21-column candidate select, spelled once as `CANDIDATE_COLS` instead of four times); `db::queries` gains the metrics reads, the retention reads and writes, the publish writes (`insert_release_in`, `cas_accepted_release_in`, `remove_index_packages_in`), the staleness reads and the source-cache lookups; `db::builds` gains `set_release_in`. Where a mutation is a *decision* — the collapse rules, the approval gate, the publish compare-and-swap — the decision stays where it was and the statements are called through the transaction handle, so the atomicity is unchanged and only the SQL moved. `audit_in` is the in-transaction audit append, and `audit` is now a wrapper over it: a decision and its audit row commit together or not at all, which is what I10 actually claims. Enforcement is two-layered, because one layer is a lie. `Writer::call`, `tx` and `send` are `pub(crate)`, which keeps the crate's *users* out — the integration tests and the shim binaries — but `pub(crate)` is crate-wide, so on its own it would not stop `approve.rs` from writing SQL tomorrow. The layer that does is `tests/schema_ownership.rs`: it walks `src/` and fails the build if a statement literal or a rusqlite statement call appears outside `src/db/`. It was checked against a deliberate violation. The test harness still needs to construct states no typed API reaches, so the raw door exists but only under the `test-support` feature, which nothing but this crate's own dev-dependency enables; a production binary cannot see it.
* hash: canonical_json is canonical now, and a serialization failure is an erroraur-build13 days2-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | The function behind `Identity::hash` — the digest an approval echoes back — did two things its name promised and it did not do. It did not order anything: the doc comment conceded that callers were expected to pass "already-canonical values", which is a convention, not a property, and a struct serializes in whatever order its fields were declared. And on a serialization failure it returned `"{}"`, so every value that failed to serialize hashed to one shared digest. For a system whose whole job is provenance, "two identities that could not be serialized would look identical to the approval echo" is the worst possible failure to have available. Serialization now routes through `serde_json::Value`, whose map is a `BTreeMap`, so object keys come out sorted whatever the input's construction order — the name describes what happens. A failure propagates: `canonical_json` returns `Result`, `Identity::hash` returns `Result`, and the four call sites (detect, put_world_snapshot, the world step, both enqueue paths) pass it on. There is no path left where a digest is invented for a value that could not be rendered. `tests/hash.rs` pins all three properties: an unserializable value is an error naming itself, two same-field-different-declaration-order values render identically (and to the exact compact sorted bytes), and the identity digest changes when any element of the tuple changes.
* the real chroot caught what no shim test could: mkarchroot has no -N flagaur-build13 days1-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ran the gated tier as far as this host allows, with real devtools, real root and real network, and it paid for itself immediately. `mkarchroot` has no `-N` option. The pipeline was calling `mkarchroot -N <seed>`; the shim ignored the unknown flag, so every test passed, and the real tool answered with a usage error. The first real chroot build would have died on its first step in a code path the shim harness structurally cannot exercise. The seed's package list is now configuration (`mkarchroot_args`, default `base`) and the call follows the real usage: `mkarchroot <working-dir> <packages...>`. What else the attempt verified, with the real binaries rather than the shims: a generated GPG key detached-signed the artifact the pipeline produced and `gpg --verify` reported a good signature; real `repo-add -s -k` built and signed a pacman database over it, and that signature verified too. So "both the packages and the .db are signed" now rests on real crypto. Where it stops: `mkarchroot <dir> base` downloaded and installed the base set into the chroot (437 MB, 14 packages, install scripts ran) and then failed in devtools' init stage with `Failed to parse --bind(-ro)= argument` from systemd-nspawn 262 inside an unprivileged container. DECISIONS.md records exactly what was run, what passed, what failed and why, and what therefore remains modelled rather than crossed — a silent skip would have hidden all of the above, including the flag bug. Also fixes the I9 test's expectation: a refused build is an `Outcome::Failed` at the `collect` step, not an `Err` from the runner, which is the correct shape (the build failed closed and said why) and the test now asserts the step name. 171 tests pass, clippy clean.
* I9: the pipeline stops trusting paths the build could have placed, plus ↵aur-build13 days1-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | README and the invariant index Three things. **A real hole, closed.** `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 generated by our own scan, but their *targets* are not: a PKGBUILD that drops a symlink called `evil.pkg.tar.zst` pointing at the signing keyring, the database, or anyone's home directory would have its target copied in, published and signed by us. The chroot is supposed to be the layer that prevents that, and the chroot tier is gated — but two protection layers must not be load-bearing on each other, and the control plane should not depend on isolation for the safety of its own secrets. `collect` now rejects symlinks and rejects anything whose canonicalized target escapes the build's own staging directory, failing the build closed with the path in the message. `i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir` acts the attack out — the shim plants a symlink to the database file — and asserts the build fails, the store is byte-for-byte untouched, and nothing publishes. This is the last §2 invariant that had no named test; docs/INVARIANTS.md says plainly which part of I9 this covers and which part belongs to the gated chroot tier. **README.md**, written for the person who has to operate this at 3am: the rule everything else follows, the quick start, the layout, how the shim harness makes the whole pipeline testable without root or network, the ops commands, the route table, and the §14 constraints stated as the hard edges they are. **docs/INVARIANTS.md**, mapping I1-I12 to the named tests that hold them, with corroborating tests listed, and an explicit note on the two invariants enforced by the schema (the partial unique index for I7, the append-only triggers for I10/I7) so a future code path cannot forget them. Also recorded in DECISIONS.md: metrics served without a session and why, retention recording a purge instead of deleting the row, and the real-chroot tier being explicitly skipped with what stands in for it and how to actually run it. .gitignore already covered .pi/ but the goal-tracker files were tracked from before the rule existed; untracked now so they stop appearing in every diff.
* pkginfo: .PKGINFO/.BUILDINFO parsing gets a real home, and a parser bug fix ↵aur-build14 days1-51/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (§10.1) Ingest decides what the index claims about a package and what the world snapshot records by reading two text files out of a tar inside a zstd stream. That code was living in src/shims — the test harness — which meant production depended on the harness for its view of a package's own metadata. Moved to src/pkginfo.rs, with the shim now delegating to it so the harness and the production path cannot disagree about what a package says about itself. Still no libalpm: tar + zstd + eighty lines of key = value parsing. Unknown keys are ignored rather than rejected, because makepkg adds fields over time and a new one must not stop us publishing. **The parser had a real bug.** A .BUILDINFO installed block puts its first entry on the same line as the key: installed = glibc 2.39-1 x86_64 - gmp 6.3.0-1 x86_64 - The old code skipped the header line, so the first dependency was silently dropped from every snapshot — exactly the kind of gap that makes staleness quietly wrong. The header line is parsed now. tests/world.rs builds real .pkg.tar.zst files and asserts the fields come out of the archive: repeated keys stay lists, an archive with no .PKGINFO is refused rather than defaulted from the filename, and the world snapshot contains our own packages and none of glibc/pacman/binutils. The empty-snapshot case for a first build is asserted too — nothing of ours existed yet, and recording that honestly beats inventing a world. Split pkgbases produce one approval, one release and N index rows each with its own artifact, asserted directly here. 143 tests pass, clippy clean.
* pipeline: dispatcher actor, worker pool and reaper (§8.2, §8.4)aur-build14 days3-0/+217
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One dispatcher thread, N workers, one crossbeam channel between them. The dispatcher loop is reap -> cancel -> claim -> send, and the reaper runs first on every pass including the first, so 'recover from a crash' and 'notice an expired lease' are literally the same code path. There is no startup recovery routine to get wrong. - claim_batch does the SELECT and the UPDATE in one BEGIN IMMEDIATE transaction. SQLite has no SKIP LOCKED, but with exactly one writer the claim cannot race: nobody can see a row between the two statements. - Backpressure is min(max_concurrent_builds - in_flight, disk headroom), measured with statvfs. A build that cannot fit on disk stays queued instead of filling the filesystem halfway through a compile. - Retry policy (§8.4): transient failures (IO, HTTP) requeue up to max_transient_attempts; a deterministic build failure is never retried, and the release stays approved_but_unbuilt so the old version never looks healthy. Tests assert attempt==1 for build-fails and attempt==3 for a transient one. - A superseded candidate sets cancel_requested on in-flight builds; the worker stops at the step boundary rather than mid-step, which is what keeps the checkpoints honest. - Publish takes a process-wide lock so two workers cannot interleave the index rewrite. The critical section is the db file rewrite, never a build. - The deterministic build id makes re-enqueue an INSERT OR IGNORE no-op, so a careless 'rebuild that again' is harmless. tests/dispatch.rs drives the real threads: the pool takes a queued build all the way to publication, a reaped build resumes from its checkpoints without re-running makechrootpkg, and backpressure admits exactly one build per slot. Serve now starts the pool alongside the watcher and the HTTP server.
* cli: operator command line with the approval path (§7.2)aur-build14 days1-8/+10
| | | | | | | | | | | | | | | | | aur-build init/subscribe/detect/reviews/show/approve/reject/build/run/ builds/status/packages/audit. approve renders the review and then approves with the hashes it just rendered, so the CLI cannot approve a diff it did not show you; --identity/--diff reproduce the stale case explicitly and a refusal exits 2 (the web equivalent is 409). Approvals are now immutable at the schema level: migration 0006 rejects UPDATE and DELETE on the approval table, because that row is the only proof the system has of what a human actually looked at (§7.2, I10). Publishing also refuses when no approval is reachable, including the manual-rebuild path that inherits one. 10 tests, including two that drive the compiled binary end to end against a file:// AUR fixture.
* pipeline: ten-step build machine with atomic signed publishaur-build14 days3-0/+1177
materialize -> plan -> chroot -> sources -> pkgver -> build -> collect -> verify -> ingest -> publish, each checkpointed in build_step so a worker that dies resumes at the next incomplete step without repeating the expensive one (I5). Step 0 materializes from the local mirror only and re-hashes the tree: there is no path from 'AUR moved since the review' to 'we built it anyway' (I3). Step 4 re-resolves a VCS pkgver and refuses when it no longer matches the approved identity. Publish renders the index to .tmp, fsyncs, commits release + package rows and the accepted pointer under a compare-and-swap, then renames over the served database and signs it, so a crash leaves the old index byte-for-byte intact (I4) and every index entry traces back to an approval (I1). Ingest records the world snapshot as the BUILDINFO installed set intersected with our own packages, which is what keeps staleness meaningful (I12). 17 shim-driven end-to-end tests, including kill-mid-publish and crash-resume, with no root, network, or real chroot.