From db11b540b1b4c60926c175cb5cd043c7555b99f3 Mon Sep 17 00:00:00 2001 From: dev Date: Sat, 21 Nov 2026 19:24:13 +0000 Subject: tools,tests: count the pub(crate) items nothing outside their own file reaches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `pub(crate)` was the good state in the census by decree: `priv` was reported and deliberately left out of the budget, on the grounds that a rising count of crate-internal items is progress. That is true of `pub` -> `pub(crate)` and false of the next step. A `pub(crate)` item that no file except the one that declares it ever names is offering the whole crate a thing nothing reaches, and nothing in the suite said so. `overwide` counts them. Same shape as `deadonly`, on purpose: a per-module number that may only shrink, an item allowed to stay only by name in `over_visibility.allowlist`, and the compiler fact that forces it written beside the name. `--list-overwide` names every one with its file:line, and `tests/architecture.rs` mirrors the definition so the two implementations are cross-checked against each other, the way the census already is. Baseline, before any item is narrowed: 35 of 170 `pub(crate)` declarations are over-wide. Eight of them are already argued — a `pub(crate)` field cannot carry a private type, privacy does not reach up to a parent module or across to a sibling one, and `pub(super)` is not a form this crate admits — which leaves 27 unargued, and 27 is what the budget now holds. The count is a grep and a grep is a lead, not a verdict: the verdict is the compiler's, and it has to be asked under both profiles, because the `cfg(not(feature = "test-support"))` half of a feature-conditional declaration is never compiled by `cargo check --all-targets`. --- tests/architecture-budget.json | 137 +++++++++++++++++++++++++++++++---------- 1 file changed, 104 insertions(+), 33 deletions(-) (limited to 'tests/architecture-budget.json') diff --git a/tests/architecture-budget.json b/tests/architecture-budget.json index 7a95341..4ac33de 100644 --- a/tests/architecture-budget.json +++ b/tests/architecture-budget.json @@ -1,24 +1,24 @@ { "dead_code": { "allowlist": { - "db.Migration": "the row type of `MIGRATIONS`, which is `pub` only under `test-support`; production walks the table through `db::migrate` without naming it", - "db.PackageRow": "what `index_packages` hands back to `http`, the publish step and the `aur-build` binary, which bind it without naming it", - "db.Subscription": "what `get_subscription` and `list_subscriptions` hand back to `watch`, `usecase`, the binary and tests/detect.rs", - "db.Unbuilt": "the attention row `approved_but_unbuilt` returns to the web UI and to tests/crash.rs", - "pkginfo.Installed": "what `parse_installed` answers with, read line by line by `pipeline` and tests/world.rs", - "pkginfo.PkgInfo": "what `parse_pkginfo` answers with; `pipeline`, `shims` and tests/world.rs read its fields, never its name", - "review.BulkItem": "one outcome of `approve::bulk`, which tests/approve.rs drives directly", - "sandbox.ProvisionRequest": "the argument of `Provisioner::provision`, the trait the public `LocalAgentProvisioner` implements", - "sandbox.Provisioner": "implemented by the test-gated public `LocalAgentProvisioner`; a private trait on a public impl is E0445", - "shims.FakeInstalled": "the whole `shims` module is `test-support`-gated, so a release build never compiles it", - "shims.FakePackage": "the whole `shims` module is `test-support`-gated, so a release build never compiles it", - "shims.Manifest": "returned by `manifest()`, which the shim tests read; the module is `test-support`-gated", - "time.VirtualClock": "lives in the `test-support`-gated clock module, behind the gated `virtualize()` that returns it", - "usecase.Checked": "what `usecase::detect` returns to the `aur-build` binary, which is a separate crate", - "usecase.GcPlan": "what `usecase::plan_gc` returns to the `aur-build` binary, which is a separate crate", - "usecase.Prepared": "what `prepare_review` and `view_review` return to the `aur-build` binary, which is a separate crate", - "watch.CheckReport": "what `detect::check_pkgbase` returns; the test tier drives it and binds the value without naming it", - "watch.StageA": "what `upstream::probe` returns; tests/ops.rs and tests/vcs.rs call `probe` directly" + "db.Migration": "the element type of `MIGRATIONS`, which is `pub` under `test-support`; narrowing it is `private_interfaces` - type `Migration` is more private than the item `MIGRATIONS`. Production walks the table through `db::migrate` without naming it", + "db.PackageRow": "what `index_packages` answers with, and `index_packages` is `pub`; narrowing the row is `private_interfaces` - type `PackageRow` is more private than the item `index_packages`. http, the publish step and the `aur-build` binary bind it without naming it", + "db.Subscription": "what `get_subscription` and `list_subscriptions` answer with, both `pub`; narrowing it is `private_interfaces` on `list_subscriptions`. `watch`, `usecase`, the binary and tests/detect.rs bind the value without naming the type", + "db.Unbuilt": "the attention row `approved_but_unbuilt` returns, and that fn is `pub`; narrowing it is `private_interfaces` on `approved_but_unbuilt`. The web UI and tests/crash.rs bind it without naming it", + "pkginfo.Installed": "what `parse_installed` answers with, and `parse_installed` is `pub`; narrowing it is `private_interfaces` on `parse_installed`. `pipeline`, `shims` and tests/world.rs read it line by line", + "pkginfo.PkgInfo": "what `parse_pkginfo` answers with, and `parse_pkginfo` is `pub`; narrowing it is `private_interfaces` on `parse_pkginfo`. `pipeline`, `shims` and tests/world.rs read its fields, never its name", + "review.BulkItem": "one outcome of `approve::bulk`, which is `pub` and which tests/approve.rs drives directly; narrowing the row is `private_interfaces` on `approve::bulk`", + "sandbox.ProvisionRequest": "the parameter of `Provisioner::provision`, a `pub` trait method - a `pub` trait method cannot take a `pub(crate)` parameter, so the compiler answers `type kata::ProvisionRequest is more private than the item kata::Provisioner::provision`", + "sandbox.Provisioner": "implemented by the test-gated `pub` `LocalAgentProvisioner` and returned by `KataBackend::bind`; a private trait on a public impl is E0445, and the compiler says `trait kata::Provisioner is more private than the item KataBackend::bind`", + "shims.FakeInstalled": "the element type of the `pub` field `Manifest::installed`, so narrowing it is `private_interfaces` on that field; the whole `shims` module is `test-support`-gated, so a release build never compiles it", + "shims.FakePackage": "the element type of the `pub` field `Manifest::packages`, so narrowing it is `private_interfaces` on that field; the whole `shims` module is `test-support`-gated, so a release build never compiles it", + "shims.Manifest": "returned by `manifest()`, which is `pub` and which seven test files read to assert what a build did; narrowing the type is `private_interfaces` on `manifest`. The module is `test-support`-gated", + "time.VirtualClock": "re-exported by the gated `pub use` that is the only public path to it; narrowing it is E0365 - `VirtualClock` is only public within the crate, and cannot be re-exported outside", + "usecase.Checked": "re-exported by `usecase`'s `pub use`, which is how the `aur-build` binary - a separate crate - names it; narrowing it is E0365, cannot be re-exported outside the crate", + "usecase.GcPlan": "re-exported by `usecase`'s `pub use` for the `aur-build` binary, a separate crate; narrowing it is E0365, cannot be re-exported outside the crate", + "usecase.Prepared": "re-exported by `usecase`'s `pub use` for the `aur-build` binary, a separate crate; narrowing it is E0365, cannot be re-exported outside the crate", + "watch.CheckReport": "what `detect::check_pkgbase` answers with, and that fn is `pub`; narrowing it is `private_interfaces` on `check_pkgbase`. The test tier drives it and binds the value without naming it", + "watch.StageA": "what `upstream::probe` answers with, and `probe` is `pub`; narrowing it is `private_interfaces` on `probe`. tests/ops.rs and tests/vcs.rs call `probe` directly" }, "deadonly": { "bin/gpg": 0, @@ -59,6 +59,7 @@ "largest": 4, "largest_file": "src/bin/gpg.rs", "lines": 4, + "overwide": 0, "priv": 0, "pub": 0, "test": 0 @@ -70,6 +71,7 @@ "largest": 4, "largest_file": "src/bin/makechrootpkg.rs", "lines": 4, + "overwide": 0, "priv": 0, "pub": 0, "test": 0 @@ -81,6 +83,7 @@ "largest": 4, "largest_file": "src/bin/makepkg.rs", "lines": 4, + "overwide": 0, "priv": 0, "pub": 0, "test": 0 @@ -92,6 +95,7 @@ "largest": 4, "largest_file": "src/bin/mkarchroot.rs", "lines": 4, + "overwide": 0, "priv": 0, "pub": 0, "test": 0 @@ -103,6 +107,7 @@ "largest": 4, "largest_file": "src/bin/pacman.rs", "lines": 4, + "overwide": 0, "priv": 0, "pub": 0, "test": 0 @@ -114,6 +119,7 @@ "largest": 4, "largest_file": "src/bin/repo-add.rs", "lines": 4, + "overwide": 0, "priv": 0, "pub": 0, "test": 0 @@ -125,6 +131,7 @@ "largest": 50, "largest_file": "src/bin/sandbox-agent.rs", "lines": 50, + "overwide": 0, "priv": 0, "pub": 0, "test": 0 @@ -133,9 +140,10 @@ "dead": 2, "deadonly": 0, "glob": 0, - "largest": 701, + "largest": 699, "largest_file": "src/config.rs", - "lines": 701, + "lines": 699, + "overwide": 1, "priv": 2, "pub": 29, "test": 2 @@ -146,7 +154,8 @@ "glob": 0, "largest": 368, "largest_file": "src/db/mod.rs", - "lines": 3897, + "lines": 3890, + "overwide": 0, "priv": 19, "pub": 189, "test": 11 @@ -155,9 +164,10 @@ "dead": 0, "deadonly": 0, "glob": 0, - "largest": 430, + "largest": 428, "largest_file": "src/error.rs", - "lines": 430, + "lines": 428, + "overwide": 0, "priv": 0, "pub": 21, "test": 0 @@ -169,6 +179,7 @@ "largest": 57, "largest_file": "src/fetch.rs", "lines": 57, + "overwide": 1, "priv": 2, "pub": 1, "test": 0 @@ -180,6 +191,7 @@ "largest": 240, "largest_file": "src/git.rs", "lines": 240, + "overwide": 0, "priv": 0, "pub": 14, "test": 0 @@ -188,9 +200,10 @@ "dead": 0, "deadonly": 0, "glob": 0, - "largest": 111, + "largest": 112, "largest_file": "src/hash.rs", - "lines": 111, + "lines": 112, + "overwide": 0, "priv": 0, "pub": 7, "test": 0 @@ -201,7 +214,8 @@ "glob": 0, "largest": 565, "largest_file": "src/http/routes/pages.rs", - "lines": 2034, + "lines": 2035, + "overwide": 1, "priv": 81, "pub": 17, "test": 5 @@ -213,6 +227,7 @@ "largest": 23, "largest_file": "src/lib.rs", "lines": 23, + "overwide": 0, "priv": 0, "pub": 0, "test": 0 @@ -224,6 +239,7 @@ "largest": 314, "largest_file": "src/main.rs", "lines": 314, + "overwide": 0, "priv": 0, "pub": 0, "test": 0 @@ -235,6 +251,7 @@ "largest": 455, "largest_file": "src/ops.rs", "lines": 455, + "overwide": 3, "priv": 5, "pub": 11, "test": 3 @@ -245,7 +262,8 @@ "glob": 0, "largest": 472, "largest_file": "src/pipeline/steps.rs", - "lines": 1411, + "lines": 1410, + "overwide": 8, "priv": 16, "pub": 21, "test": 6 @@ -257,6 +275,7 @@ "largest": 117, "largest_file": "src/pkginfo.rs", "lines": 117, + "overwide": 0, "priv": 0, "pub": 6, "test": 0 @@ -268,6 +287,7 @@ "largest": 559, "largest_file": "src/pkgver/mod.rs", "lines": 559, + "overwide": 0, "priv": 0, "pub": 7, "test": 0 @@ -279,6 +299,7 @@ "largest": 459, "largest_file": "src/recipe.rs", "lines": 459, + "overwide": 0, "priv": 0, "pub": 7, "test": 0 @@ -290,6 +311,7 @@ "largest": 301, "largest_file": "src/review/diff.rs", "lines": 915, + "overwide": 0, "priv": 4, "pub": 24, "test": 4 @@ -298,9 +320,10 @@ "dead": 7, "deadonly": 0, "glob": 0, - "largest": 508, + "largest": 507, "largest_file": "src/sandbox/kata.rs", - "lines": 1413, + "lines": 1408, + "overwide": 6, "priv": 16, "pub": 21, "test": 7 @@ -312,6 +335,7 @@ "largest": 655, "largest_file": "src/shims/mod.rs", "lines": 655, + "overwide": 7, "priv": 13, "pub": 8, "test": 4 @@ -320,9 +344,10 @@ "dead": 3, "deadonly": 0, "glob": 0, - "largest": 243, + "largest": 245, "largest_file": "src/time.rs", - "lines": 243, + "lines": 245, + "overwide": 0, "priv": 0, "pub": 13, "test": 3 @@ -334,6 +359,7 @@ "largest": 56, "largest_file": "src/urlutil.rs", "lines": 56, + "overwide": 0, "priv": 0, "pub": 1, "test": 0 @@ -345,6 +371,7 @@ "largest": 124, "largest_file": "src/usecase/reviews.rs", "lines": 405, + "overwide": 0, "priv": 0, "pub": 30, "test": 0 @@ -356,11 +383,54 @@ "largest": 296, "largest_file": "src/watch/upstream.rs", "lines": 1115, + "overwide": 0, "priv": 12, "pub": 21, "test": 4 } }, + "over_visibility": { + "allowlist": { + "db.OpenReview": "returned by `open_in` and taken by `collapse_in`, both `pub(crate)` in this file; a private type behind a `pub(crate)` signature is the `private_interfaces` warning, so the type has to be as visible as the functions that carry it", + "db.Readers": "`Db` is `pub` and its `readers` field is `pub(crate)`, and a field cannot out-reach its own type; making `Readers` private is the `private_interfaces` warning on `db::Db::readers`", + "db.ReviewSubject": "`review_subject_in` is `pub(crate)` and answers with it, and another file binds the value: with the type private that call site is `error: type ReviewSubject is private`", + "ops.EvictPlan": "`plan_retention` is `pub(crate)` and returns `Vec`; with the type private, the caller that binds that Vec in another file is `error: type EvictPlan is private`", + "pipeline.SourceIdentity": "the `pub(crate)` field `Ctx::src` has this type, and a field may not be more reachable than its type; private `SourceIdentity` is the `private_interfaces` warning on `Ctx::src`", + "review.Assessment": "`assess` is `pub(crate)` and answers with it, so a private `Assessment` is `error: type Assessment is private` at every site in another file that binds the result", + "review.LOW": "declared inside the `pub mod level` nested in risk.rs and read as `level::LOW` by the scorer in the parent module; privacy does not reach upward to a parent, and `pub(super)` is not a form this crate admits, so `pub(crate)` is the narrowest that works", + "sandbox.provision_request": "declared inside the private `kata_backend` module (kata.rs:184) and called from the sibling `#[cfg(test)] mod tests` (kata.rs:421); privacy does not cross to a sibling - E0624 - and `pub(super)` is not a form this crate admits" + }, + "overwide": { + "bin/gpg": 0, + "bin/makechrootpkg": 0, + "bin/makepkg": 0, + "bin/mkarchroot": 0, + "bin/pacman": 0, + "bin/repo-add": 0, + "bin/sandbox-agent": 0, + "config": 1, + "db": 0, + "error": 0, + "fetch": 1, + "git": 0, + "hash": 0, + "http": 1, + "lib": 0, + "main": 0, + "ops": 3, + "pipeline": 8, + "pkginfo": 0, + "pkgver": 0, + "recipe": 0, + "review": 0, + "sandbox": 6, + "shims": 7, + "time": 0, + "urlutil": 0, + "usecase": 0, + "watch": 0 + } + }, "test_surface": { "already-gated": 16, "interface": 1, @@ -372,9 +442,10 @@ "deadonly": 0, "edges": 87, "glob": 0, - "largest": 701, + "largest": 699, "largest_file": "src/config.rs", - "lines": 15684, + "lines": 15671, + "overwide": 27, "priv": 170, "pub": 448, "test": 49 -- cgit v1.2.3