summaryrefslogtreecommitdiffstats
path: root/src/shims/mod.rs
Commit message (Collapse)AuthorAgeFilesLines
* comments: say why, not whataur-build12 days1-80/+37
| | | | | | | | | | | | | | 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.
* publish: repo-add decides the database filenameaur-build12 days1-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* pipeline: replace the devtools chroot with pinned pacman -U provisioningaur-build12 days1-26/+88
| | | | | | | | | | | | | | | | | | | | | | | 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 days1-2/+7
| | | | | | | | | | | | | 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.
* pipeline: the name we publish comes from the real .PKGINFO parser, and the ↵aur-build13 days1-72/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* the real chroot caught what no shim test could: mkarchroot has no -N flagaur-build13 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-build13 days1-28/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (§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: a real process kill, and the failure state the UI must show ↵aur-build14 days1-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (§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.
* test: toolchain shims and the fake-package corpus (§16a)aur-build14 days1-0/+641
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).