From 141a14112554707e04bc2dd33f0c8071c1d74441 Mon Sep 17 00:00:00 2001 From: aur-build Date: Sat, 21 Nov 2026 14:09:28 +0000 Subject: tools: audit the tools, and let them regenerate what they already claim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Five axes were asked of `tools/*.py` — unreachable statements, unused imports, module-level functions no tool calls, constants nothing reads, parameters nothing passes, and argparse options nothing reads — and all five came back empty, which is worth recording because the alternative is to assume a script directory rots. The one real finding was staleness rather than dead code: `tools/test-surface.md` still cited line numbers from before the narrowing, and `tools/arch-census.md` last recorded a census of 470 `pub` / 84 dead / 35 unargued. Both were regenerated by the tools that own them, so the committed reports now say 448 / 49 / 0. `gen-vercmp-oracle.py` was run and reproduces the committed oracle byte for byte. --- tools/arch-census.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ tools/test-surface.md | 32 ++++++++++++++-------------- 2 files changed, 75 insertions(+), 16 deletions(-) diff --git a/tools/arch-census.md b/tools/arch-census.md index c80c1ea..f436a11 100644 --- a/tools/arch-census.md +++ b/tools/arch-census.md @@ -240,3 +240,62 @@ disposition reason, or if any disposition count exceeds preserves the `test_surface` section instead of erasing it: two tools writing one file must not delete each other's axis, or the ratchet quietly stops checking one of them. + +## 2026-11-21 14:08 + +totals: 448 pub, 49 dead (49 test-only, 0 named by nobody), 170 pub(crate), 0 glob re-exports, 87 edges, largest file 699 (src/config.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 | 29 | 2 | 2 | 0 | 2 | 0 | 699 | 699 src/config.rs | +| db | 189 | 11 | 11 | 0 | 19 | 0 | 3888 | 368 src/db/mod.rs | +| error | 21 | 0 | 0 | 0 | 0 | 0 | 430 | 430 src/error.rs | +| fetch | 1 | 0 | 0 | 0 | 2 | 0 | 57 | 57 src/fetch.rs | +| git | 14 | 0 | 0 | 0 | 0 | 0 | 240 | 240 src/git.rs | +| hash | 7 | 0 | 0 | 0 | 0 | 0 | 111 | 111 src/hash.rs | +| http | 17 | 5 | 5 | 0 | 81 | 0 | 2034 | 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 | 11 | 3 | 3 | 0 | 5 | 0 | 455 | 455 src/ops.rs | +| pipeline | 21 | 6 | 6 | 0 | 16 | 0 | 1411 | 472 src/pipeline/steps.rs | +| pkginfo | 6 | 0 | 0 | 0 | 0 | 0 | 117 | 117 src/pkginfo.rs | +| pkgver | 7 | 0 | 0 | 0 | 0 | 0 | 559 | 559 src/pkgver/mod.rs | +| recipe | 7 | 0 | 0 | 0 | 0 | 0 | 459 | 459 src/recipe.rs | +| review | 24 | 4 | 4 | 0 | 4 | 0 | 915 | 301 src/review/diff.rs | +| sandbox | 21 | 7 | 7 | 0 | 16 | 0 | 1413 | 508 src/sandbox/kata.rs | +| shims | 8 | 4 | 4 | 0 | 13 | 0 | 655 | 655 src/shims/mod.rs | +| time | 13 | 3 | 3 | 0 | 0 | 0 | 243 | 243 src/time.rs | +| urlutil | 1 | 0 | 0 | 0 | 0 | 0 | 56 | 56 src/urlutil.rs | +| usecase | 30 | 0 | 0 | 0 | 0 | 0 | 405 | 124 src/usecase/reviews.rs | +| watch | 21 | 4 | 4 | 0 | 12 | 0 | 1115 | 296 src/watch/upstream.rs | + +``` +bin/gpg -> shims +bin/makechrootpkg -> shims +bin/makepkg -> shims +bin/mkarchroot -> shims +bin/pacman -> shims +bin/repo-add -> shims +bin/sandbox-agent -> sandbox +config -> error hash +db -> config error hash pkgver time +fetch -> error hash +git -> error +http -> config db hash ops pkgver review time usecase watch +main -> config db http ops pipeline pkgver review usecase +ops -> config db error time watch +pipeline -> config db error git hash pkginfo pkgver recipe review sandbox time watch +recipe -> db error +review -> config db error git hash pkgver recipe time urlutil +sandbox -> config error hash time +shims -> hash pkginfo pkgver recipe +usecase -> config db error ops pipeline review watch +watch -> config db error fetch git hash pkgver recipe review time +``` diff --git a/tools/test-surface.md b/tools/test-surface.md index 7f22e16..37fba97 100644 --- a/tools/test-surface.md +++ b/tools/test-surface.md @@ -75,8 +75,8 @@ reaches the test tier also reaches a release build. | module | item | declared at | test files | in-module call sites | why | |---|---|---|---|---|---| | `config` | `shared_workspace` | `src/config.rs:98` | `config.rs`, `kata.rs`, `remote_agent.rs` | `src/config.rs:19`, `src/config.rs:30`, `src/config.rs:40` +8 | `Config::validate` calls it at config.rs:226; tests/kata.rs and tests/remote_agent.rs call it too and both need a fixture. | -| `config` | `store_dir` | `src/config.rs:376` | `architecture.rs`, `invariants.rs` | `src/config.rs:333`, `src/config.rs:389` ⚑ | the content-addressed store layout is resolved by this module for the cache and blob paths; tests/invariants.rs pins where a blob lands and needs a fixture. | -| `db` | `MIGRATIONS` | `src/db/migrations.rs:343` | `db.rs` | `src/db/mod.rs:157` | `db::migrate` iterates it to apply pending migrations; tests/db.rs asserts the list is ordered and complete. | +| `config` | `store_dir` | `src/config.rs:374` | `architecture.rs`, `invariants.rs` | `src/config.rs:331`, `src/config.rs:387` ⚑ | the content-addressed store layout is resolved by this module for the cache and blob paths; tests/invariants.rs pins where a blob lands and needs a fixture. | +| `db` | `MIGRATIONS` | `src/db/migrations.rs:344` | `db.rs` | `src/db/mod.rs:157` | `db::migrate` iterates it to apply pending migrations; tests/db.rs asserts the list is ordered and complete. | | `http` | `cookie` | `src/http/mod.rs:42` | `common/mod.rs`, `http.rs` | `src/http/mod.rs:223`, `src/http/routes/mod.rs:38`, `src/http/routes/mod.rs:64` +2 ⚑ | the auth cookie helper; the tests that use it build no fixture, so they move into the module and it narrows. | | `http` | `login` | `src/http/routes/mod.rs:51` | `common/mod.rs`, `http.rs` | `src/http/mod.rs:217` | the login route handler; same — its tests are harness-free and move with it. | | `ops` | `STAGING_GRACE_SECS` | `src/ops.rs:333` | `ops.rs` | `src/ops.rs:300` | the grace period the staging sweep applies at ops.rs:286; tests/ops.rs pins the value it must be. | @@ -88,30 +88,30 @@ reaches the test tier also reaches a release build. | `pipeline` | `index_world` | `src/pipeline/publish.rs:26` | `kata.rs` | `src/pipeline/mod.rs:269`, `src/pipeline/mod.rs:292`, `src/pipeline/steps.rs:92` | the world-index step, used by the pipeline at mod.rs:255 and steps.rs:92; tests/kata.rs checks what landed in the index. | | `pipeline` | `run_with` | `src/pipeline/mod.rs:194` | `failure_modes.rs`, `kata.rs`, `remote_agent.rs` | `src/pipeline/mod.rs:186` | the run entry point with an injected sandbox; production uses `run`, tests inject a fake. | | `review` | `LOW` | `src/review/risk.rs:13` | `notices.rs` | `src/review/risk.rs:105`, `src/review/risk.rs:200`, `src/review/risk.rs:206` | the risk floor, compared at risk.rs:94,189,195; tests/notices.rs pins where the floor bites. | -| `shims` | `manifest` | `src/shims/mod.rs:93` | `common/mod.rs`, `invariants.rs`, `pipeline.rs`, `production_surface.rs` … | `src/shims/mod.rs:191` | the shim manifest, read by `run` at mod.rs:161; seven test files read it to assert what a build did. | -| `shims` | `valid_db_arg` | `src/shims/mod.rs:518` | `shims.rs` | `src/shims/mod.rs:558` | the shim's `--db` argument validator; production calls it at mod.rs:510, tests check its verdicts. | -| `watch` | `needs_stage_b` | `src/watch/upstream.rs:25` | `vcs.rs` | `src/watch/detect.rs:101` ⚑ | the stage-B predicate, consulted by detect.rs:101. | -| `watch` | `probe` | `src/watch/upstream.rs:44` | `architecture.rs`, `ops.rs`, `vcs.rs` | `src/watch/detect.rs:95` | the upstream probe, called by detect.rs:95; tests/ops.rs and tests/vcs.rs both need a fixture. | -| `watch` | `sync_mirror` | `src/watch/mirror.rs:22` | `detect.rs` | `src/watch/detect.rs:40` | the mirror sync, called by detect.rs:40; tests/detect.rs drives a real sync. | +| `shims` | `manifest` | `src/shims/mod.rs:96` | `common/mod.rs`, `invariants.rs`, `pipeline.rs`, `production_surface.rs` … | `src/shims/mod.rs:194` | the shim manifest, read by `run` at mod.rs:161; seven test files read it to assert what a build did. | +| `shims` | `valid_db_arg` | `src/shims/mod.rs:521` | `shims.rs` | `src/shims/mod.rs:561` | the shim's `--db` argument validator; production calls it at mod.rs:510, tests check its verdicts. | +| `watch` | `needs_stage_b` | `src/watch/upstream.rs:26` | `vcs.rs` | `src/watch/detect.rs:102` ⚑ | the stage-B predicate, consulted by detect.rs:101. | +| `watch` | `probe` | `src/watch/upstream.rs:45` | `architecture.rs`, `ops.rs`, `vcs.rs` | `src/watch/detect.rs:96` | the upstream probe, called by detect.rs:95; tests/ops.rs and tests/vcs.rs both need a fixture. | +| `watch` | `sync_mirror` | `src/watch/mirror.rs:22` | `detect.rs` | `src/watch/detect.rs:41` | the mirror sync, called by detect.rs:40; tests/detect.rs drives a real sync. | ## Already gated — 16 items | module | item | declared at | test files | in-module call sites | why | |---|---|---|---|---|---| -| `config` | `TestHooks` | `src/config.rs:157` | `common/mod.rs`, `production_surface.rs` | `src/config.rs:142`, `src/config.rs:199` | the `hooks` field is already gated; the type and its impl are not, so they compile into a release build that can never read them. | -| `db` | `cas_accepted_release` | `src/db/pkgbases.rs:94` | `db.rs` | — | production performs this CAS inside a transaction via `cas_accepted_release_in` (publish.rs:208); the standalone form has no caller in the crate. The census credited it with a production caller at the `pub use` continuation line in db/mod.rs — a re-export is not a call. | -| `db` | `claim` | `src/db/builds/mod.rs:138` | `common/mod.rs`, `state_machine.rs`, `time.rs` | — | production leases with `claim_batch`; `claim` is called only by tests, so the release build need not compile it. | +| `config` | `TestHooks` | `src/config.rs:155` | `common/mod.rs`, `production_surface.rs` | `src/config.rs:140`, `src/config.rs:195` | the `hooks` field is already gated; the type and its impl are not, so they compile into a release build that can never read them. | +| `db` | `cas_accepted_release` | `src/db/pkgbases.rs:92` | `db.rs` | — | production performs this CAS inside a transaction via `cas_accepted_release_in` (publish.rs:208); the standalone form has no caller in the crate. The census credited it with a production caller at the `pub use` continuation line in db/mod.rs — a re-export is not a call. | +| `db` | `claim` | `src/db/builds/mod.rs:134` | `common/mod.rs`, `state_machine.rs`, `time.rs` | — | production leases with `claim_batch`; `claim` is called only by tests, so the release build need not compile it. | | `db` | `set_setting` | `src/db/settings.rs:44` | `db.rs` | — | a settings writer with no production caller; `setting`/`setting_i64` readers are used, the setter is not. | -| `db` | `snapshot_by_commit` | `src/db/snapshots.rs:55` | `detect.rs` | — | a snapshot lookup nothing in production performs. | +| `db` | `snapshot_by_commit` | `src/db/snapshots.rs:54` | `detect.rs` | — | a snapshot lookup nothing in production performs. | | `db` | `tx_for_tests` | `src/db/mod.rs:284` | `approve.rs`, `common/mod.rs`, `db.rs`, `invariants.rs` … | — | already gated behind test-support — the pattern the rest of this table asks for. | | `db` | `unapproved_index_entries` | `src/db/invariants.rs:15` | `db.rs`, `detect.rs`, `notices.rs`, `shims.rs` | — | an invariant query nothing runs; it needs `pub(crate)` diff internals to be useful, so it is gated rather than relocated. | | `db` | `world_members` | `src/db/world.rs:32` | `db.rs` | — | a world-snapshot reader nothing calls; `put_world_snapshot` is the half production uses. | | `review` | `render_and_store` | `src/review/diff.rs:282` | `approve.rs`, `common/mod.rs`, `crash.rs`, `dispatch.rs` … | — | intake renders through `review::intake::record`; this wrapper has zero callers in src and 17 in tests. Gated, not relocated: it needs the module-private diff renderer. | -| `review` | `withdraw` | `src/review/approve.rs:234` | `architecture.rs`, `pipeline.rs`, `production_surface.rs` | — | Single-release withdraw. The CLI and the web UI both go through `usecase::withdraw_package` -> `pipeline::publish::withdraw_package`; nothing invokes this. tests/pipeline.rs pins its invariants (a second withdraw is refused, an unknown release is refused), so it is gated rather than deleted: the test is the cover for the operation production has not grown yet. | -| `sandbox` | `LocalAgentProvisioner` | `src/sandbox/kata.rs:134` | `kata.rs` | — | production selects `K8sSandboxProvisioner` (kata.rs:193); nothing in the crate constructs this type. It exists so tests can drive the real agent protocol against the shim binary without a cluster, so it is gated rather than deleted. The census credited its own `impl` headers as callers. | -| `sandbox` | `local_addr` | `src/sandbox/remote.rs:57` | `architecture.rs`, `remote_agent.rs` | `src/sandbox/kata.rs:238`, `src/sandbox/mod.rs:144` ⚑ | DELETED from kata.rs and gated on remote.rs. `KataBackend::local_addr` had zero callers anywhere and is gone; `RemoteBackend::local_addr` is called only by tests/remote_agent.rs, so it is gated. Both were credited with production callers at `listener.local_addr()`, which is std's method on a TcpListener in a sibling file — the census treats all of src/sandbox as one module and a name match cannot tell a receiver's type. This row is why `dotted_only` confirmation exists. | -| `shims` | `called_with` | `src/shims/mod.rs:174` | `crash.rs`, `dispatch.rs`, `invariants.rs`, `kata.rs` … | — | reads the shim's invocation log, which only tests inspect. | -| `shims` | `invocations` | `src/shims/mod.rs:156` | `shims.rs` | — | the shim appends to invocations.jsonl in production but nothing reads it back; the two credited sites name the *filename* in a string, and the only reader, `called_with`, is itself gated. Gated with it. | +| `review` | `withdraw` | `src/review/approve.rs:235` | `architecture.rs`, `pipeline.rs`, `production_surface.rs` | — | Single-release withdraw. The CLI and the web UI both go through `usecase::withdraw_package` -> `pipeline::publish::withdraw_package`; nothing invokes this. tests/pipeline.rs pins its invariants (a second withdraw is refused, an unknown release is refused), so it is gated rather than deleted: the test is the cover for the operation production has not grown yet. | +| `sandbox` | `LocalAgentProvisioner` | `src/sandbox/kata.rs:136` | `kata.rs` | — | production selects `K8sSandboxProvisioner` (kata.rs:193); nothing in the crate constructs this type. It exists so tests can drive the real agent protocol against the shim binary without a cluster, so it is gated rather than deleted. The census credited its own `impl` headers as callers. | +| `sandbox` | `local_addr` | `src/sandbox/remote.rs:57` | `architecture.rs`, `remote_agent.rs` | `src/sandbox/kata.rs:240`, `src/sandbox/mod.rs:144` ⚑ | DELETED from kata.rs and gated on remote.rs. `KataBackend::local_addr` had zero callers anywhere and is gone; `RemoteBackend::local_addr` is called only by tests/remote_agent.rs, so it is gated. Both were credited with production callers at `listener.local_addr()`, which is std's method on a TcpListener in a sibling file — the census treats all of src/sandbox as one module and a name match cannot tell a receiver's type. This row is why `dotted_only` confirmation exists. | +| `shims` | `called_with` | `src/shims/mod.rs:177` | `crash.rs`, `dispatch.rs`, `invariants.rs`, `kata.rs` … | — | reads the shim's invocation log, which only tests inspect. | +| `shims` | `invocations` | `src/shims/mod.rs:159` | `shims.rs` | — | the shim appends to invocations.jsonl in production but nothing reads it back; the two credited sites name the *filename* in a string, and the only reader, `called_with`, is itself gated. Gated with it. | | `time` | `unpin` | `src/time.rs:57` | `time.rs` | — | the clock escape hatch; `pin`/`unpin` exist so a test can freeze time. Its only in-module mention is a unit test. | | `time` | `virtualize` | `src/time.rs:129` | `crash.rs`, `dispatch.rs`, `production_surface.rs` | — | already gated behind test-support. | -- cgit v1.2.3