summaryrefslogtreecommitdiffstats
path: root/tools/release-surface-probe.py
Commit message (Collapse)AuthorAgeFilesLines
* error,tools: a variant nothing constructed, and three tool constructs ↵aur-build10 days1-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | nothing read `Missing::Snapshot` was declared, rendered by the `Display` arm, and constructed by nothing: `From<&str> for Missing` routes a bare sentence to `Missing::Other`, and the test that mentions a snapshot asserts `Other(_)`. The variant and its formatting arm are gone. A variant scan that counted *mentions* could not see it, because the formatting arm is a mention; the scan now ignores a line that only renders the variant, and what it reports afterwards is `Error::Json` and `Error::Sqlite`, both of which the compiler proves live — deleting either breaks the hundred-odd `?` sites that reach them through `#[from]`. Three survivors in `tools/`, none of them caught by the audit that claimed the axis was empty, because that audit looked at module-level constants and function parameters and never at local bindings: - `test-surface.py` opened `render()` with `out = [...] if False else []`, a literal dead branch whose binding was then never read. Both gone. - `test-surface.py` computed a `collisions` set that nothing consulted; the rule it narrated had moved into `mentioned` as `sole_owner`. The set is deleted and the explanation now sits in the docstring of the function that applies it. - `release-surface-probe.py` built `decl_line` and used `decl_no` instead. `a, b = item.split(" as ", 1)` became `_, b = ..` for the same reason. The scans now cover locals and constant conditions as well, and report nothing: no unread binding, no `if False`, no unreachable statement after a terminator, no unused import, constant, parameter, or unread argparse option across the five tools.
* tools: the probe enumerates pub items itself instead of trusting the tableaur-build10 days1-93/+299
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `release-surface-probe.py` used to take its candidate list from `tools/test-surface.py`. That made it strictly downstream of the inference it existed to audit: an item the detector dropped could never be probed, and the tool reported "0 leaked" about a table that was missing the leak. The auditor was right that "proven by compiling, not inferring" did not hold. It now enumerates on its own — every `pub` declaration in `src/`, found by scanning the files — and applies its own deliberately simpler production-use rule (comments, strings and `use` lines do not count). Two independent rules that must agree is a check; one rule consulted twice is not. Three control experiments were run against it, and the first two failed before the tool was correct: - un-gating `review::approve::withdraw` initially reported nothing, because the probe built paths from the census module (`aur_build::review::withdraw`) instead of the real one (`aur_build::review::approve::withdraw`). A path that cannot compile even with the feature was silently filed as "not nameable". Paths are now derived from the declaring file, with the module-door and intermediate re-export paths tried too. - with that fixed, un-gating `withdraw` is caught by name and location. - restoring `open_reviews_for` together with the test that used it is caught too. Restoring only the function is correctly not caught: with no test naming it, it is dead code, not a test-only leak. That last distinction is a separate category now. A public item that nothing in `src` or `tests` reaches — `reopen_rejected`'s shape — is reported and fails the run, counted over the declaring file too so a helper used only by its own module is not falsely called unreachable. `db::Writer` stays reachable on purpose and is now probed for that claim: an item listed in `test-surface-interface.json` must actually resolve, or the file is stale and the probe says so.
* tools: key items by (module, name), and prove the surface by compilingaur-build11 days1-0/+149
The auditor's two counterexamples were both detector bugs, and they were the same class of bug as the ones before: the instrument was reading the source in a way that flattered the number. - Rows are keyed by `(module, name)`. Keyed by bare name, `pipeline::dispatch::Pool::shutdown` merged into the `db::Writer::shutdown` row, which is gated, so an ungated item was reported `already-gated`. - The production-mention index is built from lines with comments and string literals removed. Searching raw text made `review::approve::withdraw` look production-used because the *string* "withdraw" appears in an HTTP route pattern and an audit action; every real caller named `withdraw_package` or `withdraw_release_in`, which are different items. - A `pub` declaration inside a private module is not a public declaration. Without that, the inner-module narrowing made the detector report an `http::new` nobody could name. - For a name declared in several modules — `new`, `open`, `record`, `parse` — a bare mention elsewhere cannot be resolved, so the row is kept and flagged `ambiguous` rather than silently dropped, and `tools/test-surface-ambiguous.json` holds the human verdict. An ambiguous row with no verdict fails the architecture test; "the tool could not tell" is not a disposition. - The count rule was duplicated between `--json` and `--write-budget` and the two drifted the moment a rule was added to one. `tally()` is now the one place. `tools/release-surface-probe.py` replaces inference with compilation for the final claim. It writes a throwaway crate depending on `aur-build` twice, with and without `test-support`, and tries to name every dispositioned item from outside. A path that compiles with the feature proves the path is real; every such path must fail without it. Current result: 28 real external paths, 27 closed in a release build, and the one that stays open is `db::Writer`, which is public because `Db` has a `pub writer: Writer` field and Rust will not type a public field with a private type. That is recorded as `interface` in `tools/test-surface-interface.json` — a disposition that admits reachability and names the signature that forces it — and the probe fails if the file claims an item that is not in fact reachable, so it cannot quietly rot. The tool's own docstring and the generated table claimed "Rust has no test-conditional visibility". That was false and is gone, replaced with the two shapes that do it.