summaryrefslogtreecommitdiffstats
path: root/src/pipeline/dispatch.rs
Commit message (Collapse)AuthorAgeFilesLines
* rustfmt,lints: pin the formatting, adopt the idiom lints, pay them offaur-build9 days1-29/+17
| | | | | | | | | | | | | | | rustfmt.toml fixes the shape the tree is written in (120 columns, small items kept on one line) and one canonical pass makes it the truth. [lints.clippy] names the idiom lints worth enforcing and leaves out the two that would add doc-comment boilerplate rather than remove it. The tree pays them off here: write!/writeln! instead of push_str(&format!()), let-else instead of match-on-Option, borrows where a thread entry point only reads what it owns, no `&self` on a Copy state and no `self` nobody reads. ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and value are now emitted by the same call instead of three.
* pipeline,sandbox,shims: thirty-two more markers the compiler was willing to takedev10 days1-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: close the items the stricter detector surfacedaur-build10 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 days1-0/+42
| | | | | | | | | | | | | | | `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.
* 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.
* comments: keep only what the code cannot showaur-build12 days1-25/+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-31/+8
| | | | | | | | | | | | | | 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.
* pipeline: dispatcher actor, worker pool and reaper (§8.2, §8.4)aur-build14 days1-0/+203
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.