summaryrefslogtreecommitdiffstats
path: root/src/review/approve.rs
Commit message (Collapse)AuthorAgeFilesLines
* src: close the items the stricter detector surfacedaur-build11 days1-0/+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.
* src: keep every remaining test-only item out of the release buildaur-build11 days1-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The auditor was right and my "Rust has no test-conditional visibility" defence was wrong. Two shapes do it, and both are now used wherever the item allows. For free functions, methods, consts and statics: one body behind two visibility declarations. #[cfg(feature = "test-support")] pub fn probe(..) -> .. { probe_impl(..) } #[cfg(not(feature = "test-support"))] pub(crate) fn probe(..) -> .. { probe_impl(..) } fn probe_impl(..) -> .. { .. } The value lives once in a private `*_impl` / `*_VALUE`, so the aliases cannot drift apart. For types: a private inner module holding the real definition, re-exported under a feature gate. mod kata_backend { pub struct KataBackend { .. } } #[cfg(feature = "test-support")] pub use kata_backend::KataBackend; #[cfg(not(feature = "test-support"))] pub(crate) use kata_backend::KataBackend; A `pub` item inside a private module has no nameable path from outside, but it is visible enough to appear in a public trait signature — which is why `Exit`, the return type of `Sandbox::run`, narrows this way and would not as a plain `pub(crate) struct`. `ReleaseState` earns its keep the same route: `ReleaseRow` is public and its `state` field is typed here. Verified with an external crate against the built library: naming `Exit`, `SandboxInfo`, `KataBackend`, `LoopbackBackend`, `RemoteBackend`, `ReleaseState`, `BulkRefusal` or `LogTail` from a release build is `error[E0603]: .. is private`; with `test-support` the same program compiles. Where narrowing needed a re-export split by feature (`db::MIGRATIONS`, `model::ReleaseState`) the alias is split; where nothing in the crate used the alias (`watch::sync_mirror`) it is gone rather than gated.
* sandbox,http,review,watch: keep six more test-only types out of the release ↵aur-build11 days1-12/+29
| | | | build
* docs: record the census, and make the README describe the tree that existsdev11 days1-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The census report gets its after-table, and the README's Layout gets rewritten — it had drifted into fiction, listing `db/queries.rs`'s successors as "queries" and omitting `usecase`, `error`, `hash`, `time`, `urlutil`, `git`, `fetch` and `recipe` entirely. It now states the ranks and says plainly that they are enforced by `tests/architecture.rs`, not kept in hope, and names the two commands that keep it true. This commit also carries the last of the narrowing that fell out of writing the report, because writing it meant actually reading the numbers: - `watch::upstream::resolve` looked test-only and was not — the tests contain an unrelated local function of the same name, which the census matches as a word. It is crate-internal and now says so. - `read_tree` closed with it. Its two integration tests were testing the module's own batching behaviour from outside, so they moved inside as unit tests with a throwaway git repo, which is where a test about one `ls-tree` and one `cat-file --batch` belongs. They lost nothing: the empty-blob and NUL-byte assertions came across verbatim, plus one the old test never made — binary blobs are still listed, just not read. - `Assessment::is_high`, `Tree::get`, `approve::current_accepted` and `diff::full_recipe_text` were dead once their callers closed, and are gone. - `set_risk_for_tests` is gone too. The bulk-refusal test needed a candidate marked high-risk, and the honest way to get one was for the fixture to write the row — `Env::execute` — rather than the library growing a public setter that exists only so a test can pass. That was the last budget above baseline apart from `error.pub`. `error.pub` stays at 21 against a baseline of 15, and the report says why: the six payload enums are constructed in four modules and matched in `error`, so they are interface. `error.dead` is 0. Final: 281 passed / 0 failed across 36 binaries (baseline 273), clippy -D warnings clean, release clean, census within budget.
* error: give the six variants behavior carries a shape, not a sentencedev11 days1-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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.
* review: one call to record a candidate, and one way to read onedev11 days1-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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.
* comments: keep only what the code cannot showaur-build12 days1-39/+1
| | | | | | | | | | | 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-45/+17
| | | | | | | | | | | | | | 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.
* review: one host rule, one body rule, one audit constructoraur-build13 days1-27/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | m-2. `hosts` existed twice, verbatim, in `review::diff` and `review::risk`. The duplication that matters is the other one: "did the executable part of the recipe change" also existed twice, with *different* semantics. The risk scorer compared everything from the first function definition onward; the diff panel compared only the lines that name a function, so a `build()` rewritten to `curl … | sh` under the same function names told the risk scorer "code changed, high" and told the reviewer nothing at all — the one reader who could have caught it. Both questions now have one answer: `urlutil::hosts` (which also strips the `git@` from ssh URLs, so a scheme change stops crying "new source host" wolf) and `recipe::bodies_changed`, in the module that owns the recipe. m-4. The three review decisions each hand-built an `AuditEntry` literal, and their `detail` shapes drifted: approve recorded the identity hash, reject recorded only the note, withdraw only the reason — so for two of the three the log cannot answer which candidate bytes the decision was about. `AuditEntry` is built by `::human` / `::system` now, and reject records the identity hash it rejected. m-3, the four-times-copied 21-column candidate `SELECT`, was already gone: the `CANDIDATE_COLS` constant came with moving the candidate SQL into `db/` in an earlier commit. Tests: the body rule is pinned at the unit level with the exact drift case (same function names, different body), `tests/production_surface.rs` fails if either module grows a private copy again or if an audit row is hand-built, and the reject test reads its own audit row back and requires the identity in it.
* db: the review, step, release and subscription states are enums tooaur-build13 days1-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* review: a database failure is never reported to a reviewer as a stale reviewaur-build13 days1-43/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `approve()` returned `Result<Approval, Stale>` and then collapsed every inner failure into `Stale::NotPending { state: e.to_string() }`, so a SQLite error reached the human as "review is no longer pending (state: sqlite: …)". That is the one message that tells a reviewer to look again when the truth is that the write failed — and the transaction had already rolled back, so their review was still pending and nothing on screen explained why. `bulk()` bent the same variant to mean "high risk", "unknown decision" and "the database failed", and handed back a fabricated `Approval { id: 0 }` for a rejection that recorded no approval at all. `approve()` now returns `Result<Approval, ApproveError>` with two families: `Stale(Stale)` — what is stored is not what was displayed, look again — and `System(Error)` — the write failed, nothing about the review is at fault. The UI answers the first with the 409 and fresh diff it already gave, and the second with a 500 that names the cause; the CLI exits 2 for the first and propagates the second as an error. `bulk()` got its own vocabulary — `BulkOutcome::{Approved, Rejected, Refused(BulkRefusal)}` with `HighRiskUnconfirmed`, `UnknownDecision`, `NotFound`, `Stale` and `System` — and returns no approval row for a rejection, because there is none. The invented `id: 0` is gone. The web handler had its own copy of the bulk loop; it now calls `approve::bulk`, so the page and the library cannot disagree about what §7.4 says. Three tests: a dropped `audit` table mid-transaction must surface as `System` and must leave the review pending and the approval table empty; bulk refusals must name the risk, the unknown decision, and (after a real approval) the genuine staleness as three different things; a bulk rejection must record a `rejected` row and hand back nothing.
* db: the schema gets an owner — every statement moves into db/, and the ↵aur-build13 days1-111/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* pipeline: ten-step build machine with atomic signed publishaur-build14 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | 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.
* feat: AUR mirror watcher, recipe parsing, candidate creationaur-build2026-11-171-0/+267
The detection path (§5.1, §5.1a, §5.3, §7.1): * git helpers, all subprocess git in one auditable place. Mirrors are cloned with --mirror and polled with git ls-remote, fetching only when the tip actually moved; --no-prune keeps history we may need forever. * .SRCINFO parsing (authoritative) with a PKGBUILD fallback, and source=() parsing that keeps VCS kind, #commit/#tag/#branch refs and the filename:: form. * recipe_hash over the whole snapshot tree, so a shipped patch is part of the recipe and cannot change silently. * source digest resolution: declared checksums are trusted-as-declared (makepkg enforces them, no bandwidth), local files are hashed from the mirror, and SKIP sources are downloaded and stream-hashed into the content-addressed source cache. Detection always re-fetches SKIP sources — answering from our own cache would defeat drift detection. * candidate creation with base = current_accepted_release, collapse in place while unviewed, supersede only once a human has looked, and a previously rejected identity is not re-raised. * non-publishable change handling (I11): unchanged version string means no review, but never silence — recipe drift and pin drift become notices, and a changed digest on a remote source with an unchanged version becomes a high-severity integrity_alert. Also vercmp + dep-string parsing with the ALPM test vectors, and the approval record with optimistic concurrency (§7.1a) that the CLI and web layers will both call. 16 detection tests against real file:// git fixtures, incl. I2 across three unattended detections and I11 for all three drift kinds. Part of P0 (DESIGN.md §17).