summaryrefslogtreecommitdiffstats
path: root/src/config.rs
Commit message (Collapse)AuthorAgeFilesLines
* config: the test hooks are a gated submodule, not the production surfaceaur-build13 days1-46/+84
| | | | | | | | | | | | | | | | | | | | | | | 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.
* the real chroot caught what no shim test could: mkarchroot has no -N flagaur-build13 days1-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* pipeline: a real process kill, and the failure state the UI must show ↵aur-build13 days1-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (§8.4, I5) The crash-resume invariant was only ever simulated before: an in-process fault hook returns an error, and an error can be caught, unwound and cleaned up by accident. So the shims gained AUR_SHIM_KILL_PARENT — the named tool SIGKILLs the process running the pipeline, mid-step, with no Drop and no atexit. The test spawns the real aur-build binary, watches it die of SIGKILL inside the build step, and then asserts the things that matter: - the database is intact, because no transaction ever spans a build step - the completed steps are checkpointed succeeded and the running one is recorded running - after the lease expires the reaper requeues it and marks the step interrupted - resuming publishes exactly one release, and the shim invocation log proves mkarchroot ran once, makechrootpkg twice (crash + resume, not twice per attempt) and repo-add once **This found a real bug.** reap_expired only matched state='leased', but a worker sets state='running' the moment it starts a step, so a process that dies mid-step leaves a running row — and every real crash would have been stranded forever. The reaper now reaps leased and running. Also §8.4's other half, which was a comment rather than a feature: a failed build must not leave the old version looking healthy. db::approved_but_unbuilt finds approvals whose build failed and never published, and Attention and the package page now say 'v2 approved, build failed, index still serving v1' with a link to the log. Retrying is an explicit, audited POST, not something the system does to itself. Cancellation is asserted to be cooperative at a step boundary: a cancelled build runs no steps, publishes nothing, and is not counted as a failure.
* pipeline: dispatcher actor, worker pool and reaper (§8.2, §8.4)aur-build13 days1-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* pipeline: ten-step build machine with atomic signed publishaur-build14 days1-0/+10
| | | | | | | | | | | | | | | | | | | | | 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.
* test: toolchain shims and the fake-package corpus (§16a)aur-build14 days1-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The harness that makes the rest of this developable. Six real binaries named exactly like the tools the pipeline shells out to, sharing one shim module, driven entirely by environment so no production code path is test-only: AUR_SHIM_DIR where invocations are recorded (jsonl) AUR_SHIM_MANIFEST the fixture manifest to obey AUR_SHIM_FAIL optional tool forced to fail makechrootpkg emits real .pkg.tar.zst files with .PKGINFO and .BUILDINFO (the full chroot world, which is why §10.1 filters it), makepkg answers --printsrcinfo and --vercheck for Stage B, repo-add rebuilds a gzip'd .db with %FILENAME%/%VERSION%/%SHA256SUM% DESC entries, gpg writes a detached signature, mkarchroot creates a warm root. Each one records its invocation so tests assert on what actually ran. testcorpus/ holds 17 fixtures, each a PKGBUILD plus a manifest with the scripted outcome: plain-make, with-patch, install-hooks, skip-checksum, split-pkgbase, build-fails, check-fails, missing-dep, dep-cycle, epoch-bump, pkgrel-reset, downgrade, digest-drift, pin-drift, git-sourced, git-submodules, unresolvable. The harness commits a fixture into a real git repo standing in for AUR, materialises a local upstream git repo for VCS fixtures, and swaps payload bytes for the drift cases. Config.child_env is what puts the shims on PATH for child processes, so the pipeline runs completely unmodified under test. Part of P0 (DESIGN.md §17).
* feat: SQLite schema, migrations, single writer actoraur-build14 days1-0/+201
The §11 data model as four migrations, plus the §11a concurrency model: one writer thread owning the write connection (mutations arrive as closures over a crossbeam channel, so SQLITE_BUSY is not part of the design) and thread-local read-only connections under WAL. Invariants that are database guarantees rather than conventions: I7 partial unique index -> at most one pending_review per pkgbase I3 UNIQUE(pkgbase_id, identity_hash) -> no duplicate candidates I10 audit table rejects UPDATE and DELETE by trigger §16 current_accepted_release_id moves only by compare-and-swap Also: vercmp + dependency-string parsing (ALPM algorithm, no libalpm), hash helpers including recipe_hash over the whole AUR tree, the clock helper that stamps every write, and the config/root layout. Part of P0 (DESIGN.md §17).