summaryrefslogtreecommitdiffstats
path: root/tools/arch-census.md
Commit message (Collapse)AuthorAgeFilesLines
* tools: audit the tools, and let them regenerate what they already claimaur-build10 days1-0/+59
| | | | | | | | | | | | | 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: the test-surface detector credited four items with callers they lackaur-build11 days1-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An audit found that `internal` — the check deciding whether a test-only item has a real production caller — was crediting non-calls. Four items were sorted into `residue` on false evidence, and each false credit was a different mistake: db::cas_accepted_release a `pub use` continuation line at db/mod.rs:55. Production does this CAS through `cas_accepted_release_in` inside a transaction; the two names differ by three characters. shims::invocations the string "invocations.jsonl", plus a call from `called_with`, which is itself test-support gated. A test-only function cannot be evidence that another function is production-used. sandbox::LocalAgentProvisioner its own struct and impl headers. Production selects `K8sSandboxProvisioner`. sandbox::local_addr `listener.local_addr()` — std's method on a TcpListener, in sibling files. The census treats all of src/sandbox as one module, and a name match cannot tell a receiver's type. All four are gated now. `KataBackend::local_addr` had zero callers in src and zero in tests — `tests/remote_agent.rs` calls `RemoteBackend::local_addr`, a different type — so it is deleted rather than gated. The detector now strips string literals and comments, skips `use` statements including the continuation lines of a brace-delimited block, skips an item's own impl headers, and refuses to count a call made inside a `#[cfg(test)]` module or a `test-support`-gated item. The case a regex cannot resolve is `self.store_dir()` versus `listener.local_addr()`: identical to a name match. Rows whose only evidence is a call in method position are flagged `⚑`, listed in `tools/test-surface-confirmed.json` only after a human read the cited line, and `the_test_surface_is_disposed_of` fails on any unconfirmed one. Four rows are confirmed that way — `config.store_dir`, `http.cookie`, `ops.build_success_rate`, `watch.needs_stage_b`. The table now prints each item's in-module call sites as its own column, because the residue count is the one number this work cannot eliminate and the claim underneath it has to be checkable rather than asserted. Suite: 284 passed, 0 failed. Clippy clean. Release build clean.
* docs: record the test-surface movement in the census report and READMEaur-build11 days1-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The census report gets a second movement next to the first. The numbers: pub 505 -> 484, dead 105 -> 84, test-only 72 -> 48, pub(crate) 109 -> 119, globs still zero. Two budget increases are recorded rather than smoothed over, because both are consequences of narrowing and a reader is entitled to know which numbers moved the wrong way and why: - sandbox.deadonly 0 -> 2. `Provisioner` and `ProvisionRequest` are named by nobody outside sandbox but cannot be narrowed: LocalAgentProvisioner is pub because two fixture tests construct it, and Rust forbids a public type implementing a private trait or taking a private parameter. - db.deadonly 8 -> 9. Five state enums each have a `can_transition`. Three went private with their tests; ReleaseState's and SubscriptionState's are consulted by nothing at all, so the name slid from test-only to dead-only instead of disappearing. Both carry a NOTE already. `largest` went 603 -> 673 because eleven config tests moved into src/config.rs. It is reported and not budgeted: a line ceiling that counts a module and its tests together would penalise the exact act this goal was for. README's Testing section was stale in a way only a test move exposes — it named `versions::vercmp_matches_the_system_oracle`, a test that does not exist under that name in either location — and said nothing about where a test belongs. Both fixed, with the reason stated: a test outside a module can only reach what the module exports, so a fixture-free test in tests/ is a door held open by a test.
* docs: record the census, and make the README describe the tree that existsdev11 days1-0/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* tools: census how wide each module's interface actually isdev11 days1-0/+67
An interface is only as narrow as the items a module hands out, and nobody had counted them: 585 pub items across 27 modules, 146 of which nothing outside their own module ever names. That is not an interface, it is a hole in the module boundary, and every one of them is a thing a later refactor cannot change without a grep across the crate. The census counts pub items per module, how many of them are dead, how many of those a test does name (the integration tests are separate crates, so a name only they use is genuinely pub and the honest thing is to count it rather than pretend it is private), the glob re-exports that flatten a namespace, and the crate:: edge set between modules. The edge set is already acyclic, which is the useful surprise: a layer map can be declared over the graph as it stands rather than after breaking something. It also says where the width is — db hands out 226 items, http 68 of which 54 are dead — so the work has an order. Baseline for all of it: 273 tests passing, clippy -D warnings clean, release build clean.