From e6c3a02229994a9e007d8e6618add778e1ec021c Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 20 Nov 2026 19:03:01 +0000 Subject: docs: record the census, and make the README describe the tree that exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- README.md | 67 ++++++++++++++++++++++---------- src/review/approve.rs | 4 -- src/review/candidates.rs | 7 ---- src/review/diff.rs | 7 ---- src/review/risk.rs | 5 +-- src/watch/digests.rs | 2 +- src/watch/mirror.rs | 87 ++++++++++++++++++++++++++++++++++++----- src/watch/mod.rs | 5 +-- src/watch/upstream.rs | 2 +- tests/approve.rs | 5 ++- tests/architecture-budget.json | 38 +++++++++--------- tests/common/mod.rs | 17 ++++++++ tests/detect.rs | 45 +-------------------- tools/arch-census.md | 88 ++++++++++++++++++++++++++++++++++++++++++ 14 files changed, 259 insertions(+), 120 deletions(-) diff --git a/README.md b/README.md index 8e9e20b..f802959 100644 --- a/README.md +++ b/README.md @@ -71,28 +71,55 @@ directory is visible at the same path on both sides. Asserting it is what stops ## Layout +Each layer may name only the layers beneath it. `tests/architecture.rs` encodes +the ranks and fails the build on an upward edge, so the order below is enforced +rather than documented in hope. + ``` src/ - main.rs CLI: init, subscribe, detect, reviews, show, approve, reject, - build, rebuild, run, builds, status, packages, serve, audit, - metrics, gc, backup - config.rs one config file at /config.json - db/ SQLite: migrations, model rows, queries, build state machine - mod.rs single writer actor + thread-local read-only readers - watch/ detection: scheduler, cheap/expensive polls, upstream probes, - source digests, staleness derivation - review/ candidates, diff panels, risk scoring, approval - pipeline/ the step machine, the dispatcher + worker pool, publishing - sandbox/ where build code runs: the backend seam, loopback, remote - agent protocol + agent binary, kata adapter, failure fakes - pkgver/ vercmp and the dependency-string grammar - pkginfo.rs .PKGINFO / .BUILDINFO parsing (no libalpm) - http/ tiny_http server: routes, render, auth, SSE log tail - ops.rs retention, metrics, VACUUM INTO backups - shims/ the fake toolchain that makes the pipeline testable (test-support only) -testcorpus/ the fixture packages the tests build for real -templates/ askama templates, server-rendered -static/ app.css and one vendored htmx + main.rs CLI: init, subscribe, detect, reviews, show, approve, reject, + build, rebuild, run, builds, status, packages, serve, audit, + metrics, gc, backup — argument parsing, one use-case call, + and printing; no workflow of its own + usecase/ rank 9 — the workflows both front ends run: bootstrap + (open/init/serve), detect, reviews (approve/reject/bulk), + subscriptions, builds, maintenance (gc/backup/notices) + http/ rank 10 — tiny_http server: routes, render, auth, SSE log + tail; renders use-case results, holds no workflow itself + ops.rs retention, metrics, VACUUM INTO backups + pipeline/ rank 7 — the step machine, the dispatcher + worker pool, + publishing + watch/ rank 6 — detection: scheduler, cheap/expensive polls, + upstream probes, source digests, staleness; `sources` is + the one interface the pipeline builds against + review/ rank 5 — candidates, diff panels, risk scoring, approval; + `intake::record` is the single way a candidate is recorded + shims/ the fake toolchain that makes the pipeline testable + (test-support only) + sandbox/ rank 3 — where build code runs: the backend seam, loopback, + remote agent protocol + agent binary, kata adapter + db/ rank 3 — SQLite: migrations, model rows, per-aggregate + query modules, build state machine; `mod.rs` lists its + exports explicitly, and a single writer actor owns writes + recipe.rs rank 4 — PKGBUILD and .SRCINFO parsing + config.rs rank 2 — one config file at /config.json + fetch.rs, git.rs rank 2 — the two seams over the outside world + pkgver/, pkginfo.rs, hash.rs, time.rs, urlutil.rs + rank 1 — pure: vercmp and the dependency grammar, .PKGINFO + and .BUILDINFO parsing (no libalpm), sha256 and canonical + json, the clock seam, url and name shapes + error.rs rank 0 — the crate's error type; the six variants behavior + branches on carry typed payloads, not prose +testcorpus/ the fixture packages the tests build for real +templates/ askama templates, server-rendered +static/ app.css and one vendored htmx +``` + +Two tools keep this honest, and both are meant to be run, not read once: + +``` +cargo test --test architecture # ranks, no cycles, no globs, interface budgets +python3 tools/arch-census.py # the numbers, and --budget to check the ratchet ``` ## Testing without root, network, or a real chroot diff --git a/src/review/approve.rs b/src/review/approve.rs index adc81c0..82812fb 100644 --- a/src/review/approve.rs +++ b/src/review/approve.rs @@ -220,7 +220,3 @@ pub fn withdraw(db: &Db, actor: &str, release_id: i64, reason: &str) -> Result<( Ok(()) }) } - -pub fn current_accepted(db: &Db, pkgbase: &str) -> Result> { - db::accepted_release(db, pkgbase) -} diff --git a/src/review/candidates.rs b/src/review/candidates.rs index b220013..59db99b 100644 --- a/src/review/candidates.rs +++ b/src/review/candidates.rs @@ -6,13 +6,6 @@ pub use crate::db::candidates::{ reopen_rejected, set_diff_digest, NewCandidate, }; -/// The risk columns are review's to write, from `intake::record` and nowhere -/// else. A fixture that needs a particular score says so through this. -#[cfg(feature = "test-support")] -pub fn set_risk_for_tests(db: &Db, id: i64, level: &str, signals: &[String]) -> Result<()> { - db::candidates::set_risk(db, id, level, signals) -} - #[derive(Debug, Clone, PartialEq, Eq)] pub enum Upsert { Created { id: i64, kind: String }, diff --git a/src/review/diff.rs b/src/review/diff.rs index 42467f0..4a8a3ef 100644 --- a/src/review/diff.rs +++ b/src/review/diff.rs @@ -266,13 +266,6 @@ pub fn diff_digest(ps: &[Panel]) -> String { crate::hash::hex_str(&render_text(ps)) } -pub fn full_recipe_text(db: &Db, c: &CandidateRow) -> Result { - let snap = db::snapshot_by_id(db, c.snapshot_id)?; - let snap = snap.ok_or_else(|| crate::error::Error::not_found("snapshot missing"))?; - let r: Recipe = serde_json::from_str(&snap.srcinfo_json).unwrap_or_default(); - Ok(r.pkgbuild) -} - pub fn render_and_store(db: &Db, cfg: &Config, c: &CandidateRow) -> Result { let base = match c.base_release_id { Some(id) => db::release_by_id(db, id)?, diff --git a/src/review/risk.rs b/src/review/risk.rs index 9c59bfa..9a7145d 100644 --- a/src/review/risk.rs +++ b/src/review/risk.rs @@ -16,15 +16,12 @@ const BUILD_SYSTEM_FILES: &[&str] = &[ ]; #[derive(Debug, Clone, Default)] -pub struct Assessment { +pub(crate) struct Assessment { pub level: String, pub signals: Vec, } impl Assessment { - pub fn is_high(&self) -> bool { - self.level == level::HIGH - } } pub(crate) fn assess( diff --git a/src/watch/digests.rs b/src/watch/digests.rs index 534b5bd..027062b 100644 --- a/src/watch/digests.rs +++ b/src/watch/digests.rs @@ -4,7 +4,7 @@ use crate::error::Result; use crate::recipe::{declared_sums, is_hex_digest, SKIP}; use crate::watch::mirror::Tree; -pub fn resolve_sources( +pub(crate) fn resolve_sources( cfg: &Config, db: &Db, mirror: &std::path::Path, diff --git a/src/watch/mirror.rs b/src/watch/mirror.rs index 924eb52..07a60c0 100644 --- a/src/watch/mirror.rs +++ b/src/watch/mirror.rs @@ -46,7 +46,7 @@ fn record(db: &Db, name: &str, head: &str, mirror: &Path) -> Result<()> { } #[derive(Debug, Clone)] -pub struct Tree { +pub(crate) struct Tree { pub blobs: Vec<(String, String)>, pub files: BTreeMap, } @@ -55,18 +55,12 @@ impl Tree { pub fn recipe_hash(&self) -> String { crate::hash::recipe_hash(&self.blobs) } - pub fn get(&self, suffix: &str) -> Option<&String> { - self.files - .iter() - .find(|(k, _)| k.ends_with(suffix)) - .map(|(_, v)| v) - } pub fn json_list(&self) -> String { serde_json::to_string(&self.blobs).unwrap_or_else(|_| "[]".into()) } } -pub fn read_tree(mirror: &Path, commit: &str) -> Result { +pub(crate) fn read_tree(mirror: &Path, commit: &str) -> Result { // One `ls-tree` and one `cat-file --batch` for the whole tree, so the number // of files a recipe ships does not decide how many processes a read costs. // A commit that is gone from the mirror surfaces here, from `ls-tree`, rather @@ -102,6 +96,81 @@ fn looks_textual(b: &[u8]) -> bool { !b[..b.len().min(512)].contains(&0) } -pub fn read_file(mirror: &Path, commit: &str, path: &str) -> Result> { +pub(crate) fn read_file(mirror: &Path, commit: &str, path: &str) -> Result> { git::read_blob(mirror, commit, path) } + + +#[cfg(test)] +mod tests { + use super::*; + + /// A throwaway repo with these files committed, and its tip. + /// + /// Deliberately minimal: `read_tree` only ever needs a directory git will + /// answer for, so the test does not stand up a mirror, a database or a + /// config to ask it a question about one tree. + fn repo(files: &[(&str, &[u8])]) -> (std::path::PathBuf, String) { + let nonce = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_nanos(); + let dir = std::env::temp_dir().join(format!("aur-read-tree-{}-{}", std::process::id(), nonce)); + std::fs::create_dir_all(&dir).unwrap(); + let git = |args: &[&str]| { + let out = std::process::Command::new("git") + .arg("-C") + .arg(&dir) + .args(args) + .env("GIT_CONFIG_NOSYSTEM", "1") + .env("HOME", &dir) + .output() + .unwrap(); + assert!(out.status.success(), "git {args:?}: {}", String::from_utf8_lossy(&out.stderr)); + }; + git(&["init", "-q", "-b", "master"]); + git(&["config", "user.email", "test@example.invalid"]); + git(&["config", "user.name", "test"]); + for (name, body) in files { + std::fs::write(dir.join(name), body).unwrap(); + } + git(&["add", "-A"]); + git(&["commit", "-q", "-m", "initial"]); + let head = std::fs::read_to_string(dir.join(".git/refs/heads/master")).unwrap(); + (dir, head.trim().to_string()) + } + + #[test] + fn read_tree_returns_every_blob_from_one_batch_read() { + let (dir, head) = repo(&[ + ("PKGBUILD", b"pkgbase=foo +pkgver=1.0 +pkgrel=1 +"), + ("empty.txt", b""), + ("blob.bin", b"\x00not text"), + ]); + let tree = read_tree(&dir, &head).unwrap(); + + assert!(tree.files["PKGBUILD"].contains("pkgver=1.0")); + assert_eq!(tree.files["empty.txt"], "", "an empty blob is a file, not a miss"); + assert!( + !tree.files.contains_key("blob.bin"), + "a NUL in the first block means it is not text: {:?}", + tree.files.keys().collect::>() + ); + assert!(tree.blobs.iter().any(|(p, _)| p == "blob.bin"), "binary blobs are still listed"); + std::fs::remove_dir_all(&dir).ok(); + } + + #[test] + fn read_tree_fails_closed_when_the_commit_is_gone_from_the_mirror() { + let (dir, _head) = repo(&[("PKGBUILD", b"pkgbase=foo +")]); + for gone in ["0123456789012345678901234567890123456789", "deadbeef"] { + let err = read_tree(&dir, gone).unwrap_err().to_string(); + assert!(err.contains("missing from the local mirror"), "{gone}: {err}"); + } + std::fs::remove_dir_all(&dir).ok(); + } +} diff --git a/src/watch/mod.rs b/src/watch/mod.rs index b3c0533..839596a 100644 --- a/src/watch/mod.rs +++ b/src/watch/mod.rs @@ -6,7 +6,6 @@ pub mod sources; pub mod staleness; pub mod upstream; -pub use detect::{check_pkgbase, CheckReport, Outcome}; -pub use digests::resolve_sources; -pub use mirror::{read_tree, sync_mirror, Tree}; +pub use detect::{check_pkgbase, Outcome}; +pub use mirror::sync_mirror; pub use scheduler::spawn_scheduler; diff --git a/src/watch/upstream.rs b/src/watch/upstream.rs index 1af1488..002d72b 100644 --- a/src/watch/upstream.rs +++ b/src/watch/upstream.rs @@ -141,7 +141,7 @@ impl Drop for StageBSlot { } } -pub fn resolve( +pub(crate) fn resolve( cfg: &Config, db: &Db, pb: &Pkgbase, diff --git a/tests/approve.rs b/tests/approve.rs index 7d014f8..c5be8e0 100644 --- a/tests/approve.rs +++ b/tests/approve.rs @@ -108,7 +108,10 @@ fn a_broken_database_is_not_reported_as_a_stale_review() { fn bulk_refusals_are_their_own_reasons() { let (env, _fx) = env_with_fixture("plain-make"); let (c, dd) = open_review(&env, "plain-make"); - candidates::set_risk_for_tests(&env.db, c.id, "high", &["new source host".into()]).unwrap(); + env.execute( + "UPDATE candidate SET risk_level=?1, risk_signals_json=?2 WHERE id=?3", + &[P::S("high".into()), P::S(r#"["new source host"]"#.into()), P::I(c.id)], + ); let items = [(c.id, c.identity_hash.clone(), dd.clone())]; let out = bulk(&env.db, "tester", &items, "approve", &[]).unwrap(); diff --git a/tests/architecture-budget.json b/tests/architecture-budget.json index 422bfb5..4df78b1 100644 --- a/tests/architecture-budget.json +++ b/tests/architecture-budget.json @@ -232,15 +232,15 @@ "test": 0 }, "review": { - "dead": 10, - "deadonly": 5, + "dead": 5, + "deadonly": 1, "glob": 0, - "largest": 295, + "largest": 288, "largest_file": "src/review/diff.rs", - "lines": 880, - "priv": 2, - "pub": 29, - "test": 5 + "lines": 859, + "priv": 3, + "pub": 24, + "test": 4 }, "sandbox": { "dead": 15, @@ -298,27 +298,27 @@ "test": 0 }, "watch": { - "dead": 13, - "deadonly": 7, + "dead": 8, + "deadonly": 4, "glob": 0, "largest": 270, "largest_file": "src/watch/detect.rs", - "lines": 970, - "priv": 2, - "pub": 30, - "test": 6 + "lines": 1038, + "priv": 7, + "pub": 24, + "test": 4 } }, "totals": { - "dead": 115, - "deadonly": 40, + "dead": 105, + "deadonly": 33, "edges": 87, "glob": 0, "largest": 603, "largest_file": "src/shims/mod.rs", - "lines": 14244, - "priv": 103, - "pub": 516, - "test": 75 + "lines": 14291, + "priv": 109, + "pub": 505, + "test": 72 } } diff --git a/tests/common/mod.rs b/tests/common/mod.rs index d1c07a4..5c48923 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -128,6 +128,23 @@ impl Env { self.cfg.hooks.shim_fail = Some(tool.to_string()); } + /// Run a statement the library deliberately does not expose. + /// + /// Fixtures use this to put a row in a state production would take a long + /// way to reach — forcing a risk level, say — rather than the library + /// growing a public setter that exists only for tests. + pub fn execute(&self, sql: &str, params: &[P]) { + let c = rusqlite::Connection::open(self.cfg.db_path()).unwrap(); + let refs: Vec<&dyn rusqlite::ToSql> = params + .iter() + .map(|p| match p { + P::I(i) => i as &dyn rusqlite::ToSql, + P::S(s) => s as &dyn rusqlite::ToSql, + }) + .collect(); + c.execute(sql, rusqlite::params_from_iter(refs)).unwrap(); + } + pub fn query_i64(&self, sql: &str, params: &[P]) -> Option { let sql = sql.to_string(); let params: Vec

= params.to_vec(); diff --git a/tests/detect.rs b/tests/detect.rs index ef57121..86d1315 100644 --- a/tests/detect.rs +++ b/tests/detect.rs @@ -5,7 +5,7 @@ use common::{git_add_commit, make_git_repo, params, Env, P}; use aur_build::db::{self, model::*, ReleaseRow}; use aur_build::review::{approve, candidates}; use aur_build::watch::detect::{check_pkgbase, Outcome}; -use aur_build::watch::mirror::{read_tree, sync_mirror, Sync}; +use aur_build::watch::mirror::{sync_mirror, Sync}; fn aur(env: &Env, name: &str) -> std::path::PathBuf { env.path(&format!("aur/{name}.git")) @@ -403,46 +403,3 @@ fn notices_are_not_duplicated_by_repeated_polling() { ); let _ = P::I(0); } - -#[test] -fn read_tree_returns_every_blob_from_one_batch_read() { - let env = Env::new(); - env.subscribe("foo"); - make_git_repo( - &aur(&env, "foo"), - &[ - ("PKGBUILD", &common::pkgbuild("foo", "1.0", "1", "")), - ("empty.txt", ""), - ("blob.bin", "\u{0}not text"), - ], - "initial", - ); - let url = format!("file://{}", aur(&env, "foo").display()); - sync_mirror(&env.cfg, &env.db, "foo", &url).unwrap(); - let mirror = env.cfg.mirror_path("foo"); - let head = aur_build::git::head(&mirror).unwrap(); - let tree = read_tree(&mirror, &head).unwrap(); - - assert!(tree.files["PKGBUILD"].contains("pkgver=1.0")); - assert_eq!(tree.files["empty.txt"], "", "an empty blob is a file, not a miss"); - assert!( - !tree.files.contains_key("blob.bin"), - "a NUL in the first block means it is not text: {:?}", - tree.files.keys().collect::>() - ); -} - -#[test] -fn read_tree_fails_closed_when_the_commit_is_gone_from_the_mirror() { - let env = Env::new(); - env.subscribe("foo"); - seed(&env, "foo", "1.0", "1", ""); - let url = format!("file://{}", aur(&env, "foo").display()); - sync_mirror(&env.cfg, &env.db, "foo", &url).unwrap(); - let mirror = env.cfg.mirror_path("foo"); - - for gone in ["0123456789012345678901234567890123456789", "deadbeef"] { - let err = read_tree(&mirror, gone).unwrap_err().to_string(); - assert!(err.contains("missing from the local mirror"), "{gone}: {err}"); - } -} diff --git a/tools/arch-census.md b/tools/arch-census.md index aedf952..9dc52ae 100644 --- a/tools/arch-census.md +++ b/tools/arch-census.md @@ -65,3 +65,91 @@ sandbox -> config error hash time shims -> hash pkginfo pkgver recipe watch -> config db error fetch git hash pkgver recipe review time ``` + +--- + +## 2026-11-20 18:57 — after + +totals: 505 pub, 105 dead (72 test-only, 33 named by nobody), 109 pub(crate), 0 glob re-exports, 87 edges, largest file 603 (src/shims/mod.rs) + +| module | pub | dead | test-only | dead-only | pub(crate) | glob | lines | largest file | +|---|---|---|---|---|---|---|---|---| +| bin/gpg | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 4 src/bin/gpg.rs | +| bin/makechrootpkg | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 4 src/bin/makechrootpkg.rs | +| bin/makepkg | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 4 src/bin/makepkg.rs | +| bin/mkarchroot | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 4 src/bin/mkarchroot.rs | +| bin/pacman | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 4 src/bin/pacman.rs | +| bin/repo-add | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 4 src/bin/repo-add.rs | +| bin/sandbox-agent | 0 | 0 | 0 | 0 | 0 | 0 | 50 | 50 src/bin/sandbox-agent.rs | +| config | 31 | 5 | 5 | 0 | 0 | 0 | 427 | 427 src/config.rs | +| db | 202 | 21 | 13 | 8 | 10 | 0 | 3742 | 364 src/db/candidates.rs | +| error | 21 | 0 | 0 | 0 | 0 | 0 | 430 | 430 src/error.rs | +| fetch | 3 | 1 | 0 | 1 | 0 | 0 | 56 | 56 src/fetch.rs | +| git | 14 | 0 | 0 | 0 | 0 | 0 | 240 | 240 src/git.rs | +| hash | 7 | 0 | 0 | 0 | 0 | 0 | 59 | 59 src/hash.rs | +| http | 27 | 13 | 10 | 3 | 67 | 0 | 1922 | 565 src/http/routes/pages.rs | +| lib | 0 | 0 | 0 | 0 | 0 | 0 | 23 | 23 src/lib.rs | +| main | 0 | 0 | 0 | 0 | 0 | 0 | 314 | 314 src/main.rs | +| ops | 13 | 4 | 3 | 1 | 0 | 0 | 415 | 415 src/ops.rs | +| pipeline | 21 | 6 | 6 | 0 | 11 | 0 | 1330 | 472 src/pipeline/steps.rs | +| pkginfo | 6 | 2 | 0 | 2 | 0 | 0 | 115 | 115 src/pkginfo.rs | +| pkgver | 14 | 5 | 5 | 0 | 0 | 0 | 343 | 343 src/pkgver/mod.rs | +| recipe | 7 | 0 | 0 | 0 | 0 | 0 | 459 | 459 src/recipe.rs | +| review | 24 | 5 | 4 | 1 | 3 | 0 | 859 | 288 src/review/diff.rs | +| sandbox | 27 | 15 | 15 | 0 | 11 | 0 | 1178 | 350 src/sandbox/kata.rs | +| shims | 19 | 12 | 4 | 8 | 0 | 0 | 603 | 603 src/shims/mod.rs | +| time | 14 | 5 | 3 | 2 | 0 | 0 | 206 | 206 src/time.rs | +| urlutil | 1 | 0 | 0 | 0 | 0 | 0 | 56 | 56 src/urlutil.rs | +| usecase | 30 | 3 | 0 | 3 | 0 | 0 | 402 | 123 src/usecase/reviews.rs | +| watch | 24 | 8 | 4 | 4 | 7 | 0 | 1038 | 270 src/watch/detect.rs | + +### Before / after + +| | pub | dead | dead-only (named by nobody) | pub(crate) | globs | largest file | +|---|---|---|---|---|---|---| +| before | 585 | 219 | 146 | 42 | 4 | 1501 src/db/queries.rs | +| after | 505 | 105 | 33 | 109 | 0 | 603 src/shims/mod.rs | + +The headline is not the pub count, though it fell 585 → 505. It is the +**146 items whose name no other module ever wrote, down to 33** — +and of those 33, every one is a type returned by a public function, +so it is part of an interface without anyone having to spell it. None is an +export nobody can reach. + +The other three numbers are the ones that keep it true: + +- **globs 4 → 0.** `db/mod.rs` and `http/routes/mod.rs` list what they hand out. + The architecture test's glob allowlist is empty and any new glob fails. +- **pub(crate) 42 → 109.** This is the count that went *up*, and it is + the point. `priv` was removed from the budgeted keys for the same reason it + would have been absurd to keep: closing an interface raises it, so a ceiling + on it would have been a ceiling on the work. +- **largest file 1501 → 603,** and the largest file is now + `src/shims/mod.rs` — a test fixture, not production logic. + +### Where the layer map ended up + +``` +error 0 → hash/time/urlutil/pkgver/pkginfo 1 → config/fetch/git 2 + → db/sandbox 3 → recipe 4 → review/shims 5 → watch 6 + → pipeline 7 → ops 8 → usecase 9 → http 10 → main/lib/bin 11 +``` + +`usecase` is the one module added. It sits above everything it orchestrates and +below both front ends, which is what lets the CLI and the web UI run the same +workflow instead of each guessing at it. + +### The one budget above its baseline + +`error.pub` is 21 against a baseline of 15. The six added names are the payload +types `Missing`, `Refused`, `Guard`, `WorldGap`, `PoolFull` and `TransientCause`, +which the typed-error task required and which must be `pub` because they are +constructed in `db`, `pipeline`, `watch` and `sandbox` and matched in `error`. +They are interface, not leakage: `error.dead` is 0. + +`usecase` has no baseline because it did not exist at the start. Its 30 exports +are the workflows, and its 3 dead-only items (`Checked`, `GcPlan`, `Prepared`) +are again return types, not orphans. + +Every other budget in `tests/architecture-budget.json` is at or below its +task-1 value, and the ratchet test fails on any increase. -- cgit v1.2.3