summaryrefslogtreecommitdiffstats
path: root/src/shims/mod.rs
Commit message (Collapse)AuthorAgeFilesLines
* pipeline,sandbox,shims: thirty-two more markers the compiler was willing to takedev10 days1-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The whole `shims` module is behind `test-support`, so its thirteen `pub(crate)` items were invisible to a release build already — but `pub(crate)` still made each of them part of the crate's interface to every other module, and none of them had a reader outside the file that declares it. `manifest`, `record`, `split_version`, `valid_db_arg`, `DB_SUFFIXES` and the nine tool entry points are now private to `src/shims/mod.rs`, which is where the shim binaries reach them through the module's own `pub` surface. `pipeline` went 16 -> 4 and `sandbox` 16 -> 9. Two refusals are worth the sentence: `SourceIdentity` is the type of the `pub(crate)` field `Ctx::src`, and a field may not be more reachable than its type, so making it private is the `private_interfaces` warning rather than a legal narrowing. `provision_request` is declared inside the private `kata_backend` module and called from the sibling `#[cfg(test)] mod tests`, and privacy does not cross to a sibling — E0624. Both are argued in `over_visibility.allowlist` now instead of sitting unexplained. `LOW` in `review` is the same sibling case one level up: it lives in the `pub mod level` nested in risk.rs and the scorer in the parent module reads `level::LOW`, so `pub(crate)` is the narrowest thing that reaches, given that this crate does not admit `pub(super)`. priv 149 -> 117, overwide 21 -> 0 unargued. `cargo check` clean under both profiles with no new warnings; tests/pipeline.rs, remote_agent.rs, kata.rs, approve.rs, shims.rs and world.rs pass (62 tests), and `cargo test --test architecture` is 16 passed.
* src: narrow what only its own module reads, and delete what nothing reads at allaur-build10 days1-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The census's 35 `deadonly` items were a lead, not a verdict, and the compiler answered it: 17 of them are read only inside their own module and were declared `pub` for no reason, so they are `pub(crate)` now — `db::OpenReview` and its two queries, `ReviewSubject` and its query, `fetch::Body`, `http`'s `form_get`, `query_get` and `Page::flash`, `ops::EvictPlan`, `usecase`'s `StageB`… — and two are read by nobody: `ReleaseState::can_transition` and `SubscriptionState::can_transition`, both already annotated "nothing consults this table today", which is the definition of dead rather than the argument for keeping. Narrowing them is what made the compiler look harder, and it found three more: `ReviewSubject::pkgbase` was selected out of the database and never read, `StageB::cached` was written in three places and never read, and `StageB::version` was never called. All gone, the SELECT column with them. The other 18 cannot be narrowed and now say so, once at the declaration and once in the budget file: a row type the `aur-build` binary binds without naming (`PackageRow`, `Checked`, `GcPlan`, `Prepared`), a type behind a `pub` fn a test calls (`Unbuilt`, `BulkItem`, `StageA`, `CheckReport`, `PkgInfo`, `Installed`, `Subscription`, `Manifest`), a trait a public test provisioner implements (`Provisioner`, `ProvisionRequest`), and three that a release build never even compiles because their module is `test-support`-gated (`shims::*`, `VirtualClock`). `deadonly` therefore means *dead and unargued* now: an allowlisted item leaves the dead columns, which is the only way the number can be held at zero forever. 448 pub, 49 dead, 0 unargued; 284 tests pass, one ignored, none lost.
* src: close the items the stricter detector surfacedaur-build10 days1-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 days1-0/+28
| | | | | | | | | | | | | | | `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.
* tools: the test-surface detector credited four items with callers they lackaur-build11 days1-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An audit found that `internal` — the check deciding whether a test-only item has a real production caller — was crediting non-calls. Four items were sorted into `residue` on false evidence, and each false credit was a different mistake: db::cas_accepted_release a `pub use` continuation line at db/mod.rs:55. Production does this CAS through `cas_accepted_release_in` inside a transaction; the two names differ by three characters. shims::invocations the string "invocations.jsonl", plus a call from `called_with`, which is itself test-support gated. A test-only function cannot be evidence that another function is production-used. sandbox::LocalAgentProvisioner its own struct and impl headers. Production selects `K8sSandboxProvisioner`. sandbox::local_addr `listener.local_addr()` — std's method on a TcpListener, in sibling files. The census treats all of src/sandbox as one module, and a name match cannot tell a receiver's type. All four are gated now. `KataBackend::local_addr` had zero callers in src and zero in tests — `tests/remote_agent.rs` calls `RemoteBackend::local_addr`, a different type — so it is deleted rather than gated. The detector now strips string literals and comments, skips `use` statements including the continuation lines of a brace-delimited block, skips an item's own impl headers, and refuses to count a call made inside a `#[cfg(test)]` module or a `test-support`-gated item. The case a regex cannot resolve is `self.store_dir()` versus `listener.local_addr()`: identical to a name match. Rows whose only evidence is a call in method position are flagged `⚑`, listed in `tools/test-surface-confirmed.json` only after a human read the cited line, and `the_test_surface_is_disposed_of` fails on any unconfirmed one. Four rows are confirmed that way — `config.store_dir`, `http.cookie`, `ops.build_success_rate`, `watch.needs_stage_b`. The table now prints each item's in-module call sites as its own column, because the residue count is the one number this work cannot eliminate and the claim underneath it has to be checkable rather than asserted. Suite: 284 passed, 0 failed. Clippy clean. Release build clean.
* review, shims, time: gate the last three test-only entry pointsaur-build11 days1-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `review::diff::render_and_store` is the alarming row in the table: zero callers in `src/`, seventeen test files. Intake renders through `review::intake::record` — the single entry point the pipeline and both front ends use — and this is the older uncomposed form. It is gated, not relocated to `tests/common`, because it needs this module's private `panels`/`render_text` and `candidates::set_diff_digest`; widening those to let a test out would undo the narrowing the last dozen commits did. `shims::called_with` is gated: the shim *writes* its invocation log in production, which is how a fake tool leaves evidence, but nothing in the crate reads it back. Only tests ask what a build actually did. `time::pin` and `time::unpin` are gated together. Gating half of a two-function capability would leave a release binary able to freeze the clock and unable to release it. `pin` is worth naming because the census never reported it as test-only at all: its name match also fires inside `upstream_pins`, so a genuinely test-only function hid in plain sight until its counterpart was examined. The only callers in the crate are tests, and the unit test that uses them is gated with them. Nothing was relocated to `tests/common`. The table chose no `relocate` disposition — every item either needed module-private internals or moved into its own module instead — and no API was widened to accommodate a test, which was the condition on relocating anything. Test-only items across the crate: 61 at the start of this work, 46 now, of which 33 are residue and 13 already gated. `gate_pending` is zero. Suite: 284 passed, 0 failed, 0 ignored. Clippy clean.
* comments: keep only what the code cannot showaur-build12 days1-79/+0
| | | | | | | | | | | 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 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-build13 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).