Skip to main content

candor_classify/
lib.rs

1//! candor-classify — the curated effect classifier (crate+path -> effect), extracted to a STABLE
2//! crate so both the nightly `rustc_private` lint AND a stable backend share ONE source of truth
3//! (no drift). Pure string logic; no rustc internals. The effect vocabulary lives in candor-report.
4
5use candor_report::EFFECTS;
6
7/// The canonical CANDOR_POLICY DSL parser (SPEC §6.2), shared by the nightly gate and candor-query.
8pub mod policy;
9#[cfg(test)]
10mod policy_props;
11
12/// The SURPRISE heuristic (the cold-repo hook) — SHARED so candor-scan's scan-time note and
13/// candor-query's `tour` verb can't drift. Generic over the effect element type.
14pub mod surface;
15
16/// The transitive least fixed point over a call graph — SHARED so the scanner's gate-side reason-class
17/// accumulator and candor-query's `unverified --class` filter resolve over the SAME reach.
18pub mod propagate;
19
20/// ⟨0.24⟩ The §6.2 GATE over an already-accumulated signature — SHARED so `candor-scan --policy` and
21/// `candor-query gate --report` (SPEC §3.1) are the same gate reached by two routes, not two gates.
22pub mod gate;
23
24/// Project-supplied rules, consulted only when the built-in `classify` returns None.
25pub fn classify_extra(
26    crate_name: &str,
27    path: &str,
28    extra: &[(&'static str, bool, String)],
29) -> Option<&'static str> {
30    for (eff, is_crate, prefix) in extra {
31        let hit = if *is_crate { crate_name.starts_with(prefix.as_str()) } else { path.starts_with(prefix.as_str()) };
32        if hit {
33            return Some(eff);
34        }
35    }
36    None
37}
38
39/// The exact third-party crates `classify` has effect rules for, and the crate-name
40/// PREFIXES it recognizes. This is the single source of truth for "what candor knows":
41/// it is emitted beside the JSON report (`<prefix>.calibrated.json`) so the Claude Code
42/// receipt's coverage check reads candor's real coverage instead of a hand-copied list.
43/// Keep in lockstep with `classify` below — the `db_crates_are_calibrated` and
44/// `calibrated_crates_are_live` tests (in this crate's `tests` module) enforce both directions.
45pub const CALIBRATED_CRATES: [&str; 82] = [
46    // network (aws_config resolves credentials over the network on `.load()`;
47    // git2 remote ops — fetch/push/connect — contact the network; async_net is smol's net layer;
48    // pnet is raw L2/L3 packet capture)
49    "reqwest", "isahc", "ureq", "curl", "aws_config", "git2", "tokio_tcp", "tokio_udp", "async_net",
50    "async_nats", "lapin", "lettre", "tungstenite", "elasticsearch", "tonic", "rdkafka", "pnet",
51    // directory traversal (ignore = gitignore-aware walker, powers ripgrep/fd; its walk executors are Fs)
52    // + filesystem watching (notify = inotify/FSEvents/kqueue wrapper; powers watchexec/cargo-watch)
53    "ignore", "notify",
54    // database (see DB_CRATES in classify)
55    "sqlx", "rusqlite", "postgres", "tokio_postgres", "diesel", "redis", "mongodb",
56    "mysql", "mysql_async", "sea_orm", "deadpool_postgres",
57    // filesystem (async_fs = smol; fs_err = std::fs wrapper; tempfile; glob) / entropy /
58    // subprocess (async_process = smol; duct) / env (dotenvy/dotenv) / clock (time) / log / clipboard
59    "memmap2", "fs_err", "async_fs", "tempfile", "glob",
60    "rand", "getrandom", "fastrand",
61    // entropy: the password-hashing tier (salt mints + bcrypt's internal salt) + the OsRng source
62    "argon2", "bcrypt", "scrypt", "pbkdf2", "password_hash", "rand_core",
63    "portable_pty", "async_process", "duct",
64    "dotenvy", "dotenv",
65    "chrono", "time", "tracing", "log", "arboard",
66    // compiler diagnostic emission (a dylint lint's output) — see the Log rules in classify
67    "rustc_lint", "rustc_errors",
68    // raw syscalls via FFI — the syscall-name table that lights up the FFI-thin tier (nix is routed
69    // through the same table by leaf name, so a consumer of nix is covered without nix's own source)
70    "libc", "nix", "rustix",
71    // coverage-differential additions (verb-keyed; see the per-crate rules near the end of classify):
72    // sync TLS core + native-tls variants (Net); env/dir resolution + argv + LS_COLORS (Env);
73    // sqlx-core execution terminals (Net/Db); directory walk + timestamp mutation + same-file (Fs);
74    // process-spawn helpers (Exec); signal handler + interactive-tty prompts (Ipc); env_logger (Log);
75    // jiff/backoff clock reads (Clock).
76    "rustls", "native_tls_crate", "tokio_native_tls",
77    "etcetera", "wild", "lscolors",
78    "sqlx_core", "walkdir", "filetime", "clircle",
79    "execute", "ctrlc", "clap", "jiff", "env_logger",
80    "dialoguer", "console", "terminal_colorsaurus", "backoff", "grep_cli",
81    // TUI: the terminal is a user dialogue channel (Ipc), exactly as dialoguer/console already rule.
82    // crossterm does the tty I/O; ratatui renders to a Buffer and drives a backend that does.
83    "crossterm", "ratatui",
84    // tracing_subscriber: the fmt INIT terminals write program output (Log); the EnvFilter constructors
85    // read RUST_LOG (Env). Everything else — layers, formatters, filter types — is a builder.
86    "tracing_subscriber",
87];
88
89pub const CALIBRATED_PREFIXES: [&str; 3] = ["aws_sdk_", "aws_smithy", "cap_"];
90
91/// Crates `classify` matches by PATH prefix rather than crate-name equality (their effectful modules
92/// are recognised, e.g. `tokio::net::`/`async_std::fs::`/`mio::net::`), so they're absent from
93/// `CALIBRATED_CRATES` (which the liveness test probes by crate name). The coverage check must still
94/// treat them as *covered* — otherwise it would mislabel the most common async crates as blind spots.
95pub const PATH_CALIBRATED_CRATES: [&str; 3] = ["tokio", "async_std", "mio"];
96
97/// The FFI-thin syscall crates whose `CALIBRATED_CRATES` membership is INCOMPLETE BY DESIGN.
98///
99/// For every OTHER calibrated crate, "classify returned None" is a REVIEWED verdict — the table covers
100/// the crate's effectful surface, so a miss means the call really is pure, and candor-scan's coverage
101/// ledger exempts all of `CALIBRATED_CRATES` from blind-spot disclosure on exactly that theory (a
102/// calibrated crate's silence is informative). That does not hold for `libc`/`nix`/`rustix`: the table
103/// above DELIBERATELY skips their generic fd verbs (`read`/`write`/`close`/`lseek`/`dup`/`fcntl`/...)
104/// because a fixed label would mis-categorise an ambiguous fd (file? socket? pipe?) as often as it
105/// helps — an honest no-classify, not a purity finding. Real programs that touch these crates go
106/// through those exact verbs constantly (`libc::read(fd, ..)` IS the effect, not a builder step), so the
107/// blanket exemption converted "no rule here" into a confident, silent purity claim: `fn drain(fd: i32)
108/// { libc::read(fd, buf, 64); }` reported zero effects AND zero disclosure (R59, SOUNDNESS.md) — worse
109/// than an uncalibrated dependency, which at least discloses `invisible`.
110///
111/// Consumed ONLY by candor-scan's coverage-ledger filter (the same one-consumer site
112/// `coverage_has_exactly_one_anchor_and_exactly_one_consumer` enforces), to carve these three OUT of the
113/// `CALIBRATED_CRATES` exemption there — an unclassified call into them still joins the ledger and
114/// disclosed `invisible`, exactly like a call into an uncalibrated dependency, while their CLASSIFIED
115/// calls (`open`/`close`/`socket`/...) are untouched (they never reach the ledger at all — see
116/// `blind_direct`'s `classified.is_none()` gate). Deliberately NOT removed from `CALIBRATED_CRATES`
117/// itself: that list means "classify has SOME live rules here" (true — the FS/NET/EXEC/IPC/ENV/CLOCK/
118/// RAND tables all fire for these three), and stays the honest `.calibrated.json` sidecar contract.
119pub const CALIBRATED_BUT_PARTIAL_CRATES: [&str; 3] = ["libc", "nix", "rustix"];
120
121/// SOUNDNESS R311 — the version each calibrated crate's rules were actually WRITTEN AGAINST.
122///
123/// `CALIBRATED_CRATES` converts "no rule matched" into "reviewed, and pure", with no disclosure. That
124/// claim is evidence about SOURCE SOMEONE READ, and it was being granted on the crate NAME alone — so
125/// an upstream release extended it, silently, to code that did not exist when the review happened.
126/// Measured 2026-09-07: the sea_orm rule block says in terms that it was "verified against sea-orm
127/// 1.1.20 source"; the calibrated fixture resolved 2.0.2, whose `DatabaseExecutor`,
128/// `RestrictedConnection`, `RestrictedTransaction`, `RbacContext` and `RusqliteSharedConnection` carry
129/// 43 public entry points that no rule can name and every one of which read PURE.
130///
131/// A crate resolving ABOVE its ceiling is downgraded to `CALIBRATED_BUT_PARTIAL_CRATES` behaviour:
132/// matched calls keep their rules (they are still right), unmatched calls rejoin the ledger and
133/// disclose `invisible` instead of reading as reviewed-pure. Fail-closed AT THE POINT THE CLAIM IS
134/// MADE — the coverage gate can only ever notify us afterwards.
135///
136/// EXACT, not major-only, and the direction is deliberate: an exact ceiling fails NOISY (a minor bump
137/// discloses until someone re-reviews and moves the line) while major-only fails SILENT — and the
138/// minor direction is not hypothetical, since redis 1.6.0 -> 1.7.0 and mongodb 3.8.1 -> 3.9.0 both
139/// produced real uncovered entry points in the same measurement. Per the family's denylist rule, start
140/// strict and relax against measured disclosure volume, never the reverse.
141///
142/// A crate ABSENT from this table keeps its unconditional exemption: the ceiling is a denylist of
143/// versions known to be beyond the review, not an allowlist of versions blessed by it. Adding a crate
144/// here is what makes its claim honest, so the table is expected to grow toward `CALIBRATED_CRATES`.
145// SOUNDNESS R328 — this table is MERGED, never rewritten. `bbd7615` replaced it wholesale with a
146// freshly-computed dict and silently dropped NINE entries (dialoguer, dotenv, dotenvy, grep_cli, isahc,
147// lettre, portable_pty, tempfile, postgres) while its own commit message claimed "four crates are
148// deliberately absent, each with a stated reason in the code". Eight had no stated reason and every one
149// of them cites a version in its own rules — they are exactly the crates the ceiling exists to protect,
150// and the protection would have been gone the moment any of them published. Effect classes at stake:
151// Net (isahc), SMTP (lettre), Exec (portable_pty), Fs (tempfile), Env (dotenv/dotenvy), Ipc (dialoguer).
152//
153// DELIBERATELY ABSENT, and this is the complete list:
154//   postgres  — R313. Its recorded 0.7.10 was TOKIO-postgres's version, lifted by a regex from a comment
155//               about a different crate; postgres ships 0.19.x. No verified baseline exists and inventing
156//               one is the claim-without-review this table exists to stop.
157//   async_fs, getrandom — their rules match on CRATE NAME alone, so no path can go stale.
158//   rand_core — R320/R333 unresolved.
159pub const CALIBRATED_CEILINGS: [(&str, &str); 70] = [
160    ("arboard", "3.6.1"),
161    ("argon2", "0.6.0"),
162    ("async_nats", "0.35.1"),
163    ("async_process", "2.5.0"),
164    ("aws_config", "1.12.0"),
165    ("backoff", "0.4.0"),
166    ("bcrypt", "0.19.3"),
167    ("chrono", "0.4.45"),
168    ("clap", "4.6.6"),
169    ("clircle", "0.6.1"),
170    ("console", "0.15.11"),
171    ("crossterm", "0.28.1"),
172    ("ctrlc", "3.5.2"),
173    ("curl", "0.4.50"),
174    ("deadpool_postgres", "0.14.2"),
175    ("dialoguer", "0.12.0"),
176    ("diesel", "2.3.13"),
177    ("dotenv", "0.15.0"),
178    ("dotenvy", "0.15.7"),
179    ("duct", "1.1.2"),
180    ("elasticsearch", "8.19.0-alpha.1"),
181    ("env_logger", "0.11.11"),
182    ("etcetera", "0.11.0"),
183    ("execute", "0.3.0"),
184    ("fastrand", "2.5.0"),
185    ("filetime", "0.2.29"),
186    ("fs_err", "3.3.1"),
187    ("git2", "0.20.4"),
188    ("glob", "0.3.4"),
189    ("grep_cli", "0.1.12"),
190    ("ignore", "0.4.33"),
191    ("isahc", "2.0.1"),
192    ("jiff", "0.2.35"),
193    ("lapin", "4.10.0"),
194    ("lettre", "0.11.23"),
195    ("log", "0.4.34"),
196    ("lscolors", "0.21.0"),
197    ("memmap2", "0.9.11"),
198    ("mongodb", "3.8.1"),
199    ("mysql", "28.0.0"),
200    ("mysql_async", "0.37.0"),
201    ("native_tls_crate", "0.2.18"),
202    ("notify", "8.2.0"),
203    ("password_hash", "0.6.1"),
204    ("pbkdf2", "0.13.0"),
205    ("pnet", "0.35.0"),
206    ("portable_pty", "0.9.0"),
207    ("rand", "0.10.2"),
208    ("ratatui", "0.29.0"),
209    ("rdkafka", "0.39.0"),
210    ("redis", "1.6.0"),
211    ("reqwest", "0.13.4"),
212    ("rusqlite", "0.39"),
213    ("rustls", "0.23.43"),
214    ("scrypt", "0.12.0"),
215    ("sea_orm", "1.1.20"),
216    ("sqlx", "0.9.0"),
217    ("sqlx_core", "0.9.0"),
218    ("tempfile", "3.27.0"),
219    ("terminal_colorsaurus", "1.0.3"),
220    ("time", "0.3.55"),
221    ("tokio_native_tls", "0.3.1"),
222    ("tokio_postgres", "0.7.18"),
223    ("tonic", "0.12.3"),
224    ("tracing", "0.1.44"),
225    ("tracing_subscriber", "0.3.23"),
226    ("tungstenite", "0.30.0"),
227    ("ureq", "2.12.1"),
228    ("walkdir", "2.5.0"),
229    ("wild", "2.2.1"),
230];
231
232/// `true` when `resolved` is a version this crate's rules were NOT written against — i.e. strictly
233/// newer than its ceiling. Unknown crate, unparseable version, or an exact match: `false`, keep the
234/// exemption. Comparison is numeric per dotted component so `1.10.0 > 1.9.0`; a pre-release or build
235/// suffix on the resolved version is treated as ABOVE the release it decorates, which is the
236/// charging direction.
237/// Version-only comparison: is `a` strictly newer than `b`? Shared with `candor-scan`'s lockfile
238/// parser so "which of two versions of one crate do we keep" is answered by the SAME comparator that
239/// decides whether a version is beyond review — one authority, not two spellings that drift.
240pub fn calibration_exceeded_raw(a: &str, b: &str) -> bool {
241    let parts = |v: &str| -> Vec<u64> {
242        v.split(['+', '-']).next().unwrap_or("")
243            .split('.')
244            .map(|p| p.parse::<u64>().unwrap_or(0))
245            .collect()
246    };
247    let (x, y) = (parts(a), parts(b));
248    for i in 0..x.len().max(y.len()) {
249        let (p, q) = (x.get(i).copied().unwrap_or(0), y.get(i).copied().unwrap_or(0));
250        if p != q {
251            return p > q;
252        }
253    }
254    a != b
255}
256
257pub fn calibration_exceeded(crate_name: &str, resolved: &str) -> bool {
258    let Some((_, ceiling)) = CALIBRATED_CEILINGS.iter().find(|(c, _)| *c == crate_name) else {
259        return false;
260    };
261    let parts = |v: &str| -> Vec<u64> {
262        v.split(['+', '-']).next().unwrap_or("")
263            .split('.')
264            .map(|p| p.parse::<u64>().unwrap_or(0))
265            .collect()
266    };
267    let (r, c) = (parts(resolved), parts(ceiling));
268    if r.is_empty() {
269        return false;
270    }
271    for i in 0..r.len().max(c.len()) {
272        let (a, b) = (r.get(i).copied().unwrap_or(0), c.get(i).copied().unwrap_or(0));
273        if a != b {
274            return a > b;
275        }
276    }
277    // Equal numerically: a pre-release/build suffix means it is not the reviewed artifact.
278    resolved != *ceiling
279}
280
281
282/// Crates REVIEWED AND FOUND TO PERFORM NO EFFECT OF THEIR OWN — the κ ledger treats them as covered, so
283/// their calls stop being disclosed blind spots.
284///
285/// SEPARATE FROM `CALIBRATED_CRATES` BY NECESSITY, not taste. That list means "classify has effect rules
286/// here", and `calibrated_crates_are_live` fails any entry no rule matches — "a dead entry would silently
287/// suppress a real coverage warning". A genuinely pure crate has no rule to be live, so it cannot go
288/// there; without this list the only way to silence its noise would be to invent a rule, which is worse.
289///
290/// **THIS LIST MANUFACTURES PURITY CLAIMS, so an entry needs evidence and not a reputation.** A crate here
291/// stops being disclosed and starts being believed. Each of these was checked against its source in the
292/// local cargo registry for `std::{fs,net,process,env}` and stdio use, and every apparent hit was a DOC
293/// COMMENT (serde_json's `/// [`File`]: std::fs::File`, serde_yml's `///  io::stdout()`):
294///
295///   serde_json 1.0.151, serde_yml 0.0.12, toml 1.1.3, regex 1.13.1, sha2 0.11.0
296///
297/// `color_eyre` was on the same filing and is NOT here — FETCHED AND CHECKED 2026-08-03, and it is not
298/// pure. It reads `RUST_BACKTRACE` / `RUST_LIB_BACKTRACE` / `RUST_SPANTRACE` / `COLORBT_SHOW_HIDDEN`
299/// (Env, `config.rs:939..1175`) and **opens source files to render code snippets** (Fs,
300/// `config.rs:248`). It is also not CALIBRATED, deliberately: the `File::open` sits inside
301/// `impl fmt::Display for SourceSection`, reached when a report is RENDERED rather than through any named
302/// verb a caller invokes — so there is no path for a rule to match, and calibrating the crate would turn
303/// that render path into an unmatched path, i.e. a PURITY CLAIM over the file read. Its calls therefore
304/// stay disclosed as a blind spot. The noise is real; it is also honest, and that is the right trade.
305///
306/// THE SERIALIZER CAVEAT, worth stating because it is the one that looks wrong: `serde_json::from_reader`
307/// and `to_writer` do move bytes — but through a handle the CALLER had to obtain, and obtaining it (a
308/// `File::open`, a `TcpStream::connect`) is already classified on the caller. The crate performs no
309/// syscall of its own, so charging it would double-count an effect the caller already carries.
310pub const REVIEWED_PURE_CRATES: [&str; 5] = ["serde_json", "serde_yml", "toml", "regex", "sha2"];
311
312/// The completeness gate's escape hatch (`eval/coverage-gate/`, `tests/coverage_gate.rs`): exact
313/// (crate, consumer-facing path) pairs a human has read and found genuinely pure, despite `candor-scan`
314/// self-scanning the crate's own vendored source finding a reachable Fs/Net/Db/Exec effect there. SEPARATE
315/// from `REVIEWED_PURE_CRATES` — that list exempts a WHOLE crate from the coverage LEDGER's crate-level
316/// disclosure; this one exempts a single ENTRY from the completeness GATE's per-function differential.
317/// The gate's generator run (2026-08-27) found 669 self-scan-confirmed entries `classify()` already
318/// recognizes (checked in as `covered.tsv`, asserted every push) and 251 it did not yet recognize under
319/// any guessed spelling (checked in as `open.tsv`, a ratchet — NOT individually hand-verified, see that
320/// file's header). An `open.tsv` row belongs here ONLY once read against the crate's real source and
321/// confirmed to perform no effect (the SAME evidence bar `REVIEWED_PURE_CRATES` documents) — until then
322/// it stays in the ratchet as an open question, not a silent assumption. The five below were the first
323/// batch, from the 2026-08-27 coverage-gate triage:
324///
325///   - `curl::Multi::timeout` — this file's own `curl` rule (above) already documents WHY: `Easy::
326///     timeout` is a pure `CURLOPT_TIMEOUT` setter sharing the `::timeout` leaf, and an under-report on
327///     the rare event-loop kick beats mis-tagging every consumer that sets a timeout.
328///   - `execute::command` / `execute::shell` — this file's own `execute` rule (above) already documents
329///     WHY: both free functions only BUILD a `std::process::Command` (no `.spawn()`/`.output()`/
330///     `.status()` call in either body) and return it to the caller, who spawns it themselves — the
331///     caller's own `Command::spawn()` carries the effect. Self-scan's raw "Exec" signal comes from
332///     `std::process::Command::new`'s coarse whole-type rule (constructing a `Command` is Exec by
333///     default, narrowed only for crates like `async_process` that document their own pure-setter
334///     surface), not from an actual subprocess launch in either function.
335///   - `elasticsearch::Response::content_type` — a pure accessor reading a header off an ALREADY-received
336///     response (`self.response.headers().get(..)`, http/response.rs:61) — no I/O of its own. Self-scan's
337///     raw "Net" signal is the underlying HTTP client response type's coarse whole-type propagation, not
338///     a second network round-trip.
339///   - `rusqlite::Context::get_connection` — this file's own rusqlite rule (above) already documents WHY:
340///     it hands back a `ConnectionRef` BORROWED from the ALREADY-established connection a running SQL
341///     function executes within (`ffi::sqlite3_context_db_handle`, not a syscall) — the same "handle
342///     accessor, not a syscall" shape as `TcpStream::local_addr`.
343///
344/// The next two (2026-08-28, the widened-CORE audit's `Ipc` batch — see `eval/coverage-gate/generate.py`
345/// for why `Ipc` only entered the trigger set that day) are a DIFFERENT reason than the five above: not
346/// "no effect", but genuinely UNREACHABLE — the item really does perform the effect self-scan found, but
347/// no external consumer can ever name it, because the module it lives in is declared with no `pub` at
348/// all and neither the module nor the item is re-exported anywhere in the crate root (checked against
349/// real source, both ways):
350///   - `dialoguer::Paging::render_prompt` — `dialoguer::paging` is a bare `mod paging;` (dialoguer
351///     0.12.0, lib.rs:62: `use paging::Paging;`, not `pub use`), so `pub struct Paging` and its `pub fn
352///     render_prompt` (which DOES call `Term::flush`, a real Ipc effect per this file's own `console`
353///     rule) are internal machinery every `Select`/`MultiSelect`-style prompt uses to render its own
354///     paginated view — the effect is already charged at THOSE public entry points' own `::interact*`
355///     rule (above), not double-counted here.
356///   - `mysql::Stream::connect_socket` — `mysql::io` is a bare `mod io;` (mysql 28.0.0, lib.rs:897, no
357///     `pub use` of `io::*` or `Stream` anywhere), so `pub enum Stream` and its `pub fn connect_socket`
358///     (a real Unix-domain-socket `connect()`, Ipc) are reachable only from within the crate's own
359///     connection-establishment code — a real consumer can't name `mysql::Stream` at all, let alone call
360///     a bare constructor on it.
361pub const REVIEWED_PURE_ENTRIES: &[(&str, &str)] = &[
362    ("curl", "curl::Multi::timeout"),
363    ("execute", "execute::command"),
364    ("execute", "execute::shell"),
365    ("elasticsearch", "elasticsearch::Response::content_type"),
366    ("rusqlite", "rusqlite::Context::get_connection"),
367    ("dialoguer", "dialoguer::Paging::render_prompt"),
368    ("mysql", "mysql::Stream::connect_socket"),
369];
370
371/// Representative path tails (each appended to a crate name) that the `calibrated_crates_are_live`
372/// liveness test probes: at least one must match for every `CALIBRATED_CRATES` entry, else the entry is
373/// dead. Exported as ONE source of truth because the nightly lint crate (`src/lib.rs`) runs the SAME
374/// liveness test — when the two probe lists were duplicated they drifted, and a rule keyed on a
375/// distinctive tail (pnet `::datalink::channel`, ignore `::WalkBuilder::build_parallel`, notify
376/// `::RecommendedWatcher::new`) added to only one list silently broke the other crate's `cargo test`.
377pub const CALIBRATION_PROBE_TAILS: &[&str] = &[
378    "::X::send", "::X::execute", "::X::call", "::X::query", "::X::fetch_one", "::Remote::fetch",
379    "::datalink::channel", "::WalkBuilder::build_parallel", "::RecommendedWatcher::new",
380    "::X::connect", "::Utc::now", "::X::load", "::__private_api::log", "::tempfile", "::glob",
381    "::X::run", "::dotenv", "::random", "::emit", "::X::emit_span_lint", "::X::anything",
382    "::X::draw",
383    "::SaltString::generate", "::hash", "::OsRng::fill_bytes",
384    // verb-precise crates whose whole-crate rules were narrowed to the effectful surface (the pure
385    // accessors/ctors/data-types now return None), so the liveness probe must name an EFFECTFUL path:
386    "::Mmap::map", "::event", "::u32", "::Clipboard::get_text", "::spawn_command",
387    // coverage-differential crates (each needs ≥1 effectful tail; existing tails already cover
388    // native_tls_crate/tokio_native_tls/sqlx_core via ::X::connect, execute via ::X::execute, jiff via ::now):
389    "::read_tls", "::home_dir", "::args", "::from_env", "::IntoIter::next", "::set_file_mtime",
390    "::surely_conflicts_with", "::set_handler", "::get_matches", "::init", "::interact",
391    "::write_line", "::background_color", "::retry", "::build",
392];
393
394/// Database client crates whose execution verbs are I/O (see the DB branch in `classify`).
395/// Module-level so `db_crates_are_calibrated` can enforce `DB_CRATES ⊆ CALIBRATED_CRATES`.
396pub const DB_CRATES: [&str; 11] = [
397    "sqlx", "rusqlite", "postgres", "tokio_postgres", "diesel", "redis", "mongodb",
398    "mysql", "mysql_async", "sea_orm", "deadpool_postgres",
399];
400
401/// Pure file-descriptor *ownership-transfer* leaves. These ADOPT an already-open descriptor
402/// (`from_raw_fd`/`from_raw_socket`/`from_raw_handle`), EXTRACT/BORROW one
403/// (`into_raw_fd`/`into_raw_socket`/`into_raw_handle`, `as_raw_fd`/`as_raw_socket`/`as_raw_handle`),
404/// or UNWRAP an async wrapper back to its std type (`into_std`) — none of them issue a syscall or
405/// perform I/O. calling a PURE function effectful is a FABRICATION — the precision failure (candor's cardinal sin is the opposite direction, the silent under-report) — and these collide with the
406/// coarse std-type PREFIX rules (`std::net::TcpStream`/`std::fs::File`/`std::os::unix::net` → Net/Fs/Ipc)
407/// even though the descriptor was opened ELSEWHERE. The portable_pty/async_process Exec rule already
408/// exempts `from_raw_fd`; this generalises the same carve-out across the net/fs/ipc prefix rules.
409/// (Found by a real-world sweep of tokio: `TcpStream::into_std`, `*::from_raw_fd`, `*::as_raw_fd` all
410/// fabricated Net/Fs/Ipc.)
411const PURE_FD_TRANSFER: &[&str] = &[
412    "from_raw_fd", "from_raw_socket", "from_raw_handle",
413    "into_raw_fd", "into_raw_socket", "into_raw_handle",
414    "as_raw_fd", "as_raw_socket", "as_raw_handle",
415    "into_std",
416    // `SocketAddr::from_pathname` (std/async-std unix net) builds an address STRUCT from a path —
417    // it opens no socket. The `std::os::unix::net` prefix rule below would otherwise fabricate Ipc
418    // on it. (Found sweeping socket2: `SockAddr::as_unix` → `from_pathname` reported Ipc.)
419    "from_pathname",
420];
421
422/// The std I/O **handle** types whose methods the scanner's receiver inference may route into
423/// `classify` as `Type::method`.
424///
425/// WHY A LIST AND NOT "std". The std rules in `classify` are a MIXTURE: a few are type-precise with
426/// reviewed pure-accessor carve-outs (`std::net::TcpStream` → Net minus `local_addr`/`peer_addr`/…;
427/// `std::process::Command` → Exec minus `get_program`/`get_args`/…), but most are coarse MODULE
428/// prefixes (`std::fs::` → Fs) written for free functions and constructors. Applied to arbitrary
429/// method calls, a coarse prefix charges an effect for reading a struct field: `std::fs::Metadata`,
430/// `DirEntry`, `Permissions` and `FileType` all sit under `std::fs::` and are pure DATA. So the
431/// scanner used to skip EVERY std-rooted receiver — which shut the door on the pure data types and on
432/// the real handles alike, and `fn run(cmd: &mut Command) { cmd.spawn(); }` certified PURE while it
433/// spawned a process (a silent false all-clear; the `cc` crate's `command_helpers::spawn` was a live
434/// instance). This list re-opens the door for the handles ONLY.
435///
436/// MEMBERSHIP RULE, and the reason it is safe to apply a whole-type rule to an inferred method call:
437/// a type belongs here only when EVERY method on it is either the effect itself or an already-carved-
438/// out pure read-back. That holds for an open descriptor's handle — a `File`/`TcpStream`/`Child` does
439/// nothing but I/O on the thing it owns — and the `PURE_FD_TRANSFER` guard at the top of `classify`
440/// exempts the `as_raw_fd`/`into_std` family for all of them before any prefix rule runs.
441///
442/// THE OPTION-BUILDERS, `OpenOptions` and `DirBuilder`, were absent for exactly this rule and now
443/// satisfy it: each has a type-keyed carve-out in `classify` subtracting its pure setters, so only its
444/// TERMINAL VERB (`open` / `create`) is Fs. The exclusion was written as "a narrow residual, not the
445/// reported hole" and MEASURED otherwise — `fn load(o: &OpenOptions, p: &Path) { o.open(p) }` opened a
446/// file and reported NOTHING, the same silent false all-clear as the `Command` parameter, while a
447/// setter-only `OpenOptions::new().read(true)` reported `Fs` for opening nothing. The order the old
448/// comment prescribed is the order taken: the verb-precise rules went in FIRST, and this list widened
449/// onto them. `ReadDir` stays out — its `next` IS a syscall, but nothing distinguishes it from any
450/// other iterator's `next`, so no verb-precise rule can be written and the honest miss stands.
451///
452/// `std::path::Path`/`PathBuf` are NOT here: they are pure data with an effectful STAT sub-surface —
453/// the exact inverse shape — and they route through their own verb-precise carve-out in the scanner.
454const STD_EFFECT_HANDLES: &[&str] = &[
455    // Exec — the whole type is the subprocess boundary (`new` names a program, `arg`/`env` build the
456    // invocation, `spawn`/`output`/`status` run it); the read-back getters are already carved out.
457    "std::process::Command",
458    "std::process::Child",
459    // Net — an open socket. `connect`/`accept`/`read`/`write`/`shutdown`/`set_*` are socket syscalls;
460    // `local_addr`/`peer_addr`/`nodelay`/`ttl`/`take_error` are carved out.
461    "std::net::TcpStream",
462    "std::net::TcpListener",
463    "std::net::UdpSocket",
464    // Ipc — a Unix-domain socket, the same shape as the TCP/UDP handles above.
465    "std::os::unix::net::UnixStream",
466    "std::os::unix::net::UnixListener",
467    "std::os::unix::net::UnixDatagram",
468    // Fs — an open file. Every method reads, writes, syncs, truncates or stats it; the descriptor
469    // conversions are carved out by `PURE_FD_TRANSFER`.
470    "std::fs::File",
471    // Fs — the option-builders, whose PURE setters are subtracted by the type-keyed carve-outs in
472    // `classify` so that only the terminal verb (`OpenOptions::open`, `DirBuilder::create`) routes to Fs.
473    "std::fs::OpenOptions",
474    "std::fs::DirBuilder",
475];
476
477/// Is `ty` a std I/O handle type whose methods may be routed into `classify` by the scanner's
478/// receiver inference? See `STD_EFFECT_HANDLES` for the membership rule and the named exclusions.
479pub fn is_std_effect_handle(ty: &str) -> bool {
480    STD_EFFECT_HANDLES.contains(&ty)
481}
482
483/// Classify a resolved callee by the crate it belongs to and its full path.
484pub fn classify(crate_name: &str, path: &str) -> Option<&'static str> {
485    // Pure fd ownership-transfer/extraction leaves are never an effect, regardless of which std I/O
486    // type they hang off — exempt them BEFORE the coarse prefix rules can fabricate Net/Fs/Ipc.
487    if PURE_FD_TRANSFER.contains(&path.rsplit("::").next().unwrap_or(path)) {
488        return None;
489    }
490    if crate_name.starts_with("aws_sdk_") || crate_name.starts_with("aws_smithy") {
491        // Only request dispatch is network I/O; builder setters/accessors are pure.
492        if path.ends_with("::send") || path.ends_with("::send_with") {
493            return Some("Net");
494        }
495        return None;
496    }
497    // aws-config resolves credentials/region on `.load()` — it reaches the IMDS metadata
498    // endpoint / STS over the network (and reads ~/.aws + env). Builders (`defaults()`,
499    // `SdkConfig::builder()`, `BehaviorVersion::latest()`) are pure; the `load` is the I/O.
500    // (Found hardening on a real app, ebman: `builder.load().await` was classified pure.)
501    //
502    // THE FIX: `load_from_env()` (lib.rs:170/188, both the `behavior-version-latest` and deprecated
503    // forms) is `from_env().load().await` / `load_defaults(latest).await` one call down — the crate's OWN
504    // "convenience wrapper" (its own doc comment's phrase) around the already-modelled `.load()` — but
505    // `"load_from_env".ends_with("::load")` is false, so the wrapper read pure. Same vein as
506    // `ignore::Walk::new`.
507    if crate_name == "aws_config" {
508        if path.ends_with("::load") || path.ends_with("::load_defaults") || path.ends_with("::load_from_env") {
509            return Some("Net");
510        }
511        return None;
512    }
513    // git2 (libgit2 FFI): remote operations contact the network; everything else is local
514    // to the .git directory. Match the remote verbs precisely — NOT bare `::clone`, which is
515    // the `Clone`-trait dup of a `Remote` handle (pure), not `Repository::clone`. (Found
516    // hardening on gitui: `remote.fetch`/`remote.push` were classified network-free — a git
517    // client reporting it makes no network calls.)
518    //
519    // `Repository::clone`/`clone_recurse`/`clone_local`/`init` (via `RepoBuilder::clone`) IS the
520    // thing the comment above named and then excluded anyway: the bare `::clone` denylist meant
521    // to keep out `Remote::clone` (the derived trait dup) also swallowed `Repository::clone` —
522    // libgit2's actual network clone, and arguably git2's single most common entry point. A
523    // fabrication corpus round caught it: `git2::Repository::clone(url, path)` reported ZERO
524    // effects and passed `deny Net` at exit 0. FQN-exact (like the `reqwest::get` disambiguation
525    // a few lines up) so the fix doesn't just re-widen `::clone` and reintroduce the very
526    // over-charge the comment was written to prevent: `Remote::clone` (and `Repository::clone`'s
527    // own `Clone` derive, if it has one) must still read pure.
528    if crate_name == "git2" {
529        if path.ends_with("::fetch")
530            || path.ends_with("::push")
531            || path.ends_with("::download")
532            || path.ends_with("::connect")
533            || path.ends_with("::connect_auth")
534            || path.ends_with("::ls")
535            || path.ends_with("::upload")
536            || path == "git2::Repository::clone"
537            || path == "git2::Repository::clone_recurse"
538            || path == "git2::build::RepoBuilder::clone"
539            // A FOURTH+FIFTH true positive in the same gap the `Repository::clone` fix left open:
540            // `Submodule::clone`/`Submodule::update` (submodule.rs:39,234) call `raw::git_submodule_clone`/
541            // `git_submodule_update` DIRECTLY — the exact FFI leaves already in this file's own
542            // FFI-tier NET table below, but only when a caller names the raw `ffi`/`raw::` leaf itself.
543            // git2's documented, standard submodule-init idiom (`sub.clone(None)` /
544            // `sub.update(true, None)`) never does that — it calls the safe wrapper, which carried no
545            // rule of its own and read pure under `deny Net`. FQN-exact, matching the `Repository::clone`
546            // fix's own discipline: a bare `::update`/`::clone` substring would sweep in git2's many pure
547            // `update_*` setters (`CheckoutBuilder::update_only`, `DiffOptions::update_index`, …) and the
548            // derive-`Clone` dup on every other git2 type.
549            || path == "git2::Submodule::clone"
550            || path == "git2::Submodule::update"
551            // `Remote::list`/`RemoteConnection::list` (remote.rs:378,755) call `raw::git_remote_ls`
552            // directly — the reference-advertisement fetch already in the FFI-tier NET table below,
553            // reached the same way `Submodule::clone`/`update` were: the safe wrapper's OWN name
554            // (`list`, not `ls`) never matched the `::ls` suffix this block already carried (which, on
555            // git2 0.20, matches no real method at all — dead weight kept for whatever older API it once
556            // fit). FQN-exact so a `list` on some other git2 type (none exist today, but the same
557            // discipline as `Submodule::clone` above) can't be swept in by a bare suffix later.
558            || path == "git2::Remote::list"
559            || path == "git2::RemoteConnection::list"
560        {
561            return Some("Net");
562        }
563        // THE COVERAGE-GATE SWEEP (2026-08-27): every one of these is a public entry point whose body
564        // calls a `raw::git_*` FFI leaf ALREADY in this file's own FS FFI-tier table below (config.rs/
565        // index.rs/odb.rs/packbuilder.rs/reference.rs/repo.rs/treebuilder.rs, verified against git2
566        // 0.20.4 source) — but that table is UNREACHABLE for a real consumer's call, because it only
567        // fires when self-scan resolves the FFI leaf's OWN crate (`libgit2_sys`, via git2's internal
568        // `use libgit2_sys as raw`), never for `crate_name == "git2"`, which returns from THIS block
569        // first. A consumer never spells `raw::git_repository_open`; they call `git2::Repository::open`,
570        // which fell through this entire branch to `None` — the exact `ignore::Walk::new` shape (a
571        // lower-level rule the top-level entry point never reaches) but affecting git2's single most
572        // common local operations (`Repository::open`/`init`), not an edge case. FQN-exact, not a
573        // `::open`/`::write`/`::read` suffix — those verbs are common enough elsewhere (`Odb::reader`
574        // isn't `::read`, `TreeBuilder`/`Index`/`PackBuilder::write` share the name with plenty of pure
575        // builder setters on other types) that a bare suffix would either miss these or over-charge.
576        if path == "git2::Config::add_file"
577            || path == "git2::Config::open"
578            || path == "git2::Config::open_default"
579            || path == "git2::Index::add_all"
580            || path == "git2::Index::add_path"
581            || path == "git2::Index::read"
582            || path == "git2::Index::write"
583            || path == "git2::Index::write_tree"
584            || path == "git2::Index::write_tree_to"
585            || path == "git2::Odb::read"
586            || path == "git2::Odb::reader"
587            || path == "git2::Odb::write"
588            || path == "git2::Odb::writer"
589            || path == "git2::PackBuilder::write"
590            || path == "git2::Reference::delete"
591            || path == "git2::Reference::set_target"
592            || path == "git2::Repository::blob_path"
593            || path == "git2::Repository::checkout_head"
594            || path == "git2::Repository::checkout_index"
595            || path == "git2::Repository::checkout_tree"
596            || path == "git2::Repository::commit"
597            || path == "git2::Repository::discover"
598            || path == "git2::Repository::discover_path"
599            || path == "git2::Repository::init"
600            || path == "git2::Repository::init_bare"
601            || path == "git2::Repository::init_opts"
602            || path == "git2::Repository::open"
603            || path == "git2::Repository::open_bare"
604            || path == "git2::Repository::open_ext"
605            || path == "git2::Repository::open_from_env"
606            || path == "git2::Repository::reference"
607            || path == "git2::Repository::tag"
608            || path == "git2::TreeBuilder::write"
609        {
610            return Some("Fs");
611        }
612        // `Cred::credential_helper` (cred.rs:121) calls `CredentialHelper::execute` (cred.rs:326),
613        // which — on every code path — spawns a REAL `sh -c "<helper> get"` (or, if `sh` itself fails to
614        // spawn, the helper binary directly) via `std::process::Command::spawn` to resolve
615        // `credential.helper`-configured auth (cred.rs:370-390): a real subprocess launch a caller
616        // authenticating against a private remote is one call away from (`Cred::credential_helper(cfg,
617        // url, user)` is the crate's own documented way to honor `credential.helper`), not a lower-level
618        // implementation detail. FQN-exact: `execute` alone is far too generic to key on blindly.
619        if path == "git2::Cred::credential_helper" || path == "git2::CredentialHelper::execute" {
620            return Some("Exec");
621        }
622        return None;
623    }
624    // libc — raw syscalls via FFI. The FFI-thin tier (nix, and the syscall layer beneath rusqlite/git2)
625    // is invisible to a name classifier unless we model libc directly: a 35-crate calibration
626    // (eval/calibration) showed nix reporting ZERO library effects because every wrapper bottoms out in
627    // an unrecognised `libc::*` call. Classify by syscall name, but ONLY the UNAMBIGUOUS ones — the
628    // socket family is Net, path/dir syscalls are Fs, spawn/exec/wait is Exec, SysV/pipe IPC is Ipc,
629    // env/clock/entropy each their own. We deliberately SKIP the generic file-descriptor ops
630    // (read/write/close/lseek/dup/fcntl/ioctl/poll/select/epoll*/mmap): they operate on ANY fd — file,
631    // socket, or pipe — so a fixed label would mis-categorise as often as it helps. An honest
632    // no-classify (under-report) beats emitting the WRONG effect. Pure conversions (htons/inet_pton/
633    // gmtime) are also skipped.
634    //
635    // `nix` (the idiomatic SAFE libc wrapper, in ~every Rust systems/CLI crate) is routed through the
636    // SAME table: its functions keep the syscall leaf name (`nix::fcntl::open`, `nix::sys::socket::connect`,
637    // `nix::unistd::execvp`). Without this, a CONSUMER of nix analysed without nix's own source (the
638    // stable scanner, single-crate) sees `nix::*` cross-crate and under-reports — serialport-rs opens its
639    // device via `nix::fcntl::open` and reported ZERO Fs. The nightly lint reaches `libc::*` THROUGH nix's
640    // body; this gives the scanner the same coverage directly. (Found sweeping serialport-rs.)
641    // `rustix` is the same shape as nix but does RAW syscalls (no libc underneath), so its functions MUST
642    // be classified directly. Its leaf names are the syscall names too (`rustix::time::clock_settime`,
643    // `rustix::fs::mkfifoat`/`symlink`/`stat`, `rustix::net::connect`) — route it through the same table.
644    // The rustix-specific `*at`/variant leaves it doesn't share with libc just under-report (the safe
645    // direction). VALIDATED, not speculative: coreutils' `date` reads/sets the clock via
646    // `rustix::time::clock_getres`/`clock_settime` and reported Clock=0; the file I/O that goes through
647    // std::fs was already correct, which is why only the rustix-only effects (Clock/Ipc) were missing.
648    if crate_name == "libc" || crate_name == "nix" || crate_name == "rustix" {
649        let f = path.rsplit("::").next().unwrap_or(path);
650        // path / directory / metadata syscalls (incl. *64 and *at variants) — `LIBC_FS`, hoisted to module
651        // level so the AS-EFF-008 masking guard reads THE SAME TABLE (SOUNDNESS R806); see `masks_locator`.
652        const FS: &[&str] = LIBC_FS;
653        // socket family — these operate only on sockets, so Net is unambiguous (AF_UNIX domain isn't
654        // visible at the call, so a Unix socket reads as Net rather than Ipc; acceptable over-general).
655        const NET: &[&str] = LIBC_NET;
656        // process creation / replacement / reaping
657        const EXEC: &[&str] = LIBC_EXEC;
658        // pipes / FIFOs / SysV + POSIX message queues, semaphores, shared memory; socketpair (AF_UNIX)
659        const IPC: &[&str] = &[
660            "pipe", "pipe2", "mkfifo", "mkfifoat", "socketpair", "msgget", "msgsnd", "msgrcv", "msgctl",
661            "semget", "semop", "semtimedop", "semctl", "shmget", "shmat", "shmdt", "shmctl", "mq_open",
662            "mq_send", "mq_receive", "mq_timedsend", "mq_timedreceive", "mq_close", "mq_unlink",
663        ];
664        const ENV: &[&str] = &["getenv", "secure_getenv", "setenv", "putenv", "unsetenv", "clearenv"];
665        const CLOCK: &[&str] = &[
666            "time", "gettimeofday", "clock_gettime", "clock_getres", "nanosleep", "clock_nanosleep",
667            // SETTING the system clock is a clock effect too (was unclassified — found on coreutils `date`,
668            // which sets it via `clock_settime`).
669            "clock_settime", "settimeofday", "stime", "adjtime", "adjtimex", "clock_adjtime",
670        ];
671        const RAND: &[&str] = &["getrandom", "getentropy", "arc4random", "arc4random_buf", "arc4random_uniform"];
672        if FS.contains(&f) {
673            return Some("Fs");
674        }
675        if NET.contains(&f) {
676            return Some("Net");
677        }
678        if EXEC.contains(&f) {
679            return Some("Exec");
680        }
681        if IPC.contains(&f) {
682            return Some("Ipc");
683        }
684        if ENV.contains(&f) {
685            return Some("Env");
686        }
687        if CLOCK.contains(&f) {
688            return Some("Clock");
689        }
690        if RAND.contains(&f) {
691            return Some("Rand");
692        }
693        return None;
694    }
695    // C-library FFI bindings: libsqlite3 (under rusqlite) and libgit2 (under git2). Like the libc tier,
696    // these crates are thin Rust over a C library, so their real I/O is invisible until the C entry
697    // points are named. Match by the DISTINCTIVE C function name (`sqlite3_*` / `git_*`) via the call's
698    // LEAF — independent of the binding crate's alias: rusqlite calls `ffi::sqlite3_step`, git2 calls
699    // `raw::git_remote_fetch`, and the nightly lint resolves the same to `libsqlite3_sys`/`libgit2_sys`;
700    // all spellings share the leaf. Only the I/O-performing entry points are listed — the in-memory
701    // accessors (`sqlite3_bind_*`/`sqlite3_column_*`, `git_*_oid`/strarray/options builders) stay pure,
702    // so a non-listed `sqlite3_`/`git_` leaf returns None (under-report, never a wrong effect). Calibrated
703    // + validated against rusqlite 0.39 / git2 0.20 source (eval/calibration).
704    {
705        let leaf = path.rsplit("::").next().unwrap_or(path);
706        if let Some(rest) = leaf.strip_prefix("sqlite3_") {
707            let _ = rest;
708            // SQLite C API operations that touch the database (open/exec/step/prepare/backup/blob/wal).
709            //
710            // SOUNDNESS R166 — MEMBERSHIP CRITERION, stated because the list was extended and the next
711            // reader needs to know what "already audited" covers. A leaf belongs here when it either
712            // (a) reads or writes DATABASE CONTENT (disk or the in-memory image), or (b) mutates the
713            // registry of code the engine will later RUN — the extension/auto-extension registry, whose
714            // effect is not local to the calling frame. The audit boundary was the WHOLE `sqlite3_*`
715            // surface rusqlite 0.40.2 mentions (185 distinct symbols diffed against this list), not the
716            // one name the row was filed for: `sqlite3_auto_extension` arrived with its `_cancel_`/
717            // `_reset_` siblings and with four content-I/O leaves nobody had looked at.
718            //
719            // DELIBERATELY STILL ABSENT, so this is not read as "the surface is covered": the
720            // CALLBACK-INSTALLING entry points (`sqlite3_create_function[_v2]`,
721            // `sqlite3_create_window_function`, `sqlite3_create_collation_v2`, `sqlite3_create_module_v2`,
722            // `sqlite3_*_hook`, `sqlite3_set_authorizer`, `sqlite3_progress_handler`, `sqlite3_trace_v2`).
723            // Those register a UDF/hook on ONE connection for the life of that connection; they perform no
724            // database I/O themselves, and the opaque-callback boundary is already disclosed by the
725            // scanner's own `Unknown` at the call site that hands the function pointer across. The
726            // auto-extension registry is the case that differs: it is PROCESS-GLOBAL and outlives every
727            // connection, so its consequence cannot be attributed to a caller's own frame at all.
728            // Unexamined and named as such: the libgit2 (`git_*`) table below got no equivalent sweep.
729            const DB: &[&str] = &[
730                "sqlite3_open", "sqlite3_open_v2", "sqlite3_open16", "sqlite3_close", "sqlite3_close_v2",
731                "sqlite3_exec", "sqlite3_step", "sqlite3_prepare", "sqlite3_prepare_v2",
732                "sqlite3_prepare_v3", "sqlite3_prepare16", "sqlite3_prepare16_v2", "sqlite3_prepare16_v3",
733                "sqlite3_get_table", "sqlite3_backup_init", "sqlite3_backup_step", "sqlite3_backup_finish",
734                "sqlite3_blob_open", "sqlite3_blob_read", "sqlite3_blob_write", "sqlite3_blob_reopen",
735                "sqlite3_load_extension", "sqlite3_wal_checkpoint", "sqlite3_wal_checkpoint_v2",
736                // (b) the PROCESS-GLOBAL extension registry — every one of these changes what a LATER
737                // `sqlite3_open` on any connection will execute, and `sqlite3_load_extension` (already
738                // above) is the same capability one call along.
739                "sqlite3_auto_extension", "sqlite3_cancel_auto_extension", "sqlite3_reset_auto_extension",
740                "sqlite3_enable_load_extension",
741                // (a) further DATABASE-CONTENT I/O the original list missed: whole-image load/save,
742                // a forced page-cache flush to disk, a direct VFS file operation, and arming the
743                // automatic WAL checkpoint writes whose manual twin is already listed.
744                "sqlite3_deserialize", "sqlite3_serialize", "sqlite3_db_cacheflush",
745                "sqlite3_file_control", "sqlite3_wal_autocheckpoint",
746            ];
747            return DB.contains(&leaf).then_some("Db");
748        }
749        if leaf.starts_with("git_") {
750            // libgit2: remote/transport operations contact the network … (incl. submodule clone/update,
751            // which `git_clone`/fetch the subrepo over its remote — `allow_fetch` defaults on; an A/B on
752            // git2 0.20 caught `Submodule::update`/`clone` reporting no `Net`).
753            const NET: &[&str] = &[
754                "git_clone", "git_remote_connect", "git_remote_connect_ext", "git_remote_fetch",
755                "git_remote_download", "git_remote_upload", "git_remote_push", "git_remote_ls",
756                "git_submodule_clone", "git_submodule_update",
757            ];
758            // … and repository/index/odb/checkout/ref/config operations touch the on-disk .git store.
759            const FS: &[&str] = &[
760                "git_repository_open", "git_repository_open_ext", "git_repository_open_bare",
761                "git_repository_init", "git_repository_init_ext", "git_repository_discover",
762                "git_checkout_tree", "git_checkout_head", "git_checkout_index", "git_index_read",
763                "git_index_write", "git_index_write_tree", "git_index_write_tree_to",
764                "git_index_add_bypath", "git_index_add_all", "git_odb_open", "git_odb_read",
765                "git_odb_write", "git_odb_open_wstream", "git_odb_open_rstream",
766                "git_blob_create_fromdisk", "git_blob_create_fromworkdir", "git_blob_create_from_disk",
767                "git_blob_create_from_workdir", "git_blob_create_from_stream", "git_commit_create",
768                "git_commit_create_v", "git_reference_create", "git_reference_set_target",
769                "git_reference_delete", "git_config_open_default", "git_config_open_ondisk",
770                "git_config_add_file_ondisk", "git_tag_create", "git_treebuilder_write",
771                "git_packbuilder_write",
772            ];
773            if NET.contains(&leaf) {
774                return Some("Net");
775            }
776            if FS.contains(&leaf) {
777                return Some("Fs");
778            }
779            return None;
780        }
781        if leaf.starts_with("curl_") {
782            // libcurl (under the `curl` crate, called `curl_sys::curl_*`). Only the entry points that
783            // PERFORM network I/O: the blocking transfer (`curl_easy_perform`), raw socket send/recv,
784            // the HTTP/2 keepalive PING (`upkeep`), and the multi-interface transfer pumps. The large
785            // pure surface (setopt/init/cleanup/reset/getinfo/escape/multi_add_handle/fdset/info_read)
786            // stays unclassified, as do `curl_multi_wait`/`poll` (readiness WAIT on sockets, no payload —
787            // the loop's `perform` is the tagged boundary, per the I/O-boundary principle). An A/B on
788            // curl 0.4 caught the whole crate reporting ZERO Net (`Easy::perform` read as pure).
789            const NET: &[&str] = &[
790                "curl_easy_perform", "curl_easy_send", "curl_easy_recv", "curl_easy_upkeep",
791                "curl_multi_perform", "curl_multi_socket_action",
792            ];
793            return NET.contains(&leaf).then_some("Net");
794        }
795        if let Some(op) = leaf.strip_prefix("SSL_") {
796            // OpenSSL (libssl, under the `openssl`/`native-tls` crates, called `ffi::SSL_*`). The TLS
797            // handshake and record I/O run over the peer socket -> Net. Unlike libc read/write, an SSL_*
798            // op is ~always over a network BIO (the rare memory-BIO/sans-IO case is the honest exception
799            // we accept). The crypto surface (EVP_*/SHA*/AES*) and pure setup (SSL_CTX_new/SSL_set_fd) are
800            // NOT here; `BIO_*` is skipped (a BIO may be memory or socket). Validated vs openssl 0.9 source.
801            const SSL_NET: &[&str] = &[
802                "connect", "accept", "do_handshake", "read", "read_ex", "write", "write_ex", "peek",
803                "peek_ex", "shutdown",
804            ];
805            return SSL_NET.contains(&op).then_some("Net");
806        }
807    }
808    // HTTP clients use the same builder pattern as the AWS SDK: only the dispatch is
809    // I/O. (Found by the eval: ebman's reqwest calls to the Anthropic API + webhooks
810    // were silently classified network-free because reqwest wasn't recognized.)
811    if crate_name == "reqwest" || crate_name == "isahc" {
812        // The dispatch (`::send`/`::execute`) is the I/O. PLUS the one-shot CONVENIENCE functions
813        // `reqwest::get` / `reqwest::blocking::get` / `isahc::get`, which send immediately — they're
814        // an EXACT match (not `Client::get`, the builder) to avoid false-positiving the builder path.
815        // (Found running on `xh`: a one-shot `reqwest::get(url)` was classified network-free.)
816        if path.ends_with("::send")
817            || path.ends_with("::execute")
818            || path == "reqwest::get"
819            || path == "reqwest::blocking::get"
820            || path == "isahc::get"
821        {
822            return Some("Net");
823        }
824        // THE URL-BEARING BUILDER METHODS: `Client::{get,post,put,delete,patch,head,request}(URL)`.
825        // Real code almost never uses `reqwest::get(url)`; the DOMINANT idiom is the builder chain
826        // `Client::new().post(url).send()` / `Client::builder().build()?.post(url).send()`. The `.send()`
827        // already classifies `Net` — but the URL literal rides the `.post(url)` call, NOT `.send()`, so
828        // without classifying the URL-naming step `Net` the endpoint is NEVER captured and the `Llm`
829        // host refinement can't fire (ebman's `api.anthropic.com` call read as bare Net, undisclosed as
830        // Llm — the dogfood silent under-report). Classifying these `Net` (idempotent with the eventual
831        // `.send()`) makes the scanner capture the URL from their string arg. `request(method, url)`'s
832        // url is its SECOND arg — the scanner's first-string-literal capture still gets it when the
833        // method is a literal string, and misses it (honest under-report) when the method is an
834        // expression. The pure builder surface (`::header`, `::json`, `::body`, `::query`, …) stays None.
835        if path.ends_with("::get")
836            || path.ends_with("::post")
837            || path.ends_with("::put")
838            || path.ends_with("::delete")
839            || path.ends_with("::patch")
840            || path.ends_with("::head")
841            || path.ends_with("::request")
842        {
843            return Some("Net");
844        }
845        // THE COVERAGE-GATE SWEEP (2026-08-27), verified against isahc 2.0.1 — isahc-only, since
846        // reqwest has no equivalent free-function async family:
847        //
848        // `get_async`/`head_async`/`post_async`/`put_async`/`delete_async`/`send_async` (lib.rs:357-500)
849        // are the crate's async one-shot convenience functions — `HttpClient::shared().get_async(uri)`
850        // etc., the exact async mirror of the already-covered `isahc::get`, dispatching immediately.
851        // `HttpClient::new`/`HttpClientBuilder::build` (client.rs:629,444) are genuinely NOT lazy like
852        // reqwest's `Client::new`: `build()` unconditionally calls `agent_builder.spawn()`
853        // (agent/mod.rs:63), which spawns a background OS thread running `AgentContext::run` — curl's
854        // multi-handle event loop that DOES perform the real socket reads/writes for every request later
855        // sent through this client. Confirmed via self-scan on isahc's own source: `AgentBuilder::spawn`
856        // reaches `Net` through that same call chain, not a guess.
857        if crate_name == "isahc"
858            && (path == "isahc::get_async"
859                || path == "isahc::head_async"
860                || path == "isahc::post_async"
861                || path == "isahc::put_async"
862                || path == "isahc::delete_async"
863                || path == "isahc::send_async"
864                || path.ends_with("HttpClient::new")
865                || path.ends_with("HttpClientBuilder::build"))
866        {
867            return Some("Net");
868        }
869        // `reqwest::multipart::Part::file` (blocking/multipart.rs:223) opens the given path directly
870        // (`std::fs::File::open`) to attach it as a form part — genuinely Fs, not Net (the eventual
871        // upload is charged at `.send()`, already covered above).
872        //
873        // NOT modelled: `h3_client::pool::PoolClient::send_request` (async_impl/h3_client/pool.rs:207)
874        // — `mod async_impl;` is PRIVATE in reqwest's lib.rs (only `self::async_impl::multipart` is
875        // selectively re-exported), so `PoolClient` is unreachable from outside the crate; the real
876        // HTTP/3 dispatch a consumer can actually reach is the already-covered `::send`/`::execute`.
877        // Removed from open.tsv rather than guessed.
878        // SOUNDNESS R337 — THE WRAPPER, not the wrapped. candor already charges
879        // `native_tls_crate::Identity::from_pkcs8`/`from_pkcs12` `Fs` (the clause below), and the reason
880        // it does is concrete rather than defensive: on the security-framework backend those create a
881        // real `tempfile::TempDir` and write a keychain into it —
882        // `native-tls-0.2.18/src/imp/security_framework.rs:93` (`identity.keychain`, `from_pkcs8`) and
883        // `:167` (`tmp.keychain`, `from_pkcs12`). But candor classifies the call a CONSUMER writes, not
884        // the dependency body behind it, so a consumer who reaches that code through its idiomatic
885        // wrapper matched no rule at all — and in a CALIBRATED crate an unmatched path is a claim of
886        // reviewed purity with no disclosure. A call taking only BYTES writes a file on macOS, and it
887        // read pure.
888        //
889        // Swept for the CLASS rather than the two rows the coverage gate handed me: every caller of
890        // `native_tls{,_crate}::Identity::from_pkcs8|from_pkcs12` in the local registry is reqwest
891        // (0.11/0.12/0.13, all three spelling these the same way), lettre, and `tcp_stream` — which is
892        // NOT calibrated, so its calls disclose rather than claim purity and it needs no rule.
893        //
894        // Suffix-matched, not exact-path, because all three reqwest majors carry the same names; and
895        // narrow on purpose. The SIBLINGS are the fabrication control and they must stay pure:
896        // `reqwest::tls::Identity::from_pem` is rustls-only, a `Cursor` over a buffer (tls.rs:373), and
897        // lettre's `Certificate::from_der`/`from_pem` reach `native_tls::Certificate::*`, which imports
898        // items with no keychain and no temp dir (security_framework.rs:206,212).
899        // SOUNDNESS R342 — THE RESPONSE BODY IS READ FROM THE SOCKET, and `resp.text().await` is one of
900        // the most-written lines in Rust networking. `send()` is charged; the methods that DRAIN what it
901        // returned were not, so a helper that takes a `Response` and reads it — an extremely common
902        // shape — was a positive purity claim on a CALIBRATED crate. Executed at reqwest 0.13.4:
903        // `r.text()`, `r.json()` and `r.bytes()` all ABSENT while `c.get(..).send()` was `['Net']`.
904        //
905        // Verified in the source rather than assumed: `text` -> `text_with_charset` -> `bytes` ->
906        // `do_bytes`, which is `BodyExt::collect(self.res.into_body()).await`
907        // (`async_impl/response.rs:433`) — it drains the body off the wire. `chunk` and `bytes_stream`
908        // are the streaming spellings of the same read; charging the stream CONSTRUCTOR follows this
909        // file's own `Command::new` convention, where the effect is attributed at the point the caller
910        // asks for it rather than at the poll nobody can see.
911        //
912        // Scoped by `Response::` and not by the bare verb: `::text` and `::json` are far too common a
913        // leaf to match crate-wide. Found by the coverage gate the moment R185 taught the scanner to
914        // see through `Option`/`Result` unwraps — the same "closing a silence makes consumers' gaps
915        // visible" shape recorded on R302 and R337.
916        if crate_name == "reqwest"
917            && path.contains("Response::")
918            && (path.ends_with("::text")
919                || path.ends_with("::text_with_charset")
920                || path.ends_with("::json")
921                || path.ends_with("::bytes")
922                || path.ends_with("::chunk")
923                || path.ends_with("::bytes_stream"))
924        {
925            return Some("Net");
926        }
927        if crate_name == "reqwest"
928            && (path.ends_with("::Identity::from_pkcs12_der")
929                || path.ends_with("::Identity::from_pkcs8_pem"))
930        {
931            return Some("Fs");
932        }
933        if crate_name == "reqwest" && path.ends_with("::Part::file") {
934            return Some("Fs");
935        }
936        return None;
937    }
938    if crate_name == "ureq" && path.ends_with("::call") {
939        return Some("Net");
940    }
941    // THE COVERAGE-GATE SWEEP (2026-08-27), verified against ureq 2.12.1 (the version this ratchet's
942    // rows were generated from — 3.x, also cached locally, rewrote this surface beyond recognition and
943    // is a different question for a future pass). `::call` above is the no-body dispatch terminal;
944    // these are its siblings:
945    //
946    // `Request::send`/`send_bytes`/`send_form`/`send_json`/`send_string` (request.rs:78-296) are the
947    // WITH-BODY dispatch terminals — `do_call(Payload::..)`, the exact same terminal `call` reaches with
948    // an empty payload. Missing them left every `agent.post(url).send_json(&body)` (the dominant idiom
949    // for a JSON API call) silently pure.
950    // `ureq::agent`/`request`/`request_url` (lib.rs:513,539,561) are real gaps in a stranger way: each
951    // one's own body contains a REACHABLE (if `is_test(true)` was ever called — itself a `pub fn` a
952    // consumer or another dependency could invoke) call to `testserver::test_agent()`, which binds a
953    // real listening `TcpStream` (see `TestServer::new` below) — self-scan's whole-body reachability
954    // treats that as real, and per this project's over-approximate-rather-than-miss discipline (a
955    // toggleable global flag routing traffic through an internal listener is exactly the kind of path a
956    // security-conscious caller wants disclosed, not silently pure), so does this rule. `agent()` is also
957    // the crate's OWN base for `request`/`request_url` (`agent().request(..)`), and `request`/
958    // `request_url` additionally carry the URL argument — matching the reqwest/isahc precedent above of
959    // classifying the URL-bearing constructor `Net` too (idempotent with the eventual `.call()`/`.send()`)
960    // so the destination is captured even if a caller never re-touches the returned `Request`.
961    if crate_name == "ureq"
962        && (path.ends_with("::send")
963            || path.ends_with("::send_bytes")
964            || path.ends_with("::send_form")
965            || path.ends_with("::send_json")
966            || path.ends_with("::send_string")
967            || path == "ureq::agent"
968            || path == "ureq::request"
969            || path == "ureq::request_url"
970            || path == "ureq::unversioned::transport::RustlsConnector::connect"
971            || path == "ureq::tls::rustls::RustlsConnector::connect"
972            || path == "ureq::RustlsConnector::connect")
973    {
974        return Some("Net");
975    }
976    // NOT modelled (both removed from open.tsv, not guessed):
977    //   `ureq::Arc::connect` — the ratchet's generator strips generic arguments from an impl header, so
978    //   `impl TlsConnector for Arc<rustls::ClientConfig>` (rtls.rs:88) produced the type name "Arc" — a
979    //   bogus path (`ureq::Arc` names nothing; `Arc` is std's, not ureq's) that no consumer could ever
980    //   write. The trait method itself is real (ureq's own internal TLS dispatch, invoked by `.call()`,
981    //   already covered), but no FQN a real caller would spell resolves through this guess.
982    //   `ureq::TestServer::new` — `TestServer` (testserver.rs:62) lives in `mod testserver;` (lib.rs:444),
983    //   PRIVATE with no re-export, so `ureq::TestServer` is unreachable from outside the crate (the
984    //   listener it binds is real, but only `agent()`'s internal `is_test` branch above can reach it).
985    // The `curl` crate (libcurl's safe binding — cargo's own HTTP client): the dispatch verbs are
986    // `perform` (Easy/Easy2/Transfer/Multi), raw-socket `send`/`recv`, the keepalive `upkeep`, and the
987    // multi-interface `action` (socket_action). The big setopt-style builder surface stays pure.
988    // `Multi::timeout` is deliberately NOT matched: `Easy::timeout` is a pure CURLOPT_TIMEOUT setter
989    // sharing the leaf — an under-report on the rare event-loop kick beats mis-tagging every consumer
990    // that sets a timeout. (Consumer-side companion to the curl_* FFI tier, same A/B finding.)
991    if crate_name == "curl"
992        && (path.ends_with("::perform")
993            || path.ends_with("::send")
994            || path.ends_with("::recv")
995            || path.ends_with("::upkeep")
996            || path.ends_with("::action"))
997    {
998        return Some("Net");
999    }
1000    // The modern async-HTTP / TLS / QUIC / DNS stack — the LAYER reqwest/ureq/isahc build on, and that
1001    // crates use DIRECTLY. Found by the independent-method differential on `oha` (2026-06-17): candor
1002    // honestly DISCLOSED these as blind but never CLASSIFIED them, leaving real Net reaches uncovered.
1003    // Verb-keyed (the pure type/builder/codec surface stays None) and CRATE-GATED, so generic verbs
1004    // (request/connect/get/read/write/accept) never fabricate across unrelated crates. Same precision
1005    // discipline as the reqwest/curl rules above; complements the scan_builder_entry_effect entries.
1006    match crate_name {
1007        // hyper 1.x client connection I/O (the builder/Body/Request types stay pure).
1008        "hyper" if path.ends_with("::send_request") || path.ends_with("::handshake") => return Some("Net"),
1009        // hyper-util's pooled legacy Client + its TCP connectors.
1010        "hyper_util" if path.ends_with("::request") || path.ends_with("::connect") => return Some("Net"),
1011        // hickory (trust-dns) resolver — issues DNS queries over the network.
1012        "hickory_resolver"
1013            if path.ends_with("::lookup_ip") || path.ends_with("::lookup") || path.ends_with("_lookup")
1014                || path.ends_with("::resolve") => return Some("Net"),
1015        // HTTP/3 over QUIC.
1016        "h3" if path.ends_with("::send_request") || path.ends_with("::recv_data")
1017            || path.ends_with("::recv_response") || path.ends_with("::send_data") => return Some("Net"),
1018        // QUIC transport (UDP socket send/recv): connection setup, datagrams, AND the stream byte I/O
1019        // (`RecvStream::read*` / `SendStream::write*` / `finish`). Opening a stream is caught above, but a
1020        // fn that only HOLDS a stream and reads/writes it would otherwise read silent-pure (review: a Net
1021        // under-report). Crate-gated to quinn, where these verbs are unambiguously the socket I/O.
1022        "quinn" if path.ends_with("::connect") || path.ends_with("::accept") || path.ends_with("::open_bi")
1023            || path.ends_with("::open_uni") || path.ends_with("::accept_bi") || path.ends_with("::accept_uni")
1024            || path.ends_with("::send_datagram") || path.ends_with("::read_datagram")
1025            || path.ends_with("::read") || path.ends_with("::read_chunk") || path.ends_with("::read_chunks")
1026            || path.ends_with("::read_to_end") || path.ends_with("::write") || path.ends_with("::write_all")
1027            || path.ends_with("::write_chunk") || path.ends_with("::write_chunks")
1028            || path.ends_with("::finish") => return Some("Net"),
1029        // TLS-over-TCP stream adapters — the actual socket handshake/I/O (the config/cert types stay pure).
1030        "tokio_rustls" | "native_tls"
1031            if path.ends_with("::connect") || path.ends_with("::accept") || path.ends_with("::handshake") =>
1032            return Some("Net"),
1033        // AF_VSOCK host<->guest sockets — inter-process / VM comms.
1034        "tokio_vsock" if path.ends_with("::connect") || path.ends_with("::bind") || path.ends_with("::accept") =>
1035            return Some("Ipc"),
1036        // Loads the OS trust store from disk (cert files / keychain).
1037        "rustls_native_certs" if path.ends_with("::load_native_certs") => return Some("Fs"),
1038        // `rlimit` reads/mutates the process's kernel resource limits — the closest bucket is Env (host/
1039        // process config); no dedicated process-state bucket exists, so getrlimit (read) and setrlimit
1040        // (mutate) share it. NOTE: `num_cpus::get`/`get_physical` are deliberately NOT modeled — asking the
1041        // OS for the CPU count is a near-pure topology query, and std's equivalent `thread::
1042        // available_parallelism` classifies pure; modeling it as Env would spray Env over every thread-pool
1043        // constructor (review: a high-noise over-report) for no capability a reviewer cares about.
1044        "rlimit" if path.ends_with("::getrlimit") || path.ends_with("::setrlimit")
1045            || path.ends_with("::increase_nofile_limit") => return Some("Env"),
1046        // rustls — the SYNC TLS core (tokio_rustls/native_tls above are the async/system adapters). The
1047        // record-layer I/O is `read_tls`/`write_tls` (pull/push raw bytes through a held `io::Read`/`Write`)
1048        // and `complete_io` (loops them until the handshake/buffers drain). The config/cert/builder types
1049        // (`ClientConfig`/`ServerConfig`/`ConfigBuilder`) are PURE. `process_new_packets` is deliberately
1050        // EXCLUDED — it only decrypts ALREADY-buffered bytes (no socket touch; docs say call it AFTER
1051        // read_tls), so flagging it would over-report Net on the pure decrypt step.
1052        "rustls" if path.ends_with("::read_tls") || path.ends_with("::write_tls")
1053            || path.ends_with("::complete_io") => return Some("Net"),
1054        // native-tls under its alternate crate name + the tokio async wrapper (the `native_tls` arm above
1055        // is the common name). The TLS handshake over a TcpStream is Net; the builder/cert types are pure.
1056        "native_tls_crate" | "tokio_native_tls"
1057            if path.ends_with("::connect") || path.ends_with("::accept")
1058                || path.ends_with("::handshake") => return Some("Net"),
1059        _ => {}
1060    }
1061    // THE COVERAGE-GATE SWEEP (2026-08-27) — two crate-root CONSTRUCTORS the verb-keyed match above
1062    // never reached because neither ends in connect/accept/handshake, verified against their real
1063    // per-platform impl (native-tls 0.2.18, rustls 0.23.43):
1064    //
1065    // `native_tls_crate::TlsConnector::new` (lib.rs:481, the PUBLIC newtype wrapper around the private
1066    // per-platform `imp::TlsConnector`) reads the system trust store — on the openssl backend it loads
1067    // the probed cert file/dir from disk before any socket exists. `Identity::from_pkcs8` (lib.rs:178,
1068    // wrapping `imp::Identity::from_pkcs8`) on the security-framework (macOS) backend creates a real
1069    // temporary keychain file on disk to import the PKCS8 key into.
1070    // `rustls::KeyLogFile::new` (key_log_file.rs:88) reads `$SSLKEYLOGFILE` and, if set, opens (creating
1071    // if needed) that file in append mode — a real, if opt-in, disk write path independent of the sync
1072    // TLS record-layer I/O the `rustls` arm above already covers.
1073    // SOUNDNESS R331 — …and `TlsConnector::builder`, which is the SAME trust-store read reached by the
1074    // other spelling. `TlsConnector::new` is literally `TlsConnector::builder().build()`
1075    // (`native-tls-0.2.18/src/lib.rs:481`), and `TlsConnectorBuilder::build` (`:451`) is where
1076    // `imp::TlsConnector::new` — the openssl-backend cert-file/dir load — actually runs. The builder
1077    // spelling is the DOMINANT idiom the moment any option is set, and it is what `reqwest` itself
1078    // writes (`reqwest-0.12.28/src/async_impl/client.rs:529`).
1079    //
1080    // **KEYED ON `builder`, NOT ON `build`, AND THAT IS THE WHOLE FIX.** The first attempt added
1081    // `ends_with("TlsConnectorBuilder::build")` and moved nothing, so the row was closed with the
1082    // conclusion that the scanner "never types `TlsConnector::builder()`" and the repair had to be
1083    // receiver typing. **That conclusion was wrong.** `.build()` is a method on a foreign-returned
1084    // receiver and cannot be typed without a return index for a foreign crate — but `TlsConnector::
1085    // builder()` is a PATH call, recorded and classified exactly like `TlsConnector::new` beside it.
1086    // Charging the constructor rather than the terminal is also this file's own convention
1087    // (`Command::new`). Over-charge direction: a `builder()` whose `.build()` never happens, which is
1088    // not a shape anyone writes.
1089    //
1090    // WHY IT LOOKED LIKE NOTHING WAS RECORDED: under the calibration exemption a call that classifies
1091    // `None` is DROPPED from the report, so "no calls recorded" is what a correct scan of an exempt
1092    // crate looks like — not evidence that the receiver went untyped. Measured: under the PLAIN
1093    // `native_tls::` spelling (not calibrated) the same body is PRESENT with `invisible: ["native_tls"]`,
1094    // a disclosure; under `native_tls_crate` (the calibrated rename reqwest and tungstenite use) it is
1095    // ABSENT with nothing hidden. The rename is what turns a disclosure into a purity claim.
1096    if matches!(crate_name, "native_tls" | "native_tls_crate")
1097        && (path.ends_with("TlsConnector::new")
1098            || path.ends_with("TlsConnector::builder")
1099            || path.ends_with("Identity::from_pkcs8")
1100            || path.ends_with("Identity::from_pkcs12"))
1101    {
1102        return Some("Fs");
1103    }
1104    if crate_name == "rustls" && path.ends_with("KeyLogFile::new") {
1105        return Some("Fs");
1106    }
1107    // Message-queue clients fully encapsulate the socket (the underlying tokio::net lives
1108    // inside the crate, unseen), so a user's connect/publish/consume calls ARE the I/O
1109    // boundary — to a remote broker, hence Net. Match the broker round-trip verbs (snake_case
1110    // methods); the CamelCase option/property builders stay pure. (Found hardening on consumer
1111    // apps: lapin `basic_publish`/`queue_declare` and async-nats `publish`/`subscribe` were
1112    // classified pure — a message-queue client reporting no I/O.)
1113    if crate_name == "async_nats" {
1114        if path.ends_with("::connect")
1115            || path.contains("::publish")
1116            || path.ends_with("::subscribe")
1117            || path.ends_with("::queue_subscribe")
1118            || path.contains("::request")
1119            || path.ends_with("::flush")
1120        {
1121            return Some("Net");
1122        }
1123        // THE COVERAGE-GATE SWEEP (2026-08-27), verified against async-nats 0.35.1 (the version this
1124        // ratchet's rows were generated from — 0.50.0, also cached locally, removed/relocated this
1125        // exact surface, a separate question for a future pass):
1126        //
1127        // `connect_with_options` (lib.rs:891) is the crate's OWN real entry point `connect()` calls one
1128        // hop down — the actual handshake, missing because the verb list above matches the bare
1129        // `::connect` suffix, not the `_with_options` sibling.
1130        // `ConnectOptions::credentials_file`/`with_credentials_file` (options.rs:417,438) load a real
1131        // credentials file off disk via `auth_utils::load_creds` before authenticating — Fs, not Net
1132        // (the network round-trip these feed happens later, at `connect`).
1133        // `ServerAddr::socket_addrs` (lib.rs:1473) does `tokio::net::lookup_host` — a real DNS query.
1134        if path == "async_nats::connect_with_options" {
1135            return Some("Net");
1136        }
1137        if path == "async_nats::ConnectOptions::credentials_file"
1138            || path == "async_nats::ConnectOptions::with_credentials_file"
1139        {
1140            return Some("Fs");
1141        }
1142        if path == "async_nats::ServerAddr::socket_addrs" {
1143            return Some("Net");
1144        }
1145        return None;
1146    }
1147    if crate_name == "lapin" {
1148        if path.ends_with("::connect")
1149            || path.ends_with("::create_channel")
1150            || path.contains("::basic_")
1151            || path.contains("::queue_")
1152            || path.contains("::exchange_")
1153            || path.contains("::tx_")
1154            || path.ends_with("::confirm_select")
1155            || path.ends_with("::close")
1156        {
1157            return Some("Net");
1158        }
1159        return None;
1160    }
1161    // SMTP email — lettre's `Transport::send` is the network dispatch; Message building is
1162    // pure. (Found hardening on a lettre consumer: `mailer.send(&email)` classified pure.)
1163    //
1164    // THE COVERAGE-GATE SWEEP (2026-08-27), verified against lettre 0.11.23 source — the TLS-setup and
1165    // connection-establishment family this crate's own `send` rule never reached:
1166    //
1167    // `TlsParameters::new`/`new_rustls` (client/tls.rs:598,617) and `TlsParametersBuilder::build`/
1168    // `build_rustls` (tls.rs:325,446) — `build_rustls` calls `rustls_native_certs::load_native_certs()`
1169    // (a real OS-trust-store read) plus `tracing::debug!`; `build()` dispatches to it under the
1170    // (textually-visible, cfg-gated) `rustls` feature. `SmtpTransport`/`AsyncSmtpTransport::{from_url,
1171    // relay,starttls_relay}` (transport.rs:90,114,243; async_transport.rs:135,169,306) each construct a
1172    // `TlsParameters` directly (`relay`/`starttls_relay`) or via the crate's OWN `pub(crate)
1173    // from_connection_url` (`from_url`) — real TLS setup a consumer never spells `TlsParameters` to
1174    // reach. `FileTransport::read` (transport/file/mod.rs:216) calls `std::fs::read` directly.
1175    if crate_name == "lettre" {
1176        if path.ends_with("::send") || path.ends_with("::send_raw") {
1177            return Some("Net");
1178        }
1179        // SOUNDNESS R337 — lettre's half of the same wrapper gap. `Identity::from_pem(pem, key)`
1180        // (transport/smtp/client/tls.rs:749) is `native_tls::Identity::from_pkcs8(pem, key)`, which on
1181        // macOS writes a temporary keychain. The `::Identity::` in the suffix is load-bearing: the
1182        // `Certificate::from_pem` twenty lines above it (`:676`) is in-memory and must stay pure, and a
1183        // bare `::from_pem` would charge both.
1184        if path.ends_with("::Identity::from_pem") {
1185            return Some("Fs");
1186        }
1187        if path == "lettre::TlsParametersBuilder::build"
1188            || path == "lettre::transport::smtp::client::TlsParametersBuilder::build"
1189            || path == "lettre::TlsParametersBuilder::build_rustls"
1190            || path == "lettre::transport::smtp::client::TlsParametersBuilder::build_rustls"
1191            || path == "lettre::TlsParameters::new"
1192            || path == "lettre::transport::smtp::client::TlsParameters::new"
1193            || path == "lettre::TlsParameters::new_rustls"
1194            || path == "lettre::transport::smtp::client::TlsParameters::new_rustls"
1195            // SOUNDNESS R331 — the `_native` half of the same family, which this enumeration never had.
1196            // It surfaced the moment `TlsConnector::builder` started charging: the coverage gate's
1197            // oracle saw `Fs` on `TlsParameters::new_native` and `TlsParametersBuilder::build_native`
1198            // and `classify()` had no rule for either. `build_native` is `TlsConnector::builder()`
1199            // (`lettre-0.11.23/src/transport/smtp/client/tls.rs:338`) and `new_native` delegates
1200            // straight to it (`:610`); the already-listed `build`/`new` reach whichever backend is
1201            // enabled and were covered, so the list held every variant EXCEPT the one named after the
1202            // backend that does the disk read.
1203            //
1204            // `build_boring`/`new_boring` are deliberately NOT added. `build_boring` (`:384`) builds a
1205            // `boring::ssl::SslConnector`, and openssl's `SslConnector::builder` calls
1206            // `set_default_verify_paths()` — so it is PROBABLY `Fs` too, but `boring` is not a crate
1207            // this file has read, and the last three defects in this area came from charging a path
1208            // whose body nobody had opened. Left for a pass that reads it.
1209            || path == "lettre::TlsParameters::new_native"
1210            || path == "lettre::transport::smtp::client::TlsParameters::new_native"
1211            || path == "lettre::TlsParametersBuilder::build_native"
1212            || path == "lettre::transport::smtp::client::TlsParametersBuilder::build_native"
1213            || path == "lettre::SmtpTransport::from_url"
1214            || path == "lettre::SmtpTransport::relay"
1215            || path == "lettre::SmtpTransport::starttls_relay"
1216            || path == "lettre::AsyncSmtpTransport::from_url"
1217            || path == "lettre::AsyncSmtpTransport::relay"
1218            || path == "lettre::AsyncSmtpTransport::starttls_relay"
1219            || path == "lettre::FileTransport::read"
1220        {
1221            return Some("Fs");
1222        }
1223        // `AsyncStd1Executor::{connect,fs_read,fs_write}` (executor.rs:223,260,265, the sealed
1224        // `Executor` trait impl — `#[doc(hidden)]` in lettre's own source, so this is a narrower, less-
1225        // visited surface than the others above, but genuinely reachable: both the trait and the type
1226        // are `pub`, re-exported at the crate root) dial a real connection / read+write real files.
1227        // `AsyncSmtpConnection`/`AsyncNetworkStream::connect_asyncstd1` (client/async_connection.rs:121,
1228        // client/async_net.rs:207) dial a real `async-std` TCP connection — reachable only via the
1229        // module-qualified path (`transport::smtp::client::`), since neither type is re-exported at the
1230        // crate root (unlike `TlsParameters`'s sibling forms, which at least reach `client::` — the dual
1231        // spellings above, same shape as rusqlite's `Blob`/`Backup`).
1232        if path == "lettre::AsyncStd1Executor::connect"
1233            || path == "lettre::AsyncSmtpConnection::connect_asyncstd1"
1234            || path == "lettre::transport::smtp::client::AsyncSmtpConnection::connect_asyncstd1"
1235            || path == "lettre::AsyncNetworkStream::connect_asyncstd1"
1236            || path == "lettre::transport::smtp::client::AsyncNetworkStream::connect_asyncstd1"
1237        {
1238            return Some("Net");
1239        }
1240        if path == "lettre::AsyncStd1Executor::fs_read" || path == "lettre::AsyncStd1Executor::fs_write" {
1241            return Some("Fs");
1242        }
1243        // NOT included: `NetworkStream::{shutdown,set_read_timeout,set_write_timeout}` (client/net.rs)
1244        // LOOK like three more hits (self-scan flags them too, propagating from the coarse
1245        // `std::net::TcpStream` whole-handle rule) but `mod net;` (client/mod.rs:50) is PRIVATE and
1246        // `NetworkStream` is never re-exported (only imported crate-internally via a bare `use
1247        // self::net::NetworkStream;`, mod.rs:35) — no external consumer can ever name the type, so no
1248        // rule was added despite self-scan flagging it (the same `InnerConnection`/`RawStatement` shape
1249        // as the rusqlite fix elsewhere in this file).
1250        return None;
1251    }
1252    // WebSockets — tungstenite (the modern successor to the old `websocket` crate). connect
1253    // and the socket read/write/send are network; Message constructors are pure. (Found on a
1254    // tungstenite consumer: connect + send + read classified pure.)
1255    //
1256    // THE FIX: `connect` only names the URL-dialing client entry point. tungstenite ALSO ships the
1257    // stream-first client/server handshake free functions — `client`/`client_with_config` (client.rs:176,
1258    // 152: "use this if you need a nonblocking handshake ... or a custom stream") and
1259    // `accept`/`accept_with_config`/`accept_hdr`/`accept_hdr_with_config` (server.rs:23-63) — each of
1260    // which does `{Client,Server}Handshake::start(stream, ..).handshake()`, the REAL WS upgrade
1261    // handshake read/write over an already-open stream. These are the documented way to run tungstenite
1262    // over a caller-managed TCP/TLS/mio stream (exactly the shape most async runtimes use, since
1263    // tungstenite itself is sync/transport-agnostic) — missing from a verb list keyed only on the
1264    // dial-it-yourself `connect` spelling. Same vein as `git2::Submodule::clone`/`ignore::Walk::new`: an
1265    // established effect's SIBLING entry point absent from the allowlist.
1266    if crate_name == "tungstenite" {
1267        if path.ends_with("::connect")
1268            || path.ends_with("::connect_with_config")
1269            || path.ends_with("::client")
1270            || path.ends_with("::client_with_config")
1271            || path.ends_with("::client_tls")
1272            || path.ends_with("::client_tls_with_config")
1273            || path.ends_with("::accept")
1274            || path.ends_with("::accept_with_config")
1275            || path.ends_with("::accept_hdr")
1276            || path.ends_with("::accept_hdr_with_config")
1277            || path.ends_with("::read")
1278            || path.ends_with("::write")
1279            || path.ends_with("::send")
1280            || path.ends_with("::close")
1281            || path.ends_with("::flush")
1282            || path.ends_with("::read_message")
1283            || path.ends_with("::write_message")
1284        {
1285            return Some("Net");
1286        }
1287        return None;
1288    }
1289    // elasticsearch: request builders are pure; only the `.send()` dispatch is HTTP I/O
1290    // (same shape as reqwest / the AWS SDK). (Found on an elasticsearch consumer.)
1291    // SOUNDNESS R342 — …and the RESPONSE BODY, one wrapper up from reqwest's. `Response::json` is
1292    // `self.response.json::<B>().await` (`http/response.rs:102`) — reqwest's body drain, which this file
1293    // now charges — and `text`/`bytes`/`exception` are the same read. A consumer writing
1294    // `client.search(..).send().await?.json().await?` had the `send` charged and the read silent.
1295    //
1296    // This is EXACTLY the distinction this file's own exclusion list already draws for this type:
1297    // `Response::content_type` is documented there as a pure accessor reading a header off an
1298    // ALREADY-received response. `status_code`/`headers` are the same shape and stay pure; the body
1299    // methods are not accessors, they pull the remaining bytes off the wire. Both halves are asserted
1300    // in the test so the line between them cannot move by accident.
1301    if crate_name == "elasticsearch"
1302        && path.contains("Response::")
1303        && (path.ends_with("::json")
1304            || path.ends_with("::text")
1305            || path.ends_with("::bytes")
1306            || path.ends_with("::exception"))
1307    {
1308        return Some("Net");
1309    }
1310    if crate_name == "elasticsearch" && path.ends_with("::send") {
1311        return Some("Net");
1312    }
1313    // gRPC — tonic. The transport connect and the Grpc client RPC dispatch are network;
1314    // codecs and request/response wrappers are pure. (connect repro-confirmed on a consumer;
1315    // the unary/streaming RPC verbs are from the tonic::client::Grpc API.)
1316    //
1317    // THE COVERAGE-GATE FIX: the rule above only ever covered the CLIENT half. `Router::serve`/
1318    // `::serve_with_shutdown` (transport/server/mod.rs:783,811) are the SERVER's own most common entry
1319    // points — a tonic quickstart's last line — and both bind a real listening socket via
1320    // `TcpIncoming::new` (incoming.rs:197: `StdTcpListener::bind(addr)`), the crate's other bare-`pub`
1321    // constructor (`Server<L>::serve_with_shutdown` at mod.rs:530 is a DIFFERENT, `pub(crate)` method on
1322    // a different receiver — not reachable, and not this one). A `deny Net` on a gRPC SERVER app missed
1323    // its own listen call entirely.
1324    if crate_name == "tonic" {
1325        if path.ends_with("::connect")
1326            || path.ends_with("::unary")
1327            || path.ends_with("::server_streaming")
1328            || path.ends_with("::client_streaming")
1329            || path.ends_with("::streaming")
1330            || path.ends_with("::Router::serve")
1331            || path.ends_with("::Router::serve_with_shutdown")
1332            || path == "tonic::TcpIncoming::new"
1333            || path == "tonic::transport::server::TcpIncoming::new"
1334        {
1335            return Some("Net");
1336        }
1337        return None;
1338    }
1339    // Kafka — rdkafka (FFI to librdkafka). Producer send + consumer poll/recv/subscribe/
1340    // commit are network round-trips to the brokers. (API-calibrated + unit-tested; a real
1341    // repro needs librdkafka/cmake, deferred.)
1342    if crate_name == "rdkafka" {
1343        if path.ends_with("::send")
1344            || path.ends_with("::send_result")
1345            || path.ends_with("::recv")
1346            || path.ends_with("::poll")
1347            || path.ends_with("::subscribe")
1348            || path.ends_with("::commit")
1349            || path.ends_with("::commit_message")
1350            || path.ends_with("::commit_consumer_state")
1351            || path.ends_with("::store_offset")
1352            || path.ends_with("::seek")
1353            || path.ends_with("::fetch_metadata")
1354            || path.ends_with("::fetch_watermarks")
1355            || path.ends_with("::flush")
1356        {
1357            return Some("Net");
1358        }
1359        return None;
1360    }
1361    // cap-std: capability-oriented std. I/O goes *through* a held capability handle
1362    // (Dir/Pool/Clock/...), so these calls ARE the effect. Recognising them means a
1363    // cap-std project's real I/O is detected and matches the capability it declared
1364    // (via `declared_caps`/`capstd_cap`) — conformance against unforgeable capabilities.
1365    if crate_name.starts_with("cap_") {
1366        if path.contains("::net::Unix") || path.contains("::os::") {
1367            return Some("Ipc");
1368        }
1369        if path.contains("::net") {
1370            return Some("Net");
1371        }
1372        if path.contains("::time") {
1373            return Some("Clock");
1374        }
1375        if path.contains("::fs") || crate_name == "cap_tempfile" || crate_name == "cap_directories" {
1376            return Some("Fs");
1377        }
1378        return None;
1379    }
1380    // Local IPC (Unix-domain sockets) is I/O but not *network* — keep it distinct so
1381    // CANDOR_NO_AMBIENT and audits don't conflate it with internet access. async-std puts its
1382    // Unix sockets under `os::unix::net` (mirroring std); async-net (smol's net layer) under
1383    // `unix`.
1384    if path.starts_with("tokio::net::Unix")
1385        || path.starts_with("std::os::unix::net")
1386        || path.starts_with("async_std::os::unix::net")
1387        || path.starts_with("async_net::unix")
1388    {
1389        return Some("Ipc");
1390    }
1391    // Raw packet capture / raw sockets — libpnet (the dominant low-level networking crate; powers
1392    // bandwhich, sniffers, custom-protocol tools). `datalink::channel` opens an L2 socket and
1393    // `transport::transport_channel` an L3/L4 raw socket — both ARE network I/O. Packet construction
1394    // (pnet_packet / pnet_base, MacAddr, Ethernet frames…) is pure and stays unclassified. The actual
1395    // frame read/write happens via methods on the returned Sender/Receiver (trait-object dispatch the
1396    // syntactic backend can't resolve), so the channel-open call is the precise Net boundary. (Found
1397    // scanning bandwhich — a packet sniffer — which reported Net 0.)
1398    if crate_name == "pnet" || crate_name == "pnet_datalink" || crate_name == "pnet_transport" {
1399        if path.ends_with("::channel") || path.ends_with("::transport_channel") {
1400            return Some("Net");
1401        }
1402        return None;
1403    }
1404    // Directory traversal — `ignore` (BurntSushi's gitignore-aware walker; powers ripgrep, fd). The walk
1405    // EXECUTORS read the directory tree from disk = Fs. Type-precise on purpose: the configuration builders
1406    // (`OverrideBuilder::build`, `GitignoreBuilder::build`, the `WalkBuilder` setters) and `DirEntry`
1407    // accessors are PURE — only `WalkBuilder::build`/`build_parallel` (which kick off the walk) and
1408    // `WalkParallel::run` (which drives it) touch the filesystem. A bare `build` would wrongly flag the
1409    // config builders. (Found scanning fd — a file finder — which reported Fs 2: its own `fs::read_dir`
1410    // was caught, but the `ignore`-based traversal that IS fd was invisible cross-crate.)
1411    //
1412    // `Walk::new`/`Walk::from_iter` are the crate's own documented convenience constructors — literally
1413    // `WalkBuilder::new(path).build()` / `WalkBuilder::from_iter(paths).build()` in `ignore`'s own source
1414    // (walk.rs:1128-1146) — but a verb list keyed only on `WalkBuilder::build`/`build_parallel`/
1415    // `WalkParallel::run`/`add_ignore` never sees `Walk::new(root)` (the crate's own top-level doc example
1416    // and the SAME shape as the already-fixed `walkdir::WalkDir::new`/`git2::Repository::clone`: a
1417    // documented public entry point that reaches the modelled effect through a wrapper the allowlist
1418    // didn't name). `deny Fs` over `for e in Walk::new(root) { .. }` exited 0. Charged at the SAME
1419    // construction site as `WalkBuilder::build` — no receiver typing needed, it's a plain `Expr::Call` on
1420    // `ignore::Walk::new`/`ignore::Walk::from_iter`, crate-gated so an unrelated `Walk::new` (a different
1421    // crate, or a local type) cannot match this arm.
1422    if crate_name == "ignore" {
1423        if path == "ignore::WalkBuilder::build"
1424            || path == "ignore::WalkBuilder::build_parallel"
1425            || path.ends_with("::WalkParallel::run")
1426            // `add_ignore(path)` LOOKS like a config setter but reads that ignore file from disk at call
1427            // time (it returns the read error) — unlike the pure `add_custom_ignore_filename(name)` which
1428            // only stores a filename string. The lone Fs-touching builder method in the otherwise-pure setter
1429            // surface, so it was silently pure under the covered-crate floor.
1430            || path == "ignore::WalkBuilder::add_ignore"
1431            || path == "ignore::Walk::new"
1432            || path == "ignore::Walk::from_iter"
1433        {
1434            return Some("Fs");
1435        }
1436        // THE COVERAGE-GATE SWEEP (2026-08-27), verified against ignore 0.4.33 — the gitignore-matcher
1437        // construction family, a DIFFERENT public surface from the walk-builder family above:
1438        //
1439        // `Gitignore::new` (gitignore.rs:103) opens and reads the given file directly via
1440        // `GitignoreBuilder::add`. `Gitignore::global` (gitignore.rs:141) reads `$PWD` then delegates to
1441        // `GitignoreBuilder::new(cwd).build_global()`. `GitignoreBuilder::add` (gitignore.rs:405) is the
1442        // crate's own per-file loader — `File::open` + line-by-line read — the same shape `add_ignore`
1443        // above was fixed for, on the SIBLING type. `GitignoreBuilder::build_global`/
1444        // `gitconfig_excludes_path` (gitignore.rs:377,583) resolve git's global excludesfile: read
1445        // `GIT_CONFIG_GLOBAL`/`XDG_CONFIG_HOME`/`HOME` env vars, then open and parse whichever gitconfig
1446        // file they point at. `WalkBuilder::build_matchers` (walk.rs:675) is the incremental-walk
1447        // sibling of the already-covered `build_parallel` — same `self.build_ignore()` call, different
1448        // caller-facing verb. `IncrementalIgnore::matched`/`matched_with_errors` (incremental.rs:194,213)
1449        // are the newer per-directory incremental-walk API: each lazily loads that directory's ignore
1450        // files (and, when `max_filesize` is set, `stat`s the candidate file) as the walk descends.
1451        //
1452        // `Gitignore`/`GitignoreBuilder`/`gitconfig_excludes_path` live in `pub mod gitignore;`
1453        // (lib.rs:59) but — unlike `Walk`/`WalkBuilder` two lines up (`pub use crate::walk::{..}`,
1454        // lib.rs:52) — are NOT re-exported at the crate root, so the only real, compilable spelling is
1455        // the module-qualified one (proven by a consumer fixture: `ignore::Gitignore::new` does not
1456        // exist, `ignore::gitignore::Gitignore::new` does). `IncrementalIgnore` IS re-exported at the
1457        // root (`pub use crate::incremental::{..}`, lib.rs:51), so the bare form is correct there.
1458        if path == "ignore::gitignore::Gitignore::new"
1459            || path == "ignore::gitignore::Gitignore::global"
1460            || path == "ignore::gitignore::GitignoreBuilder::add"
1461            || path == "ignore::gitignore::GitignoreBuilder::build_global"
1462            || path == "ignore::gitignore::gitconfig_excludes_path"
1463            || path == "ignore::WalkBuilder::build_matchers"
1464            || path == "ignore::IncrementalIgnore::matched"
1465            || path == "ignore::IncrementalIgnore::matched_with_errors"
1466            || path == "ignore::DirEntry::metadata"
1467            || path == "ignore::walk::DirEntry::metadata"
1468            || path == "ignore::WalkParallel::visit"
1469            || path == "ignore::walk::WalkParallel::visit"
1470        {
1471            return Some("Fs");
1472        }
1473        return None;
1474    }
1475    // Filesystem watching — `notify` (the de-facto fs-watch crate: watchexec, cargo-watch, mdbook). A
1476    // watcher opens an OS notification handle (inotify / FSEvents / kqueue / ReadDirectoryChanges) and
1477    // registers paths — observing filesystem state changes = Fs. The lifecycle boundary: any
1478    // `*Watcher::new` constructor (RecommendedWatcher/PollWatcher/INotifyWatcher/FsEventWatcher/…), the
1479    // `recommended_watcher` convenience fn, and the `watch`/`unwatch` registration verbs. `Config`/`Event`/
1480    // `EventKind` data types stay pure. (Found scanning watchexec: its watcher-`create` read Fs 0.)
1481    if crate_name == "notify" {
1482        if path.ends_with("Watcher::new")
1483            || path.ends_with("::recommended_watcher")
1484            || path.ends_with("::watch")
1485            || path.ends_with("::unwatch")
1486            // `ReadDirectoryChangesWatcher::create` (windows.rs:475, `pub use windows::
1487            // ReadDirectoryChangesWatcher` at the crate root) is a SECOND, directly-callable
1488            // constructor distinct from the `Watcher::new` trait method above — it takes a raw
1489            // meta-event channel `Watcher::new`'s impl builds internally by calling THIS same
1490            // `create`, then spawns the real ReadDirectoryChangesW watch server thread.
1491            || path.ends_with("ReadDirectoryChangesWatcher::create")
1492        {
1493            return Some("Fs");
1494        }
1495        return None;
1496    }
1497    // std DNS resolution — `("host", 80).to_socket_addrs()` / `std::net::lookup_host("host")` perform a
1498    // real getaddrinfo query (Net), but the classify table covered only the socket I/O *types*, so they
1499    // floored silently (sweep [37]; the syntactic engine modelled DNS only at the libc layer).
1500    if path.ends_with("::to_socket_addrs")
1501        || path == "std::net::lookup_host"
1502        || path.ends_with("ToSocketAddrs::to_socket_addrs")
1503    {
1504        return Some("Net");
1505    }
1506    // Raw sockets. Match the I/O *types* only — `std::net` also holds pure data types
1507    // (SocketAddr, IpAddr, …) whose construction must NOT be flagged.
1508    if path.starts_with("std::net::TcpStream")
1509        || path.starts_with("std::net::TcpListener")
1510        || path.starts_with("std::net::UdpSocket")
1511        || path.starts_with("tokio::net::")
1512    {
1513        // …but the PURE accessors read back local/option state — no network I/O — so the whole-type Net
1514        // rule fabricated Net on them (sweep [24], the precision failure; mirrors the arboard/memmap2 accessor
1515        // carve-outs). local_addr/peer_addr return bound/connected addresses; nodelay/ttl/take_error read
1516        // socket options/state. Every genuine verb (connect/read/write/send/recv/accept) stays Net.
1517        if path.ends_with("::local_addr")
1518            || path.ends_with("::peer_addr")
1519            || path.ends_with("::nodelay")
1520            || path.ends_with("::ttl")
1521            || path.ends_with("::take_error")
1522        {
1523            return None;
1524        }
1525        return Some("Net");
1526    }
1527    // Legacy tokio 0.1 socket crates — `tokio_tcp`/`tokio_udp` are *entirely* networking
1528    // (no pure types to over-flag), so the whole crate is Net. (Found hardening on websocat,
1529    // which is still on tokio 0.1: its `tokio_tcp::TcpStream::connect` was classified
1530    // network-free — a network tool confidently reporting 0 Net.)
1531    if matches!(crate_name, "tokio_tcp" | "tokio_udp") {
1532        return Some("Net");
1533    }
1534    // The other async runtimes mirror tokio's module layout, and their `net` modules hold only
1535    // socket I/O types (the pure `SocketAddr`/`IpAddr` are re-exports that resolve to `std::net`,
1536    // so they're excluded by def-path). `mio` is the low-level non-blocking-socket layer under
1537    // tokio/others; `async_net` is smol's net crate. Closes the async-std/smol/mio gap the
1538    // tokio_tcp note flagged. (Calibrated by module structure — these crates ARE networking — not
1539    // a live repro; the TCP/UDP types are defined in-crate so the def-path prefix is exact.)
1540    if path.starts_with("async_std::net::")
1541        || path.starts_with("mio::net::")
1542        || crate_name == "async_net"
1543    {
1544        return Some("Net");
1545    }
1546    // Database clients. Like the AWS/HTTP builders, only the execution verbs are I/O;
1547    // query *construction* is pure. Best-effort across crates (tune via CANDOR_CONFIG).
1548    // Note: bare `::query` is deliberately omitted — it executes in postgres/rusqlite but
1549    // only *builds* in sqlx, so including it would false-positive sqlx's `query()` builder.
1550    if DB_CRATES.contains(&crate_name) {
1551        // Postgres / SQLite-family clients: `query`/`batch_execute`/`prepare`/etc. ARE the
1552        // execution (round-trips to the server). sqlx is the outlier where bare `query()`
1553        // only BUILDS — it keeps the narrow set below. (Found by running on a real
1554        // tokio-postgres app, pgman: candor had reported only 4 of ~20 DB call sites.)
1555        if matches!(crate_name, "postgres" | "tokio_postgres" | "deadpool_postgres" | "rusqlite") {
1556            // `PG_DB_VERBS`, hoisted to module level so the AS-EFF-008 masking guard reads the SAME
1557            // table (SOUNDNESS R806; see `masks_locator` and `PG_DB_VERBS_NO_SQL`).
1558            const PG: &[&str] = PG_DB_VERBS;
1559            if PG.iter().any(|v| path.ends_with(v)) {
1560                return Some("Db");
1561            }
1562            // THE COVERAGE-GATE SWEEP (2026-08-27): `CancelToken::cancel_query` (tokio-postgres
1563            // cancel_token.rs:34) opens a BRAND NEW connection to the server to send a raw CancelRequest
1564            // packet — real socket I/O, but not a query round-trip on an existing connection like the PG
1565            // verb list above, so bucketed `Net` rather than `Db`.
1566            if matches!(crate_name, "tokio_postgres" | "postgres")
1567                && path.ends_with("CancelToken::cancel_query")
1568            {
1569                return Some("Net");
1570            }
1571            // rusqlite only: opening the database IS the connection establishment (`Connection::
1572            // open`/`open_in_memory`/`open_with_flags` — the embedded analog of `::connect`).
1573            //
1574            // THE FIX: rusqlite 0.32's `Connection` type has SIX `open*` constructors, not three —
1575            // `open_with_flags_and_vfs` and `open_in_memory_with_flags_and_vfs` call the real
1576            // `InnerConnection::open_with_flags` (the sqlite3_open_v2 FFI) directly (lib.rs:492,530), and
1577            // `open_in_memory_with_flags` (lib.rs:515) calls `Connection::open_with_flags(":memory:", ..)`
1578            // — but an exact-suffix allowlist keyed on the THREE simplest names never matches any of
1579            // them (`"open_in_memory_with_flags".ends_with("::open_with_flags")` is false: the suffix
1580            // check needs the string to END in that literal tail, and `_and_vfs`/`_with_flags` add
1581            // characters AFTER it). The same shape as `ignore::Walk::new`: a sibling spelling of an
1582            // already-modelled constructor missing from the allowlist, silently pure because rusqlite is
1583            // calibrated. Match on the `Connection::open` PREFIX rather than enumerating every suffix —
1584            // every current and future `Connection::open*` constructor opens a real handle. Scoped to the
1585            // `Connection::` segment specifically (not a bare leaf prefix) so an unrelated same-crate
1586            // `open`-prefixed method on a DIFFERENT type (e.g. the private `pragma::Sql::open_brace`,
1587            // which pushes one char to a string buffer — no I/O) cannot be swept in by accident.
1588            //
1589            // Same sighting, different constructor: `Connection::blob_open` and `Blob::reopen` call
1590            // `ffi::sqlite3_blob_open`/`sqlite3_blob_reopen` directly (blob/mod.rs:218,251) — genuinely
1591            // Db, and `sqlite3_blob_open`/`sqlite3_blob_reopen` are already in this file's own FFI-leaf DB
1592            // table above (matched only when a caller names the raw `ffi::` leaf directly) — but rusqlite's
1593            // own documented safe wrapper, the incremental-BLOB-I/O API every rusqlite blob consumer
1594            // actually calls, carried no rule of its own.
1595            if crate_name == "rusqlite"
1596                && (path.contains("::Connection::open")
1597                    || path.ends_with("::Connection::blob_open")
1598                    || path.ends_with("::Blob::reopen"))
1599            {
1600                return Some("Db");
1601            }
1602            // THE COVERAGE-GATE SWEEP (2026-08-27): same shape again, and the SAME root cause as
1603            // `git2`'s — this `if crate_name == "rusqlite"` block returns unconditionally, so it never
1604            // reaches this file's own `sqlite3_*` FFI-leaf table below even though every one of these
1605            // calls a leaf ALREADY listed there (`sqlite3_backup_init`/`_step`, `sqlite3_blob_read`/
1606            // `_write`). Verified against rusqlite 0.32.1 source. `Backup::new`/`new_with_names` are the
1607            // crate's own online-backup constructors (backup.rs:187,200); `step`/`run_to_completion`
1608            // drive it; `Connection::backup`/`restore` (backup.rs:61,99) are the one-call convenience
1609            // wrappers around the same API and need their OWN rule since a consumer calling THEM never
1610            // names `Backup` at all. `Blob::{read,write}_at[_exact]`/`raw_read_at[_exact]`/
1611            // `write_all_at` (blob/pos_io.rs) are the incremental-BLOB positional-I/O methods, each
1612            // calling `ffi::sqlite3_blob_read`/`_write` directly. `Connection::from_handle`/
1613            // `_owned`/`extension_init2` and the free fn `init_auto_extension` (lib.rs:950,999,966;
1614            // auto_extension.rs:26) wrap a caller-supplied raw `*mut ffi::sqlite3` into a live
1615            // `Connection` — the loadable-extension entry points, same "produces a live connection"
1616            // effect as `Connection::open`, just over a handle the caller already has instead of one
1617            // this call opens itself (the `tokio_postgres::connect_raw`/`sea_orm::connect_proxy` shape).
1618            //
1619            // NOT included: `InnerConnection::*` and `RawStatement::step` LOOK like six more hits (self-
1620            // scan flags them too) but `mod inner_connection;`/`mod raw_statement;` (lib.rs:119,127) are
1621            // PRIVATE — despite `pub struct InnerConnection`/`RawStatement`, neither type has any public
1622            // path a real consumer could ever name or obtain a value of, so no rule was added for them
1623            // (a rule would be dead weight, never reachable). `Context::get_connection` (functions.rs)
1624            // is ALSO left out, deliberately: it returns a `ConnectionRef` accessor to an
1625            // ALREADY-established connection (`ffi::sqlite3_context_db_handle`, not an I/O verb) — the
1626            // same "handle accessor, not a syscall" shape as `TcpStream::local_addr`, not confirmed
1627            // enough to charge without risking the over-charge this file's history has repeatedly warned
1628            // against. THE COVERAGE-GATE SWEEP (2026-08-27) resolved this from "left in the ratchet"
1629            // to a formal call: `REVIEWED_PURE_ENTRIES` now carries `("rusqlite",
1630            // "rusqlite::Context::get_connection")` so the gate stops re-flagging it every refresh.
1631            //
1632            // TWO SPELLINGS EACH for `Backup`/`Blob`/`init_auto_extension`: none of the three is
1633            // re-exported at rusqlite's crate root (unlike `Connection`, declared directly in lib.rs), so
1634            // the ONLY real spelling a consumer can write is the module-qualified one
1635            // (`rusqlite::backup::Backup::new`, `rusqlite::blob::Blob::read_at`,
1636            // `rusqlite::auto_extension::init_auto_extension`) — but the coverage-gate ratchet recorded
1637            // the SHORT, technically-unreachable guess (`generate.py` always adds a bare
1638            // `{crate}::{Type}::{fn}` guess as a possible root-alias, without confirming a `pub use`
1639            // actually exists for it). Both are listed: the short form so this fix closes the exact row
1640            // the ratchet carries, the long form so it fires for what a real consumer's source (proven
1641            // against a compiling fixture) actually contains — dropping the long form would leave the
1642            // real gap open while the bookkeeping said closed.
1643            if crate_name == "rusqlite"
1644                && (path == "rusqlite::Backup::new"
1645                    || path == "rusqlite::backup::Backup::new"
1646                    || path == "rusqlite::Backup::new_with_names"
1647                    || path == "rusqlite::backup::Backup::new_with_names"
1648                    || path == "rusqlite::Backup::step"
1649                    || path == "rusqlite::backup::Backup::step"
1650                    || path == "rusqlite::Backup::run_to_completion"
1651                    || path == "rusqlite::backup::Backup::run_to_completion"
1652                    || path == "rusqlite::Connection::backup"
1653                    || path == "rusqlite::Connection::restore"
1654                    || path == "rusqlite::Blob::read_at"
1655                    || path == "rusqlite::blob::Blob::read_at"
1656                    || path == "rusqlite::Blob::read_at_exact"
1657                    || path == "rusqlite::blob::Blob::read_at_exact"
1658                    || path == "rusqlite::Blob::raw_read_at"
1659                    || path == "rusqlite::blob::Blob::raw_read_at"
1660                    || path == "rusqlite::Blob::raw_read_at_exact"
1661                    || path == "rusqlite::blob::Blob::raw_read_at_exact"
1662                    || path == "rusqlite::Blob::write_at"
1663                    || path == "rusqlite::blob::Blob::write_at"
1664                    || path == "rusqlite::Blob::write_all_at"
1665                    || path == "rusqlite::blob::Blob::write_all_at"
1666                    || path == "rusqlite::Connection::from_handle"
1667                    || path == "rusqlite::Connection::from_handle_owned"
1668                    || path == "rusqlite::Connection::extension_init2"
1669                    || path == "rusqlite::init_auto_extension"
1670                    || path == "rusqlite::auto_extension::init_auto_extension"
1671                    || path == "rusqlite::Statement::insert"
1672                    || path == "rusqlite::statement::Statement::insert"
1673                    || path == "rusqlite::Statement::raw_execute"
1674                    || path == "rusqlite::statement::Statement::raw_execute"
1675                    // SOUNDNESS R342 — `Rows::next` STEPS the statement: it is `self.advance()?`
1676                    // (`rusqlite-0.39.0/src/row.rs:40`), i.e. `sqlite3_step`, which is where a query's
1677                    // rows actually come from. Iterating a result set is the ordinary way to read from
1678                    // sqlite and it carried no `Db`. `advance` is listed beside it because it is `pub`
1679                    // and is the same call one level down.
1680                    || path == "rusqlite::Rows::next"
1681                    || path == "rusqlite::row::Rows::next"
1682                    || path == "rusqlite::Rows::advance"
1683                    || path == "rusqlite::row::Rows::advance")
1684            {
1685                return Some("Db");
1686            }
1687            return None;
1688        }
1689        // redis: the way redis is ACTUALLY used is the high-level `Commands`/`AsyncCommands`
1690        // traits (`con.get`/`set`/`hset`/`lpush`/…) — every method is a round-trip — plus
1691        // connection establishment. The shared VERBS below only catch the low-level
1692        // `cmd("GET").query(con)`, so without this a normal redis user's calls classify as
1693        // PURE. (Found hardening on redis-rs: a fn doing `con.get`/`set` reported no effects.)
1694        // SOUNDNESS R335 — the SENTINEL module, which the rules above reach only by accident. redis's
1695        // `sentinel` surface is how a client finds the current master in a failover deployment, and
1696        // every lookup TALKS TO THE SENTINEL SERVERS: `Sentinel::master_for` runs
1697        // `find_master_address` (a `SENTINEL masters` round-trip) and its own doc says "this will
1698        // connect to the master node to verify that it considers itself master"; `get_sentinel_client`
1699        // opens a client per address and issues `ROLE` until one answers. Measured on redis 1.6.0 —
1700        // which is this crate's REVIEWED CEILING, so the calibration exemption applied and every one of
1701        // them read as a positive purity claim, in both the receiver-typed and UFCS spellings.
1702        //
1703        // A DENYLIST, not the enumeration the surrounding rules use, and that is the point. The
1704        // enumerate-the-connecting-verbs shape is what goes stale: a release that ADDS a lookup verb
1705        // adds a SILENCE, the cardinal direction. Inverted, the whole module is `Db` except its
1706        // config surface, so a new verb is charged by default and only a new PURE verb costs a
1707        // fabrication. The exempt set is not guessed: every `pub fn` leaf in redis-1.6.0/src/sentinel.rs
1708        // is one of 33 names, and `build` / `new` / `set_*` are exactly the ones that touch no socket
1709        // (`Sentinel::build` parses URLs via `into_connection_info`; `SentinelClientBuilder::build`
1710        // assembles a config struct). The `contains("::Sentinel")` arm is not the loose match R321
1711        // punished: the module's ENTIRE public surface was enumerated before writing it, and no item
1712        // named `Sentinel*` exists anywhere else in the crate, nor any of these verb names.
1713        if crate_name == "redis"
1714            && (path.starts_with("redis::sentinel::") || path.contains("::Sentinel"))
1715        {
1716            let m = path.rsplit("::").next().unwrap_or(path);
1717            if m == "build" || m == "new" || m.starts_with("set_") {
1718                return None;
1719            }
1720            // §E1 HIT COUNTER (`CANDOR_ALIAS_DEBUG`) for `bin/corpus-ab.py --mark`.
1721            if std::env::var("CANDOR_ALIAS_DEBUG").is_ok() {
1722                eprintln!("R335SENTINEL {path}");
1723            }
1724            return Some("Db");
1725        }
1726        if crate_name == "redis"
1727            && (path.contains("Commands::")
1728                // THE COVERAGE-GATE SWEEP (2026-08-27), a pre-existing over-report found in passing:
1729                // `path.contains("::get_connection")` is a SUBSTRING match, so it also matched
1730                // `Client::get_connection_info` (client.rs:78) — a pure accessor returning an
1731                // already-stored `&ConnectionInfo`, no round-trip at all. Verified against redis 1.6.0.
1732                || (path.contains("::get_connection") && !path.ends_with("::get_connection_info"))
1733                || path.contains("::get_async_connection")
1734                || path.contains("::get_multiplexed_async_connection")
1735                // a live `ConnectionManager` round-trips (Db), but `ConnectionManagerConfig` is a pure
1736                // in-memory builder (set_number_of_retries/set_max_delay) — exclude it (adversarial review).
1737                // `ConnectionManager::clone` is an Arc refcount bump — no Db round-trip (sweep [27]).
1738                || (path.contains("ConnectionManager") && !path.contains("ConnectionManagerConfig")
1739                    && !path.ends_with("::clone"))
1740                || path.ends_with("::query")
1741                || path.ends_with("::query_async")
1742                || path.ends_with("::req_command")
1743                || path.ends_with("::req_packed_command")
1744                || path.ends_with("::req_packed_commands"))
1745        {
1746            return Some("Db");
1747        }
1748        // mongodb: a document-store API with none of the SQL verbs — the user calls
1749        // `coll.find_one`/`insert_one`/`aggregate`/… and `Client::with_uri_str`. Without
1750        // these a mongodb user's calls classify PURE. (Found hardening: a fn doing
1751        // `find_one`+`insert_one` reported no effects.) Handle accessors (name/namespace)
1752        // and option/doc builders don't match these verbs, so they stay pure.
1753        //
1754        // THE FIX: `Client::with_options(options)` IS `with_uri_str`'s own body one call down —
1755        // `with_uri_str` (client.rs:179) is literally `ClientOptions::parse(uri).await?;
1756        // Client::with_options(options)`, and `with_options` (client.rs:188) is where the topology/
1757        // monitoring actually spins up. A caller who already holds a `ClientOptions` (built
1758        // programmatically, or via `ClientOptions::parse` called separately) uses `with_options`
1759        // directly — mongodb's OWN alternate entry point for the identical effect, missing from an
1760        // allowlist keyed only on the URI-string spelling. Same shape as `ignore::Walk::new` and
1761        // diesel's `establish`: a sibling constructor of an already-modelled effect. Verified against
1762        // mongodb 3.8.1 source for both the async (`client.rs`) and sync (`sync/client.rs`) `Client`.
1763        if crate_name == "mongodb" {
1764            const MONGO: [&str; 28] = [
1765                "::with_uri_str", "::with_options", "::connect", "::find", "::find_one", "::insert_one",
1766                "::insert_many", "::update_one", "::update_many", "::delete_one",
1767                "::delete_many", "::replace_one", "::aggregate", "::count_documents",
1768                "::estimated_document_count", "::count", "::distinct", "::run_command",
1769                "::find_one_and_update", "::find_one_and_delete", "::find_one_and_replace",
1770                "::list_collections", "::list_collection_names", "::list_databases",
1771                "::list_database_names", "::create_collection", "::create_index", "::watch",
1772            ];
1773            if MONGO.iter().any(|v| path.ends_with(v)) {
1774                return Some("Db");
1775            }
1776            // THE COVERAGE-GATE SWEEP (2026-08-27), verified against mongodb 3.8.1 — the client-side
1777            // field-level encryption (CSFLE) surface, entirely unrelated to the CRUD verb list above.
1778            //
1779            // `ClientEncryption::decrypt` (client/csfle/client_encryption.rs:195) is an ordinary `pub
1780            // async fn` that bottoms out in `CryptExecutor::run_ctx` (client/csfle/state_machine.rs:106),
1781            // a state-machine loop that — depending on state — runs a real `list_collections` query
1782            // against the key-vault database, executes a real command against `mongocryptd` (respawning
1783            // the child process if the connection drops), and fetches data keys from the key vault:
1784            // genuinely Net (and, via mongocryptd respawn, Exec), reached from a manual decrypt call, not
1785            // a guess. Suffix-matched because the real path runs through a re-export hop the ratchet's
1786            // crate-root-alias guess skips: `ClientEncryption` is defined inside `pub(crate) mod csfle;`
1787            // (client.rs:4) and reachable only via `pub use crate::client::csfle::client_encryption;` at
1788            // the crate root (lib.rs:74) — `mongodb::client_encryption::ClientEncryption`, not bare
1789            // `mongodb::ClientEncryption`. The name is specific enough within this crate that a suffix
1790            // match carries no fabrication risk (crate-gated, and `ClientEncryption` exists nowhere else
1791            // in mongodb's own source).
1792            if path.ends_with("ClientEncryption::decrypt") {
1793                return Some("Net");
1794            }
1795            // NOT modelled (removed from open.tsv, not guessed): `CreateDataKey::execute` /
1796            // `Encrypt::execute` — a DIFFERENT false-guess shape from every other row in this pass.
1797            // `CreateDataKey`/`Encrypt` (action/csfle/create_data_key.rs, action/csfle/encrypt.rs) are
1798            // the crate's real, publicly re-exported Action-builder types (`mongodb::action::csfle::
1799            // {CreateDataKey,Encrypt}`) — but the SAME effect self-scan found (the real `run_ctx` call)
1800            // lives in `impl Action for CreateDataKey<'a> { async fn execute(self) -> .. { .. } }`
1801            // (client/csfle/client_encryption/create_data_key.rs:14), which is the INPUT to the
1802            // `#[action_impl]` proc macro, not a real method: the `Action` trait (action.rs:104) declares
1803            // only `optional`, and its own doc comment says the crate's action types are "executed via
1804            // `await` (or `run` if using the sync client)" — the macro consumes this `execute` fn body
1805            // and re-emits it as `IntoFuture::into_future`, so no compiled `CreateDataKey`/`Encrypt`
1806            // value ever has a method literally named `execute` a consumer could call. Self-scan found a
1807            // real function performing a real effect; it is just never reachable under this spelling
1808            // (nor, by construction, under ANY spelling — a consumer's call site is `.await`, not a
1809            // `.execute()` method call, so candor-scan would need to resolve the `IntoFuture` desugaring
1810            // itself to see this at all, a different, deeper question than a classify() rule can answer).
1811            return None;
1812        }
1813        // mysql / mysql_async: the `query`/`exec` families + `get_conn`/`ping` execute
1814        // immediately — no build-then-execute split like sqlx, so matching `::query` is safe
1815        // here. Same DB-verb-dialect gap class as redis/mongodb; calibrated from the Queryable
1816        // API (unit-tested; a real-app repro is the remaining confirmation).
1817        //
1818        // THE FIX: `Conn::new(opts)` is each crate's OWN primary connection constructor — not a
1819        // pool helper like `get_conn`, but the raw handle. `mysql::Conn::new` (conn/mod.rs:342) calls
1820        // `conn.connect_stream()?; conn.connect()?` directly; `mysql_async::Conn::new` (conn/mod.rs:921)
1821        // returns a future that does the same handshake. Real connection establishment, same shape as
1822        // diesel's `establish`/rusqlite's `open*` — but `::new` never appeared in this verb list, so a
1823        // bare `Conn::new(opts)?` (the crate's OWN first doctest example) read pure. Scoped to the
1824        // `Conn::` segment specifically (`::new` alone is far too generic a suffix to key on blindly —
1825        // `Opts`/`Pool`/query-result types in the same two crates have their own pure `new`s).
1826        if matches!(crate_name, "mysql" | "mysql_async") {
1827            if path.ends_with("::Conn::new") {
1828                return Some("Db");
1829            }
1830            const MY: [&str; 16] = [
1831                "::query", "::query_first", "::query_iter", "::query_map", "::query_fold",
1832                "::query_drop", "::exec", "::exec_first", "::exec_iter", "::exec_map",
1833                "::exec_fold", "::exec_drop", "::exec_batch", "::prep", "::ping", "::get_conn",
1834            ];
1835            if MY.iter().any(|v| path.ends_with(v)) {
1836                return Some("Db");
1837            }
1838            // THE COVERAGE-GATE SWEEP (2026-08-27), verified against mysql_async 0.37.0:
1839            // `Conn::from_url` (conn/mod.rs:1059) is `Conn::new(Opts::from_str(url)?)` one hop down —
1840            // the crate's OWN alternate entry point for the identical connect effect `Conn::new` above
1841            // already carries, same shape as `ignore::Walk::new`/diesel's `establish`.
1842            // `WhiteListFsHandler::handle` (local_infile_handler/builtin.rs:58, the `GlobalHandler` impl
1843            // for `LOAD DATA LOCAL INFILE`) opens a real file off the caller-supplied whitelist —
1844            // reachable at the crate root (`pub use self::local_infile_handler::{builtin::
1845            // WhiteListFsHandler, ..}`, lib.rs:500).
1846            if path == "mysql_async::Conn::from_url" {
1847                return Some("Db");
1848            }
1849            if path.ends_with("WhiteListFsHandler::handle") {
1850                return Some("Fs");
1851            }
1852            // NOT modelled (all three removed from open.tsv, not guessed): `mysql::MyTcpBuilder::connect`/
1853            // `Stream::connect_tcp`/`Stream::make_secure` (mysql, not mysql_async — io/tcp.rs, io/mod.rs,
1854            // io/tls/native_tls_io.rs). `mod io;` is PRIVATE in mysql's lib.rs with no re-export of
1855            // `MyTcpBuilder`/`Stream`, so none of the three is a path any external consumer can name —
1856            // the crate's real, externally-reachable connect effect is `Conn::new` above (already
1857            // covered), which calls into this private `io` module internally. Also NOT modelled:
1858            // `mysql_async::PathOrBuf::read` (opts/mod.rs) — `PathOrBuf` is declared in the same private
1859            // `mod opts;` whose OTHER types (`Opts`, `OptsBuilder`, …) ARE individually `pub use`-
1860            // re-exported at the crate root (lib.rs:493) but `PathOrBuf` specifically is not, so it too
1861            // is unreachable — the same private-module shape as tempfile's `imp::` functions above.
1862            return None;
1863        }
1864        // sea_orm: an ORM whose execution is split from building (like sqlx). The query
1865        // BUILDERS (`Entity::find`, `Entity::insert`) are pure; execution happens at `.all`/
1866        // `.one`/`.count`/`.stream` and `Insert/Update/Delete::exec`. The write path via an
1867        // ActiveModel (`model.insert(db)`) executes too — distinguished from the `EntityTrait`
1868        // builder by the trait in the path (`ActiveModelTrait::`). (Found hardening on a
1869        // sea_orm consumer app: `.all(db)` reads and `ActiveModel::insert` writes were pure.)
1870        if crate_name == "sea_orm" {
1871            // sea_orm RE-EXPORTS sea_query (`sea_orm::sea_query::…`), whose builder algebra collides with
1872            // the execution verbs: `Func::count(col)` builds a COUNT() expr, `Condition::all()` AND-groups
1873            // filters, `Expr::count(…)` — all PURE, none touch a db. The `::all`/`::count`/`::one` execution
1874            // rule fabricated Db on them (sweep [5]). sea_query is pure query construction end-to-end, so
1875            // exclude the whole re-exported namespace first.
1876            if path.contains("sea_query") {
1877                return None;
1878            }
1879            if path.ends_with("::all")
1880                || path.ends_with("::one")
1881                || path.ends_with("::count")
1882                || path.ends_with("::stream")
1883                || path.ends_with("::exec")
1884                || path.ends_with("::exec_with_returning")
1885                || path.ends_with("::exec_without_returning")
1886                || path.ends_with("::connect")
1887                // `Database::connect_proxy` (database/mod.rs:139, behind the `proxy` feature) is
1888                // `Database::connect`'s sibling for a caller-supplied `ProxyDatabaseTrait` backend —
1889                // same effect (produces a live `DatabaseConnection`), different verb, missing from an
1890                // allowlist keyed on the plain `connect` spelling.
1891                || path.ends_with("::connect_proxy")
1892                || path.ends_with("::execute")
1893                || path.ends_with("::execute_unprepared")
1894                || path.ends_with("::query_one")
1895                || path.ends_with("::query_all")
1896                || path.ends_with("::fetch_page")
1897                || path.ends_with("::num_items")
1898                || path.contains("ActiveModelTrait::")
1899            {
1900                return Some("Db");
1901            }
1902            // THE COVERAGE-GATE SWEEP (2026-08-27): sea_orm's TRANSACTION and PAGINATION families,
1903            // verified against sea-orm 1.1.20 source — each of these was found effectful by self-scan
1904            // under no guessed spelling this allowlist already covered.
1905            //
1906            // `DatabaseConnection::transaction`/`transaction_with_config` (db_connection.rs:302,345, the
1907            // `TransactionTrait` impl) is the crate's documented callback-transaction API
1908            // (`db.transaction(|txn| ...)`) — every sqlx-backed match arm dispatches to the
1909            // `SqlxXxxPoolConnection::transaction` methods FQN-listed below, a real BEGIN. FQN-exact
1910            // (not a bare `::transaction` suffix) because `MockDatabaseConnection`/`ProxyDatabaseConnection`
1911            // (driver/mock.rs, driver/proxy.rs, both feature-gated) have their OWN `begin`/`commit`/
1912            // `rollback`/`ping`/`transaction` methods sharing every one of these verb names — a mock
1913            // backend performs no real I/O by construction, and a caller-supplied proxy is a callback
1914            // boundary, not a provable effect; a bare suffix would fabricate Db on both.
1915            if path == "sea_orm::DatabaseConnection::transaction"
1916                || path == "sea_orm::DatabaseConnection::transaction_with_config"
1917                // BONUS, found while proving the above reachable with a real consumer fixture (not in
1918                // the original coverage-gate ratchet — self-scan's own reachability pass didn't flag
1919                // these, apparently because it doesn't track an enum match arm's payload binding as a
1920                // typed receiver, but they dispatch through the identical match-on-`self` shape as
1921                // `transaction` two lines up): `DatabaseConnection::ping` (db_connection.rs:462) and the
1922                // `TransactionTrait::begin`/`begin_with_config` impl (db_connection.rs:246,268) — a fixture
1923                // proved `ping` silently read pure with no rule at all.
1924                || path == "sea_orm::DatabaseConnection::ping"
1925                || path == "sea_orm::DatabaseConnection::begin"
1926                || path == "sea_orm::DatabaseConnection::begin_with_config"
1927                // `DatabaseTransaction::commit`/`rollback` (transaction.rs:119,159) call
1928                // `<sqlx::X as sqlx::Database>::TransactionManager::commit`/`rollback` directly — real
1929                // COMMIT/ROLLBACK, not sea_orm's OWN `::begin`/`::run` (both `pub(crate)`, unreachable).
1930                || path == "sea_orm::DatabaseTransaction::commit"
1931                || path == "sea_orm::DatabaseTransaction::rollback"
1932                // The three sqlx-backed pool connections' OWN `begin`/`ping`/`transaction` (driver/
1933                // sqlx_{mysql,postgres,sqlite}.rs) — `begin`/`transaction` acquire a pool connection and
1934                // start a real transaction, `ping` round-trips `conn.ping()` to the server.
1935                || path == "sea_orm::SqlxMySqlPoolConnection::begin"
1936                || path == "sea_orm::SqlxMySqlPoolConnection::ping"
1937                || path == "sea_orm::SqlxMySqlPoolConnection::transaction"
1938                || path == "sea_orm::SqlxPostgresPoolConnection::begin"
1939                || path == "sea_orm::SqlxPostgresPoolConnection::ping"
1940                || path == "sea_orm::SqlxPostgresPoolConnection::transaction"
1941                || path == "sea_orm::SqlxSqlitePoolConnection::begin"
1942                || path == "sea_orm::SqlxSqlitePoolConnection::ping"
1943                || path == "sea_orm::SqlxSqlitePoolConnection::transaction"
1944                // `Paginator::fetch`/`fetch_and_next`/`into_stream`/`num_pages`/`num_items_and_pages`
1945                // (executor/paginator.rs) all transitively reach `fetch_page`/`num_items` — already-
1946                // covered verbs — but each is ALSO a documented entry point a real consumer calls
1947                // directly (`cake::Entity::find().paginate(db, 50).into_stream()`, the crate's own
1948                // pagination doc example) and needs its own rule for the same reason
1949                // `Connection::backup` needed one beside `Backup::new` in rusqlite.
1950                || path == "sea_orm::Paginator::fetch"
1951                || path == "sea_orm::Paginator::fetch_and_next"
1952                || path == "sea_orm::Paginator::into_stream"
1953                || path == "sea_orm::Paginator::num_pages"
1954                || path == "sea_orm::Paginator::num_items_and_pages"
1955                // `Insert`/`Inserter`/`TryInsert::exec_with_returning_keys`/`_many` (executor/insert.rs)
1956                // are sibling spellings of the already-covered `::exec_with_returning` (same shape as
1957                // rusqlite's `open_with_flags_and_vfs` beside `open_with_flags`): each calls through to
1958                // the same underlying `exec_with_returning_keys`/`_many` executor, a real INSERT.
1959                || path.ends_with("::exec_with_returning_keys")
1960                || path.ends_with("::exec_with_returning_many")
1961            {
1962                return Some("Db");
1963            }
1964            return None;
1965        }
1966        // (Reached by sqlx + diesel — the build-vs-execute-split crates.) `first` is diesel's
1967        // LIMIT-1 round trip and `load_iter` its 2.x streaming execution; `fetch_many` is sqlx's
1968        // multi-result stream. All crate-gated, so a std `Vec::first` never resolves here.
1969        //
1970        // `establish` is diesel's OWN name for `::connect` — `Connection::establish(url)`
1971        // (connection/mod.rs:243), implemented by opening the real backend handle in
1972        // `SqliteConnection`/`PgConnection`/`MysqlConnection::establish` (sqlite/connection/mod.rs:230,
1973        // pg/connection/mod.rs:176, mysql/connection/mod.rs:158 — each does the real file-open/socket-
1974        // connect). It is diesel's canonical, and by far most common, connection entry point — every
1975        // diesel quickstart opens with it — yet it shares no verb spelling with `::connect`, so it fell
1976        // through this allowlist to `None`, and because `diesel` IS a CALIBRATED_CRATES entry the miss
1977        // produced NO `coverage.uncovered` disclosure either (that ledger is crate-level: a calibrated
1978        // crate's unmatched path reads as reviewed-pure, not as a gap) — the same silent-purity shape as
1979        // `ignore::Walk::new` above, one call away from `establish_test_transaction`/`establish_inner`,
1980        // which are diesel's own private plumbing and stay unmatched (no `::` in the allowed suffix keeps
1981        // this exact-verb, not a substring match).
1982        const VERBS: [&str; 20] = [
1983            "::execute", "::query_row", "::query_map", "::query_one", "::fetch_one",
1984            "::fetch_all", "::fetch_optional", "::fetch", "::fetch_many", "::connect",
1985            "::acquire", "::begin", "::commit", "::rollback", "::load", "::load_iter",
1986            "::first", "::get_result", "::get_results", "::establish",
1987        ];
1988        if VERBS.iter().any(|v| path.ends_with(v)) {
1989            return Some("Db");
1990        }
1991        return None;
1992    }
1993    // std::path::Path / PathBuf STAT-family methods hit the filesystem (each is a stat/readlink/
1994    // readdir syscall) — unlike the rest of the std::path surface, which is pure string manipulation
1995    // (join/file_name/extension/parent/…). Verb-precise so the scanner's receiver inference can safely
1996    // route a `path.symlink_metadata()` method call here. (A blackout screen caught gix-dir — an entire
1997    // directory WALKER — reporting ZERO Fs because all its I/O is Path-method calls; same class as
1998    // fd's residual `Path::symlink_metadata` under-report.)
1999    if let Some(m) = path
2000        .strip_prefix("std::path::Path::")
2001        .or_else(|| path.strip_prefix("std::path::PathBuf::"))
2002    {
2003        const STAT: &[&str] = &[
2004            "metadata", "symlink_metadata", "canonicalize", "read_link", "read_dir", "exists",
2005            "try_exists", "is_file", "is_dir", "is_symlink",
2006        ];
2007        return STAT.contains(&m).then_some("Fs");
2008    }
2009    // OPTION-BUILDERS, the shape SPEC §1 ⟨0.32⟩ separates from an invocation object: "option-builders for
2010    // other effects (`OpenOptions`, request builders) stay pure because their resource arrives at the
2011    // terminal verb, which is charged at its own call site". An `OpenOptions` holds a handful of bools and
2012    // names no file; `DirBuilder` holds one bool and a mode. Both sit under the coarse `std::fs::` prefix
2013    // below, which charged Fs for `OpenOptions::new()` and for every `o.read(true)` — MEASURED: a
2014    // `let o = OpenOptions::new().read(true);` with no `open` ANYWHERE reported `Fs`.
2015    //
2016    // A DENYLIST, and keyed on the TYPE. Only the provably-pure setters/ctors are subtracted; anything
2017    // else under the type keeps its effect, so the terminal verb (`OpenOptions::open`, `DirBuilder::create`)
2018    // stays Fs and a std addition we have not read about fails in the safe direction. The type key is not
2019    // decoration: `create` is a pure flag SETTER on `OpenOptions` and the mkdir SYSCALL on `DirBuilder` —
2020    // one leaf, opposite answers. (candor-java keys the same carve-out by DESCRIPTOR, because its collision
2021    // is an overload — `command()` reads back, `command(List)` sets. Rust has no overloads, so the type IS
2022    // the discriminator; a bare-name denylist would silence `DirBuilder::create`.)
2023    if let Some(m) = path.strip_prefix("std::fs::OpenOptions::") {
2024        const PURE: &[&str] = &[
2025            // the builder itself + the std flag setters
2026            "new", "read", "write", "append", "truncate", "create", "create_new",
2027            // the platform extension setters (`OpenOptionsExt`, unix + windows)
2028            "mode", "custom_flags", "security_qos_flags", "access_mode", "share_mode", "attributes",
2029            // derives
2030            "clone", "default", "fmt", "eq", "ne", "hash",
2031        ];
2032        return (!PURE.contains(&m)).then_some("Fs");
2033    }
2034    if let Some(m) = path.strip_prefix("std::fs::DirBuilder::") {
2035        const PURE: &[&str] = &["new", "recursive", "mode", "clone", "default", "fmt"];
2036        return (!PURE.contains(&m)).then_some("Fs");
2037    }
2038    // THE PLATFORM `fs` MODULES — `std::os::{unix,windows,wasi}::fs`. Measured 2026-09-02, ground truth
2039    // EXECUTED (a `cargo run` that really created a symlink on disk and then stat'd it back):
2040    // `std::os::unix::fs::symlink`, `chown`, `lchown` and `chroot` all read PURE, so `deny Fs` over a
2041    // crate whose only filesystem write is a symlink exited 0. The `std::fs::` prefix below is the whole
2042    // filesystem rule and these modules are simply not under it — the platform-specific half of std's
2043    // filesystem API had no rule at all. (Found tracing why `tokio::fs::symlink` carries no `Fs` of its
2044    // own; its body is `asyncify(move || std::os::unix::fs::symlink(..))`.)
2045    //
2046    // A DENYLIST keyed on the TRAIT, exactly like `OpenOptions`/`DirBuilder` above and for the same
2047    // reason: subtract only the provably-pure surfaces, so a std addition nobody here has read about
2048    // fails in the SAFE direction. What is subtracted, and why each is pure:
2049    //   * `MetadataExt` / `DirEntryExt` / `FileTypeExt` — accessors over data ALREADY fetched by the
2050    //     `metadata()`/`read_dir()` call that is charged at its own site. `m.uid()` issues no syscall.
2051    //   * `PermissionsExt` — reads/sets bits on an in-memory `Permissions`; the syscall is
2052    //     `set_permissions`, charged under `std::fs::`.
2053    //   * `OpenOptionsExt` / `DirBuilderExt` — SPEC §1 ⟨0.32⟩ option-builders: the resource arrives at
2054    //     the terminal verb (`open`/`create`), which is charged at its own call site.
2055    // `FileExt` is deliberately NOT subtracted — `read_at`/`write_at`/`seek_read`/`seek_write` are the
2056    // positional-I/O syscalls and are exactly what this rule must keep.
2057    if let Some(rest) = path
2058        .strip_prefix("std::os::unix::fs::")
2059        .or_else(|| path.strip_prefix("std::os::windows::fs::"))
2060        .or_else(|| path.strip_prefix("std::os::wasi::fs::"))
2061    {
2062        const PURE_TRAITS: &[&str] = &[
2063            "MetadataExt::", "DirEntryExt::", "DirEntryExt2::", "FileTypeExt::",
2064            "PermissionsExt::", "OpenOptionsExt::", "DirBuilderExt::",
2065        ];
2066        return (!PURE_TRAITS.iter().any(|t| rest.starts_with(t))).then_some("Fs");
2067    }
2068    // THE PLATFORM `process` MODULES — `std::os::{unix,windows,wasi}::process`. SOUNDNESS R141, the
2069    // EXACT SIBLING of the `fs` rule above, and unruled for the same reason it was: R130 closed
2070    // `std::os::*::fs` and translated that question across ENGINES while never translating it across
2071    // SIBLING MODULES of the namespace it had just found unruled.
2072    //
2073    // Ground truth EXECUTED when the row was filed: a consumer printed `before`, then
2074    // `EXECED-THROUGH-LIB`, and never reached the following line — `CommandExt::exec` is `execvp` and
2075    // really does replace the process image. Re-measured at HEAD 2026-09-27 on a 5-function fixture:
2076    // `CommandExt::exec(c)`, `std::os::unix::process::CommandExt::exec(c)` and
2077    // `fn f<C: CommandExt>(c: &mut C) { c.exec() }` were all ABSENT from `functions[]` — no `Unknown`,
2078    // no `unresolved` — and `deny Exec`, `pure` and `deny Exec Unknown` all exited 0, while on the SAME
2079    // tree the RECEIVER spelling `c.exec()` exited 1 and the sibling-namespace UFCS control
2080    // `FileExt::read_at(f, b, 0)` exited 1. So this is the one-spelling-of-two shape of R130 itself:
2081    // `c.exec()` was only ever charged because the receiver types to `std::process::Command` and the
2082    // whole-type rule below answers; nothing answered for the trait-path spelling.
2083    //
2084    // A DENYLIST keyed on the TRAIT, exactly like the `fs` rule and for the same reason — subtract only
2085    // the provably-pure surfaces so a std addition nobody here has read about fails in the SAFE
2086    // direction. What is subtracted, and why each is pure:
2087    //   * `ExitStatusExt` / `ExitStatusError` / `ExitCodeExt` — accessors and constructors over an
2088    //     ALREADY-COLLECTED status (`signal()`, `core_dumped()`, `from_raw(n)`). The wait that produced
2089    //     it is charged at its own site under `std::process::Child`.
2090    //   * `parent_id` — `getppid()`, a read of this process's own identity, no spawn. Kept at PARITY
2091    //     with `std::process::id`, which carries no rule either; subtracting it here rather than
2092    //     leaving it to the Exec cliff is the one place this rule departs from "unrecognised keeps
2093    //     Exec", and it is named rather than folded in.
2094    // Everything else keeps Exec: `CommandExt::{exec, pre_exec, arg0, uid, gid, groups,
2095    // process_group}` and the windows `CommandExt::{creation_flags, raw_arg, …}` / `ChildExt`. That is
2096    // also what the receiver spelling already answers — `c.uid(0)` reports `['Exec']` at HEAD — so this
2097    // rule makes the two spellings agree rather than inventing a new verdict for either.
2098    if let Some(rest) = path
2099        .strip_prefix("std::os::unix::process::")
2100        .or_else(|| path.strip_prefix("std::os::windows::process::"))
2101        .or_else(|| path.strip_prefix("std::os::wasi::process::"))
2102    {
2103        const PURE: &[&str] =
2104            &["ExitStatusExt::", "ExitStatusError::", "ExitCodeExt::", "parent_id"];
2105        return (!PURE.iter().any(|t| rest.starts_with(t))).then_some("Exec");
2106    }
2107    // Filesystem. `tokio::fs`/`async_std::fs` are the async mirrors of `std::fs`; `async_fs` is
2108    // smol's fs crate; `fs_err` is a drop-in `std::fs` wrapper (its whole surface is fs I/O).
2109    if path.starts_with("std::fs::")
2110        || path.starts_with("tokio::fs::")
2111        || path.starts_with("async_std::fs::")
2112        || crate_name == "async_fs"
2113        || crate_name == "fs_err"
2114    {
2115        return Some("Fs");
2116    }
2117    // memmap2: only `MmapOptions::map*` (and the in-place `Mmap::flush`/`make_*` protection
2118    // changes / `remap`) actually issue the mmap/msync/mprotect/mremap syscall = Fs. The rest of the
2119    // crate is PURE: `MmapOptions::new`/setters BUILD the request, and once a region is mapped, reads
2120    // over it (`Mmap::len`/`is_empty`/`as_ptr`/`as_mut_ptr`/`deref` into the byte slice) are plain
2121    // memory access with no syscall. Whole-crate Fs fabricated Fs on those reads (a `m.len()` the
2122    // scanner's receiver inference routes to `memmap2::Mmap::len`). Match the syscall-issuing verbs;
2123    // everything else returns None (pure). `map*` covers `map`/`map_mut`/`map_exec`/`map_copy`/
2124    // `map_copy_read_only`/`map_raw`/`map_raw_read_only`/`map_anon`.
2125    if crate_name == "memmap2" {
2126        let m = path.rsplit("::").next().unwrap_or(path);
2127        if m.starts_with("map")
2128            || m == "flush"
2129            || m == "flush_async"
2130            || m == "flush_range"
2131            || m == "flush_async_range"
2132            || m == "remap"
2133            || m.starts_with("make_")
2134            || m == "advise"
2135            || m == "advise_range"
2136            || m == "lock"
2137            || m == "unlock"
2138        {
2139            return Some("Fs");
2140        }
2141        return None;
2142    }
2143    // tempfile: creating a temp file/dir touches the disk. Match the create/persist verbs (the
2144    // `Builder` setters — prefix/suffix/rand_bytes — stay pure). `persist`/`keep` rename/retain
2145    // the file on disk; `close` removes it.
2146    if crate_name == "tempfile"
2147        && (path.ends_with("::tempfile")
2148            || path.ends_with("::tempfile_in")
2149            || path.ends_with("::tempdir")
2150            || path.ends_with("::tempdir_in")
2151            || path.ends_with("NamedTempFile::new")
2152            || path.ends_with("NamedTempFile::new_in")
2153            || path.ends_with("TempDir::new")
2154            || path.ends_with("TempDir::new_in")
2155            || path.ends_with("::persist")
2156            || path.ends_with("::persist_noclobber")
2157            || path.ends_with("::keep"))
2158    {
2159        return Some("Fs");
2160    }
2161    // THE COVERAGE-GATE SWEEP (2026-08-27), verified against tempfile 3.27.0 source — the SIBLING
2162    // constructors/closers the create/persist verb list above never reached:
2163    //
2164    // `Builder::make`/`make_in` (lib.rs:716,739) are the crate's OWN documented escape hatch for a
2165    // caller-supplied factory (`Builder::new().make_in(dir, |path| UnixListener::bind(path))`) — real
2166    // disk creation via `util::create_helper`, same mechanism as `Builder::tempfile`/`tempfile_in`
2167    // two lines up, just a different entry verb.
2168    // `NamedTempFile::with_prefix`/`with_prefix_in`/`with_suffix`/`with_suffix_in` (file/mod.rs:630-677)
2169    // are one-call convenience wrappers documented as equivalent to `Builder::new().prefix(..).tempfile()`
2170    // — real creation, missing because the verb list matched `NamedTempFile::new`/`new_in` but not these.
2171    // `NamedTempFile::reopen` (file/mod.rs:951) calls the platform `imp::reopen`, a real `open`/`fstat`
2172    // pair (found the original file was replaced, or hands back a fresh handle to it).
2173    // `TempPath::close` (file/mod.rs:161) and `TempDir::close` (dir/mod.rs:470) `fs::remove_file`/
2174    // `remove_dir_all` the real path — `NamedTempFile::close` (file/mod.rs:727) is a thin `self.path.close()`
2175    // delegate to the same `TempPath::close`, so matching the `::close` suffix (crate-gated, and the ONLY
2176    // three `pub fn close` in this crate) catches it too without a separate rule.
2177    // `SpooledTempFile::set_len` (spooled.rs:134) calls `File::set_len` on the real disk file once the
2178    // in-memory buffer has spilled past `max_size` — the crate's own roll-over threshold, not a corner case.
2179    //
2180    // NOT included: `tempfile::create`/`create_named`/`reopen` (dir/imp/any.rs, file/imp/windows.rs,
2181    // file/imp/unix.rs) — despite being `pub fn`, `mod dir;`/`mod file;` are PRIVATE at the crate root
2182    // (lib.rs:202,204) with no re-export of the `imp` submodules, so no external consumer can ever name
2183    // these paths; the ratchet's generator guesses a crate-root alias for every candidate regardless of
2184    // whether one is real (the same "second, related shape" gap the previous pass's rusqlite/lettre
2185    // private-module findings already documented — restricted_types()/is_bare_pub check a type's or fn's
2186    // OWN visibility keyword, not its enclosing module chain). Removed from open.tsv rather than guessed.
2187    if crate_name == "tempfile"
2188        && (path == "tempfile::Builder::make"
2189            || path == "tempfile::Builder::make_in"
2190            || path == "tempfile::NamedTempFile::with_prefix"
2191            || path == "tempfile::NamedTempFile::with_prefix_in"
2192            || path == "tempfile::NamedTempFile::with_suffix"
2193            || path == "tempfile::NamedTempFile::with_suffix_in"
2194            || path == "tempfile::NamedTempFile::reopen"
2195            || path == "tempfile::SpooledTempFile::set_len"
2196            || path.ends_with("::close"))
2197    {
2198        return Some("Fs");
2199    }
2200    // glob: walks the filesystem to expand a pattern (the returned iterator reads directories).
2201    // `Pattern::matches` is pure string matching — match only the directory-walking entry points.
2202    if crate_name == "glob" && (path.ends_with("::glob") || path.ends_with("::glob_with")) {
2203        return Some("Fs");
2204    }
2205    // Password-hashing / KDF crates — the entropy tier (the TS engine's CTA lesson: an invisible
2206    // argon2 landed on exactly the call a security review cares about). In this engine's
2207    // verb-precise style the ENTROPY is the salt mint: `SaltString::generate(OsRng)` in the
2208    // password-hash API family, and bcrypt's `hash`/`hash_with_result` (salt minted internally).
2209    // Verification and explicit-salt hashing are deterministic recomputation — pure. `rand_core`
2210    // carries the OsRng source itself (otherwise the most common salt mint is invisible).
2211    if matches!(crate_name, "argon2" | "scrypt" | "pbkdf2" | "password_hash") {
2212        // SOUNDNESS R318 — `SaltString::generate` was this block's ONLY match target and the type was
2213        // DELETED upstream in password-hash 0.6.0 (0.5.0: 21 occurrences; 0.6.1: zero). Everything below
2214        // it fell through to `return None`, so all four crates asserted purity — including on
2215        // `argon2.hash_password(password)`, the one-argument DEFAULT TRAIT METHOD at
2216        // `password-hash-0.6.1/src/lib.rs:107` whose body is `let salt = try_generate_salt()?;`. That is
2217        // the most documented call shape in the family, minting OS entropy, reading pure, on crates whose
2218        // entire purpose is a security review.
2219        //
2220        // `ends_with`, NOT `contains`: `hash_password_with_salt` takes an explicit salt and is
2221        // deterministic recomputation — correctly PURE — and a `contains` match would fabricate `Rand`
2222        // on it. `hash_password_with_rng` DOES draw, from the caller's RNG, so it is charged.
2223        // The old `SaltString::generate` clause is kept: it is still the right answer for 0.5.x.
2224        if path.contains("SaltString::generate")
2225            || path.ends_with("::generate_salt")
2226            || path.ends_with("::try_generate_salt")
2227            // SOUNDNESS R330 — this suffix is a DEFAULT, refined by arity at the call site. `hash_password`
2228            // is one name with two signatures (see `password_hash_explicit_salt` below), and the path
2229            // cannot tell them apart. Charging here and NARROWING there is deliberate: a consumer that
2230            // never consults the refinement keeps the over-report, never the silence.
2231            || path.ends_with("::hash_password")
2232            || path.ends_with("::hash_password_with_rng")
2233        {
2234            return Some("Rand");
2235        }
2236        return None;
2237    }
2238    if crate_name == "bcrypt" {
2239        // SOUNDNESS R319 — this list was EXACTLY bcrypt's internal-salt surface at 0.15.1 and fell
2240        // behind by ADDITION, not by rename: 0.19.3 adds four more verbs that each document "the salt
2241        // is generated randomly using the OS randomness" and reach `getrandom::fill`. A stale-PATH
2242        // check could never have found this, because every old path still exists and still works —
2243        // a version ceiling catches additions, a path check only catches removals.
2244        // The explicit-salt family (`hash_with_salt`, `hash_with_salt_bytes`,
2245        // `non_truncating_hash_with_salt*`) stays PURE: the caller supplies the salt.
2246        if path.ends_with("::hash")
2247            || path.ends_with("::hash_with_result")
2248            || path.ends_with("::non_truncating_hash")
2249            || path.ends_with("::hash_bytes")
2250            || path.ends_with("::non_truncating_hash_bytes")
2251            || path.ends_with("::non_truncating_hash_with_result")
2252        {
2253            return Some("Rand");
2254        }
2255        return None;
2256    }
2257    if crate_name == "rand_core" {
2258        if path.contains("OsRng")
2259            || path.ends_with("::next_u32")
2260            || path.ends_with("::next_u64")
2261            || path.ends_with("::fill_bytes")
2262            // SOUNDNESS R333 — the FALLIBLE trait. rand_core 0.10 splits `RngCore` from `TryRngCore`,
2263            // and `SysRng` (the renamed `OsRng`) is fallible, so `try_next_u32` is the natural API on
2264            // it. `ends_with("::next_u32")` does NOT match `::try_next_u32`, so the modern spelling of
2265            // a real entropy draw read PURE. Third instance in one day, after R319 and R321, of the
2266            // same shape: an upstream rename is rarely just a rename — it arrives with an API SHAPE
2267            // change, and a suffix list written against the old shape stops covering the new one.
2268            || path.ends_with("::try_next_u32")
2269            || path.ends_with("::try_next_u64")
2270            || path.ends_with("::try_fill_bytes")
2271        {
2272            return Some("Rand");
2273        }
2274        return None;
2275    }
2276    // Randomness / entropy. `getrandom`/`fastrand` are effectful end-to-end. `rand` is NOT — it
2277    // mixes entropy/generation (effectful) with *pure* distribution constructors (`Uniform::new`,
2278    // `Normal::new`) and deterministic-seed constructors (`seed_from_u64`). Flagging the whole crate
2279    // over-reported those as `Rand`; match only the calls that actually consume randomness — the
2280    // entropy sources (`OsRng`, `thread_rng`/`rng`, `from_entropy`/`from_os_rng`) and the generation
2281    // verbs (`gen*`/`random*`/`fill*`/`sample*`/`next_u*`). A `Uniform::new` is now correctly pure.
2282    if crate_name == "getrandom" {
2283        return Some("Rand");
2284    }
2285    // fastrand: like `rand`, it mixes entropy-consuming generation (effectful) with PURE deterministic
2286    // pieces. `Rng::with_seed(42)` is a DETERMINISTIC seeded constructor (consumes no entropy — the same
2287    // seed gives the same stream), and `Rng::fork`/`Rng::clone` just split/copy existing state. Those are
2288    // PURE; whole-crate Rand fabricated Rand on them. The effect is the value-drawing methods (`u32`/
2289    // `usize`/`bool`/`f64`/`char`/`alphanumeric`/`choice`/`choose_multiple`/`shuffle`/`fill`/the range
2290    // forms) AND the entropy-seeded entry points: bare `Rng::new()` (seeds from the global entropy-backed
2291    // generator), `fastrand::seed`, and the top-level `fastrand::u32(..)` free functions (which draw from
2292    // the thread-local generator). `with_seed` is exempted explicitly; any other method on an `Rng`
2293    // (i.e. a value draw) is Rand.
2294    if crate_name == "fastrand" {
2295        let m = path.rsplit("::").next().unwrap_or(path);
2296        // Provably pure: deterministic seeded ctor + state split/copy.
2297        if m == "with_seed" || m == "fork" || m == "clone" {
2298            return None;
2299        }
2300        // Everything else fastrand exposes either draws a value or seeds from entropy → Rand. (The crate
2301        // has no pure data types beyond the `Rng` handle itself, so a non-draw stray would have to be a
2302        // method we don't recognise — keep the effect, the safe direction.)
2303        return Some("Rand");
2304    }
2305    if crate_name == "rand" {
2306        let rng_verb = path.ends_with("::gen")
2307            || path.ends_with("::gen_range")
2308            || path.ends_with("::gen_bool")
2309            || path.ends_with("::gen_ratio")
2310            || path.ends_with("::random")
2311            || path.ends_with("::random_range")
2312            || path.ends_with("::random_bool")
2313            || path.ends_with("::random_ratio")
2314            || path.ends_with("::random_iter") // rand 0.9 iterator generator
2315            || path.ends_with("::gen_iter")
2316            || path.ends_with("::fill")
2317            || path.ends_with("::fill_bytes")
2318            || path.ends_with("::try_fill")
2319            || path.ends_with("::try_fill_bytes")
2320            || path.ends_with("::sample")
2321            || path.ends_with("::sample_iter")
2322            || path.ends_with("::next_u32")
2323            || path.ends_with("::next_u64")
2324            // SOUNDNESS R333 — the FALLIBLE trait, in the `rand` block as well as `rand_core`'s. Two
2325            // verb lists answer one question ("is this a draw?") and only one had been widened, which
2326            // is why the first half of this fix moved nothing: correct code on a path the call does not
2327            // take. `TryRngCore`'s verbs are the natural API on the fallible `SysRng`.
2328            || path.ends_with("::try_next_u32")
2329            || path.ends_with("::try_next_u64")
2330            || path.ends_with("::thread_rng")
2331            || path.ends_with("::rng")
2332            || path.ends_with("::from_entropy")
2333            || path.ends_with("::from_os_rng");
2334        // `OsRng` is the OS entropy SOURCE, but `clone`/`fork`/`default` just copy or construct the
2335        // (zero-sized) handle and draw no entropy — pure, exactly like the `fastrand` arm's clone/fork
2336        // exemption above. The actual draws (`fill_bytes`/`next_u*`/…) are caught by `rng_verb`. Without
2337        // this exemption the blanket `contains("OsRng")` fabricated `Rand` on `OsRng::clone` (adversarial
2338        // review: OsRng is a unit struct, cloning consumes nothing).
2339        let m = path.rsplit("::").next().unwrap_or(path);
2340        let os_rng = path.contains("OsRng") && !matches!(m, "clone" | "fork" | "default");
2341        // SOUNDNESS R320 — …and the SAME clause for the type's CURRENT NAME. rand 0.10 renamed the OS
2342        // entropy source to `SysRng` and moved it to `getrandom`, re-exporting it as
2343        // `rand::rngs::SysRng` (`rand-0.10.2/src/rngs/mod.rs:119`). Measured, not assumed: candor
2344        // resolves the crate from the path the CONSUMER writes, so `rand::rngs::SysRng` arrives with
2345        // crate_name `rand` and lands here — NOT in getrandom's whole-crate exemption, which is what
2346        // R320 left open. The asymmetry that leaves was executed on a fixture: with `OsRng` as the
2347        // receiver an unrecognised verb charges `Rand` (the `contains` clause is the safety margin over
2348        // the verb list); with `SysRng` it read PURE. So the margin protected the DELETED spelling and
2349        // not its replacement, which is the wrong way round for a type whose only purpose is to draw
2350        // from the OS. Same construction exemption for the same reason — `SysRng` is a unit struct
2351        // (`getrandom-0.4.3/src/sys_rng.rs:34`), so copying the handle consumes nothing.
2352        let sys_rng = path.contains("SysRng") && !matches!(m, "clone" | "fork" | "default");
2353        // §E1 HIT COUNTER (`CANDOR_ALIAS_DEBUG`), for `bin/corpus-ab.py --mark`: a widened charge that
2354        // moves no rows is either inert or unreached, and those two print identically.
2355        if sys_rng && std::env::var("CANDOR_ALIAS_DEBUG").is_ok() {
2356            eprintln!("R320SYSRNG {path}");
2357        }
2358        if rng_verb || os_rng || sys_rng {
2359            return Some("Rand");
2360        }
2361        return None;
2362    }
2363    // Subprocess spawning. `tokio::process` is the async mirror of `std::process` — it exists
2364    // only to spawn/control subprocesses (`Command`/`Child`, no pure data types like std's
2365    // `Stdio`/`ExitStatus`/`exit`), so spawning through it is Exec just the same. Without this an
2366    // async app's `tokio::process::Command::new(..).spawn()` classified pure — a silent under-report
2367    // of subprocess execution, the dangerous direction (mirrors the tokio::fs/tokio::net coverage).
2368    if path.starts_with("std::process::Command")
2369        || path.starts_with("std::process::Child")
2370        || path.starts_with("tokio::process::Command")
2371        || path.starts_with("tokio::process::Child")
2372        || path.starts_with("async_std::process::Command")
2373        || path.starts_with("async_std::process::Child")
2374    {
2375        // PURE read-backs of the builder's stored fields / the cached pid — no spawn, no syscall — so the
2376        // whole-type Exec rule fabricated Exec on them (sweep [23]; mirrors the portable_pty getter carve-
2377        // out just below). get_program/get_args/get_envs/get_current_dir read the Command; Child::id reads
2378        // the cached pid. Every genuine verb (new/spawn/output/status/wait/kill) stays Exec.
2379        if path.ends_with("::get_program")
2380            || path.ends_with("::get_args")
2381            || path.ends_with("::get_envs")
2382            || path.ends_with("::get_current_dir")
2383            || path.ends_with("Child::id")
2384        {
2385            return None;
2386        }
2387        return Some("Exec");
2388    }
2389    // portable_pty / async_process are whole-crate Exec EXCEPT for the proven-pure surface they expose:
2390    // the `CommandBuilder` GETTERS (`get_argv`/`get_cwd`/`get_env`/`as_unix_command_line`…) read back
2391    // configuration, and the PURE DATA types (`PtySize::default`, `ExitStatus`/`Stdio`/`CommandBuilder`
2392    // construction/setters). The earlier `is_cmd_naming_method` fix stopped the head-refinement LEAK, but
2393    // the BASE Exec still fabricated on these accessors (a `cmd.get_cwd()` the scanner routes to
2394    // `portable_pty::CommandBuilder::get_cwd`). Subtract the read-back getters and the obvious pure
2395    // ctors/setters; the spawn/wait/exec surface (`spawn_command`/`openpty`/`wait`/`kill`/`exec`…) keeps
2396    // Exec. SUBTRACT only what is provably pure — when unrecognised, KEEP Exec (the safe direction).
2397    if crate_name == "async_process" || crate_name == "portable_pty" {
2398        let m = path.rsplit("::").next().unwrap_or(path);
2399        // THE COVERAGE-GATE SWEEP (2026-08-27): `CommandBuilder::get_shell` (cmdbuilder.rs:544, unix)
2400        // LOOKS like a config read-back getter — same `get_` naming as the pure getters below — but its
2401        // unix body calls `nix::unistd::access(shell, X_OK)`, a real filesystem-access syscall, before
2402        // falling back to a password-database lookup if `$SHELL` isn't set or isn't executable. Carved
2403        // out of the `get_` prefix exemption BEFORE it, not folded into it — the one getter this crate
2404        // exposes that is not actually pure. Verified against portable-pty 0.9.0.
2405        if m == "get_shell" {
2406            return Some("Fs");
2407        }
2408        // configuration read-back getters — pure (no spawn).
2409        if m.starts_with("get_") || m == "as_unix_command_line" {
2410            return None;
2411        }
2412        // pure data-type ctors/setters/derives that NAME no program and spawn nothing.
2413        if matches!(
2414            m,
2415            "default" | "new" | "piped" | "null" | "inherit" | "from_raw_fd"
2416                | "arg" | "args" | "arg0" | "env" | "envs" | "env_clear" | "env_remove"
2417                | "cwd" | "current_dir" | "rows" | "cols"
2418                | "clone" | "fmt" | "eq" | "ne" | "hash"
2419        ) {
2420            return None;
2421        }
2422        return Some("Exec");
2423    }
2424    // duct: a subprocess-orchestration crate. `cmd()`/`cmd!` only *build* an Expression; the
2425    // spawn/wait happens at `run`/`read`/`start`. Match the execution verbs, not the builder.
2426    if crate_name == "duct"
2427        && (path.ends_with("::run")
2428            || path.ends_with("::read")
2429            || path.ends_with("::start")
2430            || path.ends_with("::read_chars")
2431            // `Expression::reader` (lib.rs:357) calls the already-covered `.start()` internally to
2432            // launch the child and hands back a streaming `ReaderHandle` — a distinct public entry
2433            // point from `start` itself, so the suffix match above never reached it.
2434            || path.ends_with("Expression::reader"))
2435    {
2436        return Some("Exec");
2437    }
2438    if path.starts_with("std::env::") {
2439        return Some("Env");
2440    }
2441    // dotenvy / dotenv: load environment variables (reading a `.env` file and mutating the process
2442    // environment). Match the load/read entry points; `Error`/builder types stay pure.
2443    if matches!(crate_name, "dotenvy" | "dotenv")
2444        && (path.ends_with("::dotenv")
2445            || path.ends_with("::dotenv_override")
2446            || path.ends_with("::from_path")
2447            || path.ends_with("::from_path_override")
2448            || path.ends_with("::from_filename")
2449            || path.ends_with("::from_filename_override")
2450            || path.ends_with("::from_read")
2451            || path.ends_with("::from_read_override")
2452            || path.ends_with("::load")
2453            || path.ends_with("::var")
2454            || path.ends_with("::vars"))
2455    {
2456        return Some("Env");
2457    }
2458    // THE COVERAGE-GATE SWEEP (2026-08-27), verified against dotenv 0.15.0 and dotenvy 0.15.7
2459    // (byte-identical shape in both crates) — the ITERATOR-returning siblings of the load verbs above,
2460    // which return the parsed pairs instead of mutating the environment but still touch disk to get
2461    // them: `dotenv_iter`/`from_filename_iter` (lib.rs) resolve and open a `.env`-shaped file exactly
2462    // like `dotenv`/`from_filename` two lines up (same `Finder::new().find()` call); `from_path_iter`
2463    // opens the given path directly. Bucketed `Env` for consistency with the rest of this family rather
2464    // than `Fs` (self-scan's raw signal): the crate's OWN purpose is env-var loading, and splitting the
2465    // iterator variants into a different effect bucket from their non-iterator siblings would be an
2466    // arbitrary distinction a reviewer gains nothing from.
2467    //
2468    // NOT included: `Finder::find` / the free fn `find` (find.rs) — both are used only via a PRIVATE
2469    // `use crate::find::Finder;` (no `pub use`) inside a private `mod find;` (lib.rs), so neither
2470    // `dotenv(y)::Finder` nor `dotenv(y)::find` is a path any external consumer can compile a call to;
2471    // the ratchet's generator still guesses a crate-root alias for every candidate (the same private-
2472    // module shape as tempfile's `imp::` functions above). Removed from open.tsv rather than guessed.
2473    if matches!(crate_name, "dotenvy" | "dotenv")
2474        && (path.ends_with("::dotenv_iter")
2475            || path.ends_with("::from_filename_iter")
2476            || path.ends_with("::from_path_iter"))
2477    {
2478        return Some("Env");
2479    }
2480    // Wall-clock reads. Match the `now` accessor precisely (ends_with), not any path
2481    // containing the substring "now". The `time` crate (distinct from `std::time`/`chrono`)
2482    // reads the clock via `now_utc`/`now_local` (and the deprecated `Instant::now`).
2483    if (crate_name == "chrono" || path.starts_with("std::time::")) && path.ends_with("::now") {
2484        return Some("Clock");
2485    }
2486    if crate_name == "time"
2487        && (path.ends_with("::now_utc") || path.ends_with("::now_local") || path.ends_with("::now"))
2488    {
2489        return Some("Clock");
2490    }
2491    // `tracing`: same principle as the `log` facade below — the crate's TYPES are pure data, so match
2492    // the emit, not the whole crate. The actual program output is the macro-expanded
2493    // `Subscriber::event`/`event!`/`Span::*enter*` dispatch and the `Span::new*`/`Span::record`
2494    // recording path that drives the subscriber. The data-type accessors — `Level::as_str`,
2495    // `Span::is_disabled`/`metadata`/`id`, and constructing/reading `Level`/`LevelFilter`/`Span`/
2496    // `Event`/`Metadata`/`Field`/`FieldSet`/`Id` — are PURE (no output is produced), so whole-crate Log
2497    // fabricated Log on them. Match the emit verbs; everything else returns None.
2498    if crate_name == "tracing" {
2499        let m = path.rsplit("::").next().unwrap_or(path);
2500        // The user-facing emit MACROS (`tracing::info!`/`warn!`/…) — candor-scan is pre-expansion, so it
2501        // sees the raw macro path `tracing::info`, not the expanded `__tracing`/`Subscriber::event` the
2502        // deep (post-expansion) engine sees. Only the macro names; the pure DATA types (Level/Span/Event)
2503        // have other tails and stay None.
2504        if m == "trace" || m == "debug" || m == "info" || m == "warn" || m == "error"
2505            || m == "trace_span" || m == "debug_span" || m == "info_span" || m == "warn_span"
2506            || m == "error_span" || m == "span"
2507            || m == "event"
2508            || m == "new_span"
2509            || m == "record"
2510            || m == "record_follows_from"
2511            || m == "enter"
2512            || m == "exit"
2513            || m == "in_scope"
2514            || m == "entered"
2515            || path.contains("::__macro_support")
2516            || path.contains("::__tracing")
2517            || path.contains("Subscriber::event")
2518            || path.contains("Subscriber::new_span")
2519            || path.contains("Subscriber::enter")
2520            || path.contains("Subscriber::exit")
2521        {
2522            return Some("Log");
2523        }
2524        return None;
2525    }
2526    // The `log` facade: its macros route through `log::__private_api`; the crate's types
2527    // (`Level`, `LevelFilter`) are pure, so match the logging entry, not the whole crate.
2528    if crate_name == "log" {
2529        // Expanded macro form (deep engine) OR the raw user-facing macro names (candor-scan, pre-expansion).
2530        // `log::Level`/`LevelFilter`/`Record`/`Metadata` have other tails, so the type surface stays pure.
2531        let m = path.rsplit("::").next().unwrap_or(path);
2532        if path.contains("::__private_api")
2533            || m == "error" || m == "warn" || m == "info" || m == "debug" || m == "trace" || m == "log"
2534        {
2535            return Some("Log");
2536        }
2537    }
2538    // Compiler diagnostic emission — the ONE genuinely effectful operation in the otherwise-pure
2539    // rustc_* surface (a dylint lint's actual OUTPUT: it writes warnings/errors to the compiler's
2540    // diagnostic sink). Classified `Log` (same family as `tracing`/`log` — program output). Match the
2541    // emission verbs precisely; rustc_lint/rustc_errors are mostly pure types (Lint, LintId, the Diag
2542    // BUILDERS), and only the terminal `emit`/`emit_span_lint` actually produces output.
2543    if crate_name == "rustc_lint"
2544        && (path.ends_with("::emit_span_lint")
2545            || path.ends_with("::span_lint")
2546            || path.ends_with("::span_lint_hir"))
2547    {
2548        return Some("Log");
2549    }
2550    if crate_name == "rustc_errors"
2551        && (path.ends_with("::emit")
2552            || path.ends_with("::emit_diagnostic")
2553            || path.ends_with("::emit_now"))
2554    {
2555        return Some("Log");
2556    }
2557    // arboard: the effectful surface is the `Clipboard` handle's read/write verbs (each talks to the
2558    // OS clipboard / X11/Wayland/Win32/NSPasteboard server). The data types — chiefly `arboard::Error`
2559    // (whose `Display`/`to_string` formatting is pure) and the `ImageData`/`GetExtLinux`/`SetExtLinux`
2560    // option types — are PURE, so whole-crate Clipboard fabricated Clipboard on e.g. an error
2561    // `to_string()`. Match the handle verbs; everything else returns None. `Clipboard::new` opens the
2562    // connection to the clipboard server, so it's an effect too; `get`/`set` return the
2563    // builder-then-read `Get`/`Set` cursors whose `text`/`image`/`html` terminals do the I/O.
2564    //
2565    // THE ~79-CRATE R59-CLASS AUDIT (2026-08-28), verified against arboard 3.6.1: `file_list`
2566    // (lib.rs:205,251, `Get::file_list`/`Set::file_list`) is the SAME builder-then-terminal shape as
2567    // `text`/`image`/`html` two lines up — reading/writing the clipboard's file-path list — but was
2568    // missing, not because it's ambiguous (it's the only `file_list` in the crate) but because
2569    // `eval/coverage-gate/generate.py`'s own generator only triggers on a self-scan `inferred` set
2570    // containing Fs/Net/Db/Exec; Clipboard isn't in that trigger set, so a missing Clipboard verb is
2571    // structurally invisible to the completeness gate regardless of phrasing. `Clear::default`
2572    // (lib.rs:265) is `Clipboard::clear`'s own documented alternate entry point
2573    // (`clear() { self.clear_with().default() }`, lib.rs:156-158) — the SAME "sibling constructor"
2574    // shape as `ignore::Walk::new` beside `WalkBuilder::build`; `clear_with()` itself doesn't share
2575    // `clear`'s leaf, so neither the constructor nor its terminal was covered. `default` is otherwise
2576    // unused in this crate (no derived `Default` impls), so the bare leaf carries no fabrication risk
2577    // once crate-gated.
2578    if crate_name == "arboard" {
2579        let m = path.rsplit("::").next().unwrap_or(path);
2580        if m == "new"
2581            || m == "get"
2582            || m == "set"
2583            || m == "clear"
2584            || m == "get_text"
2585            || m == "set_text"
2586            || m == "set_html"
2587            || m == "get_image"
2588            || m == "set_image"
2589            || m == "text"
2590            || m == "image"
2591            || m == "html"
2592            || m == "file_list"
2593            || m == "default"
2594        {
2595            return Some("Clipboard");
2596        }
2597        return None;
2598    }
2599    // ── Coverage-differential additions (calibrated against each crate's real API; see the per-crate
2600    //    notes). All verb-keyed + crate-gated, with the pure builder/config/data surface returning None.
2601
2602    // `etcetera` — XDG/known-folder base+app directory resolution. Each dir ACCESSOR reads the
2603    // environment at call time (`$HOME`/`$XDG_*` on Unix, `%APPDATA%`/`%LOCALAPPDATA%` on Windows), and
2604    // the `choose_*`/`home_dir` entry points read `$HOME`. The `AppStrategyArgs` data struct and the
2605    // strategy types themselves are PURE. (Found DISCLOSED-but-unmodeled in 3/4 differential projects.)
2606    if crate_name == "etcetera" {
2607        let m = path.rsplit("::").next().unwrap_or(path);
2608        if m == "home_dir"
2609            || m == "choose_base_strategy" || m == "choose_native_strategy" || m == "choose_app_strategy"
2610            || m == "config_dir" || m == "data_dir" || m == "cache_dir"
2611            || m == "state_dir" || m == "runtime_dir" || m == "data_local_dir"
2612        {
2613            return Some("Env");
2614        }
2615        return None;
2616    }
2617    // `sqlx-core` (crate `sqlx_core`) — the execution terminals under the sqlx core (the `sqlx` builder
2618    // table maps `sqlx::query*`; here it's the core `Executor`/`Connection`/`Pool` round-trips). Opening
2619    // the connection is the network boundary (Net); the query/transaction round-trips are Db. The
2620    // `*Options`/query-builder/row data types are PURE. Crate-gated so the generic verbs never spread.
2621    if crate_name == "sqlx_core" {
2622        if path.ends_with("::connect") || path.ends_with("::connect_with") {
2623            return Some("Net");
2624        }
2625        if path.ends_with("::fetch") || path.ends_with("::fetch_all") || path.ends_with("::fetch_one")
2626            || path.ends_with("::fetch_optional") || path.ends_with("::fetch_many")
2627            || path.ends_with("::execute") || path.ends_with("::execute_many")
2628            || path.ends_with("::prepare") || path.ends_with("::prepare_with")
2629            || path.ends_with("::acquire") || path.ends_with("::begin") || path.ends_with("::ping")
2630        {
2631            return Some("Db");
2632        }
2633        // THE COVERAGE-GATE SWEEP (2026-08-27), verified against sqlx-core 0.8.6/0.9.0 (identical
2634        // shape in both) — the free-function surface under `pub mod fs`/`pub mod net::tls`/
2635        // `pub mod migrate`, none of which end in the connect/fetch/execute verbs above:
2636        //
2637        // `fs::{read,read_to_string,create_dir_all,remove_file,remove_dir,remove_dir_all,read_dir}`
2638        // (fs.rs) are direct `std::fs::*` calls off-loaded to `spawn_blocking` — sqlx's OWN async
2639        // filesystem shim, used by the migrator to read `.sql` files and by SQLite to manage on-disk
2640        // databases. `net::tls::handshake` (net/tls/mod.rs:69) is the real TLS handshake dispatch
2641        // reqwest/ureq-style crates already model — sqlx has its OWN copy because it drives the
2642        // handshake over its own `Socket` trait rather than a `TcpStream` directly.
2643        // `migrate::resolve_blocking`/`resolve_blocking_with_config` (migrate/source.rs:151,156) are
2644        // `#[doc(hidden)]` but still `pub use`-exported at `sqlx_core::migrate` (mod.rs:16) — real,
2645        // callable, and reads the migrations directory off disk (`fs::read_dir` + per-file `canonicalize`).
2646        //
2647        // NOT included: `net::tls::tls_rustls::RustlsSocket::poll_{flush,read_ready,write_ready,
2648        // shutdown}` — `RustlsSocket` is declared inside `mod tls_rustls;` (net/tls/mod.rs), which is
2649        // PRIVATE with no re-export, so no external consumer can ever name it (the same private-module
2650        // shape as tempfile's `imp::` functions above). Removed from open.tsv rather than guessed.
2651        if path == "sqlx_core::fs::read"
2652            || path == "sqlx_core::fs::read_to_string"
2653            || path == "sqlx_core::fs::create_dir_all"
2654            || path == "sqlx_core::fs::remove_file"
2655            || path == "sqlx_core::fs::remove_dir"
2656            || path == "sqlx_core::fs::remove_dir_all"
2657            || path == "sqlx_core::fs::read_dir"
2658            || path.ends_with("::migrate::resolve_blocking")
2659            || path.ends_with("::migrate::resolve_blocking_with_config")
2660            || path == "sqlx_core::config::Config::try_from_path"
2661            || path == "sqlx_core::Config::try_from_path"
2662            || path == "sqlx_core::config::Config::try_from_path_or_default"
2663            || path == "sqlx_core::Config::try_from_path_or_default"
2664            || path == "sqlx_core::config::Config::try_from_crate_or_default"
2665            || path == "sqlx_core::Config::try_from_crate_or_default"
2666        {
2667            return Some("Fs");
2668        }
2669        if path.ends_with("::net::tls::handshake") {
2670            return Some("Net");
2671        }
2672        return None;
2673    }
2674    // `walkdir` — recursive directory traversal. Charged at `WalkDir::new` (construction), the SAME
2675    // point `ignore::WalkBuilder::build`/`glob::glob` are charged, and NOT at `IntoIter::next` (driving
2676    // the iterator) as this rule originally read. The disk read (`read_dir`+`stat`) is technically lazy
2677    // — nothing happens until the value is iterated — but `.next()` is reached ONLY through a receiver
2678    // typed as `walkdir::IntoIter`, and candor-scan's receiver-typing (`ctor_type`/`resolve_recv_type`)
2679    // hard-blocks the `.into_iter()` verb (a guard against fabricating onto a DIFFERENT std type, e.g.
2680    // `Vec::into_iter()` -> `std::vec::IntoIter`) with no per-crate exception for the SAME-crate case.
2681    // `WalkDir::into_iter()` returns `walkdir::IntoIter` (same crate as `WalkDir` itself, exactly the
2682    // shape the blocklist exists to protect, not the shape it should be blocking) — so every idiomatic
2683    // form (`for e in WalkDir::new(p)`, `.into_iter().count()`, `.into_iter().filter_map(..)`, an
2684    // untyped `let it = ...into_iter(); it.next()`) never reaches a typed `IntoIter::next` receiver and
2685    // read silent-pure under the OLD rule, with `deny Fs` exiting 0 over code that walks the filesystem.
2686    // Charging at `WalkDir::new` needs no receiver typing at all — it's a plain `Expr::Call`, robust to
2687    // however the iterator is later consumed. `max_depth`/`follow_links`/`sort_by`/`into_iter` (the
2688    // BUILDER chain, no I/O until pulled) and the cached `DirEntry::path`/`file_name`/`file_type`/`depth`
2689    // accessors (`file_type` makes NO syscall) stay PURE — matched by nothing here, so they fall through.
2690    // The `IntoIter::next`/`DirEntry::metadata` rule is KEPT, not dead: it still fires whenever the
2691    // concrete `walkdir::IntoIter` type reaches `.next()` by a route the blocklist doesn't gate — an
2692    // EXPLICIT type annotation (`let it: walkdir::IntoIter = ...`), a struct field declared with that
2693    // type, or a local fn's declared return type — real, if rarer, shapes than the inline-chain idiom.
2694    // (Companion to the already-modeled `ignore`.)
2695    if crate_name == "walkdir" {
2696        if path.ends_with("::WalkDir::new")
2697            || path.ends_with("::IntoIter::next")
2698            || path.ends_with("::DirEntry::metadata")
2699        {
2700            return Some("Fs");
2701        }
2702        return None;
2703    }
2704    // `filetime` — file-timestamp mutation. The `set_*` free fns issue utimes/utimensat/futimens (Fs).
2705    // `FileTime::now` reads the system clock (Clock). The `FileTime::from_*`/`zero` value constructors
2706    // (incl. `from_last_modification_time(&Metadata)` etc., which read an ALREADY-loaded `&Metadata`, not
2707    // the disk) and the `seconds`/`nanoseconds` accessors are PURE.
2708    if crate_name == "filetime" {
2709        if path.ends_with("::set_file_mtime") || path.ends_with("::set_file_atime")
2710            || path.ends_with("::set_file_times") || path.ends_with("::set_symlink_file_times")
2711            || path.ends_with("::set_file_handle_times")
2712        {
2713            return Some("Fs");
2714        }
2715        if path.ends_with("::FileTime::now") {
2716            return Some("Clock");
2717        }
2718        return None;
2719    }
2720    // `execute` — the `Execute` trait that extends `std::process::Command` with run helpers. The
2721    // `execute*` verbs SPAWN a child process (Exec). The `execute::command`/`shell` free fns and the
2722    // `command!`/`command_args!` macros only BUILD a Command (no spawn) and stay PURE.
2723    if crate_name == "execute" {
2724        if path.contains("::execute") {
2725            return Some("Exec");
2726        }
2727        return None;
2728    }
2729    // `ctrlc` — installs an OS signal handler (Unix SIGINT/SIGTERM/SIGHUP, Windows CTRL_C_EVENT) and
2730    // spawns its handler thread. Signals are an inter-process control channel, so the closest bucket is
2731    // Ipc (candor has no dedicated Signal effect; same judgment as routing SysV/pipe IPC to Ipc).
2732    if crate_name == "ctrlc" {
2733        if path.ends_with("::set_handler") || path.ends_with("::try_set_handler") {
2734            return Some("Ipc");
2735        }
2736        return None;
2737    }
2738    // `clap` — argument parsing. ONLY the terminals that read `std::env::args_os` at call time are an
2739    // effect (Env): `get_matches`/`get_matches_mut`/`try_get_matches` and the derive `parse`/`try_parse`.
2740    // clap is MOSTLY PURE: the ENTIRE builder surface (`Command::new`/`arg`/`about`/`Arg::new`) stays
2741    // None, and crucially the `*_from`/`*_parse_from` variants take an EXPLICIT iterator (they do NOT
2742    // read argv) so they stay pure too.
2743    //
2744    // THE ~79-CRATE R59-CLASS AUDIT (2026-08-28): this file used to leave `Arg::env` unmodeled, calling
2745    // bare `::env` "too generic to gate safely" — the same words used for libc's genuinely ambiguous fd
2746    // verbs. It isn't the same shape: `Arg::env(name)` calls `env::var_os(&name)` DIRECTLY at builder
2747    // time (verified against clap_builder 4.6.6, builder/arg.rs:2205-2213 — real, immediate, not
2748    // deferred to `get_matches()`), and — unlike a bare fd, which could be Fs/Net/Ipc — `clap_builder`
2749    // has exactly ONE `pub fn` ending `::env` in its entire source (`Arg::env`; the deprecated
2750    // `Arg::env_os` is a one-line delegate to it). This whole match arm is already crate-gated on
2751    // `crate_name == "clap"`, so no ambiguity survives to fabricate on: a fixture proved the untreated
2752    // gap silently vanishes the function ("functions": [] — the exact R59 shape, worse than an
2753    // uncalibrated dependency, since `clap` is fully `CALIBRATED_CRATES` and the miss reads as
2754    // reviewed-pure rather than disclosed). Classified, not carved into
2755    // `CALIBRATED_BUT_PARTIAL_CRATES`, because the effect IS unambiguous once actually checked.
2756    if crate_name == "clap" {
2757        if path.ends_with("::get_matches") || path.ends_with("::get_matches_mut")
2758            || path.ends_with("::try_get_matches")
2759            || path.ends_with("::parse") || path.ends_with("::try_parse")
2760            || path.ends_with("::env") || path.ends_with("::env_os")
2761        {
2762            return Some("Env");
2763        }
2764        return None;
2765    }
2766    // `jiff` — date/time. `Timestamp::now`/`Zoned::now`/`Zoned::now_with` read the wall clock (Clock).
2767    // `tz::TimeZone::system`/`get` and `tz::db().get` read the system tzdb files from disk
2768    // (`/etc/localtime`, `/usr/share/zoneinfo`; `system` is also `$TZ`-overridable — Fs is the dominant
2769    // op, modeled as Fs). The `Span`/`civil` date math and `Timestamp`/`Zoned` arithmetic are PURE.
2770    if crate_name == "jiff" {
2771        if path.ends_with("::now") || path.ends_with("::now_with") {
2772            return Some("Clock");
2773        }
2774        if path.ends_with("::TimeZone::system") || path.ends_with("::TimeZone::get")
2775            || path.ends_with("::TimeZoneDatabase::get")
2776            // `TimeZone::try_system` (tz/timezone.rs:391) is `TimeZone::system`'s fallible sibling —
2777            // same `crate::tz::system::get(crate::tz::db())` call, real localtime/zoneinfo disk read.
2778            || path.ends_with("::TimeZone::try_system")
2779        {
2780            return Some("Fs");
2781        }
2782        return None;
2783    }
2784    // `env_logger` — installs the global logger and emits to stderr; reads `RUST_LOG`/`RUST_LOG_STYLE`.
2785    // The init terminals are the effect (Log — program output, same family as `log`/`tracing`). The
2786    // `Builder::new`/`build` and the format/filter/target config setters are PURE.
2787    if crate_name == "env_logger" {
2788        if path.ends_with("::init") || path.ends_with("::try_init")
2789            || path.ends_with("::init_from_env") || path.ends_with("::try_init_from_env")
2790        {
2791            return Some("Log");
2792        }
2793        return None;
2794    }
2795    // `dialoguer` — interactive terminal prompts. The `interact*` verbs read stdin + write the tty (a
2796    // console dialogue with the user — Ipc, like the other local-channel effects). The
2797    // `with_prompt`/`default`/`items`/`validate_with` BUILDERS are PURE.
2798    if crate_name == "dialoguer" {
2799        if path.ends_with("::interact") || path.ends_with("::interact_on")
2800            || path.ends_with("::interact_text") || path.ends_with("::interact_text_on")
2801            || path.ends_with("::interact_opt") || path.ends_with("::interact_on_opt")
2802        {
2803            return Some("Ipc");
2804        }
2805        // `Editor::edit` (edit.rs:93) writes the caller's string to a real tempfile, spawns
2806        // `$VISUAL`/`$EDITOR` on it via `process::Command::spawn().wait()`, then reads the result back
2807        // — a real subprocess launch, not a terminal-dialogue read/write like the verbs above.
2808        if path.ends_with("Editor::edit") {
2809            return Some("Exec");
2810        }
2811        // WIDENED-CORE AUDIT (2026-08-28): `Editor::new`/`Editor::default` (edit.rs:54,44) call
2812        // `get_default_editor()` (edit.rs:31), which reads `env::var_os("VISUAL")` then `("EDITOR")`
2813        // IMMEDIATELY at construction — a real, independent Env read a consumer triggers just by
2814        // building an `Editor`, whether or not `.edit()` is ever called (the SAME "builder-time env
2815        // read, separate from the terminal verb" shape as `clap::Arg::env`, R59-class). Verified against
2816        // dialoguer 0.12.0: `get_default_editor` is the ONLY caller of either `env::var_os`, so there is
2817        // no ambiguity gating this to just these two constructors.
2818        if path.ends_with("Editor::new") || path.ends_with("Editor::default") {
2819            return Some("Env");
2820        }
2821        return None;
2822    }
2823    // `tracing_subscriber` — the subscriber that gives `tracing` somewhere to go. TWO effects, and the
2824    // filing said "Log/Fs": VERIFIED against 0.3.23, the Fs half is WRONG.
2825    //
2826    //   Log — `fmt/fmt_layer.rs:749` defaults `make_writer: io::stdout`, so the fmt INIT terminals install
2827    //         a subscriber that writes program output. Same family as `log`/`tracing`/`env_logger`.
2828    //   Env — `fmt/mod.rs:1219` reads `RUST_LOG` on the `init()` path, `fmt_layer.rs` reads `NO_COLOR`,
2829    //         and `filter/env/builder.rs:189,203` read `env::var(self.env_var_name())`.
2830    //
2831    // NOT Fs. The only `std::fs` in the crate is `impl MakeWriter for std::fs::File` — the crate ACCEPTING
2832    // a caller-supplied File, not opening one. The caller's `File::create` is classified on the caller, so
2833    // charging Fs here would double-count, exactly the `serde_json::from_reader` caveat one crate over.
2834    //
2835    // The builders (`fmt()`, `layer()`, `with_writer`, `with_target`, `EnvFilter::new`) are PURE: they
2836    // describe a subscriber. Only the INIT terminals install one, and only the from-env constructors read.
2837    if crate_name == "tracing_subscriber" {
2838        if path.ends_with("::init") || path.ends_with("::try_init") {
2839            return Some("Log");
2840        }
2841        if path.ends_with("::from_default_env") || path.ends_with("::try_from_default_env")
2842            || path.ends_with("::from_env") || path.ends_with("::from_env_lossy")
2843            || path.ends_with("::try_from_env")
2844        {
2845            return Some("Env");
2846        }
2847        return None;
2848    }
2849    // `crossterm` — the terminal driver. The tty is a USER DIALOGUE CHANNEL, so this is Ipc, matching the
2850    // ruling `dialoguer`/`console`/`terminal_colorsaurus` already carry rather than a new one.
2851    //
2852    // VERIFIED against crossterm-0.28.1 rather than assumed: `command.rs` `execute`/`queue` end in
2853    // `self.flush()?` on the writer (real code, not a doc example), `event::read`/`poll` read tty input,
2854    // and `terminal::{enable,disable}_raw_mode` + `size`/`window_size` talk to the device.
2855    //
2856    // `size`/`window_size`/`is_raw_mode_enabled` ARE classified, and that is deliberate: once a crate is
2857    // CALIBRATED every unmatched path becomes a PURITY CLAIM rather than a disclosed blind spot, so a tty
2858    // ioctl left to fall through would be claimed pure. The genuinely pure surface — the Command VALUE
2859    // types (`Print`, `MoveTo`, `SetForegroundColor`), the style/event data types — carries none of these
2860    // tails and stays pure correctly.
2861    if crate_name == "crossterm" {
2862        if path.ends_with("::execute") || path.ends_with("::queue")
2863            || path.ends_with("::event::read") || path.ends_with("::event::poll")
2864            || path.ends_with("::enable_raw_mode") || path.ends_with("::disable_raw_mode")
2865            || path.ends_with("::size") || path.ends_with("::window_size")
2866            || path.ends_with("::is_raw_mode_enabled")
2867        {
2868            return Some("Ipc");
2869        }
2870        // `terminal::supports_keyboard_enhancement` (terminal/sys/unix.rs:188, re-exported `pub use
2871        // sys::supports_keyboard_enhancement` in terminal.rs) drives the SAME channel as
2872        // `event::read`/`enable_raw_mode` above (it toggles raw mode, then reads/polls terminal events
2873        // to detect the kitty keyboard protocol) — bucketed `Ipc` for consistency with the rest of this
2874        // tty-dialogue family rather than the `Fs` self-scan's raw signal reports (that signal traces
2875        // through the crate's internal event source opening `/dev/tty` as a fallback fd, the same
2876        // primitive `tty_fd` below wraps — not a distinct effect from the terminal channel itself).
2877        //
2878        // NOT modelled: `tty_fd` (terminal/sys/file_descriptor.rs:124) — declared inside `pub(crate) mod
2879        // sys;` (terminal.rs:99), so despite being `pub fn` it is unreachable from outside the crate
2880        // (only used internally by the event source). Removed from open.tsv rather than guessed.
2881        if path.ends_with("::supports_keyboard_enhancement") {
2882            return Some("Ipc");
2883        }
2884        return None;
2885    }
2886    // `ratatui` — the TUI renderer, and the single loudest source of disclosed-blind calls measured in the
2887    // 2026-07-14 four-ecosystem sweep (3,345 across three real repos). The backlog filed it as
2888    // "mark reviewed-pure"; VERIFYING against ratatui-0.29.0 REFUTES that for part of the surface:
2889    // `terminal/terminal.rs` `draw`/`flush`/`clear`/`autoresize`/`hide_cursor`/`show_cursor` end in a
2890    // backend flush, and `backend/` writes to the terminal. Marking the whole crate pure would have
2891    // claimed purity over the one API that actually writes.
2892    //
2893    // So the split is where the sweep's noise actually is: the BULK of those 3,345 calls are widget,
2894    // layout, buffer, style and text constructors — genuinely pure, and now covered rather than disclosed.
2895    // The Terminal/backend verbs are Ipc, same channel as crossterm underneath them.
2896    if crate_name == "ratatui" {
2897        // CARVE-OUT FIRST: `widgets::canvas` is an IN-MEMORY grid. `Context::draw(&shape)` sets
2898        // `self.dirty` and paints into a `Painter` — no terminal, no writer, provably pure — but it ends
2899        // in `::draw` and the tails below would have charged it `Ipc`. MEASURED as a live fabrication on a
2900        // fixture (`plot(ctx) -> ['Ipc']`) before this line existed, and it is a HOT path: a TUI drawing
2901        // charts or maps calls it per shape per frame.
2902        //
2903        // A DENYLIST (carve out the proven-pure module) rather than an allowlist of `Terminal::`, per the
2904        // family rule: an allowlist silently under-reports whatever it forgot, and the write surface here
2905        // is Terminal AND the backends (`CrosstermBackend::flush`), so pinning to `Terminal::` would drop
2906        // a direct backend call. Reading the crate, canvas is the only module whose methods collide with
2907        // these tails.
2908        if path.contains("::canvas::") {
2909            return None;
2910        }
2911        if path.ends_with("::draw") || path.ends_with("::try_draw") || path.ends_with("::flush")
2912            || path.ends_with("::autoresize") || path.ends_with("::clear")
2913            || path.ends_with("::hide_cursor") || path.ends_with("::show_cursor")
2914            || path.ends_with("::insert_before")
2915            || path.ends_with("::set_cursor_position") || path.ends_with("::get_cursor_position")
2916        {
2917            return Some("Ipc");
2918        }
2919        return None;
2920    }
2921    // `console` — terminal handle + styling. The `Term` read/write verbs do tty I/O (Ipc, the user
2922    // dialogue channel; note there is NO `write_str` — `Term` impls `io::Write`). The free-fn terminal
2923    // detection (`colors_enabled`/`user_attended`) reads `CLICOLOR`/`CLICOLOR_FORCE` (Env). The `Style`
2924    // color/format methods and the text utils (`strip_ansi_codes`/`pad_str`/`measure_text_width`) are PURE.
2925    //
2926    // THE ~79-CRATE R59-CLASS AUDIT (2026-08-28): the note above ("no `write_str` — `Term` impls
2927    // `io::Write`") RECORDED the trait impl without covering it. `Term::write`/`Term::flush` (console
2928    // 0.15.11, term.rs:622-633) call `self.write_through(buf)` — the SAME primitive `write_line` already
2929    // charges Ipc for — and `Term::read` (term.rs:650-654) calls `io::stdin().read(buf)` directly. These
2930    // are a second, real entry point to the identical tty channel, missed because `read`/`write`/`flush`
2931    // are the names every I/O type shares — but crate-gated on `crate_name == "console"`, term.rs
2932    // defines exactly one of each (verified against the real source; no ambiguity survives the gate,
2933    // same shape as `clap::Arg::env`). Left unclassified, a fn calling only `term.write_all(..)` (no
2934    // `write_line`) read as reviewed-pure, since `console` is fully `CALIBRATED_CRATES`.
2935    if crate_name == "console" {
2936        if path.ends_with("::write_line") || path.ends_with("::read_line")
2937            || path.ends_with("::read_line_initial_text") || path.ends_with("::read_char")
2938            || path.ends_with("::read_key") || path.ends_with("::read_key_raw")
2939            || path.ends_with("::read_secure_line")
2940            || path.ends_with("Term::write") || path.ends_with("Term::flush")
2941            || path.ends_with("Term::read")
2942        {
2943            return Some("Ipc");
2944        }
2945        if path.ends_with("::colors_enabled") || path.ends_with("::colors_enabled_stderr")
2946            || path.ends_with("::user_attended") || path.ends_with("::user_attended_stderr")
2947        {
2948            return Some("Env");
2949        }
2950        return None;
2951    }
2952    // `terminal_colorsaurus` — queries the terminal's colours by writing OSC 10/11 escapes and reading the
2953    // reply (bidirectional tty dialogue — Ipc, consistent with dialoguer/console). Nothing else is I/O.
2954    if crate_name == "terminal_colorsaurus" {
2955        if path.ends_with("::background_color") || path.ends_with("::foreground_color")
2956            || path.ends_with("::color_palette")
2957            // SOUNDNESS R321 — FQN-exact, not a suffix. `1.0.3` added
2958            // `ColorPalette::theme_mode(&self)` (src/lib.rs:112), a PURE derived accessor
2959            // comparing `perceived_lightness()` on two already-fetched colours, alongside the
2960            // effectful free `theme_mode(options)` (src/lib.rs:157). A `::theme_mode` suffix
2961            // charges `Ipc` to both. Counterpart to R319: the same upstream mechanism — a
2962            // release ADDING a name — under-reports in one crate and fabricates in another,
2963            // depending only on whether the new name is effectful.
2964            || path == "terminal_colorsaurus::theme_mode"
2965        {
2966            return Some("Ipc");
2967        }
2968        return None;
2969    }
2970    // `backoff` — retry-with-backoff. `retry`/`retry_notify` consult the clock and `thread::sleep`
2971    // between attempts (Clock). The `ExponentialBackoff`/builder config is PURE. (The user closure's own
2972    // effects are out of scope here — we model only backoff's own Clock effect.)
2973    if crate_name == "backoff" {
2974        if path.ends_with("::retry") || path.ends_with("::retry_notify") {
2975            return Some("Clock");
2976        }
2977        return None;
2978    }
2979    // `lscolors` — LS_COLORS parsing. ONLY `from_env` reads the environment (Env). `from_string`/
2980    // `style_for_path`/`style_for*` and the `Style` type take explicit input and are PURE.
2981    if crate_name == "lscolors" {
2982        if path.ends_with("::from_env") {
2983            return Some("Env");
2984        }
2985        return None;
2986    }
2987    // `wild` — argv with glob expansion. `args`/`args_os` read `std::env::args(_os)` (Env). Nothing else.
2988    if crate_name == "wild" {
2989        if path.ends_with("::args") || path.ends_with("::args_os") {
2990            return Some("Env");
2991        }
2992        return None;
2993    }
2994    // `grep_cli` — only the firm effect is modeled: `CommandReaderBuilder::build` spawns a child process
2995    // (Exec). The `is_readable_stdin`/`is_tty_*` fd probes (isatty/fstat on the std descriptors) are
2996    // deliberately NOT modeled — candor doesn't classify `IsTerminal`/isatty as an effect anywhere, and
2997    // they read no data; flagging them would be an inconsistent over-report.
2998    if crate_name == "grep_cli" {
2999        if path.ends_with("::build") {
3000            return Some("Exec");
3001        }
3002        // THE COVERAGE-GATE SWEEP (2026-08-27), verified against grep-cli 0.1.12 — the sibling entry
3003        // points to `::build` above, none of which end in that suffix:
3004        //
3005        // `CommandReader::new` (process.rs:195) is `CommandReaderBuilder::new().build(cmd)` — the same
3006        // spawn, reached through the type's own one-call constructor instead of the builder.
3007        // `CommandReader::close` (process.rs:218) drops the child's stdout handle then calls
3008        // `self.child.wait()` — `std::process::Child::wait` is ALREADY classified `Exec` elsewhere in
3009        // this file (reaping/blocking on a spawned child is part of the subprocess lifecycle this
3010        // project tracks), and self-scan resolves `self.child`'s concrete `process::Child` type to
3011        // confirm it, not a guess.
3012        // `DecompressionMatcher::command` (decompress.rs:179) builds a REAL `Command::new(&decomp_cmd.bin)`
3013        // naming an actual decompressor binary (gzip/xz/bzip2/…) and returns it un-spawned — the same
3014        // "constructs a real argv, caller spawns it" shape `Cred::credential_helper` was classified for
3015        // in git2 (see the FQN-exact rule near this file's top).
3016        // `DecompressionReader::new` (decompress.rs:352) is `DecompressionReaderBuilder::new().build(path)`,
3017        // which calls the already-covered `CommandReaderBuilder::build` two hops down.
3018        // `patterns_from_path` (pattern.rs:82) opens and reads the given file directly (`std::fs::File::
3019        // open`) — unrelated to the Exec family above, genuinely Fs.
3020        // SOUNDNESS R342 — `DecompressionReader::close` was the sibling this enumeration missed. It is
3021        // `match self.rdr { Ok(ref mut rdr) => rdr.close(), Err(_) => Ok(()) }` (`decompress.rs:383`),
3022        // i.e. the already-listed `CommandReader::close` one level up, so it reaps the same child. Its
3023        // `CommandReader` counterpart was listed and it was not — measured on a consumer fixture:
3024        // `CommandReader::close` charged `Exec` and `DecompressionReader::close` read ABSENT.
3025        //
3026        // The `read` pair is listed for the same reason one hop over: reading a `DecompressionReader`
3027        // or a `CommandReader` pulls bytes from the child's stdout, which is the point of having
3028        // spawned it. FQN-exact rather than a `::read`/`::close` suffix, because both are far too
3029        // common a leaf to match crate-wide — the R321 lesson.
3030        //
3031        // Found because R185 taught the scanner to see through `match self.rdr { Ok(..) }`, which made
3032        // grep-cli's own self-scan nominate it. The rule is what a CONSUMER needs; the self-scan only
3033        // pointed at it.
3034        if path == "grep_cli::CommandReader::new"
3035            || path == "grep_cli::CommandReader::close"
3036            || path == "grep_cli::CommandReader::read"
3037            || path == "grep_cli::DecompressionMatcher::command"
3038            || path == "grep_cli::DecompressionReader::new"
3039            || path == "grep_cli::DecompressionReader::close"
3040            || path == "grep_cli::DecompressionReader::read"
3041            || path == "grep_cli::decompress::DecompressionReader::close"
3042            || path == "grep_cli::decompress::DecompressionReader::read"
3043            || path == "grep_cli::process::CommandReader::close"
3044            || path == "grep_cli::process::CommandReader::read"
3045        {
3046            return Some("Exec");
3047        }
3048        if path == "grep_cli::patterns_from_path" {
3049            return Some("Fs");
3050        }
3051        return None;
3052    }
3053    // `clircle` — detects whether two handles are the same file (cycle protection). `Identifier::try_from`
3054    // (File/Stdio) issues an `fstat`, and `surely_conflicts_with` does an `lseek` (`stream_position`) — both
3055    // Fs. The `PartialEq`/`Hash` comparisons read stored dev/ino and are PURE. (The named methods
3056    // `are_identical`/`same_file` do NOT exist in the crate — not modeled.)
3057    if crate_name == "clircle" {
3058        if path.ends_with("::try_from") || path.ends_with("::surely_conflicts_with") {
3059            return Some("Fs");
3060        }
3061        return None;
3062    }
3063    None
3064}
3065
3066pub fn cap_from_name(name: &str) -> Option<&'static str> {
3067    EFFECTS.iter().copied().find(|e| *e == name)
3068}
3069
3070/// Refine the `Exec` cliff (spec §4 ⟨0.5⟩): the effects a *literal, statically-known* subprocess
3071/// head implies, matched by basename (`/usr/bin/curl` → `curl`). The head's effects are ADDED to a
3072/// caller that already carries `Exec` (a subprocess is still spawned — `Exec` is never dropped); an
3073/// unrecognised or dynamically-built head returns `&[]` and keeps the bare cliff (never guess). A
3074/// **candor engine** reads `Fs`/`Env` only — spec §7 item 12 (the analyzer self-boundary) guarantees
3075/// that, so that case is spec-supplied, not curation. The rest is a small curated table under the
3076/// same under-report rule as the crate classifier. INVARIANT: every head here is an external tool
3077/// that does NOT run the analysed project's own code (so `make`/`npm`/`cargo` are deliberately
3078/// absent — they stay the cliff). The reference engines share this table so the `Exec` boundary —
3079/// the one boundary every engine hits — refines identically (the §4-consistency argument).
3080/// SPEC §2 `fs` — for a call ALREADY classified `Fs`, the read/write direction its path implies.
3081/// `["read"]`, `["write"]`, `["read","write"]`, or `[]` when the verb does not say.
3082///
3083/// THE EMPTY CASE IS THE DISCIPLINE. §2: *"when `Fs` is reached but its kind is unknown … the field MUST
3084/// be omitted rather than guessed. An empty or partial `fs` would be read as a positive claim ('reads but
3085/// never writes'), which is the §4 trust contract's forbidden direction."* So an unrecognised verb
3086/// contributes nothing and the field stays absent; absence means "kind undetermined", never "read-only".
3087///
3088/// A syntactic refinement of an effect already proved, NOT a soundness claim. Deliberately the same
3089/// vocabulary as candor-java's `fsKind`, candor-swift's and candor-ts's — the surface is spec'd four-way,
3090/// and four engines inventing four verb tables for one field is how a shared field stops meaning one thing.
3091pub fn fs_kind(path: &str) -> &'static [&'static str] {
3092    // the terminal segment is the verb (`std::fs::write`, `File::create`, `f.read_to_string`)
3093    let leaf = path.rsplit("::").next().unwrap_or(path);
3094    // `OpenOptions::open` is the one verb that does NOT carry its own direction — the direction was set
3095    // by the BUILDER chain (`.read(true)`/`.write(true)`), which this function cannot see. The READ list
3096    // below holds a bare `open` for `File::open`, unambiguously a read; letting an `OpenOptions` receiver
3097    // reach it publishes `fs: ["read"]` for a builder configured `write(true)`, and §2 reads that as the
3098    // positive claim "reads but never writes" — the forbidden direction. The paragraph under the READ
3099    // list has always SAID this; nothing implemented it, and it only became REACHABLE when
3100    // `OpenOptions::open` started classifying on its own — before, the `Fs` came from the
3101    // `OpenOptions::new` constructor, whose leaf claims nothing, so the field was simply absent.
3102    // MEASURED on this commit's own fix before this guard: `OpenOptions::new().read(true).open(p)` went
3103    // from `fs` ABSENT to `fs: ["read"]`, i.e. the fix minted a claim the engine cannot support. Keyed on
3104    // the TYPE segment, so it holds for the `fs_err`/`tokio::fs`/`async_std::fs` spellings too.
3105    if path.rsplit("::").nth(1) == Some("OpenOptions") {
3106        return &[];
3107    }
3108    // Reads the source AND writes the destination in one call.
3109    if matches!(leaf, "copy" | "rename" | "hard_link" | "soft_link" | "symlink") {
3110        return &["read", "write"];
3111    }
3112    const WRITE: &[&str] = &[
3113        "write", "write_all", "write_fmt", "write_vectored", "create", "create_new", "create_dir",
3114        "create_dir_all", "remove_file", "remove_dir", "remove_dir_all", "set_permissions",
3115        "set_len", "set_modified", "set_times", "append", "flush", "sync_all", "sync_data",
3116        "write_at", "truncate",
3117    ];
3118    const READ: &[&str] = &[
3119        "read", "read_to_string", "read_to_end", "read_exact", "read_dir", "read_link",
3120        "metadata", "symlink_metadata", "exists", "try_exists", "canonicalize", "open",
3121        "read_at", "file_type", "permissions", "modified", "accessed", "created", "len",
3122    ];
3123    if WRITE.contains(&leaf) { return &["write"]; }
3124    if READ.contains(&leaf) { return &["read"]; }
3125    // `OpenOptions` carries the direction in its BUILDER chain, not its terminal verb, so `.open()` on one
3126    // says nothing here and is deliberately left to the READ arm above only when it is `File::open`
3127    // (unambiguously a read). Anything else: no claim.
3128    if leaf.starts_with("write") || leaf.starts_with("append") { return &["write"]; }
3129    if leaf.starts_with("read") { return &["read"]; }
3130    &[]
3131}
3132
3133pub fn classify_command_head(cmd: &str) -> &'static [&'static str] {
3134    // Only UNAMBIGUOUS single-effect tools belong here. A multi-modal head (`git status` is local,
3135    // `git push` is Net; `rsync` local-vs-remote) would FABRICATE the effect for its common case —
3136    // the under-report rule forbids it, so such heads keep the bare cliff.
3137    match cmd.rsplit(['/', '\\']).next().unwrap_or(cmd) {
3138        "curl" | "wget" | "http" | "ssh" | "scp" | "sftp" | "ftp" | "telnet" => &["Net"],
3139        "psql" | "mysql" | "sqlite3" | "mongosh" | "mongo" | "redis-cli" | "cqlsh" | "influx" => &["Db"],
3140        // candor engines — Fs/Env only, guaranteed by spec §7 item 12 (the analyzer self-boundary)
3141        "candor" | "candor-run.sh" | "candor-scan" | "candor-query" | "candor-java"
3142        | "candor-classify" | "candor-report" | "cargo-candor" => &["Env", "Fs"],
3143        _ => &[],
3144    }
3145}
3146
3147/// Known machine-learning MODEL-provider hosts — the SPEC §1 ⟨0.13⟩ `Llm` host-literal refinement:
3148/// a statically-known `Net` request to one of these classifies `Llm` IN ADDITION to `Net` (Net is
3149/// never dropped — a model call IS network I/O, exactly as an `Exec`-refined subprocess keeps `Exec`),
3150/// just as a jdbc URL classifies `Db`. Matched by host, case-insensitive; a SUBDOMAIN of a listed host
3151/// counts. The reference engines share this table VERBATIM with candor-java's `Literals.MODEL_HOSTS`
3152/// (the analog of `classify_command_head`) so the `Net` boundary refines to `Llm` identically. An
3153/// UNKNOWN host stays bare `Net` — never guessed. Curated STARTER set; the §7 coverage ledger
3154/// discloses an uncovered provider like any other.
3155pub const MODEL_HOSTS: &[&str] = &[
3156    "api.openai.com",
3157    "api.anthropic.com",
3158    "generativelanguage.googleapis.com",
3159    "api.mistral.ai",
3160    "api.cohere.ai",
3161    "api.cohere.com",
3162    "api.groq.com",
3163    "api.together.xyz",
3164    "api.perplexity.ai",
3165    "openrouter.ai",
3166];
3167
3168/// Whether an endpoint HOST literal is a known model provider (case-insensitive; a subdomain of a
3169/// `MODEL_HOSTS` entry counts). Strips a `:port` suffix first. Two special forms carry their own rule,
3170/// matching candor-java's `Literals.isModelHost` exactly: any host whose port is `11434` is a local
3171/// Ollama endpoint (a LOOPBACK host — `localhost`/`127.0.0.1`/`::1` — on port 11434); and an AWS Bedrock
3172/// runtime host (the model-inference service label `bedrock-runtime`/`bedrock-agent-runtime`).
3173pub fn is_model_host(host_literal: &str) -> bool {
3174    // Strip any `:port` (via the shared host_part) and lowercase for the name comparisons.
3175    let host = policy::host_part(host_literal).to_ascii_lowercase();
3176    // Ollama is a LOCAL endpoint: :11434 → Llm ONLY on a loopback host (max-review r3 parity fix — "any
3177    // host on :11434" fabricated Llm on unrelated internal services on that port).
3178    if let Some((_, port)) = host_literal.rsplit_once(':') {
3179        if port == "11434" {
3180            return matches!(host.as_str(), "localhost" | "127.0.0.1" | "::1");
3181        }
3182    }
3183    if MODEL_HOSTS.contains(&host.as_str()) {
3184        return true;
3185    }
3186    // A subdomain of a known model host counts (`eu.api.openai.com` → api.openai.com).
3187    if MODEL_HOSTS.iter().any(|m| host.ends_with(&format!(".{m}"))) {
3188        return true;
3189    }
3190    // AWS Bedrock runtime: the FIRST label is the model-inference service (`bedrock-runtime.<region>.
3191    // amazonaws.com`), NOT the substring "bedrock" (which caught `bedrock-backups.s3.amazonaws.com`, an
3192    // S3 bucket) and NOT the control-plane `bedrock.<region>.amazonaws.com`.
3193    host.ends_with(".amazonaws.com")
3194        && matches!(host.split('.').next(), Some("bedrock-runtime") | Some("bedrock-agent-runtime"))
3195}
3196
3197/// ⟨0.20⟩ Curated telemetry / analytics / APM hosts — the `Net` destination-class `known-telemetry` set
3198/// (NET-DESTINATION-CLASS-DESIGN.md), shared VERBATIM with candor-java's `Literals.TELEMETRY_HOSTS` (like
3199/// `MODEL_HOSTS`). A benign observability endpoint. Matched by host, case-insensitive; a SUBDOMAIN of a
3200/// listed host counts. Tight, high-precision STARTER set — mis-including an exfil-capable host would
3201/// under-gate `deny Net[unknown-host]`.
3202pub const TELEMETRY_HOSTS: &[&str] = &[
3203    "sentry.io",
3204    "bugsnag.com",
3205    "rollbar.com",
3206    "segment.io",
3207    "segment.com",
3208    "mixpanel.com",
3209    "amplitude.com",
3210    "google-analytics.com",
3211    "analytics.google.com",
3212    "datadoghq.com",
3213    "datadoghq.eu",
3214    "newrelic.com",
3215    "nr-data.net",
3216    "honeycomb.io",
3217    "logtail.com",
3218    // ⟨0.20.1⟩ corpus-grown (a real-repo dogfood): more single-purpose analytics / session-replay / RUM
3219    // providers — vendor-specific product domains only (no general-purpose host), so no under-gate risk.
3220    "posthog.com",
3221    "plausible.io",
3222    "usefathom.com",
3223    "heapanalytics.com",
3224    "fullstory.com",
3225    "hotjar.com",
3226    "logrocket.com",
3227    "cloudflareinsights.com",
3228];
3229
3230/// Whether an endpoint HOST literal is in `set` (case-insensitive; a subdomain of a listed host counts).
3231/// Strips a `:port` suffix first via `host_part`. The shared membership test for `TELEMETRY_HOSTS` and the
3232/// config-declared partner set (mirrors candor-java's `Literals.hostInSet`).
3233pub fn host_in_set(host_literal: &str, set: &[&str]) -> bool {
3234    let host = policy::host_part(host_literal).to_ascii_lowercase();
3235    set.contains(&host.as_str()) || set.iter().any(|e| host.ends_with(&format!(".{e}")))
3236}
3237
3238/// Whether an endpoint HOST literal is a known telemetry/analytics/APM host (`TELEMETRY_HOSTS`).
3239pub fn is_telemetry_host(host_literal: &str) -> bool {
3240    host_in_set(host_literal, TELEMETRY_HOSTS)
3241}
3242
3243/// ⟨0.20⟩ The `Net` DESTINATION CLASS of a host literal (NET-DESTINATION-CLASS-DESIGN.md): `known-telemetry`
3244/// (curated), `known-partner` (config `net-partner` OR a model host — a declared-ish external API), else
3245/// `unknown-host` — the HONEST default (candor makes no claim; the security gate bites this). A partner set
3246/// is per-project (config-declared). Never fabricated onto a safe class: an unresolved host is unknown-host.
3247/// Mirrors candor-java's `Literals.netDestClass`.
3248pub fn net_dest_class(host_literal: &str, partners: &std::collections::BTreeSet<String>) -> &'static str {
3249    if is_telemetry_host(host_literal) {
3250        return "known-telemetry";
3251    }
3252    if partner_for(host_literal, partners).is_some() || is_model_host(host_literal) {
3253        return "known-partner";
3254    }
3255    "unknown-host"
3256}
3257
3258/// ⟨0.31⟩ WHICH declared partner a host matched, or `None` — the SAME match `net_dest_class` decides on,
3259/// extracted so the DISCLOSURE and the DECISION cannot use different rules.
3260///
3261/// That is not a stylistic preference. The reverted first attempt at the `net-partner` disclosure
3262/// re-implemented this match against a normaliser that KEEPS the port, so an observed
3263/// `partner.example:443` never equalled a declared `partner.example` and the disclosure came back
3264/// SILENTLY EMPTY on every real run — while the verdicts it was reporting on had flipped. A disclosure
3265/// normalised differently from the decision it reports can only be wrong, and one function with two
3266/// callers is what makes writing one impossible.
3267pub fn partner_for(
3268    host_literal: &str,
3269    partners: &std::collections::BTreeSet<String>,
3270) -> Option<String> {
3271    if partners.is_empty() {
3272        return None;
3273    }
3274    let host = policy::host_part(host_literal).to_ascii_lowercase();
3275    if partners.contains(&host) {
3276        return Some(host);
3277    }
3278    partners
3279        .iter()
3280        .find(|p| host.ends_with(&format!(".{p}")))
3281        .cloned()
3282}
3283
3284/// ⟨0.20⟩ The closed `Net` destination-class vocabulary, for the `deny Net[<dest…>]` policy filter.
3285pub const NET_DEST_CLASSES: &[&str] = &["known-telemetry", "known-partner", "unknown-host"];
3286
3287/// Curated Rust model-provider SDK crates — the SPEC §1 ⟨0.13⟩ `Llm` model-SDK surface, the Rust analog
3288/// of candor-java's `Rules.MODEL_SDK_PACKAGES`. A resolved call into one of these crates classifies
3289/// `Llm` + `Net` (the caller adds both — a model dispatch IS network I/O). NO method-name gating: these
3290/// are single-purpose provider clients, so ANY call into the crate is a model dispatch (matches the java
3291/// reference's judgment call). Curated STARTER list; the §7 coverage ledger discloses the rest.
3292pub const MODEL_SDK_CRATES: &[&str] = &[
3293    "async_openai",           // async-openai — the de-facto OpenAI client
3294    "anthropic_sdk",          // anthropic-sdk
3295    "anthropic",              // anthropic (community client crate)
3296    "aws_sdk_bedrockruntime", // AWS Bedrock runtime (invoke/converse) — the model surface of the aws-sdk family
3297    "ollama_rs",              // ollama-rs — local Ollama client
3298    "langchain_rust",         // langchain-rust — the LangChain invoke surfaces
3299    "mistralai",              // mistralai (Mistral client)
3300    "genai",                  // genai — a multi-provider model client
3301];
3302
3303/// Whether a resolved call's CRATE is a curated model-provider SDK (`MODEL_SDK_CRATES`) → the SPEC §1
3304/// ⟨0.13⟩ `Llm` model-SDK classification (the caller adds both `Llm` and `Net`). Crate-level, no
3305/// method gating — a single-purpose client, matching candor-java's `isModelSdkOwner`.
3306pub fn is_model_sdk_crate(crate_name: &str) -> bool {
3307    MODEL_SDK_CRATES.contains(&crate_name)
3308}
3309
3310/// The libc / nix / rustix PATH-and-directory syscall leaves `classify` charges `Fs` (incl. `*64` and
3311/// `*at` variants). Module-level, not local to `classify`, because it is ONE of the two answers to one
3312/// question: the AS-EFF-008 masking guard (`masks_locator`) reads this same table, so a leaf added here
3313/// is masked by default — see `LIBC_FS_NO_PATH` for the direction. SOUNDNESS R806.
3314pub const LIBC_FS: &[&str] = &[
3315            "open", "open64", "openat", "openat2", "creat", "creat64", "stat", "stat64", "lstat",
3316            "lstat64", "fstatat", "fstatat64", "newfstatat", "statx", "access", "faccessat",
3317            "faccessat2", "mkdir", "mkdirat", "rmdir", "unlink", "unlinkat", "rename", "renameat",
3318            "renameat2", "link", "linkat", "symlink", "symlinkat", "readlink", "readlinkat", "chmod",
3319            "fchmodat", "chown", "lchown", "fchownat", "truncate", "truncate64", "ftruncate",
3320            "ftruncate64", "opendir", "fdopendir", "readdir", "readdir64", "readdir_r", "closedir",
3321            "rewinddir", "seekdir", "telldir", "scandir", "mkstemp", "mkstemps", "mkostemp", "mkdtemp",
3322            "mknod", "mknodat", "chdir", "fchdir", "getcwd", "get_current_dir_name", "chroot",
3323            "pivot_root", "statfs", "statfs64", "fstatfs", "fstatfs64", "statvfs", "fstatvfs", "mount",
3324            "umount", "umount2", "fsync", "fdatasync", "sync", "syncfs", "sync_file_range", "fallocate",
3325            "posix_fallocate", "posix_fadvise", "sendfile", "sendfile64", "copy_file_range", "flock",
3326            "getdents", "getdents64", "utime", "utimes", "lutimes", "futimens", "utimensat", "futimesat",
3327            "realpath",
3328        ];
3329
3330/// The libc / nix / rustix socket-family leaves `classify` charges `Net`. See `LIBC_NET_NO_DESTINATION`.
3331pub const LIBC_NET: &[&str] = &[
3332            "socket", "setsockopt", "getsockopt", "bind", "listen", "accept", "accept4", "connect",
3333            "shutdown", "send", "sendto", "sendmsg", "sendmmsg", "recv", "recvfrom", "recvmsg",
3334            "recvmmsg", "getpeername", "getsockname", "getaddrinfo", "freeaddrinfo", "getnameinfo",
3335        ];
3336
3337/// The libc / nix / rustix process creation / replacement / reaping leaves `classify` charges `Exec`.
3338/// See `LIBC_EXEC_NO_PROGRAM`.
3339pub const LIBC_EXEC: &[&str] = &[
3340            "fork", "vfork", "clone", "clone3", "execl", "execlp", "execle", "execv", "execvp",
3341            "execvpe", "execve", "execveat", "fexecve", "posix_spawn", "posix_spawnp", "system",
3342            "popen", "pclose", "wait", "waitpid", "wait3", "wait4", "waitid",
3343        ];
3344
3345/// The Postgres / SQLite-family client verbs `classify` charges `Db` for `postgres`, `tokio_postgres`,
3346/// `deadpool_postgres` and `rusqlite` — the round-trips themselves. Module-level because the masking
3347/// guard reads it too (`masks_locator`, SOUNDNESS R806): every verb here takes the SQL text at
3348/// argument 0 except the three in `PG_DB_VERBS_NO_SQL`, so a verb added here is masked by default.
3349pub const PG_DB_VERBS: &[&str] = &[
3350                "::query", "::query_one", "::query_opt", "::query_raw", "::execute",
3351                "::batch_execute", "::simple_query", "::prepare", "::prepare_typed",
3352                "::copy_in", "::copy_out", "::transaction", "::connect",
3353                // `Config::connect_raw` (tokio-postgres config.rs:739) does the SAME protocol handshake
3354                // as `Config::connect` over a caller-supplied stream (a Unix socket, a TLS-terminated
3355                // proxy) instead of dialing one itself — real Db/Net I/O, missing because the verb
3356                // doesn't end in the plain `connect` spelling.
3357                "::connect_raw",
3358                // rusqlite's dialect of the same verbs (a verb-probe found the CANONICAL rusqlite
3359                // consumer API classifying pure): `query_row` is the one-row read, `query_map`/
3360                // `query_and_then` the many-row reads, `execute_batch` is rusqlite's name for
3361                // batch_execute, `prepare_cached` round-trips like prepare. `query_typed` is
3362                // tokio_postgres 0.7.10+.
3363                "::query_row", "::query_map", "::query_and_then", "::execute_batch",
3364                "::prepare_cached", "::query_typed",
3365                "::prepare_typed_cached",
3366];
3367
3368/// The members of `PG_DB_VERBS` that take NO SQL text, each checked against its signature:
3369/// `Client::transaction(&mut self)`, `connect(params, tls)` / `Config::connect_raw(stream, tls)` —
3370/// a connection string or a stream, never a query. A name wrongly listed here is a silent bypass;
3371/// a name missing from here is an over-mask that fails closed. SOUNDNESS R806.
3372pub const PG_DB_VERBS_NO_SQL: &[&str] = &["::transaction", "::connect", "::connect_raw"];
3373
3374/// The members of `LIBC_FS` that take NO path — every one operates on a file DESCRIPTOR, a `DIR*`
3375/// stream, or nothing — so a missing literal there hides no locator. **CHECKED AGAINST EACH SIGNATURE,
3376/// because this is a denylist on a masking guard: a path-taking name wrongly listed here is the
3377/// benign-sibling-literal bypass (R399), while a no-path name missing from here only over-masks.**
3378/// Everything else in `LIBC_FS` names a path, at argument 0 or — for the `*at` family — argument 1.
3379pub const LIBC_FS_NO_PATH: &[&str] = &[
3380    "ftruncate", "ftruncate64", "fdopendir", "readdir", "readdir64", "readdir_r", "closedir",
3381    "rewinddir", "seekdir", "telldir", "fchdir", "getcwd", "get_current_dir_name", "fstatfs",
3382    "fstatfs64", "fstatvfs", "fsync", "fdatasync", "sync", "syncfs", "sync_file_range", "fallocate",
3383    "posix_fallocate", "posix_fadvise", "sendfile", "sendfile64", "copy_file_range", "flock",
3384    "getdents", "getdents64", "futimens",
3385];
3386
3387/// The members of `LIBC_EXEC` that name NO program: process duplication (`fork`/`vfork`/`clone*`,
3388/// which run THIS image) and reaping (`wait*`, `pclose`). Every other member names what runs —
3389/// `system`/`popen` a shell command line, `exec*`/`posix_spawn*` a path or file name, `fexecve` an fd
3390/// whose program is invisible at the call. Same direction rule as `LIBC_FS_NO_PATH`.
3391pub const LIBC_EXEC_NO_PROGRAM: &[&str] = &[
3392    "fork", "vfork", "clone", "clone3", "wait", "waitpid", "wait3", "wait4", "waitid", "pclose",
3393];
3394
3395/// The members of `LIBC_NET` that name NO destination: socket setup and options, the LOCAL side
3396/// (`bind`/`listen`/`accept*` — where the process listens, never a place it reaches; ⟨0.29⟩
3397/// `is_net_binding`), use-verbs on an already-connected or already-bound socket (`send`/`recv*`),
3398/// teardown and read-backs. The destination-naming remainder is `connect`, `sendto`, `sendmsg`,
3399/// `sendmmsg`, and the resolver pair `getaddrinfo`/`getnameinfo`.
3400pub const LIBC_NET_NO_DESTINATION: &[&str] = &[
3401    "socket", "setsockopt", "getsockopt", "bind", "listen", "accept", "accept4", "shutdown", "send",
3402    "recv", "recvfrom", "recvmsg", "recvmmsg", "getpeername", "getsockname", "freeaddrinfo",
3403];
3404
3405/// Whether `crate_name` is one of the three crates `classify` routes through the libc syscall tables.
3406fn is_syscall_crate(crate_name: &str) -> bool {
3407    matches!(crate_name, "libc" | "nix" | "rustix")
3408}
3409
3410/// Whether a subprocess-builder method only MODIFIES the command (`.arg`, `.env`, `.current_dir`)
3411/// rather than NAMING the program (`Command::new`, `duct::cmd`). A WHOLE-CRATE-Exec crate
3412/// (`portable_pty`, `duct`, `async_process`) classifies *every* method as `Exec`, so the
3413/// head-refinement must skip these: an arg or env-var-name literal that happened to match a head
3414/// (`.env("psql", …)`, `.arg("curl")`) would FABRICATE that effect — the §1 under-report rule. The
3415/// method is the call path's last segment.
3416pub fn is_cmd_builder_method(method: &str) -> bool {
3417    matches!(
3418        method,
3419        "arg" | "args" | "arg0" | "env" | "envs" | "env_clear" | "env_remove" | "current_dir"
3420            | "cwd" | "stdin" | "stdout" | "stderr" | "pre_exec" | "creation_flags" | "uid" | "gid"
3421            | "groups" | "process_group"
3422    )
3423}
3424
3425/// Whether a subprocess method NAMES the program (so its first string literal IS the command head to
3426/// refine): `Command::new("curl")`, `duct::cmd("curl", …)`. The head-refinement must fire ONLY here —
3427/// an ALLOWLIST, not "any method except known modifiers". A whole-crate-Exec crate classifies EVERY
3428/// method as `Exec`, so a denylist leaked NON-naming methods that aren't modifiers — a getter like
3429/// `CommandBuilder::get_env("psql")` (reading back an env-var KEY, not a program) fed `"psql"` to the
3430/// head classifier and FABRICATED `Db` (review find). Only `new`/`cmd` name a program; everything else
3431/// (modifiers, getters `get_*`, custom builder methods) keeps the bare `Exec` cliff — under-refine
3432/// (safe) rather than fabricate. `std::process::Command` is verb-precise so getters never fire `Exec`
3433/// there anyway; the allowlist makes the whole-crate-Exec crates safe too.
3434pub fn is_cmd_naming_method(method: &str) -> bool {
3435    matches!(method, "new" | "cmd")
3436}
3437
3438/// The masking guard (AS-EFF-008): a Net call whose method takes the HOST/URL as an argument is
3439/// "establishing" — a classified Net call here with no captured host literal leaves the endpoint
3440/// structurally INVISIBLE (a runtime-built host), so the surface is incomplete and the gate must fail
3441/// closed (else a benign sibling literal masks the runtime endpoint). An ALLOWLIST of connection-
3442/// establishing verbs — the SAFE direction: a USE-verb on an already-connected socket
3443/// (`stream.write`/`read`/`flush`, `socket.send`/`recv`) is NOT here, so a missing literal there (the
3444/// host was fixed at `connect`) never false-positives. **THAT LAST CLAIM WAS FALSE AND IS WITHDRAWN —
3445/// see R379 in the body: under-catching an establishing verb IS a broken gate whenever a benign sibling
3446/// literal sits in the same function, which is the exact scenario the first sentence names.** The list is
3447/// now an ALLOWLIST still — see the R379 body below: the denylist inversion was BUILT, A/B'd over
3448/// 1,545 crates and REFUSED (544 rows over-masked). An earlier draft of this line said "now a
3449/// DENYLIST", which was a leftover from the rejected cut and asserted the opposite of the code it
3450/// sits on — the comment-asserting-safety shape this register records. The arg is the method (path's
3451/// last segment).
3452pub fn is_net_establishing(method: &str) -> bool {
3453    // SOUNDNESS R379 — the DNS RESOLVER verbs were missing, and their absence was a GATE BYPASS.
3454    //
3455    // `classify` (see the `hickory_resolver` arm) already maps `::lookup_ip`, `::lookup` and any
3456    // `*_lookup` to `Net`, and asserts it. This list did not, so a `Net` call whose host is a runtime
3457    // value was never marked `incomplete` and a benign sibling literal certified it. Measured against
3458    // real hickory-resolver 0.26.2, on a fixture that builds clean:
3459    //
3460    //     pub async fn masked(r: &Resolver<TokioRuntimeProvider>, host: &str) {
3461    //         let _ = r.lookup_ip("good.example.com").await;   // the benign literal
3462    //         let _ = r.lookup_ip(host).await;                 // the runtime target
3463    //     }
3464    //
3465    // reported `hosts:['good.example.com'] incomplete:NONE`, and `allow Net good.example.com` exited
3466    // **0** over a DNS resolution of a caller-controlled hostname. `TcpStream::connect(host)` — one
3467    // verb over, same fixture — marked `incomplete:['Net']` and failed closed. The mechanism was
3468    // sound; only the enumeration was short.
3469    //
3470    // THE DOC ABOVE USED TO CLAIM under-catching here is "a missed mask (sound-with-disclosure), never
3471    // a broken gate". That is false and is withdrawn: it is a broken gate whenever a benign sibling
3472    // literal shares the function, which is the scenario the guard's own first sentence names.
3473    //
3474    // **AND IT STAYS AN ALLOWLIST, WHICH IS NOT THE FAMILY'S USUAL DIRECTION — the exception is
3475    // measured and it is the same one `is_cmd_naming_method` states two doc-blocks up.** Inverting to
3476    // a denylist of use-verbs was built and A/B'd over all 1,545 registry crates: **544 rows gained
3477    // `incomplete` and none lost it**, because a WHOLE-CRATE-Net crate classifies EVERY method as Net,
3478    // so a denylist masks essentially everything in one — `cap-std` 66 rows, `hickory-net` 44. The
3479    // triggers it added were conversions, accessors and combinators (`into` 24, `from_std` 20,
3480    // `as_socket` 15, `setsockopt` 32, `map_err` 7, `ok` 5, `try_clone` 4) — none of which hides a
3481    // host. Worse, it masked **`bind` (31)**, which this very file has `is_net_binding` to exclude
3482    // because a bind address is where the process LISTENS, never a destination it reaches. So here the
3483    // allowlist is the precise side and the denylist is the leaky one, exactly as recorded for Exec.
3484    //
3485    // The resolver family is written out rather than the one spelling in hand (R346): `_lookup`
3486    // catches `reverse_lookup`/`srv_lookup`/`mx_lookup`/`txt_lookup`/`ipv4_lookup`/`ipv6_lookup` and
3487    // the rest of the record-type verbs in one test, mirroring `classify`'s own `ends_with("_lookup")`.
3488    method.ends_with("_lookup")
3489        || matches!(
3490            method,
3491            "connect"
3492                | "connect_timeout"
3493                | "get"
3494                | "post"
3495                | "put"
3496                | "patch"
3497                | "delete"
3498                | "head"
3499                | "request"
3500                | "send_to"
3501                | "lookup_host"
3502                | "to_socket_addrs"
3503                // R379 — the DNS resolver verbs `classify` already calls Net.
3504                | "lookup"
3505                | "lookup_ip"
3506                | "resolve"
3507        )
3508}
3509
3510/// ⟨0.29⟩ The Net verbs whose LOCATOR is at argument **1**, not 0 — the rust analogue of candor-ts's
3511/// `NET_URL_ARG1_MEMBERS`.
3512///
3513/// **A REGRESSION FOUND IN REVIEW, and the direction matters.** The positional-literal rung replaced
3514/// `first_str_lit` ("the first string literal ANYWHERE in the call") with `positional_str_lit(args, 0)`
3515/// as the UNIVERSAL default. That is right for `Fs`/`Db`/`Exec`, whose locator is always argument 0 —
3516/// but `is_net_establishing` already listed two verbs whose locator is not: `reqwest::Client::request`
3517/// takes `(Method, url)` and `UdpSocket::send_to` takes `(buf, addr)`. MEASURED after the swap:
3518/// `c.request(Method::GET, "https://api.example.com/v1")` published NO `hosts` at all and could not be
3519/// certified, while `c.get("https://api.example.com/v1")` certified normally.
3520///
3521/// ⟨0.29⟩ MEASURED FOR `request` ONLY. `send_to` is a METHOD on a receiver the STABLE syntactic backend
3522/// does not type, so `s.send_to(buf, "203.0.113.9:53")` is not classified at all there and its arg-1
3523/// literal is still uncaptured on the floor; the position is right and the deep engine can use it. Said
3524/// plainly because the first version of this fix's changelog listed both verbs as measured.
3525///
3526/// The direction is SAFE — an uncaptured locator fails closed, it never certifies something invisible —
3527/// which is exactly why it needed a review to find: the gate stayed sound and quietly stopped being
3528/// USABLE for a common shape. candor-ts avoided this by making its resolver verb-aware in the same rung;
3529/// this is that discipline arriving one engine late.
3530pub fn is_net_host_arg1(method: &str) -> bool {
3531    matches!(method, "request" | "send_to")
3532}
3533
3534/// ⟨0.29⟩ / ⟨0.40⟩ A LOCAL BIND/LISTEN VERB — the address it names is where the process LISTENS, never a
3535/// destination it reaches (SPEC §2 ⟨0.40⟩ *A BIND OR LISTEN ADDRESS IS WHERE THE PROCESS LISTENS*, PART 96
3536/// `a_litbind`). Its literal never enters `hosts`.
3537///
3538/// **MEASURED, and it is a false all-clear rather than a naming quibble.** `UdpSocket::bind("0.0.0.0:0")`
3539/// put `0.0.0.0:0` into `hosts`, the DESTINATION surface `allow Net` gates on (§2), and — because a
3540/// literal had been captured — nothing marked the surface incomplete. So:
3541///
3542/// ```text
3543/// let s = UdpSocket::bind("0.0.0.0:0")?;   // local
3544/// s.send_to(b"secrets", dst);              // destination is a RUNTIME value
3545/// allow Net 0.0.0.0   ->   policy ✓, exit 0
3546/// ```
3547///
3548/// A local listen address certified a send to an endpoint nobody can see. That is the masking evasion
3549/// AS-EFF-008 exists to close, reached through a verb whose literal is not a destination at all.
3550///
3551/// **A BIND MARKS NOTHING** (⟨0.40⟩). This doc used to say *"A BIND CANNOT BE CERTIFIED, EVER, which is
3552/// why this marks the surface incomplete"*, and that has been false since `16fb46f` dropped the hedge:
3553/// neither rust engine marks a bind, and both only withhold its literal. ⟨0.40⟩ makes the withholding the
3554/// rule — an ephemeral client's own `send_to`/`connect` carries its locator under `is_net_establishing`,
3555/// so hedging the bind as well made every UDP client uncertifiable while adding nothing a gate could use;
3556/// and a bind with nothing beside it still fails `allow Net` closed on its EMPTY literal surface. The
3557/// half of the old sentence that WAS right — *a server that binds and accepts talks to whoever connects*
3558/// — belongs to the ACCEPT, not the bind, and lives in `is_net_accepting`, which is why `accept` and
3559/// `incoming` are no longer members here.
3560pub fn is_net_binding(method: &str) -> bool {
3561    matches!(method, "bind" | "listen" | "bind_to_device")
3562}
3563
3564/// ⟨0.40⟩ A CALL THAT ACCEPTS CONNECTIONS — its peers are chosen by whoever connects, so no literal can name
3565/// them, and the unit's `Net` surface is INCOMPLETE (SPEC §2 ⟨0.40⟩ *A UNIT THAT ACCEPTS A CONNECTION …*,
3566/// AS-EFF-008, SEMANTICS §6 `masked_Net`; PART 96 `c_accept`). Both rust engines mark `incomplete` on a
3567/// `Net`-classified call this answers, WHETHER OR NOT a literal was captured (a server bootstrap's literal is
3568/// a LISTEN address, withheld like a bind's), and contribute no `hosts` entry for it.
3569///
3570/// **SOUNDNESS R817 — `accept`/`incoming` WERE MEMBERS OF `is_net_binding`, WHICH WITHHOLDS AND NEVER
3571/// MARKS**, so they were read exactly like a use-verb. `pub fn f(l: &TcpListener) { let _ =
3572/// TcpStream::connect("ok.example:80"); if let Ok((mut s, _)) = l.accept() { s.write_all(b"hi") } }`
3573/// reported `hosts: ["ok.example:80"]`, no `incomplete`, and `allow Net in f ok.example` exited **0** over a
3574/// server writing to whoever connected — EXECUTED: a client on 127.0.0.1 received the bytes.
3575///
3576/// The membership, by spelling (`path` is the resolved call path, `leaf` its last segment):
3577///   * `accept`, `accept4` (libc/nix/rustix), `poll_accept` (tokio's poll form), `incoming` and
3578///     `into_incoming` (std's iterator forms) — exact LEAF. `accept_bi`/`accept_uni` (quinn) are NOT here:
3579///     they accept a STREAM on a connection whose peer was already fixed by the endpoint's `accept`.
3580///   * tonic's `Router::serve`/`Router::serve_with_shutdown` and `TcpIncoming::new`, the server bootstraps
3581///     `classify` already charges `Net` — each binds a listener and begins accepting on it (classify's own
3582///     tonic arm cites the source lines). By PATH, because `serve`/`new` are not accept verbs anywhere else.
3583///
3584/// A wrong `true` over-masks and fails CLOSED, saying so; a wrong `false` is the benign-sibling-literal
3585/// bypass this row closed. An exact `accept` leaf also matches a TLS/WebSocket acceptor wrapping a stream
3586/// that was already accepted (`TlsAcceptor::accept(stream)`, `tungstenite::accept`) — whose peer is likewise
3587/// whoever connected, so the mark is redundant there, never false.
3588pub fn is_net_accepting(path: &str, leaf: &str) -> bool {
3589    matches!(leaf, "accept" | "accept4" | "poll_accept" | "incoming" | "into_incoming")
3590        || (path.starts_with("tonic::")
3591            && (path.ends_with("::Router::serve")
3592                || path.ends_with("::Router::serve_with_shutdown")
3593                || path.ends_with("::TcpIncoming::new")))
3594}
3595
3596/// The masking guard (AS-EFF-008), the `Fs` analog of `is_net_establishing`: whether an `Fs`-classified
3597/// call takes the filesystem PATH as a string argument (so a missing literal leaves the path
3598/// structurally INVISIBLE — a runtime-built path — and the surface is incomplete, fail-closed). An
3599/// ALLOWLIST of the path-NAMING free functions / constructors (`fs::write`/`read`/`File::open`/…), the
3600/// SAFE direction: a path-stat METHOD whose path is the RECEIVER (`p.metadata()`, `p.exists()`) is
3601/// invoked method-form and the caller gates on `!is_method`, so this never sees it; an op on an
3602/// already-opened handle (`file.write_all`, `mmap.flush`, `tempfile()` — a random name, no path arg)
3603/// is not here, so a missing literal there never false-positives. Under-catching an unusual
3604/// path-naming fn is a missed mask (sound-with-disclosure), ~~never a broken gate~~ — **AND THAT LAST
3605/// CLAUSE IS FALSE. SOUNDNESS R399.** R379 withdrew this exact sentence from `is_net_establishing` after
3606/// MEASURING it wrong, and R383 and R386 are counter-examples on this guard and its Db sibling: an
3607/// unlisted path-taking call contributes no locator, nothing marks the surface incomplete, and a benign
3608/// sibling literal then CERTIFIES the invisible destination — `allow Fs /etc/hostname` exit 0 over
3609/// `unixfs::chown(caller, …)`, with the control (`OpenOptions::open(caller)`) exiting 1. The sentence
3610/// survived here only because nobody re-read it after R379, and it is what licenses leaving the list
3611/// short. Under-catching is a BROKEN GATE, not a missed mask. The arg is the
3612/// method/fn leaf (the path's last segment).
3613pub fn is_fs_path_arg(leaf: &str) -> bool {
3614    matches!(
3615        leaf,
3616        // SOUNDNESS R399 — the POSIX ownership/root verbs take a path as argument 0 and were absent, so a
3617        // benign sibling literal certified them: `allow Fs /etc/hostname` exit 0 over
3618        // `unixfs::chown(caller, …)`, control `OpenOptions::open(caller)` exit 1. `std::os::unix::fs`.
3619        "chown"
3620            | "lchown"
3621            | "chroot"
3622        // std::fs / tokio::fs / async_std::fs / fs_err free functions taking a path argument
3623            | "write"
3624            | "read"
3625            | "read_to_string"
3626            | "read_dir"
3627            | "read_link"
3628            | "copy"
3629            | "rename"
3630            | "remove_file"
3631            | "remove_dir"
3632            | "remove_dir_all"
3633            | "create_dir"
3634            | "create_dir_all"
3635            | "hard_link"
3636            | "soft_link"
3637            | "symlink"
3638            | "symlink_file"
3639            | "symlink_dir"
3640            | "symlink_metadata"
3641            | "canonicalize"
3642            | "metadata"
3643            | "set_permissions"
3644            | "exists"
3645            | "try_exists"
3646            // File / OpenOptions constructors taking a path argument
3647            | "open"
3648            | "create"
3649            | "create_new"
3650    )
3651}
3652
3653/// SOUNDNESS R334 — IS THIS PATH SEGMENT THE OS ENTROPY SOURCE ITSELF (as a VALUE, not a verb)?
3654///
3655/// **THE DEFECT THIS EXISTS FOR.** Every entropy rule in the `rand` block keys on the CALLEE — a verb
3656/// (`from_os_rng`, `next_u32`, `fill_bytes`) or the source type in RECEIVER position
3657/// (`contains("OsRng")`/`contains("SysRng")`, R320). The idiomatic way to seed a userspace CSPRNG from
3658/// the OS puts the source in ARGUMENT position, where neither key can see it. Executed, one fixture,
3659/// four rows:
3660///
3661/// ```text
3662/// StdRng::try_from_rng(&mut SysRng)   ABSENT   quinn-proto-0.11.17 endpoint.rs:81
3663/// StdRng::from_rng(&mut OsRng)        ABSENT   the same hole in the OLD spelling
3664/// StdRng::from_seed([0u8; 32])        ABSENT   correct — deterministic, and the control
3665/// StdRng::from_os_rng()               ['Rand'] the verb form
3666/// ```
3667///
3668/// Both spellings, so this is NOT a rename residual and predates R320 — whose "stale `OsRng` clause"
3669/// framing would have sent the audit straight past it.
3670///
3671/// **WHY THE ARGUMENT AND NOT THE VERB.** `from_rng`/`try_from_rng` cannot simply be charged: their
3672/// effect is decided by what is passed to them, `from_rng(&mut pcg)` is deterministic, and there are
3673/// 802 `from_seed`/`seed_from_u64` call sites in this machine's registry cache — the deterministic
3674/// population is the larger one. Charging the verb is R330's mistake one crate over. The discriminator
3675/// is the ARGUMENT, so that is what is read.
3676///
3677/// **THE OVER-APPROXIMATION IS DELIBERATE AND STATED.** Naming one of these types as a VALUE is charged
3678/// wherever it appears in an argument list, including moves that do not themselves draw (`Some(OsRng)`,
3679/// `Box::new(SysRng)`). That is sound and it is also the ONLY place candor can see it: a source handed
3680/// off into a struct field is drawn from in some later function whose own call list never mentions it.
3681/// A user type coincidentally named `OsRng` would be charged too — an over-report, the safe direction,
3682/// and cheaper than the silence it replaces.
3683pub fn is_entropy_source_ident(seg: &str) -> bool {
3684    matches!(seg, "OsRng" | "SysRng")
3685}
3686
3687/// SOUNDNESS R338 — DOES THIS CALL ALSO READ THE SYSTEM TRUST STORE? A SECOND effect, not a
3688/// replacement for the one `classify` returns.
3689///
3690/// **THE DEFECT.** candor charges `native_tls::TlsConnector::new` `Fs` because on the openssl backend
3691/// it loads the probed cert file/dir from disk. Several calibrated crates construct that connector
3692/// INSIDE a public entry point, so the consumer's call discloses the transport effect and drops the
3693/// `Fs` — `tungstenite::client_tls` reports `['Net']`, and `deny Fs` passes over a real trust-store
3694/// read. `wrap_stream` does `tls_connector.map_or_else(TlsConnector::new, Ok)`
3695/// (`tungstenite-0.30.0/src/tls.rs:54`), so a caller supplying no connector gets `TlsConnector::new()`.
3696/// (The row the coverage gate nominated — `tungstenite::tls::encryption::native_tls::wrap_stream` — is
3697/// unreachable from outside: `mod tls;` is private at `lib.rs:32`. The reachable form is one level up.)
3698///
3699/// **WHY THIS IS SO SHORT: the sweep found four more crates and every one was PRICED AND REJECTED,
3700/// which is the deliverable rather than a gap.** Callers of `native_tls::TlsConnector::new` in the
3701/// local registry are redis, tungstenite, ureq, minreq and tokio-websockets.
3702///   - `minreq`, `tokio_websockets` — NOT calibrated, so their calls already disclose rather than
3703///     claim purity. No rule can improve them.
3704///   - `redis` — `ActualConnection::new` (`redis-1.6.0/src/connection.rs:932`) constructs it only for a
3705///     `rediss://` address, and the consumer-visible verb is `Client::get_connection`. Charging that
3706///     `Fs` would fabricate on every PLAIN redis user, which is the majority. Rejected on the trade.
3707///   - `ureq` — `agent.rs:265` takes `crate::default_tls_config()`, and ureq's default features are
3708///     `["tls", "gzip"]`: `native-certs` is OFF, so the default build resolves to
3709///     `rtls::root_certs()`'s `#[cfg(not(feature = "native-certs"))]` arm, which is
3710///     `webpki_roots::TLS_SERVER_ROOTS` — COMPILED IN, no disk read (`ureq-2.12.1/src/rtls.rs:82`).
3711///     Charging it would fabricate on the default build. Rejected on the evidence.
3712///
3713/// What is left is tungstenite's two explicitly-TLS-named entry points, where no caller is
3714/// over-charged: `client_tls` passes `None` for the connector unconditionally, and
3715/// `client_tls_with_config`'s callers are by definition doing TLS. **`tungstenite::connect` is a stated
3716/// residual, not an oversight** — it serves `ws://` and `wss://` alike, so charging it would hit real
3717/// plain-WebSocket users; the scheme is often a string literal candor already captures in `str_arg`,
3718/// which is the shape a future fix should use rather than a blanket charge.
3719pub fn reads_trust_store(crate_name: &str, path: &str) -> bool {
3720    crate_name == "tungstenite"
3721        && (path.ends_with("::client_tls") || path.ends_with("::client_tls_with_config"))
3722}
3723
3724/// SOUNDNESS R330 — IS THIS `hash_password` CALL PROVABLY THE EXPLICIT-SALT ONE (password-hash 0.5.x)?
3725///
3726/// **THE DEFECT THIS EXISTS FOR, and it was mine, introduced by R318's fix the previous day.** R318
3727/// correctly found that `hash_password` mints OS entropy — at password-hash **0.6.x**, where
3728/// `fn hash_password(&self, password)` (`lib.rs:107`) has the body `let salt = try_generate_salt()?;`.
3729/// At **0.5.0** (`traits.rs:33`) and argon2 **0.5.3** (`lib.rs:572`) the identical name is
3730/// `fn hash_password(&self, password, salt)`: the caller supplies the salt and the call is deterministic
3731/// recomputation — PURE. So the `ends_with`-not-`contains` guard R318 relied on was keyed on the 0.6.x
3732/// name, and at 0.5.x the explicit-salt call IS named `hash_password`. Measured: two calls with the same
3733/// stored salt produce byte-identical hashes, and all four 0.5.x spellings were charged `Rand`.
3734///
3735/// **Why arity and not the resolved version.** R330's remedy offered both. The version is only knowable
3736/// where a lockfile resolves, and `calibration_exceeded` is ONE-SIDED — it fires when resolved > ceiling,
3737/// so it can never see a rule that mis-describes an OLDER release, which is exactly this direction. The
3738/// arity is written at the call site, needs no lockfile, and distinguishes the two signatures exactly.
3739///
3740/// **The direction is stated so it cannot drift:** this returns true only for the shape it can PROVE is
3741/// explicit-salt. An unrecorded arity (`argc == 0`, every synthesized edge and every pre-R330 cache
3742/// entry) returns false and the call stays charged. Narrowing a sound over-approximation by DENYLIST,
3743/// never by allowlist — the family rule.
3744pub fn password_hash_explicit_salt(crate_name: &str, path: &str, argc: u8, method: bool) -> bool {
3745    if !matches!(crate_name, "argon2" | "scrypt" | "pbkdf2" | "password_hash")
3746        || !path.ends_with("::hash_password")
3747    {
3748        return false;
3749    }
3750    if argc == 0 {
3751        return false; // NOT RECORDED — see `Call::argc`. Unknown charges.
3752    }
3753    // `syn` hands a method call its args WITHOUT the receiver and a UFCS `Trait::method(&recv, ..)`
3754    // WITH it, so normalize to the non-receiver count before comparing: 0.5.x is `(password, salt)` = 2,
3755    // 0.6.x is `(password)` = 1.
3756    let non_receiver = if method { argc } else { argc - 1 };
3757    let hit = non_receiver == 2;
3758    // §E1 HIT COUNTER, the `CANDOR_ALIAS_DEBUG` pattern. A refinement that narrows a charge must be
3759    // able to prove it REACHED real code, because "nothing moved" and "the branch never ran" print the
3760    // same corpus A/B. This is what `bin/corpus-ab.py --mark` counts.
3761    if hit && std::env::var("CANDOR_ALIAS_DEBUG").is_ok() {
3762        eprintln!("R330EXPLICITSALT {path} argc={argc} method={method}");
3763    }
3764    hit
3765}
3766
3767/// ⟨0.29⟩ HOW MANY LEADING ARGUMENTS OF AN `Fs` PATH-TAKING CALL ARE PATHS.
3768///
3769/// **THE DEFECT THIS EXISTS FOR.** The literal harvester took the first string literal found ANYWHERE in
3770/// the argument list, so `fs::write(user_path, "/tmp/lit")` published `paths: ["/tmp/lit"]` — the BYTES
3771/// BEING WRITTEN — as the destination surface, and `allow Fs /tmp/lit` certified a write to an
3772/// attacker-controlled path at exit 0. Measured on candor-scan and candor-ts; candor-java and
3773/// candor-swift read the path POSITION and fail closed correctly. Removing the sibling literal made the
3774/// same call fail closed, which is what identified the mechanism: any literal in the call, in any
3775/// position, defeated the runtime-path incompleteness marker.
3776///
3777/// So the surface is read from the PATH POSITIONS and nowhere else, and every one of them must be a
3778/// literal for the surface to be complete. Two-path operations are the reason this is an arity and not a
3779/// boolean: `fs::copy("/safe", user_path)` has a literal at position 0 and still writes somewhere
3780/// nobody can see, so requiring only position 0 would leave the identical hole one argument along.
3781pub fn fs_path_arity(leaf: &str) -> usize {
3782    match leaf {
3783        "copy" | "rename" | "hard_link" | "soft_link" | "symlink" | "symlink_file" | "symlink_dir" => 2,
3784        _ => 1,
3785    }
3786}
3787
3788/// SOUNDNESS R383 — THE METHOD FORMS WHOSE PATH IS AN ARGUMENT, not the receiver.
3789///
3790/// `scan.rs`'s Fs masking arm reads `!c.method && is_fs_path_arg(leaf)`. The `!c.method` gate exists for
3791/// a real reason — the path-STAT methods (`p.metadata()`, `p.exists()`) carry the path as the RECEIVER,
3792/// so masking them would be wrong — but it excluded EVERY method form, and `OpenOptions::open(path)` is
3793/// a method whose path IS the argument. Measured, with the instrument calibrated first: a function doing
3794/// `File::open("/etc/hostname")` beside `OpenOptions::new().read(true).open(caller_path)` reported
3795/// `paths:['/etc/hostname'] incomplete:NONE`; `deny Fs` exited 1 and **`allow Fs /etc/hostname` exited
3796/// 0** — a policy saying "only /etc/hostname" going green over a caller-supplied path. The FREE-fn
3797/// spelling of the same call is the isolating control: it marks incomplete and fails closed.
3798///
3799/// **`argc` does not discriminate; the RECEIVER TYPE does.** Instrumented, the four shapes are
3800/// `OpenOptions::open` (argc 1, path IS the arg), `File::read_to_string` and `File::write` (argc 1,
3801/// BUFFER arg) and `Path::exists` (argc 0, path is the receiver).
3802///
3803/// **The family is from a 1,545-crate sweep, not from the one spelling that was found (R346):** the only
3804/// path-taking METHOD pairs in the registry are `OpenOptions::open` (69 std + 2 tokio + 9
3805/// `cap_primitives`) and `DirBuilder::create` (5 std + tokio). Every other method on those same receivers
3806/// is a builder modifier (`read`/`write`/`truncate`/`mode`) or a combinator (`map`/`map_err`/`or_else`/
3807/// `with_context`), and `std::fs::File`'s 267 method hits are all use-verbs whose path was fixed at open.
3808///
3809/// Matched on the TAIL of the resolved call path, so std, tokio, `cap_primitives` and `fs_err` are all
3810/// covered by one rule without naming a crate. **Stays an ALLOWLIST:** R379 built the denylist inversion
3811/// for the Net twin and the corpus refused it, and here a denylist over method forms would mask all 267
3812/// `File` use-verbs and every combinator on a whole-crate-Fs receiver.
3813///
3814/// **SOUNDNESS R417 — THE CAPABILITY-`Dir` FAMILY WAS ABSENT, AND IT IS A LIVE GATE BYPASS.**
3815/// `cap_std::fs::Dir` (and its `fs_utf8`/`cap_async_std` twins, and `openat::Dir`) is a whole second
3816/// filesystem API whose path is an ARGUMENT to a METHOD on a directory handle — `d.write(caller, …)`,
3817/// `d.open(caller)`, `d.remove_file(caller)`. MEASURED, with the free-fn spelling as the isolating
3818/// control in the same fixture:
3819///
3820/// ```text
3821/// control(caller)  std::fs::write("/tmp/benign",…); std::fs::write(caller,…)
3822///                  → paths:['/tmp/benign'] incomplete:['Fs']   allow Fs /tmp/benign → exit 1  ✔
3823/// mixed(d,caller)  std::fs::write("/tmp/benign",…); d.write(caller,…)
3824///                  → paths:['/tmp/benign'] incomplete:NONE     allow Fs /tmp/benign → exit 0  ✘
3825/// ```
3826///
3827/// The call path resolves in full (`cap_std::fs::Dir::write`), so this is not a resolution gap — the
3828/// guard simply had two names in it. `alone(d,caller)` confirms the call IS classified `Fs`: the
3829/// effect was seen, the locator was not, and nothing said so.
3830///
3831/// **WHY THIS HALF IS A DENYLIST WHILE THE REST OF THE GUARD IS AN ALLOWLIST**, which is not a
3832/// contradiction but the point: the allowlist above exists because the receiver is UNKNOWN, so masking
3833/// by default would swallow `File`'s 267 use-verbs. Here the receiver is KNOWN to be a directory
3834/// capability, and on that receiver essentially every method names a path — 24 of the 49 declared on
3835/// `cap_std::fs::Dir` are already `is_fs_path_arg` leaves, and most of the remaining 25 (`open_with`,
3836/// `open_dir`, `is_file`, `is_dir`, `symlink_contents`, `read_link_contents`, `create_dir_with`,
3837/// the `bind_unix_*`/`connect_unix_*` socket-path verbs) take one too. An allowlist here would be the
3838/// R346→R348 hand-list vein by construction: every name I failed to write down is a silent bypass, and
3839/// R399 settled that an under-catch on this guard is a BROKEN GATE, not a missed mask.
3840///
3841/// So the default on a `Dir` receiver is MASK, and the exceptions are the handful of methods that
3842/// provably take no path: handle-to-handle conversions and the iterator/`self`-only verbs. Being wrong
3843/// about one of those costs an over-mask on a rare API (fails CLOSED, disclosed); being wrong the other
3844/// way is the exit-0 above. [[candor-denylist-over-allowlist]] — say which direction it fails in first.
3845///
3846/// Scoped on the RECEIVER SEGMENT being exactly `Dir`, so `cap_std`, `cap_std::fs_utf8`,
3847/// `cap_async_std` and `openat` are covered by one rule without naming a crate — the same tail-matching
3848/// discipline as the two names above. A non-filesystem type that happens to be called `Dir` would be
3849/// over-masked, which fails closed.
3850/// SOUNDNESS R414 / SPEC ⟨0.37⟩ — **a RECEIVER-form path stat names its destination, and every engine
3851/// in this family was silent on it.** `p.exists()`, `p.metadata()`, `p.canonicalize()` reach the
3852/// filesystem against the path they are invoked ON; the locator is the RECEIVER, not an argument.
3853/// MEASURED before the clause was written, one variable, a benign allowed literal beside a
3854/// caller-chosen path:
3855///
3856/// ```text
3857/// fn f(p: &Path) { fs::write("/tmp/benign", b"x"); p.exists(); }
3858///   -> paths:['/tmp/benign'] incomplete:NONE   allow Fs /tmp/benign -> exit 0, "nothing hidden"
3859/// ```
3860///
3861/// The ARGUMENT spelling of the identical reach (`fs::metadata(p)`) was already marked, which is what
3862/// makes this a drift rather than a policy: `is_fs_path_arg` deliberately excluded the method form
3863/// because its receiver was assumed to be an OPEN HANDLE. That assumption holds for `File` and is
3864/// false for `Path` — a `Path` is a path VALUE, and a stat on it is `Fs` reaching that value.
3865///
3866/// **NO CARVE-OUT LIST, and that is structural rather than lucky.** The pure `Path` algebra —
3867/// `join`, `parent`, `file_name`, `extension`, `to_str`, `display`, `starts_with`, `to_path_buf`,
3868/// `as_path` — is NOT classified `Fs` (measured: a function calling all nine reports `fs:['write']`
3869/// from an unrelated sibling call and nothing else), so it never reaches the branch that consults
3870/// this predicate. The carve-out falls out of the classification, exactly as it does on the java
3871/// side, instead of being a list that must be kept in sync with `std`.
3872///
3873/// Matched on the RECEIVER SEGMENT so `std::path` and the `camino` mirrors are covered by one rule
3874/// without naming a crate. Being generous here is the SAFE direction: the predicate is only ever
3875/// consulted for a call the classifier ALREADY resolved to `Fs`, so an extra receiver name can at
3876/// worst over-mask (fails closed, disclosed), while a missing one is the exit-0 above — R399's
3877/// ruling that an under-catch on a masking guard is a broken gate, not a missed mask.
3878pub fn is_fs_receiver_locator(call_path: &str) -> bool {
3879    let mut segs = call_path.rsplit("::");
3880    let (Some(_leaf), Some(recv)) = (segs.next(), segs.next()) else { return false };
3881    matches!(recv, "Path" | "PathBuf" | "Utf8Path" | "Utf8PathBuf")
3882}
3883
3884/// SOUNDNESS R460 / SPEC ⟨0.37⟩ — **the Exec twin of `is_fs_receiver_locator`: a spawn's locator is
3885/// its RECEIVER, and rust was silent on it.** `is_cmd_naming_method` marks the surface incomplete at
3886/// `Command::new(<runtime value>)`, which covers every spelling that NAMES the program inside the
3887/// function. It cannot cover the spelling that names it somewhere else:
3888///
3889/// ```text
3890/// fn masked(cmd: &mut Command) { Command::new("git").status(); cmd.spawn(); }
3891///   -> cmds:['git'] incomplete:NONE   allow Exec git -> exit 0, "nothing hidden"
3892/// ```
3893///
3894/// MEASURED on the pre-fix binary, one variable — deleting the benign `Command::new("git")` line, and
3895/// nothing else, turns the same gate to exit 1. The real instance is tokio's own
3896/// `process::unix::spawn_child(cmd: &mut std::process::Command) { cmd.spawn()? }`, production source,
3897/// charged `Exec` with no `cmds` and no `incomplete`.
3898///
3899/// **A DENYLIST, and the direction is the point.** On a `Command` receiver essentially every method
3900/// that is not a documented BUILDER modifier reaches the boundary (`spawn`, `status`, `output`, `exec`,
3901/// and every async / pty mirror of them), so an allowlist of terminal names would be the R346→R348
3902/// hand-list vein by construction: each name not written down is a silent bypass. The carve-out is
3903/// `is_cmd_builder_method` — the SAME list the head-refinement already trusts, not a second copy of it
3904/// (§G, ask the authority) — plus the `get_*` getters that list's own doc-block names. Being wrong
3905/// about a carve-out costs an over-mask on a configure-only call (fails closed, disclosed); being
3906/// wrong the other way is the exit-0 above.
3907///
3908/// Scoped on the RECEIVER SEGMENT being exactly `Command`, so `std::process`, `tokio::process`,
3909/// `async_process` and the `std::os::unix` extension trait are one rule without naming a crate — the
3910/// same tail-matching discipline as `is_fs_receiver_locator`. The predicate is only ever consulted for
3911/// a call the classifier ALREADY resolved to `Exec`, so a non-spawning type that happens to be called
3912/// `Command` (clap's builder) is unreachable unless something already charged it Exec.
3913///
3914/// The DETERMINED receiver does not arrive here: the collector resolves a builder chain rooted at
3915/// `Command::new("git")` — inline or through a `let` binding — into `str_arg`, so only a receiver whose
3916/// program was never named in this function reaches the mask. That split is this fix's over-charge
3917/// control, and it is what keeps the dominant spelling certifiable.
3918pub fn is_exec_receiver_locator(call_path: &str) -> bool {
3919    let mut segs = call_path.rsplit("::");
3920    let (Some(leaf), Some(recv)) = (segs.next(), segs.next()) else { return false };
3921    // SOUNDNESS R808 — AND ITS EXTENSION TRAIT. The deep engine resolves `cmd.exec()` to the TRAIT method
3922    // `std::os::unix::process::CommandExt::exec`, not to `Command::exec`, so a receiver test on the
3923    // literal segment `Command` let the deep engine certify a caller-supplied `exec` while `candor-scan`
3924    // (which forms `Command::exec` from the typed receiver) flagged it — the R808 port's own boundary,
3925    // measured on the port's fixture one method over. `CommandExt`'s other members (`uid`, `gid`,
3926    // `groups`, `pre_exec`, `arg0`, `process_group`) are already `is_cmd_builder_method` carve-outs.
3927    matches!(recv, "Command" | "CommandExt") && !is_cmd_builder_method(leaf) && !leaf.starts_with("get_")
3928}
3929
3930pub fn is_fs_path_arg_method(call_path: &str) -> bool {
3931    if call_path.ends_with("OpenOptions::open") || call_path.ends_with("DirBuilder::create") {
3932        return true;
3933    }
3934    let mut segs = call_path.rsplit("::");
3935    let (Some(leaf), Some(recv)) = (segs.next(), segs.next()) else { return false };
3936    if recv != "Dir" {
3937        return false;
3938    }
3939    // The no-path exceptions on a directory capability: handle↔handle conversions, the entry
3940    // iterators, and the verbs whose only operand is `self`. Everything else on a `Dir` names a path.
3941    //
3942    // EVERY NAME HERE WAS CHECKED AGAINST ITS SIGNATURE, because a wrong entry here is not a precision
3943    // loss, it is the exit-0 above. `read_dir` was in this list on the first cut on the reasonable-
3944    // sounding grounds that `entries()` is the self-only form — and `cap_std::fs::Dir::read_dir` is
3945    // `fn read_dir<P: AsRef<Path>>(&self, path: P)`, so that entry was a bypass I had just written.
3946    // Adding a name here requires reading its signature, not recognising it.
3947    !matches!(
3948        leaf,
3949        "try_clone"
3950            | "into_std_file"
3951            | "from_std_file"
3952            | "into_std"
3953            | "from_std"
3954            | "entries"
3955            | "entries_utf8"
3956            | "dir_metadata"
3957            | "reopen_dir"
3958            | "remove_open_dir"
3959            | "remove_open_dir_all"
3960            | "open_parent_dir"
3961            | "rewind"
3962            | "as_raw_fd"
3963            | "as_fd"
3964    )
3965}
3966
3967/// The masking guard (AS-EFF-008), the `Db` analog of `is_net_establishing`: whether a `Db`-classified
3968/// call takes the raw SQL QUERY as a string argument (so a missing literal leaves the table
3969/// structurally INVISIBLE — a runtime-built query — and the surface is incomplete, fail-closed). An
3970/// ALLOWLIST of the SQL-string-bearing execution/prepare verbs, the SAFE direction: a
3971/// build-then-execute terminal that takes NO SQL string (sqlx/diesel/sea_orm `fetch*`/`load*`/`first`/
3972/// `all`/`one`/`stream`, the document-store `find*`/`insert*`/…), and a non-query op (`connect`/
3973/// `open`/`acquire`/`begin`/`commit`/`ping`/`get_conn`), are NOT here — their query is built
3974/// structurally (never a maskable string literal) so a missing literal must not false-positive.
3975/// Under-catching an unusual query verb is a missed mask (sound-with-disclosure), ~~never a broken
3976/// gate~~ — **FALSE, SOUNDNESS R399**, and R386 three lines below is this guard's own counter-example.
3977/// `mysql`'s `query_drop`/`query_iter` are that crate's PRIMARY API, take `Q: AsRef<str>`, and were
3978/// absent: `allow Db users` exited 0 over `c.query_drop(caller_sql)` beside one literal query, with the
3979/// verb-only control exiting 1. The arg is the method leaf (the path's last segment).
3980pub fn is_db_query_arg(leaf: &str) -> bool {
3981    // SOUNDNESS R386 — THE `sqlite3_*` C API TAKES SQL AND WAS ABSENT, so a benign sibling literal
3982    // certified arbitrary caller-supplied SQL. `classify` in this same crate maps `sqlite3_exec`/
3983    // `sqlite3_step`/`sqlite3_prepare*` to `Db`; this list had none of them, while candor-swift covers
3984    // the whole family by prefix — a cross-engine divergence, which is how it was found.
3985    //
3986    // MEASURED, calibrated first (`deny Db` exits 1): `conn.execute("INSERT INTO users (id) VALUES (1)",
3987    // [])` beside `sqlite3_exec(db, caller_sql, …)` reported `tables:['users'] incomplete:NONE` and
3988    // **`allow Db users` exited 0**. R383 recorded this gap as "REAL BUT NOT LIVE" on the grounds that a
3989    // C-string literal never reaches `tables` — true of an ISOLATED function, and the wrong shape: the
3990    // literal does not have to come from the masked call, only from the same FUNCTION.
3991    //
3992    // ONLY THE SQL-BEARING SPELLINGS. `sqlite3_step`/`_close`/`_serialize`/`_deserialize` carry no query,
3993    // and `sqlite3_open*` takes a FILENAME — masking that would claim a Db surface for an Fs locator,
3994    // which is the over-mask this allowlist exists to avoid. Direction stays an ALLOWLIST for the reason
3995    // R379 measured: a denylist over a whole-crate-Db crate masks every lifecycle verb in it.
3996    if matches!(
3997        leaf,
3998        "sqlite3_exec"
3999            | "sqlite3_prepare"
4000            | "sqlite3_prepare_v2"
4001            | "sqlite3_prepare_v3"
4002            | "sqlite3_prepare16"
4003            | "sqlite3_prepare16_v2"
4004            | "sqlite3_prepare16_v3"
4005            // R386's OWN BOUNDARY DEFECT, found by a release panel: `sqlite3_get_table(db, zSql, …)`
4006            // takes SQL as its second argument and `classify` maps it to `Db`, and the first cut of
4007            // this list — which cites R346 — omitted it. Two of the family's SQL-bearing spellings
4008            // written down out of three. Reach on the local registry is ZERO call sites (only
4009            // declarations in `libsqlite3-sys` and `sqlite-wasm-rs`), so this is latent, not live.
4010            | "sqlite3_get_table"
4011    ) {
4012        return true;
4013    }
4014    matches!(
4015        leaf,
4016        "execute"
4017            | "execute_batch"
4018            | "execute_unprepared"
4019            | "batch_execute"
4020            | "simple_query"
4021            | "query"
4022            | "query_one"
4023            | "query_opt"
4024            | "query_raw"
4025            | "query_row"
4026            | "query_map"
4027            // SOUNDNESS R399 — `mysql`'s OWN PRIMARY API was absent, and this is a live gate bypass rather
4028            // than the "missed mask" the struck sentence above promised. All four take `Q: AsRef<str>`
4029            // (`mysql-28.0.2/src/conn/queryable.rs:29,50,126`), so the SQL is a maskable string argument of
4030            // THIS call, which is the exact condition this list encodes. Measured: `allow Db users` exits 0
4031            // over `c.query_drop(caller_sql)` beside one literal query; the control, the same fixture with
4032            // the verb changed to `query`, exits 1.
4033            | "query_drop"
4034            | "query_iter"
4035            | "query_first"
4036            | "query_fold"
4037            // postgres COPY: the statement is a SQL string argument (`postgres-0.19.14/src/client.rs:492,520`).
4038            | "copy_in"
4039            | "copy_out"
4040            | "query_and_then"
4041            | "query_typed"
4042            | "query_all"
4043            | "prepare"
4044            | "prepare_typed"
4045            | "prepare_cached"
4046            | "exec"
4047            | "exec_first"
4048            | "exec_iter"
4049            | "exec_map"
4050            | "exec_fold"
4051            | "exec_drop"
4052            | "exec_batch"
4053            | "prep"
4054            | "run_command"
4055    )
4056}
4057
4058/// THE AS-EFF-008 MASKING GUARD, ONE AUTHORITY FOR BOTH RUST ENGINES. SOUNDNESS R806 / R808.
4059///
4060/// The question: this call carries a surface effect `eff` and NO literal locator was captured for it —
4061/// is its locator (host, program, path, SQL) therefore a RUNTIME value the gate cannot see? If so the
4062/// caller marks the surface `incomplete`, so a benign sibling literal cannot certify it.
4063///
4064/// **WHY ONE FUNCTION.** Both rust engines asked this question, each with its own copy of the
4065/// disjunction over the `is_*` predicates below, and the copies drifted: R460's receiver-locator arm and
4066/// R383's `OpenOptions::open` arm reached `candor-scan` and never the deep engine (R808). A rule added
4067/// here now reaches both, which is the only way this class stops recurring one crate over.
4068///
4069/// `leaf` is the call's own method/function name; `path` the resolved call path; `method` whether the
4070/// call is written in method form on a receiver (so a path-stat `p.exists()` is not mistaken for an
4071/// argument-form `fs::metadata(p)`, and the receiver-locator arms can fire). `crate_name` is the
4072/// resolved crate, used only to scope the table-derived FFI arms.
4073///
4074/// **THE DIRECTION, stated so it cannot drift:** a wrong `true` over-masks — the gate fails CLOSED and
4075/// says so; a wrong `false` is the benign-sibling-literal bypass, a broken gate (R399). Every arm that
4076/// reads a `classify` table below reads it with a NO-LOCATOR DENYLIST, so a leaf added to that table is
4077/// masked until someone reads its signature and says otherwise.
4078pub fn masks_locator(eff: &str, crate_name: &str, path: &str, leaf: &str, method: bool) -> bool {
4079    let by_list = match eff {
4080        "Net" => is_net_establishing(leaf),
4081        // SOUNDNESS R808 — the receiver arm is NOT gated on method form. `Command::spawn(cmd)` (UFCS)
4082        // runs the same caller-supplied program as `cmd.spawn()`, and with the gate BOTH engines
4083        // certified it at exit 0 on the unit and its caller. In call form the receiver is argument 0;
4084        // neither engine resolves a determined argument-0 command, so a UFCS spawn on a command built
4085        // in the same function over-masks (fails closed) — the rare spelling paying for the silent one.
4086        "Exec" => is_cmd_naming_method(leaf) || is_exec_receiver_locator(path),
4087        "Fs" => {
4088            (!method && is_fs_path_arg(leaf))
4089                || (method && is_fs_path_arg_method(path))
4090                || (method && is_fs_receiver_locator(path))
4091        }
4092        "Db" => is_db_query_arg(leaf),
4093        _ => false,
4094    };
4095    by_list || masks_locator_by_table(eff, crate_name, path, leaf)
4096}
4097
4098/// SOUNDNESS R806 — THE TABLE-DERIVED HALF OF `masks_locator`, separate only so a reach probe can ask
4099/// the very function the guard asks (`R806MASK` in candor-scan) rather than a copy of it.
4100///
4101/// Each hand list in `masks_locator` was SHORT against the `classify` table that charges the effect:
4102/// `is_fs_path_arg` held 28 names while `LIBC_FS` charges 92, `is_cmd_naming_method` held `new`/`cmd`
4103/// while `LIBC_EXEC` names `system`/`popen`/`exec*`/`posix_spawn*`, `is_net_establishing` lacked
4104/// `getaddrinfo`, and `is_db_query_arg` lacked `prepare_typed_cached` from `PG_DB_VERBS`. EXECUTED on
4105/// each: a caller's file really unlinked, a caller's shell command really run, a real resolver lookup,
4106/// all under `allow <E> in <unit> <benign literal>` at exit 0 on the unit AND its caller.
4107///
4108/// Adding the missing names would leave two tables to drift again the next time one grows — the shape
4109/// swift closed as R787 and java as R794, both by derivation. So these arms READ the charging table and
4110/// subtract a signature-checked NO-LOCATOR denylist: a leaf added to the table is masked by default.
4111pub fn masks_locator_by_table(eff: &str, crate_name: &str, path: &str, leaf: &str) -> bool {
4112    let syscall = is_syscall_crate(crate_name);
4113    match eff {
4114        "Net" => {
4115            syscall
4116                && LIBC_NET.contains(&leaf)
4117                && !LIBC_NET_NO_DESTINATION.contains(&leaf)
4118                // `rustix::net::sendmsg(socket, iov, control, flags)` takes NO address — rustix spells
4119                // the addressed forms `sendmsg_addr`/`sendmsg_v4`/`sendmsg_v6`/`sendmsg_unix` (not in
4120                // `LIBC_NET`, so unclassified). libc's and nix's `sendmsg` DO carry one (`msg_name` /
4121                // `addr: Option<&S>`), which is why this is scoped to the crate rather than the leaf.
4122                // Measured on the A/B: x11rb's `DefaultStream::do_write` over its connected X11 socket
4123                // was the only reach, an over-mask, removed here.
4124                && !(crate_name == "rustix" && leaf == "sendmsg")
4125        }
4126        "Exec" => syscall && LIBC_EXEC.contains(&leaf) && !LIBC_EXEC_NO_PROGRAM.contains(&leaf),
4127        "Fs" => syscall && LIBC_FS.contains(&leaf) && !LIBC_FS_NO_PATH.contains(&leaf),
4128        "Db" => {
4129            (matches!(crate_name, "postgres" | "tokio_postgres" | "deadpool_postgres" | "rusqlite")
4130                && PG_DB_VERBS.iter().any(|v| path.ends_with(v))
4131                && !PG_DB_VERBS_NO_SQL.iter().any(|v| path.ends_with(v)))
4132                // `sqlx_core`'s `Executor::prepare_with(sql, params)` — the one SQL-TEXT verb in that
4133                // crate's Db rule that the leaf list lacked (`prepare` is there). The rest of that rule
4134                // (`fetch*`/`execute*` on a `Query`) takes an EXECUTOR at argument 0, so deriving the
4135                // whole rule would mask every `query(lit).fetch_all(&pool)`; it is a named member
4136                // rather than a derivation for that reason.
4137                || (crate_name == "sqlx_core" && leaf == "prepare_with")
4138        }
4139        _ => false,
4140    }
4141}
4142
4143/// Map a cap-std capability *type* to the effect it authorises. Holding one of these
4144/// (e.g. `&Dir`) is the real, unforgeable right to perform that effect — so candor
4145/// treats it as a declared capability, exactly like its own `&Fs` token.
4146pub fn capstd_cap(crate_name: &str, type_name: &str) -> Option<&'static str> {
4147    if !crate_name.starts_with("cap_") {
4148        return None;
4149    }
4150    Some(match type_name {
4151        "Dir" => "Fs",
4152        "TcpListener" | "TcpStream" | "UdpSocket" | "Pool" => "Net",
4153        "UnixListener" | "UnixStream" | "UnixDatagram" => "Ipc",
4154        "SystemClock" | "MonotonicClock" => "Clock",
4155        _ => return None,
4156    })
4157}
4158
4159/// Table names a SQL string literal STATICALLY reaches — the `Db` analog of the `Net` host /
4160/// `Exec` command / `Fs` path literal surface (feeds `allow Db in <scope> <table>…`, AS-EFF-008).
4161/// Conservative by construction, because a wrong capture here would FABRICATE: the string must
4162/// open with a SQL statement keyword, and only identifiers in table position are taken —
4163/// `FROM`/`JOIN` anywhere, `INTO` anywhere, statement-leading `UPDATE`/`TRUNCATE`, and
4164/// `TABLE` (create/drop/alter), skipping `ONLY`/`IF NOT EXISTS`. `UPDATE` mid-statement is
4165/// deliberately ignored (`FOR UPDATE SKIP LOCKED` must not yield a table "skip"). A
4166/// dynamically-built query yields nothing — the gate's opaque case — never a guess.
4167/// Output is lower-cased, quote/backtick-stripped, `schema.table` kept qualified, deduped.
4168/// SPEC §2 pins this algorithm token-for-token across engines; the cross-impl vector battery
4169/// (candor-spec conformance/tables/vectors.json, run.sh Part 4b) enforces the JVM/TS mirrors.
4170pub fn tables_in_sql(sql: &str) -> Vec<String> {
4171    const STMT: &[&str] =
4172        &["select", "insert", "update", "delete", "create", "drop", "alter", "truncate", "merge", "replace", "with"];
4173    // Tokens that can FOLLOW a table-introducing keyword without being a table.
4174    const SKIP: &[&str] = &["only", "if", "not", "exists", "table"];
4175    // Identifier-position tokens that are grammar, not a table (subqueries, locking clauses…).
4176    const STOP: &[&str] = &[
4177        "select", "set", "where", "values", "on", "using", "group", "order", "by", "limit",
4178        "returning", "as", "inner", "outer", "left", "right", "cross", "lateral", "natural",
4179        "union", "all", "distinct", "case", "when", "null", "default", "skip", "nowait", "of",
4180        "from", "join", "into", "update", "delete", "insert",
4181    ];
4182    // `,` survives as its OWN token (not a space): it's what lets `FROM t1, t2` continue the table
4183    // list without fabricating from other comma-ridden positions (column lists, ON clauses).
4184    let cleaned: String = sql
4185        .to_lowercase()
4186        .chars()
4187        .flat_map(|c| match c {
4188            '(' | ')' | ';' => vec![' '],
4189            ',' => vec![' ', ',', ' '],
4190            _ => vec![c],
4191        })
4192        .collect();
4193    let toks: Vec<&str> = cleaned.split_whitespace().collect();
4194    let Some(first) = toks.first() else { return Vec::new() };
4195    if !STMT.contains(first) {
4196        return Vec::new(); // not SQL — nothing to certify, nothing fabricated
4197    }
4198    let ident = |t: &str| -> Option<String> {
4199        let t = t.trim_matches(|c| matches!(c, '"' | '`' | '\''));
4200        let mut chars = t.chars();
4201        let ok_first = chars.next().is_some_and(|c| c.is_ascii_alphabetic() || c == '_');
4202        let ok_rest = t.chars().all(|c| c.is_ascii_alphanumeric() || matches!(c, '_' | '.' | '$' | '"' | '`'));
4203        (ok_first && ok_rest && !STOP.contains(&t)).then(|| t.replace(['"', '`'], ""))
4204    };
4205    let mut out: Vec<String> = Vec::new();
4206    let mut push = |t: Option<String>| {
4207        if let Some(t) = t {
4208            if !out.contains(&t) {
4209                out.push(t);
4210            }
4211        }
4212    };
4213    for (i, tok) in toks.iter().enumerate() {
4214        let table_pos = match *tok {
4215            "from" | "join" | "into" | "table" => true,
4216            // statement-leading only (see doc comment): `update t set …`, `truncate [table] t`.
4217            "update" | "truncate" => i == 0,
4218            _ => false,
4219        };
4220        if !table_pos {
4221            continue;
4222        }
4223        let mut j = i + 1;
4224        while j < toks.len() && SKIP.contains(&toks[j]) {
4225            j += 1;
4226        }
4227        let Some(next) = toks.get(j) else { continue };
4228        let Some(first) = ident(next) else { continue };
4229        push(Some(first));
4230        // Comma-ADJACENT continuation only: `FROM t1, t2, t3` takes all three, while an alias breaks
4231        // the chain (`FROM t1 a, t2` keeps just t1 — an under-report, never a guess: skipping an
4232        // alias to chase the comma would fabricate tables out of `INSERT INTO t (a, b)`'s column
4233        // list, whose parens are spaces by the time we tokenize).
4234        while j + 2 < toks.len() && toks[j + 1] == "," {
4235            let Some(more) = ident(toks[j + 2]) else { break };
4236            push(Some(more));
4237            j += 2;
4238        }
4239    }
4240    out
4241}
4242
4243#[cfg(test)]
4244mod tests {
4245    #[test]
4246    fn model_host_recognizes_known_providers_and_special_forms() {
4247        use super::is_model_host as m;
4248        // exact known hosts (case-insensitive), with/without a port
4249        assert!(m("api.openai.com"));
4250        assert!(m("API.OpenAI.com"));
4251        assert!(m("api.anthropic.com:443"));
4252        assert!(m("generativelanguage.googleapis.com"));
4253        assert!(m("api.mistral.ai"));
4254        assert!(m("api.cohere.ai"));
4255        assert!(m("api.cohere.com")); // BOTH cohere hosts
4256        assert!(m("api.groq.com"));
4257        assert!(m("api.together.xyz"));
4258        assert!(m("api.perplexity.ai"));
4259        assert!(m("openrouter.ai"));
4260        // a subdomain of a known host counts
4261        assert!(m("eu.api.openai.com"));
4262        // Ollama: :11434 on a LOOPBACK host only (max-review r3 — a remote host on 11434 is not Ollama)
4263        assert!(m("localhost:11434"));
4264        assert!(m("127.0.0.1:11434"));
4265        assert!(!m("ollama.internal:11434")); // a remote/internal service on 11434 is NOT a model host
4266        // Bedrock: the FIRST label is the model-inference service, not the substring "bedrock"
4267        assert!(m("bedrock-runtime.us-east-1.amazonaws.com"));
4268        assert!(m("bedrock-runtime.eu-west-1.amazonaws.com"));
4269        assert!(m("bedrock-agent-runtime.us-east-1.amazonaws.com"));
4270        // NOT model hosts (never guessed)
4271        assert!(!m("example.com"));
4272        assert!(!m("api.stripe.com"));
4273        assert!(!m("localhost:8080")); // a non-Ollama local port
4274        assert!(!m("s3.us-east-1.amazonaws.com")); // amazonaws but not bedrock
4275        assert!(!m("bedrock-backups.s3.amazonaws.com")); // an S3 bucket merely NAMED bedrock — not the runtime
4276        assert!(!m("bedrock.us-east-1.amazonaws.com")); // the Bedrock CONTROL plane — not model inference
4277        assert!(!m("openai.com.evil.com")); // suffix trick — not a subdomain of a known host
4278    }
4279
4280    #[test]
4281    fn model_sdk_crate_is_crate_level_no_method_gating() {
4282        use super::is_model_sdk_crate as s;
4283        assert!(s("async_openai"));
4284        assert!(s("aws_sdk_bedrockruntime"));
4285        assert!(s("ollama_rs"));
4286        assert!(s("langchain_rust"));
4287        assert!(!s("reqwest"));
4288        assert!(!s("aws_sdk_s3"));
4289    }
4290
4291    #[test]
4292    fn sql_table_extraction_is_conservative() {
4293        use super::tables_in_sql as t;
4294        assert_eq!(t("SELECT id FROM users WHERE x = 1"), vec!["users"]);
4295        assert_eq!(t("select * from ledger.entries e join customers c on c.id = e.cid"),
4296                   vec!["ledger.entries", "customers"]);
4297        assert_eq!(t("INSERT INTO audit_log (a) VALUES (?1)"), vec!["audit_log"]);
4298        assert_eq!(t("UPDATE accounts SET v = ?"), vec!["accounts"]);
4299        assert_eq!(t("DELETE FROM sessions WHERE id = ?"), vec!["sessions"]);
4300        assert_eq!(t("CREATE TABLE IF NOT EXISTS cache (k TEXT)"), vec!["cache"]);
4301        assert_eq!(t("TRUNCATE TABLE staging"), vec!["staging"]);
4302        // FOR UPDATE locking clause must not yield a phantom table (mid-statement update ignored)
4303        assert_eq!(t("SELECT * FROM jobs FOR UPDATE SKIP LOCKED"), vec!["jobs"]);
4304        // a subquery in FROM position yields nothing for that position
4305        assert_eq!(t("SELECT * FROM (SELECT 1) q"), Vec::<String>::new());
4306        // not SQL -> nothing (never fabricate)
4307        assert_eq!(t("/tmp/some/path"), Vec::<String>::new());
4308        assert_eq!(t("hello world from nowhere"), Vec::<String>::new());
4309        // comma-ADJACENT continuation: a FROM list takes every table in the chain…
4310        assert_eq!(t("SELECT a FROM t1, t2, s.t3 WHERE x = 1"), vec!["t1", "t2", "s.t3"]);
4311        // …but an alias breaks it (under-report, never a guess)…
4312        assert_eq!(t("SELECT a FROM t1 a1, t2 WHERE x = 1"), vec!["t1"]);
4313        // …which is exactly what keeps a column list from fabricating (parens are spaces by now).
4314        assert_eq!(t("INSERT INTO t (a, b) VALUES (1, 2)"), vec!["t"]);
4315        // a subquery after the comma stops the chain too
4316        assert_eq!(t("SELECT a FROM t1, (SELECT 1) q"), vec!["t1"]);
4317    }
4318
4319    use super::*;
4320
4321    /// The routed-handle list's MEMBERSHIP RULE, enforced rather than merely documented.
4322    ///
4323    /// (a) Every routed type must have a whole-type rule that answers an ARBITRARY method on it.
4324    /// If it did not, routing it would hand the scanner a path the classifier drops — motion with no
4325    /// effect, and the silent under-report would survive the fix that was supposed to close it. The
4326    /// probe leaf is deliberately a name no carve-out lists, so it measures the BASE rule.
4327    ///
4328    /// (b) The named exclusions stay excluded. `ReadDir` cannot have a verb-precise rule written for it
4329    /// (its `next` is a syscall and is spelled like every other iterator's), and `Metadata`/`DirEntry`/
4330    /// `Permissions`/`FileType` are pure DATA under the coarse `std::fs::` prefix — routing any of them
4331    /// charges an effect for reading a field. `OpenOptions`/`DirBuilder` LEFT this list by the route the
4332    /// list's own comment prescribed: their type-keyed setter carve-outs were written first, so the
4333    /// whole-type rule under them now answers only for the terminal verb.
4334    #[test]
4335    fn std_effect_handles_have_a_whole_type_rule_and_exclude_the_pure_surfaces() {
4336        for ty in STD_EFFECT_HANDLES {
4337            let probe = format!("{ty}::__candor_probe_verb");
4338            assert!(
4339                classify("std", &probe).is_some(),
4340                "`{ty}` is routed into the classifier by receiver inference, but an arbitrary method \
4341                 on it classifies to NOTHING — the routing cannot close any under-report"
4342            );
4343            assert!(is_std_effect_handle(ty), "the predicate must agree with the list");
4344        }
4345        for ty in [
4346            "std::fs::ReadDir",
4347            "std::fs::Metadata", "std::fs::DirEntry", "std::fs::Permissions", "std::fs::FileType",
4348            "std::path::Path", "std::path::PathBuf", "std::vec::Vec",
4349        ] {
4350            assert!(!is_std_effect_handle(ty),
4351                    "`{ty}` has a pure surface the coarse prefix rules would charge — it must not be \
4352                     routed as a handle (Path/PathBuf route through their own verb-precise carve-out)");
4353        }
4354    }
4355
4356    /// The pure read-backs on the ROUTED types, which is what makes (a) above safe: a whole-type rule
4357    /// answering every method is only acceptable because the genuinely-pure methods were carved out
4358    /// first. Receiver routing is a second door into these rules, so it must not re-fabricate.
4359    #[test]
4360    fn routed_std_handles_keep_their_pure_accessor_carve_outs() {
4361        for p in [
4362            "std::process::Command::get_program", "std::process::Command::get_args",
4363            "std::process::Command::get_envs", "std::process::Command::get_current_dir",
4364            "std::process::Child::id",
4365            "std::net::TcpStream::local_addr", "std::net::TcpStream::peer_addr",
4366            "std::net::TcpStream::nodelay", "std::net::TcpStream::ttl",
4367            "std::net::UdpSocket::take_error",
4368            "std::fs::File::as_raw_fd", "std::fs::File::into_raw_fd",
4369            "std::os::unix::net::UnixStream::as_raw_fd",
4370            // The OPTION-BUILDER setters (SPEC §1 ⟨0.32⟩): flags in a struct, no file named, nothing
4371            // opened. `create` is here as `OpenOptions`' setter and is a VERB on `DirBuilder` below —
4372            // one leaf, two answers, which is why these carve-outs are keyed on the TYPE.
4373            "std::fs::OpenOptions::new", "std::fs::OpenOptions::read", "std::fs::OpenOptions::write",
4374            "std::fs::OpenOptions::append", "std::fs::OpenOptions::truncate",
4375            "std::fs::OpenOptions::create", "std::fs::OpenOptions::create_new",
4376            "std::fs::OpenOptions::mode", "std::fs::OpenOptions::custom_flags",
4377            "std::fs::DirBuilder::new", "std::fs::DirBuilder::recursive", "std::fs::DirBuilder::mode",
4378        ] {
4379            assert_eq!(classify("std", p), None, "`{p}` is a pure read-back");
4380        }
4381        // …and the verbs on the same types still answer, or the carve-outs would have eaten the rule.
4382        for (p, want) in [
4383            ("std::process::Command::spawn", "Exec"),
4384            ("std::process::Child::wait", "Exec"),
4385            ("std::fs::File::write_all", "Fs"),
4386            ("std::net::TcpStream::write_all", "Net"),
4387            ("std::os::unix::net::UnixStream::send", "Ipc"),
4388            // the TERMINAL VERBS of the two option-builders — the whole point of routing them.
4389            ("std::fs::OpenOptions::open", "Fs"),
4390            ("std::fs::DirBuilder::create", "Fs"),
4391        ] {
4392            assert_eq!(classify("std", p), Some(want), "`{p}` must stay {want}");
4393        }
4394    }
4395
4396    #[test]
4397    fn db_crates_are_calibrated() {
4398        // The calibrated set must cover every DB client the classifier knows, or the receipt's coverage
4399        // check would flag a recognized crate as a blind spot. (Was nightly-lint-only; now runs on stable.)
4400        for c in DB_CRATES {
4401            assert!(
4402                CALIBRATED_CRATES.contains(&c),
4403                "DB crate `{c}` is matched by classify() but missing from CALIBRATED_CRATES"
4404            );
4405        }
4406    }
4407
4408    /// The two coverage lists mean OPPOSITE things and must stay disjoint.
4409    ///
4410    /// `CALIBRATED_CRATES` = "classify has effect rules here". `REVIEWED_PURE_CRATES` = "read it, it
4411    /// performs nothing". A crate in both would be asserting both at once, and the ledger consults them
4412    /// with an OR — so the contradiction would resolve silently to "covered" and nobody would look again.
4413    #[test]
4414    fn reviewed_pure_and_calibrated_are_disjoint() {
4415        for c in REVIEWED_PURE_CRATES {
4416            assert!(!CALIBRATED_CRATES.contains(&c),
4417                    "`{c}` is in BOTH lists — it cannot be rule-covered AND effect-free");
4418            assert!(!PATH_CALIBRATED_CRATES.contains(&c), "`{c}` is in BOTH lists (path-calibrated)");
4419            assert!(!CALIBRATED_PREFIXES.iter().any(|p| c.starts_with(p)),
4420                    "`{c}` is covered by a calibrated PREFIX as well as the pure list");
4421        }
4422    }
4423
4424    /// A reviewed-pure crate must actually classify as pure — the mirror of `calibrated_crates_are_live`.
4425    ///
4426    /// The list makes candor BELIEVE these crates rather than disclose them, so if someone later adds a
4427    /// rule for one, the claim "performs no effect of its own" is dead and the entry has to be re-read,
4428    /// not silently outvoted by the rule. Probed with the same tails the liveness test uses, which is a
4429    /// broad sweep of the effectful verb shapes candor knows.
4430    #[test]
4431    fn reviewed_pure_crates_classify_as_pure() {
4432        for c in REVIEWED_PURE_CRATES {
4433            for t in CALIBRATION_PROBE_TAILS {
4434                assert!(classify(c, &format!("{c}{t}")).is_none(),
4435                        "`{c}` is listed REVIEWED-PURE but classify() gives it an effect on `{c}{t}` — \
4436                         one of the two is wrong, and the list is the claim");
4437            }
4438        }
4439    }
4440
4441    /// ⟨CALIBRATION CEILING — the table must agree with the REVIEW RECORD⟩ SOUNDNESS R328.
4442    ///
4443    /// `CALIBRATED_CEILINGS` is the version each crate's rules were actually written against. Nothing
4444    /// derived it from, or checked it against, the review record — and three separate failures followed
4445    /// in one day: a wholesale table rewrite silently DROPPED nine entries while the commit message
4446    /// claimed four were absent "each with a stated reason"; `git2` was ceilinged ABOVE the only version
4447    /// its rules record reading (the SILENT direction, and 0.21 added `author_from_env` /
4448    /// `committer_from_env` / `Oid::hash_file_ext`, none of them ruled); and `sqlx_core` sat BELOW the
4449    /// version its own comment says was verified, which is also an impossible sibling of `sqlx 0.9.0`'s
4450    /// `=0.9.0` pin. All three were invisible to 410 tests and 29 gates.
4451    ///
4452    /// This asserts the one invariant that catches all of them: **a crate whose rules cite a reviewed
4453    /// version must carry a ceiling, and it must be THAT version.** Citations are read with wrapped
4454    /// comment lines joined and both name spellings tried — R315, where a line-by-line dashed-only
4455    /// sweep silently under-counted the citations by three.
4456    #[test]
4457    fn calibration_ceilings_match_the_recorded_review() {
4458        let src = include_str!("lib.rs");
4459        // join wrapped comment continuations, then collapse whitespace: a citation is prose and prose wraps.
4460        let flat = src
4461            .replace("\n    //", " ")
4462            .replace("\n        //", " ")
4463            .replace("\n            //", " ");
4464        let flat: String = flat.split_whitespace().collect::<Vec<_>>().join(" ");
4465        let ceilings: std::collections::HashMap<&str, &str> =
4466            CALIBRATED_CEILINGS.iter().copied().collect();
4467        // Absences are deliberate and enumerated in the table's own comment; keep the list HERE too so
4468        // dropping one silently is impossible — that is exactly what happened.
4469        let deliberate = ["postgres", "async_fs", "getrandom", "rand_core"];
4470        let mut problems: Vec<String> = Vec::new();
4471        for c in CALIBRATED_CRATES {
4472            if deliberate.contains(&c) {
4473                continue;
4474            }
4475            // EVERY citation, both verbs, both name spellings, and slash-separated lists —
4476            // "verified against sqlx-core 0.8.6/0.9.0" records TWO reviewed versions, and a crate may
4477            // be cited in more than one comment ("validated against rusqlite 0.39" elsewhere). An
4478            // extractor that stops at the first hit under-collects, and under-collecting here makes a
4479            // correct ceiling look like it is above the record — R315's lesson, one level up.
4480            let mut cited: Vec<String> = Vec::new();
4481            for form in [c.to_string(), c.replace('_', "-")] {
4482                for verb in ["verified against ", "validated against "] {
4483                    let pat = format!("{verb}{form} ");
4484                    let mut from = 0usize;
4485                    while let Some(i) = flat[from..].find(&pat) {
4486                        let at = from + i + pat.len();
4487                        let tail: String = flat[at..]
4488                            .chars()
4489                            .take_while(|ch| ch.is_ascii_digit() || *ch == '.' || *ch == '/')
4490                            .collect();
4491                        for v in tail.split('/') {
4492                            let v = v.trim_end_matches('.').to_string();
4493                            if v.split('.').count() >= 2 && !cited.contains(&v) {
4494                                cited.push(v);
4495                            }
4496                        }
4497                        from = at;
4498                    }
4499                }
4500            }
4501            if cited.is_empty() {
4502                continue;
4503            }
4504            match ceilings.get(c) {
4505                None => problems.push(format!(
4506                    "{c}: rules cite {} but there is NO ceiling — the exemption is unconditional",
4507                    cited.join("/")
4508                )),
4509                // A comment may legitimately record MORE THAN ONE reviewed version
4510                // ("verified against sqlx-core 0.8.6/0.9.0"), so matching any of them is fine, and a
4511                // ceiling BELOW the newest review is merely noisy. The failure that matters is a
4512                // ceiling ABOVE EVERY recorded review: that grants reviewed-purity over source nobody
4513                // read, which is the SILENT direction and the whole reason this table exists.
4514                Some(have) => {
4515                    let ok = cited.iter().any(|v| have.starts_with(v) || v.starts_with(*have))
4516                        || cited.iter().any(|v| calibration_exceeded_raw(v, have));
4517                    if !ok {
4518                        problems.push(format!(
4519                            "{c}: ceiling {have} is ABOVE every recorded review ({}) — it grants \
4520                             reviewed-purity over source no comment records anyone reading",
4521                            cited.join("/")
4522                        ));
4523                    }
4524                }
4525            }
4526        }
4527        assert!(
4528            problems.is_empty(),
4529            "CALIBRATED_CEILINGS disagrees with the review record:\n  {}\n\n\
4530             A ceiling ABOVE the recorded review grants reviewed-purity over source nobody read (SILENT); \
4531             a ceiling BELOW it is noisy but safe. Either way the table and the record must agree, or \
4532             neither is evidence.",
4533            problems.join("\n  ")
4534        );
4535    }
4536
4537    #[test]
4538    fn calibrated_crates_are_live() {
4539        // Conversely, every crate advertised as calibrated must actually be matched by classify() for
4540        // some representative path — a dead entry would silently suppress a real coverage warning.
4541        for c in CALIBRATED_CRATES {
4542            assert!(
4543                CALIBRATION_PROBE_TAILS.iter().any(|t| classify(c, &format!("{c}{t}")).is_some()),
4544                "calibrated crate `{c}` is matched by no path in classify() — dead list entry"
4545            );
4546        }
4547    }
4548
4549    #[test]
4550    fn async_http_stack_classifies() {
4551        // The modern async-HTTP/TLS/QUIC/DNS stack (found by the independent-method differential on oha):
4552        // verb-keyed Net/Ipc/Fs/Env, crate-gated so generic verbs never fabricate across crates.
4553        assert_eq!(classify("hyper", "hyper::client::conn::http1::SendRequest::send_request"), Some("Net"));
4554        assert_eq!(classify("hyper", "hyper::client::conn::http1::handshake"), Some("Net"));
4555        assert_eq!(classify("hyper_util", "hyper_util::client::legacy::Client::request"), Some("Net"));
4556        assert_eq!(classify("hickory_resolver", "hickory_resolver::Resolver::lookup_ip"), Some("Net"));
4557        assert_eq!(classify("quinn", "quinn::Endpoint::connect"), Some("Net"));
4558        assert_eq!(classify("quinn", "quinn::RecvStream::read_to_end"), Some("Net")); // stream byte I/O, not just open
4559        assert_eq!(classify("quinn", "quinn::SendStream::write_all"), Some("Net"));
4560        assert_eq!(classify("tokio_rustls", "tokio_rustls::TlsConnector::connect"), Some("Net"));
4561        assert_eq!(classify("native_tls", "native_tls::TlsConnector::connect"), Some("Net"));
4562        assert_eq!(classify("tokio_vsock", "tokio_vsock::VsockStream::connect"), Some("Ipc"));
4563        assert_eq!(classify("rustls_native_certs", "rustls_native_certs::load_native_certs"), Some("Fs"));
4564        assert_eq!(classify("rlimit", "rlimit::setrlimit"), Some("Env"));
4565        // num_cpus is deliberately PURE (consistency with std::thread::available_parallelism; avoids Env spray)
4566        assert_eq!(classify("num_cpus", "num_cpus::get"), None);
4567        assert_eq!(classify("num_cpus", "num_cpus::get_physical"), None);
4568        // pure surface stays None (no fabrication): builder/type/config paths, and other crates' generic verbs
4569        assert_eq!(classify("hyper", "hyper::Request::builder"), None);
4570        assert_eq!(classify("hyper", "hyper::body::Bytes::new"), None);
4571        assert_eq!(classify("native_tls", "native_tls::TlsConnectorBuilder::min_protocol_version"), None);
4572        assert_eq!(classify("serde", "serde::Deserialize::request"), None); // generic verb, wrong crate
4573    }
4574
4575    #[test]
4576    fn coverage_differential_crates_classify() {
4577        // Crates the coverage differential found DISCLOSED-but-unmodeled. Each rule is verb-keyed +
4578        // crate-gated; the EFFECT verbs map to the right bucket and the PURE surface stays None (a
4579        // wrongly-flagged pure crate is a fabrication, so the negatives matter as much as the positives).
4580
4581        // rustls (sync TLS core) — record I/O is Net; config/cert + the buffered-decrypt step are pure.
4582        assert_eq!(classify("rustls", "rustls::ClientConnection::read_tls"), Some("Net"));
4583        assert_eq!(classify("rustls", "rustls::ConnectionCommon::write_tls"), Some("Net"));
4584        assert_eq!(classify("rustls", "rustls::Connection::complete_io"), Some("Net"));
4585        assert_eq!(classify("rustls", "rustls::ConnectionCommon::process_new_packets"), None); // buffered decrypt, no I/O
4586        assert_eq!(classify("rustls", "rustls::ClientConfig::builder"), None); // pure config
4587
4588        // native-tls variants — handshake is Net; builder is pure.
4589        assert_eq!(classify("native_tls_crate", "native_tls_crate::TlsConnector::connect"), Some("Net"));
4590        assert_eq!(classify("tokio_native_tls", "tokio_native_tls::TlsAcceptor::accept"), Some("Net"));
4591        assert_eq!(classify("native_tls_crate", "native_tls_crate::TlsConnectorBuilder::min_protocol_version"), None);
4592
4593        // etcetera — dir resolution reads env; the args data type is pure.
4594        assert_eq!(classify("etcetera", "etcetera::home_dir"), Some("Env"));
4595        assert_eq!(classify("etcetera", "etcetera::base_strategy::choose_base_strategy"), Some("Env"));
4596        assert_eq!(classify("etcetera", "etcetera::base_strategy::Xdg::config_dir"), Some("Env"));
4597        assert_eq!(classify("etcetera", "etcetera::app_strategy::AppStrategyArgs::new"), None); // pure data
4598
4599        // sqlx-core — connect is Net, execute/fetch round-trips are Db; options/builders pure.
4600        assert_eq!(classify("sqlx_core", "sqlx_core::connection::Connection::connect"), Some("Net"));
4601        assert_eq!(classify("sqlx_core", "sqlx_core::executor::Executor::fetch_one"), Some("Db"));
4602        assert_eq!(classify("sqlx_core", "sqlx_core::executor::Executor::execute"), Some("Db"));
4603        assert_eq!(classify("sqlx_core", "sqlx_core::pool::Pool::acquire"), Some("Db"));
4604        assert_eq!(classify("sqlx_core", "sqlx_core::pool::PoolOptions::max_connections"), None); // pure builder
4605
4606        // walkdir — charged at construction (`WalkDir::new`, mirroring `ignore`/`glob`), NOT solely at
4607        // the lazy `next()`/`metadata()` read: candor-scan's receiver-typing blocklist hard-blocks
4608        // `.into_iter()`, so a typed `IntoIter::next` receiver is unreachable from the idiomatic
4609        // `WalkDir::new(p).into_iter()...` chain — `WalkDir::new` is the only point every real usage
4610        // (for-loop, `.count()`, untyped `.next()`) actually reaches. `IntoIter::next`/`DirEntry::metadata`
4611        // stay Some("Fs") as a secondary rule for the narrower explicit-type-annotation case. Builder
4612        // setters (`into_iter` itself, `max_depth`, …) and cached accessors stay pure.
4613        assert_eq!(classify("walkdir", "walkdir::WalkDir::new"), Some("Fs"));
4614        assert_eq!(classify("walkdir", "walkdir::IntoIter::next"), Some("Fs"));
4615        assert_eq!(classify("walkdir", "walkdir::DirEntry::metadata"), Some("Fs"));
4616        assert_eq!(classify("walkdir", "walkdir::WalkDir::into_iter"), None); // no I/O until pulled
4617        assert_eq!(classify("walkdir", "walkdir::WalkDir::max_depth"), None); // builder setter
4618        assert_eq!(classify("walkdir", "walkdir::DirEntry::file_type"), None); // cached, no syscall
4619
4620        // filetime — set_* are utimes (Fs), now is Clock; from_* constructors pure.
4621        assert_eq!(classify("filetime", "filetime::set_file_mtime"), Some("Fs"));
4622        assert_eq!(classify("filetime", "filetime::set_file_handle_times"), Some("Fs"));
4623        assert_eq!(classify("filetime", "filetime::FileTime::now"), Some("Clock"));
4624        assert_eq!(classify("filetime", "filetime::FileTime::from_unix_time"), None);
4625        assert_eq!(classify("filetime", "filetime::FileTime::from_last_modification_time"), None); // reads &Metadata, not disk
4626
4627        // execute — the execute* verbs spawn (Exec); command/shell builders pure.
4628        assert_eq!(classify("execute", "execute::Execute::execute"), Some("Exec"));
4629        assert_eq!(classify("execute", "execute::Execute::execute_output"), Some("Exec"));
4630        assert_eq!(classify("execute", "execute::Execute::execute_multiple_output"), Some("Exec"));
4631        assert_eq!(classify("execute", "execute::command"), None); // only builds a Command
4632        assert_eq!(classify("execute", "execute::shell"), None);
4633
4634        // ctrlc — install signal handler (Ipc).
4635        assert_eq!(classify("ctrlc", "ctrlc::set_handler"), Some("Ipc"));
4636        assert_eq!(classify("ctrlc", "ctrlc::try_set_handler"), Some("Ipc"));
4637
4638        // clap — only the argv-reading terminals are Env; the whole builder + *_from variants pure.
4639        assert_eq!(classify("clap", "clap::Command::get_matches"), Some("Env"));
4640        assert_eq!(classify("clap", "clap::Command::try_get_matches"), Some("Env"));
4641        assert_eq!(classify("clap", "clap::Parser::parse"), Some("Env"));
4642        assert_eq!(classify("clap", "clap::Command::new"), None); // builder
4643        assert_eq!(classify("clap", "clap::Arg::about"), None); // builder
4644        assert_eq!(classify("clap", "clap::Command::get_matches_from"), None); // explicit args, no argv read
4645        // R59-class audit: `Arg::env` calls `env::var_os` DIRECTLY at builder time (verified against
4646        // clap_builder 4.6.6) — unambiguous (the crate's only `::env` method), so classify it rather
4647        // than leave a real effect to fall silently into the CALIBRATED_CRATES purity exemption.
4648        assert_eq!(classify("clap", "clap::Arg::env"), Some("Env"));
4649        assert_eq!(classify("clap", "clap::Arg::env_os"), Some("Env"));
4650
4651        // jiff — now* is Clock; tz lookups read the tzdb (Fs); span/civil math pure.
4652        assert_eq!(classify("jiff", "jiff::Timestamp::now"), Some("Clock"));
4653        assert_eq!(classify("jiff", "jiff::Zoned::now_with"), Some("Clock"));
4654        assert_eq!(classify("jiff", "jiff::tz::TimeZone::system"), Some("Fs"));
4655        assert_eq!(classify("jiff", "jiff::tz::TimeZone::get"), Some("Fs"));
4656        assert_eq!(classify("jiff", "jiff::Span::checked_add"), None); // pure arithmetic
4657
4658        // env_logger — init installs the logger + reads RUST_LOG (Log); config setters pure.
4659        // TUI — the tty is a user dialogue channel (Ipc), the ruling dialoguer/console already carry.
4660        // Each verb below was read off the crate source (crossterm-0.28.1, ratatui-0.29.0), not guessed.
4661        assert_eq!(classify("crossterm", "crossterm::ExecutableCommand::execute"), Some("Ipc"));
4662        assert_eq!(classify("crossterm", "crossterm::QueueableCommand::queue"), Some("Ipc"));
4663        assert_eq!(classify("crossterm", "crossterm::event::read"), Some("Ipc"));
4664        assert_eq!(classify("crossterm", "crossterm::event::poll"), Some("Ipc"));
4665        assert_eq!(classify("crossterm", "crossterm::terminal::enable_raw_mode"), Some("Ipc"));
4666        // a tty IOCTL must not fall through: in a CALIBRATED crate an unmatched path is a purity CLAIM
4667        assert_eq!(classify("crossterm", "crossterm::terminal::size"), Some("Ipc"));
4668        // the Command VALUE types are pure — they describe an action, they do not perform one
4669        assert_eq!(classify("crossterm", "crossterm::style::Print"), None);
4670        assert_eq!(classify("crossterm", "crossterm::cursor::MoveTo"), None);
4671
4672        // ratatui: the backlog said "mark reviewed-pure"; the SOURCE says `Terminal::draw` ends in a
4673        // backend flush, so the write surface is Ipc and only the render surface is pure.
4674        assert_eq!(classify("ratatui", "ratatui::Terminal::draw"), Some("Ipc"));
4675        assert_eq!(classify("ratatui", "ratatui::Terminal::flush"), Some("Ipc"));
4676        assert_eq!(classify("ratatui", "ratatui::Terminal::clear"), Some("Ipc"));
4677        assert_eq!(classify("ratatui", "ratatui::Terminal::hide_cursor"), Some("Ipc"));
4678        // REGRESSION: `widgets::canvas` is an in-memory grid. `Context::draw` ends in `::draw` and was
4679        // FABRICATING Ipc — caught in review, measured on a fixture, and a hot path (per shape, per frame).
4680        assert_eq!(classify("ratatui", "ratatui::widgets::canvas::Context::draw"), None);
4681        assert_eq!(classify("ratatui", "ratatui::widgets::canvas::Context::layer"), None);
4682        // …while the real write surface still classifies, including a DIRECT backend call (which is why
4683        // the carve-out is a denylist on canvas rather than an allowlist on `Terminal::`).
4684        assert_eq!(classify("ratatui", "ratatui::backend::CrosstermBackend::flush"), Some("Ipc"));
4685        // the BULK of the 3,345 disclosed calls — widgets, layout, style — are genuinely pure
4686        assert_eq!(classify("ratatui", "ratatui::widgets::Paragraph::new"), None);
4687        assert_eq!(classify("ratatui", "ratatui::layout::Layout::split"), None);
4688        assert_eq!(classify("ratatui", "ratatui::style::Style::fg"), None);
4689        assert_eq!(classify("ratatui", "ratatui::buffer::Buffer::set_string"), None);
4690
4691        // tracing_subscriber — two effects, both read off 0.3.23. The filing said "Log/Fs"; the Fs half
4692        // is wrong (the crate ACCEPTS a File as a writer, it never opens one).
4693        assert_eq!(classify("tracing_subscriber", "tracing_subscriber::fmt::init"), Some("Log"));
4694        assert_eq!(classify("tracing_subscriber", "tracing_subscriber::fmt::try_init"), Some("Log"));
4695        assert_eq!(classify("tracing_subscriber", "tracing_subscriber::fmt::SubscriberBuilder::init"), Some("Log"));
4696        assert_eq!(classify("tracing_subscriber", "tracing_subscriber::EnvFilter::from_default_env"), Some("Env"));
4697        assert_eq!(classify("tracing_subscriber", "tracing_subscriber::EnvFilter::from_env"), Some("Env"));
4698        // builders DESCRIBE a subscriber; they do not install one
4699        assert_eq!(classify("tracing_subscriber", "tracing_subscriber::fmt::layer"), None);
4700        assert_eq!(classify("tracing_subscriber", "tracing_subscriber::fmt::SubscriberBuilder::with_target"), None);
4701        assert_eq!(classify("tracing_subscriber", "tracing_subscriber::EnvFilter::new"), None);
4702
4703        assert_eq!(classify("env_logger", "env_logger::init"), Some("Log"));
4704        assert_eq!(classify("env_logger", "env_logger::try_init"), Some("Log"));
4705        assert_eq!(classify("env_logger", "env_logger::Builder::init"), Some("Log"));
4706        assert_eq!(classify("env_logger", "env_logger::Builder::format_timestamp"), None); // config
4707        assert_eq!(classify("env_logger", "env_logger::Builder::build"), None); // pure build
4708
4709        // dialoguer — interact* is tty I/O (Ipc); builders pure.
4710        assert_eq!(classify("dialoguer", "dialoguer::Input::interact_text"), Some("Ipc"));
4711        assert_eq!(classify("dialoguer", "dialoguer::Confirm::interact"), Some("Ipc"));
4712        assert_eq!(classify("dialoguer", "dialoguer::Select::interact_opt"), Some("Ipc"));
4713        assert_eq!(classify("dialoguer", "dialoguer::Input::with_prompt"), None); // builder
4714        // widened-CORE audit: `Editor::new`/`::default` read VISUAL/EDITOR at construction, independent
4715        // of `Editor::edit`'s already-covered Exec (spawning that editor is a separate, later step).
4716        assert_eq!(classify("dialoguer", "dialoguer::Editor::new"), Some("Env"));
4717        assert_eq!(classify("dialoguer", "dialoguer::Editor::default"), Some("Env"));
4718        assert_eq!(classify("dialoguer", "dialoguer::Editor::edit"), Some("Exec"));
4719        assert_eq!(classify("dialoguer", "dialoguer::Editor::extension"), None); // pure setter
4720
4721        // console — Term I/O is Ipc, detection is Env, Style is pure.
4722        assert_eq!(classify("console", "console::Term::write_line"), Some("Ipc"));
4723        assert_eq!(classify("console", "console::Term::read_key"), Some("Ipc"));
4724        assert_eq!(classify("console", "console::colors_enabled"), Some("Env"));
4725        assert_eq!(classify("console", "console::Style::cyan"), None); // pure styling
4726        assert_eq!(classify("console", "console::strip_ansi_codes"), None); // pure text util
4727        // R59-class audit: `Term` also implements raw `io::{Read,Write}` (console 0.15.11) — the same
4728        // tty channel as `write_line`/`read_key`, reached through the generic trait methods instead of
4729        // the crate's own named convenience methods. Crate-gated and `Term::`-scoped, so it cannot spread.
4730        assert_eq!(classify("console", "console::Term::write"), Some("Ipc"));
4731        assert_eq!(classify("console", "console::Term::flush"), Some("Ipc"));
4732        assert_eq!(classify("console", "console::Term::read"), Some("Ipc"));
4733
4734        // terminal_colorsaurus — tty colour query (Ipc).
4735        assert_eq!(classify("terminal_colorsaurus", "terminal_colorsaurus::background_color"), Some("Ipc"));
4736        assert_eq!(classify("terminal_colorsaurus", "terminal_colorsaurus::color_palette"), Some("Ipc"));
4737
4738        // backoff — retry sleeps + reads the clock (Clock); config pure.
4739        assert_eq!(classify("backoff", "backoff::retry"), Some("Clock"));
4740        assert_eq!(classify("backoff", "backoff::retry_notify"), Some("Clock"));
4741        assert_eq!(classify("backoff", "backoff::ExponentialBackoff::default"), None);
4742
4743        // lscolors — ONLY from_env reads the environment; from_string/style_for_path pure.
4744        assert_eq!(classify("lscolors", "lscolors::LsColors::from_env"), Some("Env"));
4745        assert_eq!(classify("lscolors", "lscolors::LsColors::from_string"), None);
4746        assert_eq!(classify("lscolors", "lscolors::LsColors::style_for_path"), None);
4747
4748        // wild — argv readers (Env).
4749        assert_eq!(classify("wild", "wild::args"), Some("Env"));
4750        assert_eq!(classify("wild", "wild::args_os"), Some("Env"));
4751
4752        // grep_cli — only the firm Exec (CommandReader spawn); the isatty probes stay unmodeled.
4753        assert_eq!(classify("grep_cli", "grep_cli::CommandReaderBuilder::build"), Some("Exec"));
4754        assert_eq!(classify("grep_cli", "grep_cli::is_readable_stdin"), None); // isatty/fstat, not modeled
4755        assert_eq!(classify("grep_cli", "grep_cli::is_tty_stdout"), None);
4756
4757        // clircle — same-file detection issues fstat/lseek (Fs); equality is pure.
4758        assert_eq!(classify("clircle", "clircle::Identifier::try_from"), Some("Fs"));
4759        assert_eq!(classify("clircle", "clircle::Clircle::surely_conflicts_with"), Some("Fs"));
4760    }
4761
4762    #[test]
4763    fn log_tracing_emit_macros_classify_pre_expansion() {
4764        // candor-scan is pre-expansion: it sees the raw macro path (`log::info`, `tracing::warn`), not the
4765        // expanded dispatch the deep engine sees. Both the user-facing macro names AND the type surface:
4766        assert_eq!(classify("log", "log::info"), Some("Log"));
4767        assert_eq!(classify("log", "log::error"), Some("Log"));
4768        assert_eq!(classify("tracing", "tracing::warn"), Some("Log"));
4769        assert_eq!(classify("tracing", "tracing::info_span"), Some("Log"));
4770        // pure data-type surface stays None (no fabricated Log)
4771        assert_eq!(classify("log", "log::Level::as_str"), None);
4772        assert_eq!(classify("tracing", "tracing::Level::INFO"), None);
4773    }
4774
4775    #[test]
4776    fn classify_core_effects() {
4777        // A representative smoke test of the classifier's main families, so the published crate is not
4778        // shipped untested (these used to live only in the nightly-only src/lib.rs).
4779        assert_eq!(classify("std", "std::fs::read_to_string"), Some("Fs"));
4780        // std::path stat-family methods are Fs (each is a stat/readdir syscall); the pure
4781        // string-manipulation surface stays unclassified (the blackout screen's gix-dir find).
4782        assert_eq!(classify("std", "std::path::Path::symlink_metadata"), Some("Fs"));
4783        assert_eq!(classify("std", "std::path::PathBuf::read_dir"), Some("Fs"));
4784        assert_eq!(classify("std", "std::path::Path::exists"), Some("Fs"));
4785        assert_eq!(classify("std", "std::path::Path::join"), None); // pure string manipulation
4786        assert_eq!(classify("std", "std::path::PathBuf::file_name"), None);
4787        assert_eq!(classify("std", "std::path::Path::parent"), None);
4788        assert_eq!(classify("std", "std::process::Command::new"), Some("Exec"));
4789        assert_eq!(classify("std", "std::env::var"), Some("Env"));
4790        assert_eq!(classify("reqwest", "reqwest::Client::execute"), Some("Net"));
4791        // one-shot convenience fns send immediately → Net.
4792        assert_eq!(classify("reqwest", "reqwest::get"), Some("Net"));
4793        assert_eq!(classify("reqwest", "reqwest::blocking::get"), Some("Net"));
4794        // the URL-BEARING builder methods classify Net too — the DOMINANT idiom is the builder chain
4795        // `Client::new().post(url).send()`, whose URL literal rides the `.post(url)` step (NOT `.send()`),
4796        // so the endpoint (and the Llm host refinement) only get captured if the URL-naming step is Net.
4797        assert_eq!(classify("reqwest", "reqwest::Client::get"), Some("Net"));
4798        assert_eq!(classify("reqwest", "reqwest::Client::post"), Some("Net"));
4799        assert_eq!(classify("reqwest", "reqwest::Client::put"), Some("Net"));
4800        assert_eq!(classify("reqwest", "reqwest::Client::delete"), Some("Net"));
4801        assert_eq!(classify("reqwest", "reqwest::Client::request"), Some("Net"));
4802        // the PURE builder surface stays None (no URL, no dispatch).
4803        assert_eq!(classify("reqwest", "reqwest::RequestBuilder::header"), None);
4804        assert_eq!(classify("reqwest", "reqwest::RequestBuilder::json"), None);
4805        assert_eq!(classify("reqwest", "reqwest::ClientBuilder::build"), None);
4806        // RAW POSIX SOCKETS — the lowest network tier, pinned as a regression guard (four-way close:
4807        // swift got a raw-socket regression this week from a bare-identifier collision; rust never had
4808        // the gap because it classifies path-QUALIFIED via the syscall-leaf table, but pin it so the
4809        // `socket`/`connect` Net rows can't silently drop). `libc::connect`/`libc::socket` are the direct
4810        // FFI syscalls; `nix::sys::socket::connect` is the safe wrapper; both bottom out in the NET table.
4811        assert_eq!(classify("libc", "libc::connect"), Some("Net"));
4812        assert_eq!(classify("libc", "libc::socket"), Some("Net"));
4813        assert_eq!(classify("libc", "libc::bind"), Some("Net"));
4814        assert_eq!(classify("libc", "libc::accept"), Some("Net"));
4815        // nix routes through the libc syscall table (same leaves): I/O classified, generic fd ops skipped.
4816        assert_eq!(classify("nix", "nix::fcntl::open"), Some("Fs"));
4817        assert_eq!(classify("nix", "nix::sys::socket::connect"), Some("Net"));
4818        assert_eq!(classify("nix", "nix::sys::socket::socket"), Some("Net"));
4819        assert_eq!(classify("nix", "nix::unistd::execvp"), Some("Exec"));
4820        assert_eq!(classify("nix", "nix::unistd::write"), None); // generic fd op — deliberately unclassified
4821        assert_eq!(classify("nix", "nix::unistd::getpid"), None); // not I/O
4822        // rustix does raw syscalls (no libc underneath) → classified directly by leaf, same table.
4823        assert_eq!(classify("rustix", "rustix::time::clock_settime"), Some("Clock"));
4824        assert_eq!(classify("rustix", "rustix::fs::symlink"), Some("Fs"));
4825        assert_eq!(classify("rustix", "rustix::net::connect"), Some("Net"));
4826        assert_eq!(classify("rustix", "rustix::io::read"), None); // generic fd op
4827        // pnet raw packet capture: channel openers are Net, packet construction stays pure.
4828        assert_eq!(classify("pnet", "pnet::datalink::channel"), Some("Net"));
4829        assert_eq!(classify("pnet", "pnet::transport::transport_channel"), Some("Net"));
4830        assert_eq!(classify("pnet_datalink", "pnet_datalink::channel"), Some("Net"));
4831        assert_eq!(classify("pnet", "pnet::packet::ethernet::EthernetPacket::new"), None);
4832        assert_eq!(classify("pnet_base", "pnet_base::MacAddr::new"), None);
4833        // ignore (gitignore-aware walker): walk executors are Fs, config builders stay pure.
4834        assert_eq!(classify("ignore", "ignore::WalkBuilder::build_parallel"), Some("Fs"));
4835        assert_eq!(classify("ignore", "ignore::WalkBuilder::build"), Some("Fs"));
4836        assert_eq!(classify("ignore", "ignore::WalkParallel::run"), Some("Fs"));
4837        assert_eq!(classify("ignore", "ignore::WalkBuilder::add_ignore"), Some("Fs")); // reads the ignore file
4838        assert_eq!(classify("ignore", "ignore::overrides::OverrideBuilder::build"), None); // pure config
4839        assert_eq!(classify("ignore", "ignore::gitignore::GitignoreBuilder::build"), None); // pure config
4840        assert_eq!(classify("ignore", "ignore::DirEntry::path"), None); // pure accessor
4841        // THE FIX: `Walk::new`/`Walk::from_iter` are `WalkBuilder::new(path).build()` /
4842        // `WalkBuilder::from_iter(paths).build()` in ignore's own source — the crate's documented
4843        // convenience constructors, and its own top-level doc example (`for entry in Walk::new(path)`).
4844        // A corpus round caught `deny Fs` exiting 0 over exactly that idiom.
4845        assert_eq!(classify("ignore", "ignore::Walk::new"), Some("Fs"));
4846        assert_eq!(classify("ignore", "ignore::Walk::from_iter"), Some("Fs"));
4847        // NO FABRICATION: a same-named `Walk::new` from an unrelated crate must not gain Fs — crate-gated.
4848        assert_eq!(classify("walkdir", "walkdir::Walk::new"), None);
4849        assert_eq!(classify("some_local_crate", "some_local_crate::Walk::new"), None);
4850        // notify fs-watching: watcher constructors + watch/unwatch are Fs, data types stay pure.
4851        assert_eq!(classify("notify", "notify::RecommendedWatcher::new"), Some("Fs"));
4852        assert_eq!(classify("notify", "notify::PollWatcher::new"), Some("Fs"));
4853        assert_eq!(classify("notify", "notify::recommended_watcher"), Some("Fs"));
4854        assert_eq!(classify("notify", "notify::INotifyWatcher::watch"), Some("Fs"));
4855        assert_eq!(classify("notify", "notify::Config::default"), None); // pure config
4856        assert_eq!(classify("notify", "notify::Event::new"), None); // pure data type
4857        assert_eq!(classify("rusqlite", "rusqlite::Connection::execute"), Some("Db"));
4858        // the rusqlite verb DIALECT (a verb probe found the canonical consumer API classifying pure):
4859        assert_eq!(classify("rusqlite", "rusqlite::Connection::query_row"), Some("Db"));
4860        assert_eq!(classify("rusqlite", "rusqlite::Statement::query_map"), Some("Db"));
4861        assert_eq!(classify("rusqlite", "rusqlite::Connection::execute_batch"), Some("Db"));
4862        assert_eq!(classify("rusqlite", "rusqlite::Connection::prepare_cached"), Some("Db"));
4863        assert_eq!(classify("rusqlite", "rusqlite::Connection::open"), Some("Db"));
4864        assert_eq!(classify("rusqlite", "rusqlite::Connection::open_in_memory"), Some("Db"));
4865        // THE FIX: three more real `Connection::open*` constructors an exact-suffix list missed
4866        // (`open_in_memory_with_flags` doesn't END in `open_with_flags`), plus the documented blob-I/O
4867        // API (`blob_open`/`Blob::reopen`), each calling the real sqlite3 FFI directly.
4868        assert_eq!(classify("rusqlite", "rusqlite::Connection::open_in_memory_with_flags"), Some("Db"));
4869        assert_eq!(classify("rusqlite", "rusqlite::Connection::open_with_flags_and_vfs"), Some("Db"));
4870        assert_eq!(
4871            classify("rusqlite", "rusqlite::Connection::open_in_memory_with_flags_and_vfs"),
4872            Some("Db")
4873        );
4874        assert_eq!(classify("rusqlite", "rusqlite::Connection::blob_open"), Some("Db"));
4875        assert_eq!(classify("rusqlite", "rusqlite::blob::Blob::reopen"), Some("Db"));
4876        // NO FABRICATION: a same-crate, DIFFERENT type's `open`-prefixed method (rusqlite's own private
4877        // `pragma::Sql::open_brace`, which pushes one char to a string buffer) must not gain Db — the
4878        // fix keys on the `Connection::` segment, not a bare leaf prefix.
4879        assert_eq!(classify("rusqlite", "rusqlite::pragma::Sql::open_brace"), None);
4880        // THE COVERAGE-GATE SWEEP FIX: the online-backup API and incremental-BLOB positional I/O,
4881        // verified against rusqlite 0.32.1 (each calls an `ffi::sqlite3_*` leaf already in this file's
4882        // own FFI-leaf DB table, but the `crate_name == "rusqlite"` block above returned before ever
4883        // reaching it — same shape as the git2 fix elsewhere in this file).
4884        assert_eq!(classify("rusqlite", "rusqlite::Backup::new"), Some("Db"));
4885        assert_eq!(classify("rusqlite", "rusqlite::Backup::new_with_names"), Some("Db"));
4886        assert_eq!(classify("rusqlite", "rusqlite::Backup::step"), Some("Db"));
4887        assert_eq!(classify("rusqlite", "rusqlite::Backup::run_to_completion"), Some("Db"));
4888        assert_eq!(classify("rusqlite", "rusqlite::Connection::backup"), Some("Db"));
4889        assert_eq!(classify("rusqlite", "rusqlite::Connection::restore"), Some("Db"));
4890        assert_eq!(classify("rusqlite", "rusqlite::Blob::read_at"), Some("Db"));
4891        assert_eq!(classify("rusqlite", "rusqlite::Blob::read_at_exact"), Some("Db"));
4892        assert_eq!(classify("rusqlite", "rusqlite::Blob::raw_read_at"), Some("Db"));
4893        assert_eq!(classify("rusqlite", "rusqlite::Blob::raw_read_at_exact"), Some("Db"));
4894        assert_eq!(classify("rusqlite", "rusqlite::Blob::write_at"), Some("Db"));
4895        assert_eq!(classify("rusqlite", "rusqlite::Blob::write_all_at"), Some("Db"));
4896        assert_eq!(classify("rusqlite", "rusqlite::Connection::from_handle"), Some("Db"));
4897        assert_eq!(classify("rusqlite", "rusqlite::Connection::from_handle_owned"), Some("Db"));
4898        assert_eq!(classify("rusqlite", "rusqlite::Connection::extension_init2"), Some("Db"));
4899        assert_eq!(classify("rusqlite", "rusqlite::init_auto_extension"), Some("Db"));
4900        // …and the REAL module-qualified spellings (`Backup`/`Blob`/`init_auto_extension` are not
4901        // re-exported at rusqlite's crate root, unlike `Connection` — a real consumer's source, proven
4902        // against a compiling fixture, must use these, not the short forms above).
4903        assert_eq!(classify("rusqlite", "rusqlite::backup::Backup::new"), Some("Db"));
4904        assert_eq!(classify("rusqlite", "rusqlite::blob::Blob::read_at"), Some("Db"));
4905        assert_eq!(classify("rusqlite", "rusqlite::auto_extension::init_auto_extension"), Some("Db"));
4906        // NO FABRICATION: `InnerConnection`/`RawStatement` live in PRIVATE modules (lib.rs `mod
4907        // inner_connection;`/`mod raw_statement;`, no `pub`) — no external consumer can ever name either
4908        // type, so no rule was added despite self-scan flagging them too.
4909        assert_eq!(classify("rusqlite", "rusqlite::InnerConnection::close"), None);
4910        assert_eq!(classify("rusqlite", "rusqlite::RawStatement::step"), None);
4911        // …but `open` stays rusqlite-only (postgres has no open; nothing else may borrow it):
4912        assert_eq!(classify("postgres", "postgres::Client::open"), None);
4913        assert_eq!(classify("tokio_postgres", "tokio_postgres::Client::query_typed"), Some("Db"));
4914        // THE FIX: `Config::connect_raw` does the same protocol handshake as `Config::connect`, over a
4915        // caller-supplied stream instead of one it dials itself.
4916        assert_eq!(classify("tokio_postgres", "tokio_postgres::Config::connect_raw"), Some("Db"));
4917        // diesel's LIMIT-1 + streaming executions; sqlx's multi-result stream:
4918        assert_eq!(classify("diesel", "diesel::RunQueryDsl::first"), Some("Db"));
4919        assert_eq!(classify("diesel", "diesel::RunQueryDsl::load_iter"), Some("Db"));
4920        // THE FIX: `Connection::establish` is diesel's own name for `::connect` — the crate's canonical,
4921        // most-used connection entry point (`SqliteConnection::establish(url)` in every diesel
4922        // quickstart), implemented by really opening the backend handle — but shared no verb spelling
4923        // with `::connect`, so it read pure with zero `coverage.uncovered` disclosure (diesel is
4924        // calibrated, so the miss reads as reviewed-pure, not as a gap).
4925        assert_eq!(classify("diesel", "diesel::sqlite::SqliteConnection::establish"), Some("Db"));
4926        assert_eq!(classify("diesel", "diesel::pg::PgConnection::establish"), Some("Db"));
4927        assert_eq!(classify("diesel", "diesel::mysql::MysqlConnection::establish"), Some("Db"));
4928        assert_eq!(classify("diesel", "diesel::Connection::establish"), Some("Db"));
4929        // NO FABRICATION: diesel's own private plumbing shares the substring but not the exact verb.
4930        assert_eq!(classify("diesel", "diesel::sqlite::SqliteConnection::establish_inner"), None);
4931        assert_eq!(classify("sqlx", "sqlx::query::Query::fetch_many"), Some("Db"));
4932        // sqlx's bare `query()` builder must STAY pure (the original sqlx lesson):
4933        assert_eq!(classify("sqlx", "sqlx::query"), None);
4934        // tracing: the emit/span-lifecycle dispatch is Log; the pure DATA-type accessors are not
4935        // (whole-crate Log fabricated Log on `Level::as_str` / `Span::is_disabled` — the data types are
4936        // pure, same principle as the `log` facade).
4937        assert_eq!(classify("tracing", "tracing::event"), Some("Log"));
4938        assert_eq!(classify("tracing", "tracing::Span::new_span"), Some("Log"));
4939        assert_eq!(classify("tracing", "tracing::Span::record"), Some("Log"));
4940        assert_eq!(classify("tracing", "tracing::Span::enter"), Some("Log"));
4941        assert_eq!(classify("tracing", "tracing::Level::as_str"), None); // pure accessor
4942        assert_eq!(classify("tracing", "tracing::Span::is_disabled"), None); // pure state read
4943        assert_eq!(classify("tracing", "tracing::Span::metadata"), None); // pure accessor
4944        assert_eq!(classify("tracing", "tracing::metadata::Level::TRACE"), None); // pure data type
4945        assert_eq!(classify("tracing", "tracing::field::Field::name"), None); // pure data type
4946        // git2 (high-level Rust API, not the `raw::git_*` FFI tier tested above): remote verbs are Net.
4947        assert_eq!(classify("git2", "git2::Remote::fetch"), Some("Net"));
4948        assert_eq!(classify("git2", "git2::Remote::push"), Some("Net"));
4949        assert_eq!(classify("git2", "git2::Remote::download"), Some("Net"));
4950        assert_eq!(classify("git2", "git2::Remote::connect"), Some("Net"));
4951        assert_eq!(classify("git2", "git2::Remote::connect_auth"), Some("Net"));
4952        assert_eq!(classify("git2", "git2::Remote::ls"), Some("Net"));
4953        assert_eq!(classify("git2", "git2::Remote::upload"), Some("Net"));
4954        // THE COVERAGE-GATE SWEEP FIX: `Repository::open`/`init` (and every other local .git-directory
4955        // operation below) used to read PURE here — the comment this replaced called that "honest, no
4956        // network", but candor-scan self-scanning git2's OWN source (eval/coverage-gate) proved these
4957        // reach a REAL Fs effect (`raw::git_repository_open`/`_init_ext`, already in this file's FFI-tier
4958        // table) that a real consumer's call to the safe wrapper could never surface, because THIS
4959        // block's early `return None` sat in front of that table for every `crate_name == "git2"` call.
4960        // "local, no network" was true and beside the point: Fs was the effect being missed. See MEMORY /
4961        // the commit that added this block for the full sweep (Config/Index/Odb/PackBuilder/Reference/
4962        // Repository/TreeBuilder — every FQN below calls a listed FS FFI leaf; verified against git2
4963        // 0.20.4 source).
4964        assert_eq!(classify("git2", "git2::Repository::open"), Some("Fs"));
4965        assert_eq!(classify("git2", "git2::Repository::init"), Some("Fs"));
4966        assert_eq!(classify("git2", "git2::Repository::open_bare"), Some("Fs"));
4967        assert_eq!(classify("git2", "git2::Repository::open_ext"), Some("Fs"));
4968        assert_eq!(classify("git2", "git2::Repository::open_from_env"), Some("Fs"));
4969        assert_eq!(classify("git2", "git2::Repository::discover"), Some("Fs"));
4970        assert_eq!(classify("git2", "git2::Repository::discover_path"), Some("Fs"));
4971        assert_eq!(classify("git2", "git2::Repository::init_bare"), Some("Fs"));
4972        assert_eq!(classify("git2", "git2::Repository::init_opts"), Some("Fs"));
4973        assert_eq!(classify("git2", "git2::Repository::blob_path"), Some("Fs"));
4974        assert_eq!(classify("git2", "git2::Repository::checkout_head"), Some("Fs"));
4975        assert_eq!(classify("git2", "git2::Repository::checkout_index"), Some("Fs"));
4976        assert_eq!(classify("git2", "git2::Repository::checkout_tree"), Some("Fs"));
4977        assert_eq!(classify("git2", "git2::Repository::commit"), Some("Fs"));
4978        assert_eq!(classify("git2", "git2::Repository::reference"), Some("Fs"));
4979        assert_eq!(classify("git2", "git2::Repository::tag"), Some("Fs"));
4980        assert_eq!(classify("git2", "git2::Config::add_file"), Some("Fs"));
4981        assert_eq!(classify("git2", "git2::Config::open"), Some("Fs"));
4982        assert_eq!(classify("git2", "git2::Config::open_default"), Some("Fs"));
4983        assert_eq!(classify("git2", "git2::Index::add_all"), Some("Fs"));
4984        assert_eq!(classify("git2", "git2::Index::add_path"), Some("Fs"));
4985        assert_eq!(classify("git2", "git2::Index::read"), Some("Fs"));
4986        assert_eq!(classify("git2", "git2::Index::write"), Some("Fs"));
4987        assert_eq!(classify("git2", "git2::Index::write_tree"), Some("Fs"));
4988        assert_eq!(classify("git2", "git2::Index::write_tree_to"), Some("Fs"));
4989        assert_eq!(classify("git2", "git2::Odb::read"), Some("Fs"));
4990        assert_eq!(classify("git2", "git2::Odb::reader"), Some("Fs"));
4991        assert_eq!(classify("git2", "git2::Odb::write"), Some("Fs"));
4992        assert_eq!(classify("git2", "git2::Odb::writer"), Some("Fs"));
4993        assert_eq!(classify("git2", "git2::PackBuilder::write"), Some("Fs"));
4994        assert_eq!(classify("git2", "git2::Reference::delete"), Some("Fs"));
4995        assert_eq!(classify("git2", "git2::Reference::set_target"), Some("Fs"));
4996        assert_eq!(classify("git2", "git2::TreeBuilder::write"), Some("Fs"));
4997        // `Remote::list`/`RemoteConnection::list` call `raw::git_remote_ls` directly — the same
4998        // reference-advertisement Net effect `Remote::ls` was meant to catch, under the name git2 0.20
4999        // actually uses (there is no `ls` method left in the crate at all — that suffix rule is dead
5000        // weight, kept rather than removed since deleting it is a separate, unrelated cleanup).
5001        assert_eq!(classify("git2", "git2::Remote::list"), Some("Net"));
5002        assert_eq!(classify("git2", "git2::RemoteConnection::list"), Some("Net"));
5003        // `Cred::credential_helper` spawns a real `sh -c "<helper> get"` subprocess to resolve
5004        // `credential.helper` config (cred.rs:370-390) — a real consumer's most common way to honor it.
5005        assert_eq!(classify("git2", "git2::Cred::credential_helper"), Some("Exec"));
5006        assert_eq!(classify("git2", "git2::CredentialHelper::execute"), Some("Exec"));
5007        // NO FABRICATION controls: a `write`/`read`/`open` on some OTHER git2 type (not FQN-listed above)
5008        // must stay pure — this fix is FQN-exact, not a suffix re-widen.
5009        assert_eq!(classify("git2", "git2::Repository::state"), None);
5010        assert_eq!(classify("git2", "git2::Blob::content"), None);
5011        // tonic's SERVER half (the coverage-gate sweep found only the client verbs were covered):
5012        // `Router::serve`/`::serve_with_shutdown` bind a real listening socket via `TcpIncoming::new`
5013        // (`StdTcpListener::bind`), verified against tonic 0.12.3 source.
5014        assert_eq!(classify("tonic", "tonic::transport::server::Router::serve"), Some("Net"));
5015        assert_eq!(
5016            classify("tonic", "tonic::transport::server::Router::serve_with_shutdown"),
5017            Some("Net")
5018        );
5019        assert_eq!(classify("tonic", "tonic::TcpIncoming::new"), Some("Net"));
5020        // NO FABRICATION control: `Server<L>::serve_with_shutdown` (mod.rs:530) is a DIFFERENT,
5021        // `pub(crate)` method on a different type — not reachable by any consumer, and this fix does not
5022        // fabricate an effect for it by widening past the `Router::` FQN.
5023        assert_eq!(classify("tonic", "tonic::transport::server::Server::serve_with_shutdown"), None);
5024        // THE FIX: `Repository::clone`/`clone_recurse` and `RepoBuilder::clone` ARE libgit2's real
5025        // network clone — a corpus round found `git2::Repository::clone(url, path)` reporting ZERO
5026        // effects and passing `deny Net` at exit 0, because the bare `::clone` denylist meant to keep
5027        // out `Remote`'s derived `Clone` dup (below) also excluded the one thing the old comment named
5028        // as NOT meant to be excluded.
5029        assert_eq!(classify("git2", "git2::Repository::clone"), Some("Net"));
5030        assert_eq!(classify("git2", "git2::Repository::clone_recurse"), Some("Net"));
5031        assert_eq!(classify("git2", "git2::build::RepoBuilder::clone"), Some("Net"));
5032        // THE CONTROL: `Remote::clone` is the DERIVED `Clone` trait impl (an Arc/handle duplication, no
5033        // libgit2 call) — it must stay pure. Re-fabricating Net here would undo the very over-charge the
5034        // original exclusion existed to prevent. FQN-exact matching (not a bare `::clone` re-widen) keeps
5035        // this pure while catching `Repository::clone` above.
5036        assert_eq!(classify("git2", "git2::Remote::clone"), None);
5037        // THE SWEEP FIX: a fourth+fifth true positive in the SAME gap — `Submodule::clone`/
5038        // `Submodule::update` call `raw::git_submodule_clone`/`git_submodule_update` directly (the exact
5039        // leaves already in this file's FFI-tier NET table), but git2's documented submodule-init idiom
5040        // calls the safe Rust wrapper, which carried no rule of its own.
5041        assert_eq!(classify("git2", "git2::Submodule::clone"), Some("Net"));
5042        assert_eq!(classify("git2", "git2::Submodule::update"), Some("Net"));
5043        // NO FABRICATION: git2's many pure `update_*` setters (CheckoutBuilder/DiffOptions/StatusOptions)
5044        // must not gain Net — FQN-exact, not a bare `::update` substring.
5045        assert_eq!(classify("git2", "git2::build::CheckoutBuilder::update_only"), None);
5046        assert_eq!(classify("git2", "git2::DiffOptions::update_index"), None);
5047        assert_eq!(classify("git2", "git2::Submodule::update_strategy"), None);
5048        // memmap2: only the syscall-issuing map/flush/protect verbs are Fs; reads over an already-mapped
5049        // region (len/as_ptr/is_empty) and the request builder are PURE (whole-crate Fs fabricated Fs).
5050        assert_eq!(classify("memmap2", "memmap2::MmapOptions::map"), Some("Fs"));
5051        assert_eq!(classify("memmap2", "memmap2::MmapOptions::map_mut"), Some("Fs"));
5052        assert_eq!(classify("memmap2", "memmap2::Mmap::flush"), Some("Fs"));
5053        assert_eq!(classify("memmap2", "memmap2::MmapMut::make_read_only"), Some("Fs"));
5054        assert_eq!(classify("memmap2", "memmap2::Mmap::len"), None); // length read — pure
5055        assert_eq!(classify("memmap2", "memmap2::Mmap::is_empty"), None); // pure
5056        assert_eq!(classify("memmap2", "memmap2::Mmap::as_ptr"), None); // pointer — pure
5057        assert_eq!(classify("memmap2", "memmap2::MmapOptions::new"), None); // request builder — pure
5058        // arboard: the Clipboard handle's read/write verbs are Clipboard; `arboard::Error` formatting
5059        // and option data types are PURE (whole-crate Clipboard fabricated Clipboard on `Error::to_string`).
5060        assert_eq!(classify("arboard", "arboard::Clipboard::new"), Some("Clipboard"));
5061        assert_eq!(classify("arboard", "arboard::Clipboard::get_text"), Some("Clipboard"));
5062        assert_eq!(classify("arboard", "arboard::Clipboard::set_text"), Some("Clipboard"));
5063        assert_eq!(classify("arboard", "arboard::Clipboard::clear"), Some("Clipboard"));
5064        assert_eq!(classify("arboard", "arboard::Error::to_string"), None); // error formatting — pure
5065        assert_eq!(classify("arboard", "arboard::Error::fmt"), None); // Display impl — pure
5066        assert_eq!(classify("arboard", "arboard::ImageData::to_owned_img"), None); // pure data type
5067        // R59-class audit: `file_list` is `Get`/`Set`'s sibling terminal beside `text`/`image`/`html`
5068        // (verified against arboard 3.6.1 — the only `file_list` in the crate, so no ambiguity survives
5069        // the crate gate); `Clear::default` is `clear()`'s own alternate entry point.
5070        assert_eq!(classify("arboard", "arboard::Get::file_list"), Some("Clipboard"));
5071        assert_eq!(classify("arboard", "arboard::Set::file_list"), Some("Clipboard"));
5072        assert_eq!(classify("arboard", "arboard::Clear::default"), Some("Clipboard"));
5073        // fastrand: value draws + entropy-seeded entry points are Rand; the DETERMINISTIC seeded ctor
5074        // `with_seed` and state split/copy (`fork`/`clone`) are PURE (whole-crate Rand fabricated Rand).
5075        assert_eq!(classify("fastrand", "fastrand::u32"), Some("Rand")); // top-level draw
5076        assert_eq!(classify("fastrand", "fastrand::Rng::usize"), Some("Rand"));
5077        assert_eq!(classify("fastrand", "fastrand::Rng::shuffle"), Some("Rand"));
5078        assert_eq!(classify("fastrand", "fastrand::Rng::new"), Some("Rand")); // entropy-seeded
5079        assert_eq!(classify("fastrand", "fastrand::Rng::with_seed"), None); // deterministic ctor — pure
5080        assert_eq!(classify("fastrand", "fastrand::Rng::fork"), None); // state split — pure
5081        assert_eq!(classify("fastrand", "fastrand::Rng::clone"), None); // state copy — pure
5082        // portable_pty / async_process: spawn/wait keep Exec; config GETTERS and pure data ctors/setters
5083        // do NOT (base Exec fabricated on `CommandBuilder::get_cwd` / `PtySize::default` / `Stdio::piped`).
5084        assert_eq!(classify("portable_pty", "portable_pty::PtySystem::openpty"), Some("Exec"));
5085        assert_eq!(classify("portable_pty", "portable_pty::SlavePty::spawn_command"), Some("Exec"));
5086        assert_eq!(classify("portable_pty", "portable_pty::CommandBuilder::get_argv"), None); // getter
5087        assert_eq!(classify("portable_pty", "portable_pty::CommandBuilder::get_cwd"), None); // getter
5088        assert_eq!(classify("portable_pty", "portable_pty::PtySize::default"), None); // pure data type
5089        assert_eq!(classify("portable_pty", "portable_pty::CommandBuilder::new"), None); // builder ctor
5090        assert_eq!(classify("async_process", "async_process::Command::spawn"), Some("Exec"));
5091        assert_eq!(classify("async_process", "async_process::Command::output"), Some("Exec"));
5092        assert_eq!(classify("async_process", "async_process::Stdio::piped"), None); // pure data type
5093        assert_eq!(classify("async_process", "async_process::Stdio::null"), None); // pure data type
5094        // FFI tiers (matched by distinctive leaf, alias-independent)
5095        assert_eq!(classify("libc", "libc::open"), Some("Fs"));
5096        assert_eq!(classify("libc", "libc::connect"), Some("Net"));
5097        assert_eq!(classify("libc", "libc::read"), None); // generic fd op — deliberately unclassified
5098        assert_eq!(classify("ffi", "ffi::sqlite3_step"), Some("Db"));
5099        // SOUNDNESS R166 — the PROCESS-GLOBAL extension registry. `rusqlite::register_auto_extension`
5100        // calls `ffi::sqlite3_auto_extension` directly and read `[]` on the 0.34.0 binary: an explicit
5101        // empty effect set over a call that changes what every LATER `sqlite3_open` executes.
5102        assert_eq!(classify("ffi", "ffi::sqlite3_auto_extension"), Some("Db"));
5103        assert_eq!(classify("ffi", "ffi::sqlite3_cancel_auto_extension"), Some("Db"));
5104        assert_eq!(classify("ffi", "ffi::sqlite3_reset_auto_extension"), Some("Db"));
5105        assert_eq!(classify("ffi", "ffi::sqlite3_enable_load_extension"), Some("Db"));
5106        // …and the database-CONTENT I/O the same sweep found unlisted beside it.
5107        assert_eq!(classify("ffi", "ffi::sqlite3_deserialize"), Some("Db"));
5108        assert_eq!(classify("ffi", "ffi::sqlite3_serialize"), Some("Db"));
5109        assert_eq!(classify("ffi", "ffi::sqlite3_db_cacheflush"), Some("Db"));
5110        assert_eq!(classify("ffi", "ffi::sqlite3_file_control"), Some("Db"));
5111        assert_eq!(classify("ffi", "ffi::sqlite3_wal_autocheckpoint"), Some("Db"));
5112        // CONTROLS for the boundary this list deliberately stops at — an in-memory accessor and a
5113        // per-connection callback INSTALLER stay unclassified, so the additions above are not read as
5114        // "every `sqlite3_*` is Db". Both pass before and after R166; recorded as boundary, not coverage.
5115        assert_eq!(classify("ffi", "ffi::sqlite3_column_int64"), None);
5116        assert_eq!(classify("ffi", "ffi::sqlite3_create_function_v2"), None);
5117        assert_eq!(classify("raw", "raw::git_remote_fetch"), Some("Net"));
5118        // libgit2 clone + submodule clone/update fetch over the network (an A/B on git2 0.20 caught
5119        // `Submodule::update`/`clone` and `Repository::clone` reporting no Net — the latter because the
5120        // `src/build.rs` module was being dropped as if it were the Cargo build script).
5121        assert_eq!(classify("raw", "raw::git_clone"), Some("Net"));
5122        assert_eq!(classify("raw", "raw::git_submodule_clone"), Some("Net"));
5123        assert_eq!(classify("raw", "raw::git_submodule_update"), Some("Net"));
5124        assert_eq!(classify("raw", "raw::git_submodule_open"), None); // local subrepo open — not Net
5125        // libcurl: the transfer/raw-socket entry points are Net (an A/B on curl 0.4 caught the whole
5126        // crate reporting ZERO Net); the big setopt/init/getinfo surface — and the readiness-wait
5127        // multi_wait/poll — stay unclassified (the loop's perform is the boundary).
5128        assert_eq!(classify("curl_sys", "curl_sys::curl_easy_perform"), Some("Net"));
5129        assert_eq!(classify("curl_sys", "curl_sys::curl_easy_send"), Some("Net"));
5130        assert_eq!(classify("curl_sys", "curl_sys::curl_multi_perform"), Some("Net"));
5131        assert_eq!(classify("curl_sys", "curl_sys::curl_multi_socket_action"), Some("Net"));
5132        assert_eq!(classify("curl_sys", "curl_sys::curl_easy_setopt"), None); // in-memory option write
5133        assert_eq!(classify("curl_sys", "curl_sys::curl_easy_init"), None); // handle alloc
5134        assert_eq!(classify("curl_sys", "curl_sys::curl_multi_wait"), None); // readiness wait, no payload
5135        // consumer-side `curl` crate rule: the dispatch verbs are Net, the setopt builders pure.
5136        assert_eq!(classify("curl", "curl::easy::Easy::perform"), Some("Net"));
5137        assert_eq!(classify("curl", "curl::multi::Multi::perform"), Some("Net"));
5138        assert_eq!(classify("curl", "curl::easy::Easy::send"), Some("Net"));
5139        assert_eq!(classify("curl", "curl::easy::Easy::url"), None); // CURLOPT setter — pure
5140        assert_eq!(classify("curl", "curl::easy::Easy::timeout"), None); // pure setter; Multi::timeout under-reported by design
5141        assert_eq!(classify("ffi", "ffi::SSL_connect"), Some("Net"));
5142        // pure crates stay pure
5143        assert_eq!(classify("serde", "serde::Serialize::serialize"), None);
5144        assert_eq!(classify("std", "std::vec::Vec::push"), None);
5145
5146        // ── sweep 2026-06-17: fabrication carve-outs + DNS coverage (each fails pre-fix) ──
5147        // [24] std::net socket accessors are pure; the I/O verbs stay Net.
5148        assert_eq!(classify("std", "std::net::TcpStream::connect"), Some("Net"));
5149        assert_eq!(classify("std", "std::net::TcpStream::local_addr"), None);
5150        assert_eq!(classify("std", "std::net::TcpStream::nodelay"), None);
5151        assert_eq!(classify("std", "std::net::TcpStream::ttl"), None);
5152        assert_eq!(classify("std", "std::net::UdpSocket::peer_addr"), None);
5153        // [37] std DNS resolution is Net (was floored).
5154        assert_eq!(classify("std", "std::net::lookup_host"), Some("Net"));
5155        assert_eq!(classify("std", "core::net::ToSocketAddrs::to_socket_addrs"), Some("Net"));
5156        // [23] std::process getters are pure; spawn/new stay Exec.
5157        assert_eq!(classify("std", "std::process::Command::get_program"), None);
5158        assert_eq!(classify("std", "std::process::Command::get_args"), None);
5159        assert_eq!(classify("std", "std::process::Child::id"), None);
5160        assert_eq!(classify("std", "std::process::Command::spawn"), Some("Exec"));
5161        // [27] redis ConnectionManager::clone is an Arc bump (pure); a query round-trips.
5162        assert_eq!(classify("redis", "redis::aio::ConnectionManager::clone"), None);
5163        assert_eq!(classify("redis", "redis::aio::ConnectionManager::send_packed_command"), Some("Db"));
5164        // [5] sea_orm re-exported sea_query builder algebra is pure; execution verbs stay Db.
5165        assert_eq!(classify("sea_orm", "sea_orm::sea_query::Func::count"), None);
5166        assert_eq!(classify("sea_orm", "sea_orm::sea_query::Condition::all"), None);
5167        assert_eq!(classify("sea_orm", "sea_orm::Select::all"), Some("Db"));
5168        // THE FIX: `Database::connect_proxy` (the `proxy`-feature sibling of `Database::connect`) opens
5169        // a live `DatabaseConnection` through a caller-supplied `ProxyDatabaseTrait` — same effect,
5170        // missing from an allowlist keyed on the plain `connect` spelling.
5171        assert_eq!(classify("sea_orm", "sea_orm::Database::connect_proxy"), Some("Db"));
5172        // THE COVERAGE-GATE SWEEP: the transaction and pagination families, verified against sea-orm
5173        // 1.1.20 source.
5174        assert_eq!(classify("sea_orm", "sea_orm::DatabaseConnection::transaction"), Some("Db"));
5175        assert_eq!(
5176            classify("sea_orm", "sea_orm::DatabaseConnection::transaction_with_config"),
5177            Some("Db")
5178        );
5179        // BONUS (found proving the above reachable with a real fixture, not in the original ratchet):
5180        assert_eq!(classify("sea_orm", "sea_orm::DatabaseConnection::ping"), Some("Db"));
5181        assert_eq!(classify("sea_orm", "sea_orm::DatabaseConnection::begin"), Some("Db"));
5182        assert_eq!(
5183            classify("sea_orm", "sea_orm::DatabaseConnection::begin_with_config"),
5184            Some("Db")
5185        );
5186        assert_eq!(classify("sea_orm", "sea_orm::DatabaseTransaction::commit"), Some("Db"));
5187        assert_eq!(classify("sea_orm", "sea_orm::DatabaseTransaction::rollback"), Some("Db"));
5188        assert_eq!(classify("sea_orm", "sea_orm::SqlxMySqlPoolConnection::begin"), Some("Db"));
5189        assert_eq!(classify("sea_orm", "sea_orm::SqlxMySqlPoolConnection::ping"), Some("Db"));
5190        assert_eq!(classify("sea_orm", "sea_orm::SqlxMySqlPoolConnection::transaction"), Some("Db"));
5191        assert_eq!(classify("sea_orm", "sea_orm::SqlxPostgresPoolConnection::begin"), Some("Db"));
5192        assert_eq!(classify("sea_orm", "sea_orm::SqlxSqlitePoolConnection::ping"), Some("Db"));
5193        assert_eq!(classify("sea_orm", "sea_orm::Paginator::fetch"), Some("Db"));
5194        assert_eq!(classify("sea_orm", "sea_orm::Paginator::fetch_and_next"), Some("Db"));
5195        assert_eq!(classify("sea_orm", "sea_orm::Paginator::into_stream"), Some("Db"));
5196        assert_eq!(classify("sea_orm", "sea_orm::Paginator::num_pages"), Some("Db"));
5197        assert_eq!(classify("sea_orm", "sea_orm::Paginator::num_items_and_pages"), Some("Db"));
5198        assert_eq!(classify("sea_orm", "sea_orm::Insert::exec_with_returning_keys"), Some("Db"));
5199        assert_eq!(classify("sea_orm", "sea_orm::Inserter::exec_with_returning_many"), Some("Db"));
5200        assert_eq!(classify("sea_orm", "sea_orm::TryInsert::exec_with_returning_keys"), Some("Db"));
5201        // NO FABRICATION: the mock/proxy backends share every one of these verb names but perform no
5202        // real I/O (mock) or dispatch through a caller-supplied trait (proxy) — FQN-exact, not a bare
5203        // `::ping`/`::begin`/`::transaction`/`::commit`/`::rollback` suffix, keeps them pure/unknown.
5204        assert_eq!(classify("sea_orm", "sea_orm::MockDatabaseConnection::ping"), None);
5205        assert_eq!(classify("sea_orm", "sea_orm::MockDatabaseConnection::begin"), None);
5206        assert_eq!(classify("sea_orm", "sea_orm::ProxyDatabaseConnection::commit"), None);
5207        assert_eq!(classify("sea_orm", "sea_orm::ProxyDatabaseConnection::ping"), None);
5208    }
5209
5210    #[test]
5211    fn lettre_tls_setup_and_connection_family_is_covered() {
5212        // THE COVERAGE-GATE SWEEP, verified against lettre 0.11.23 source. `build_rustls` calls
5213        // `rustls_native_certs::load_native_certs()` (a real OS-trust-store read) + `tracing::debug!`.
5214        assert_eq!(
5215            classify("lettre", "lettre::transport::smtp::client::TlsParametersBuilder::build_rustls"),
5216            Some("Fs")
5217        );
5218        assert_eq!(classify("lettre", "lettre::TlsParametersBuilder::build"), Some("Fs"));
5219        assert_eq!(classify("lettre", "lettre::TlsParameters::new"), Some("Fs"));
5220        assert_eq!(classify("lettre", "lettre::TlsParameters::new_rustls"), Some("Fs"));
5221        assert_eq!(classify("lettre", "lettre::SmtpTransport::from_url"), Some("Fs"));
5222        assert_eq!(classify("lettre", "lettre::SmtpTransport::relay"), Some("Fs"));
5223        assert_eq!(classify("lettre", "lettre::SmtpTransport::starttls_relay"), Some("Fs"));
5224        assert_eq!(classify("lettre", "lettre::AsyncSmtpTransport::from_url"), Some("Fs"));
5225        assert_eq!(classify("lettre", "lettre::AsyncSmtpTransport::relay"), Some("Fs"));
5226        assert_eq!(classify("lettre", "lettre::AsyncSmtpTransport::starttls_relay"), Some("Fs"));
5227        assert_eq!(classify("lettre", "lettre::FileTransport::read"), Some("Fs"));
5228        // The sealed `Executor` trait impl — `#[doc(hidden)]`, a narrower surface, but genuinely
5229        // reachable (both the trait and `AsyncStd1Executor` are `pub`, re-exported at the crate root).
5230        assert_eq!(classify("lettre", "lettre::AsyncStd1Executor::connect"), Some("Net"));
5231        assert_eq!(classify("lettre", "lettre::AsyncStd1Executor::fs_read"), Some("Fs"));
5232        assert_eq!(classify("lettre", "lettre::AsyncStd1Executor::fs_write"), Some("Fs"));
5233        // Only reachable via the module-qualified path — neither type is re-exported at the crate root.
5234        assert_eq!(
5235            classify(
5236                "lettre",
5237                "lettre::transport::smtp::client::AsyncSmtpConnection::connect_asyncstd1"
5238            ),
5239            Some("Net")
5240        );
5241        assert_eq!(
5242            classify(
5243                "lettre",
5244                "lettre::transport::smtp::client::AsyncNetworkStream::connect_asyncstd1"
5245            ),
5246            Some("Net")
5247        );
5248        // NO FABRICATION: `NetworkStream` lives in a PRIVATE module (`mod net;`, never re-exported) — no
5249        // external consumer can ever name it, so no rule was added despite self-scan flagging its
5250        // `shutdown`/`set_read_timeout`/`set_write_timeout` (propagated from the coarse
5251        // `std::net::TcpStream` whole-handle rule).
5252        assert_eq!(classify("lettre", "lettre::NetworkStream::shutdown"), None);
5253        assert_eq!(classify("lettre", "lettre::NetworkStream::set_read_timeout"), None);
5254    }
5255
5256    #[test]
5257    fn rand_osrng_handle_ops_are_pure_but_draws_are_rand() {
5258        // Adversarial-review fabrication: the blanket `contains("OsRng")` tagged `OsRng::clone` Rand,
5259        // but OsRng is a unit struct — clone/fork/default draw no entropy. The real draws still fire.
5260        assert_eq!(classify("rand", "rand::rngs::OsRng::clone"), None);
5261        assert_eq!(classify("rand", "rand::rngs::OsRng::default"), None);
5262        assert_eq!(classify("rand", "rand::rngs::OsRng::fill_bytes"), Some("Rand")); // a real draw
5263        assert_eq!(classify("rand", "rand::rngs::OsRng::next_u32"), Some("Rand"));
5264        assert_eq!(classify("rand", "rand::Rng::gen"), Some("Rand")); // verb path unaffected
5265        assert_eq!(classify("rand", "rand::distributions::Uniform::new"), None); // pure ctor still pure
5266    }
5267
5268    #[test]
5269    fn redis_connection_manager_config_builder_is_pure() {
5270        // Adversarial-review fabrication: `contains("ConnectionManager")` hit the pure *Config* builder.
5271        assert_eq!(classify("redis", "redis::aio::ConnectionManagerConfig::new"), None);
5272        assert_eq!(classify("redis", "redis::aio::ConnectionManagerConfig::set_max_delay"), None);
5273        // the LIVE manager still round-trips (Db).
5274        assert_eq!(classify("redis", "redis::aio::ConnectionManager::new"), Some("Db"));
5275        assert_eq!(classify("redis", "redis::Commands::get"), Some("Db"));
5276    }
5277
5278    #[test]
5279    fn redis_get_connection_info_is_a_pure_accessor_not_swept_by_the_substring() {
5280        // coverage-gate sweep (2026-08-27): `contains("::get_connection")` also matched
5281        // `Client::get_connection_info` (a pure accessor over an already-stored field) because it is a
5282        // literal substring of that name — the real connection-getters stay caught.
5283        assert_eq!(classify("redis", "redis::Client::get_connection_info"), None);
5284        assert_eq!(classify("redis", "redis::Client::get_connection"), Some("Db"));
5285        assert_eq!(classify("redis", "redis::Client::get_async_connection"), Some("Db"));
5286        assert_eq!(
5287            classify("redis", "redis::Client::get_multiplexed_async_connection"),
5288            Some("Db")
5289        );
5290    }
5291
5292    #[test]
5293    fn aws_config_load_from_env_is_loads_own_convenience_wrapper() {
5294        // THE FIX: `load_from_env()` is the crate's OWN "convenience wrapper" (its doc comment's words)
5295        // around `from_env().load().await` — the exact already-modelled effect one call down — but
5296        // "load_from_env".ends_with("::load") is false.
5297        assert_eq!(classify("aws_config", "aws_config::load"), Some("Net"));
5298        assert_eq!(classify("aws_config", "aws_config::load_defaults"), Some("Net"));
5299        assert_eq!(classify("aws_config", "aws_config::load_from_env"), Some("Net"));
5300        assert_eq!(classify("aws_config", "aws_config::from_env"), None); // pure builder
5301    }
5302
5303    #[test]
5304    fn tungstenite_stream_first_handshake_entry_points_are_net() {
5305        // THE FIX: `client`/`client_with_config`/`client_tls`/`client_tls_with_config` (client.rs:176,
5306        // 159; tls.rs:163,179) and `accept`/`accept_with_config`/`accept_hdr`/`accept_hdr_with_config`
5307        // (server.rs:23-63) each run `{Client,Server}Handshake::start(stream, ..).handshake()` — the real
5308        // WS upgrade I/O over an already-open stream. tungstenite's OWN documented way to run over a
5309        // caller-managed TCP/TLS/mio stream, missing from a verb list keyed only on `connect`.
5310        assert_eq!(classify("tungstenite", "tungstenite::client::client"), Some("Net"));
5311        assert_eq!(classify("tungstenite", "tungstenite::client::client_with_config"), Some("Net"));
5312        assert_eq!(classify("tungstenite", "tungstenite::tls::client_tls"), Some("Net"));
5313        assert_eq!(classify("tungstenite", "tungstenite::tls::client_tls_with_config"), Some("Net"));
5314        assert_eq!(classify("tungstenite", "tungstenite::server::accept"), Some("Net"));
5315        assert_eq!(classify("tungstenite", "tungstenite::server::accept_with_config"), Some("Net"));
5316        assert_eq!(classify("tungstenite", "tungstenite::server::accept_hdr"), Some("Net"));
5317        assert_eq!(classify("tungstenite", "tungstenite::server::accept_hdr_with_config"), Some("Net"));
5318        assert_eq!(classify("tungstenite", "tungstenite::client::connect_with_config"), Some("Net"));
5319    }
5320
5321    #[test]
5322    fn mysql_conn_new_is_the_real_connect() {
5323        // THE FIX: `mysql::Conn::new` (conn/mod.rs:342) calls `connect_stream()?; connect()?` directly;
5324        // `mysql_async::Conn::new` (conn/mod.rs:921) is the async equivalent. Each crate's own primary
5325        // connection constructor, the crate's own first doctest example — but `::new` never appeared in
5326        // the verb list.
5327        assert_eq!(classify("mysql", "mysql::Conn::new"), Some("Db"));
5328        assert_eq!(classify("mysql_async", "mysql_async::Conn::new"), Some("Db"));
5329        // NO FABRICATION: the SAME two crates' unrelated pure `new`s (Opts/PoolConstraints/TxOpts/…)
5330        // must not gain Db — scoped to the `Conn::` segment, not a bare `::new` suffix.
5331        assert_eq!(classify("mysql", "mysql::Opts::new"), None);
5332        assert_eq!(classify("mysql", "mysql::PoolConstraints::new"), None);
5333        assert_eq!(classify("mysql_async", "mysql_async::TxOpts::new"), None);
5334    }
5335
5336    #[test]
5337    fn mongodb_with_options_is_the_same_effect_as_with_uri_str() {
5338        // THE FIX: `with_uri_str` (client.rs:179) is `ClientOptions::parse(uri).await?;
5339        // Client::with_options(options)` one call down — `with_options` (client.rs:188) is where the
5340        // topology/monitoring actually spins up, and mongodb's own doc calls it the entry point for a
5341        // caller who already holds parsed `ClientOptions`. Verified against mongodb 3.8.1 (both the
5342        // async `client.rs` and sync `sync/client.rs` `Client`).
5343        assert_eq!(classify("mongodb", "mongodb::Client::with_uri_str"), Some("Db"));
5344        assert_eq!(classify("mongodb", "mongodb::Client::with_options"), Some("Db"));
5345        assert_eq!(classify("mongodb", "mongodb::sync::Client::with_options"), Some("Db"));
5346        assert_eq!(classify("mongodb", "mongodb::Collection::find_one"), Some("Db"));
5347        // NO FABRICATION: an unrelated crate's `with_options` builder must not gain Db — crate-gated.
5348        assert_eq!(classify("some_other_crate", "some_other_crate::Widget::with_options"), None);
5349    }
5350
5351    #[test]
5352    fn pure_fd_transfer_is_not_an_effect() {
5353        // ADOPTING / EXTRACTING / BORROWING an already-open descriptor (or unwrapping an async type back
5354        // to its std type) issues NO syscall — it must be PURE even though it hangs off a std I/O type
5355        // whose prefix rule would otherwise fire Net/Fs/Ipc. (Real tokio sweep: `into_std`, `from_raw_fd`,
5356        // `as_raw_fd` all fabricated effects.)
5357        assert_eq!(classify("std", "std::net::TcpStream::from_raw_fd"), None);
5358        assert_eq!(classify("std", "std::net::TcpStream::into_raw_fd"), None);
5359        assert_eq!(classify("std", "std::net::TcpStream::as_raw_fd"), None);
5360        assert_eq!(classify("std", "std::net::TcpListener::from_raw_fd"), None);
5361        assert_eq!(classify("std", "std::net::UdpSocket::from_raw_socket"), None);
5362        assert_eq!(classify("std", "std::fs::File::from_raw_fd"), None);
5363        assert_eq!(classify("std", "std::fs::File::into_raw_fd"), None);
5364        assert_eq!(classify("std", "std::fs::File::as_raw_handle"), None);
5365        assert_eq!(classify("std", "std::os::unix::net::UnixStream::from_raw_fd"), None);
5366        // `SocketAddr::from_pathname` builds an address struct, opens no socket — pure. (socket2 sweep.)
5367        assert_eq!(classify("std", "std::os::unix::net::SocketAddr::from_pathname"), None);
5368        assert_eq!(classify("tokio", "tokio::net::TcpStream::from_raw_fd"), None);
5369        assert_eq!(classify("tokio", "tokio::net::TcpStream::into_std"), None); // unwrap → std type, pure
5370        assert_eq!(classify("tokio", "tokio::fs::File::into_std"), None);
5371        // …but a REAL open/connect on the SAME types still fires the effect — the carve-out is leaf-precise.
5372        assert_eq!(classify("std", "std::net::TcpStream::connect"), Some("Net"));
5373        assert_eq!(classify("std", "std::fs::File::open"), Some("Fs"));
5374        assert_eq!(classify("std", "std::fs::read"), Some("Fs"));
5375        assert_eq!(classify("std", "std::os::unix::net::UnixStream::connect"), Some("Ipc"));
5376        assert_eq!(classify("tokio", "tokio::net::TcpStream::connect"), Some("Net"));
5377    }
5378
5379    /// THE PLATFORM `fs` MODULES. `std::fs::` was the whole filesystem rule, so every function in
5380    /// `std::os::{unix,windows,wasi}::fs` read PURE — measured with EXECUTED ground truth (a `cargo run`
5381    /// that created a real symlink and stat'd it back), `deny Fs` over a crate whose only filesystem
5382    /// write was `std::os::unix::fs::symlink` exited 0.
5383    ///
5384    /// The controls are the point: the `*Ext` DATA/BUILDER traits must stay pure, or the fix trades a
5385    /// silent under-report for a fabrication on every `m.uid()` — and `FileExt` must NOT, because
5386    /// `read_at`/`write_at` are the positional-I/O syscalls this rule exists to catch.
5387    #[test]
5388    fn the_platform_fs_modules_are_filesystem_io_and_their_data_traits_are_not() {
5389        for p in [
5390            "std::os::unix::fs::symlink", "std::os::unix::fs::chown", "std::os::unix::fs::lchown",
5391            "std::os::unix::fs::fchown", "std::os::unix::fs::chroot",
5392            "std::os::windows::fs::symlink_dir", "std::os::windows::fs::symlink_file",
5393            "std::os::windows::fs::junction_point",
5394            "std::os::unix::fs::FileExt::read_at", "std::os::unix::fs::FileExt::write_at",
5395            "std::os::windows::fs::FileExt::seek_read", "std::os::windows::fs::FileExt::seek_write",
5396        ] {
5397            assert_eq!(classify("std", p), Some("Fs"), "{p} performs filesystem I/O");
5398        }
5399        for p in [
5400            "std::os::unix::fs::MetadataExt::uid", "std::os::unix::fs::MetadataExt::mode",
5401            "std::os::unix::fs::PermissionsExt::mode", "std::os::unix::fs::PermissionsExt::set_mode",
5402            "std::os::unix::fs::OpenOptionsExt::custom_flags",
5403            "std::os::unix::fs::DirBuilderExt::mode",
5404            "std::os::unix::fs::DirEntryExt::ino", "std::os::unix::fs::FileTypeExt::is_fifo",
5405            "std::os::windows::fs::MetadataExt::file_attributes",
5406        ] {
5407            assert_eq!(classify("std", p), None,
5408                       "{p} reads or configures data already in hand — charging it would FABRICATE Fs");
5409        }
5410        // `std::os::unix::net` is Ipc and must be untouched by a rule keyed one segment along.
5411        assert_eq!(classify("std", "std::os::unix::net::UnixStream::connect"), Some("Ipc"));
5412    }
5413
5414    /// SOUNDNESS R141 — the platform `process` modules, the sibling `fs` had a rule and `process` did
5415    /// not. `CommandExt::exec` is `execvp`: it REPLACES the process image, ground-truthed by a
5416    /// `cargo run` that printed a line from the exec'd image and never reached the line after the call.
5417    /// Both directions are driven here: the spawn surface must charge Exec (without the rule every
5418    /// assertion in the first loop returns `None` and `deny Exec` over a library whose only function
5419    /// calls `CommandExt::exec` exits 0), and the already-collected-status traits must NOT, or the fix
5420    /// trades a silent under-report for a fabrication on every `status.signal()` — the same control
5421    /// shape as the `fs` test above.
5422    #[test]
5423    fn the_platform_process_modules_are_exec_and_their_status_traits_are_not() {
5424        for p in [
5425            "std::os::unix::process::CommandExt::exec",
5426            "std::os::unix::process::CommandExt::pre_exec",
5427            "std::os::unix::process::CommandExt::arg0",
5428            "std::os::unix::process::CommandExt::uid",
5429            "std::os::unix::process::CommandExt::gid",
5430            "std::os::unix::process::CommandExt::groups",
5431            "std::os::unix::process::CommandExt::process_group",
5432            "std::os::windows::process::CommandExt::creation_flags",
5433            "std::os::windows::process::CommandExt::raw_arg",
5434            "std::os::windows::process::ChildExt::main_thread_handle",
5435            "std::os::wasi::process::CommandExt::exec",
5436        ] {
5437            assert_eq!(classify("std", p), Some("Exec"), "{p} is subprocess machinery");
5438        }
5439        for p in [
5440            "std::os::unix::process::ExitStatusExt::signal",
5441            "std::os::unix::process::ExitStatusExt::core_dumped",
5442            "std::os::unix::process::ExitStatusExt::from_raw",
5443            "std::os::unix::process::ExitStatusExt::into_raw",
5444            "std::os::unix::process::ExitStatusError::signal",
5445            "std::os::windows::process::ExitStatusExt::from_raw",
5446            "std::os::windows::process::ExitCodeExt::from_raw",
5447            "std::os::unix::process::parent_id",
5448        ] {
5449            assert_eq!(classify("std", p), None,
5450                       "{p} reads a status already collected (or this process's own pid) — charging it \
5451                        would FABRICATE Exec");
5452        }
5453        // Keyed one segment along: `fs` and `net` under the same platform root must be untouched.
5454        assert_eq!(classify("std", "std::os::unix::fs::FileExt::read_at"), Some("Fs"));
5455        assert_eq!(classify("std", "std::os::unix::net::UnixStream::connect"), Some("Ipc"));
5456    }
5457
5458    #[test]
5459    fn command_head_refines_the_exec_cliff() {
5460        use super::classify_command_head as h;
5461        // unambiguous external tools classify by basename (spec §4 ⟨0.5⟩)
5462        assert_eq!(h("curl"), &["Net"]);
5463        assert_eq!(h("telnet"), &["Net"]);
5464        assert_eq!(h("sftp"), &["Net"]);
5465        assert_eq!(h("/usr/local/bin/psql"), &["Db"]); // basename match strips the path
5466        assert_eq!(h("mongo"), &["Db"]);
5467        assert_eq!(h("cqlsh"), &["Db"]);
5468        // a candor engine is Fs/Env — spec-SUPPLIED by §7 item 12, not curation
5469        assert_eq!(h("candor-scan"), &["Env", "Fs"]);
5470        assert_eq!(h("candor-run.sh"), &["Env", "Fs"]);
5471        // an unrecognised head adds nothing — the bare Exec cliff stands (never guess). `make`/`npm`
5472        // run the project's own code; `git`/`rsync` are multi-modal (local vs remote) — all keep the
5473        // cliff rather than fabricate an effect for the common case.
5474        assert_eq!(h("some-unknown-tool"), &[] as &[&str]);
5475        assert_eq!(h("make"), &[] as &[&str]);
5476        assert_eq!(h("npm"), &[] as &[&str]);
5477        assert_eq!(h("git"), &[] as &[&str]);
5478        assert_eq!(h("rsync"), &[] as &[&str]);
5479        // a builder MODIFIER (`.arg`/`.env`) names no program — its literal must NOT refine (a
5480        // whole-crate-Exec crate classifies every method; `.env("psql",..)` must not fabricate Db).
5481        assert!(is_cmd_builder_method("env") && is_cmd_builder_method("arg") && is_cmd_builder_method("current_dir"));
5482        assert!(!is_cmd_builder_method("new")); // Command::new NAMES the program
5483        assert!(!is_cmd_builder_method("cmd")); // duct::cmd NAMES the program
5484        // The gate that ADMITS a literal to classify_command_head is an ALLOWLIST of program-NAMING
5485        // methods, not the builder denylist. Inversion matters: a whole-crate-Exec crate (portable_pty)
5486        // classifies EVERY method as Exec, so a getter like `cmd.get_env("psql")` — absent from the
5487        // builder denylist — would have leaked "psql" to the head and FABRICATED Db. Only `new`/`cmd`
5488        // name a program, so only they may refine.
5489        assert!(is_cmd_naming_method("new") && is_cmd_naming_method("cmd"));
5490        assert!(!is_cmd_naming_method("get_env")); // a GETTER, not a namer — the leak this closes
5491        assert!(!is_cmd_naming_method("arg") && !is_cmd_naming_method("env") && !is_cmd_naming_method("current_dir"));
5492    }
5493
5494    /// SOUNDNESS R379 — THE MASKING GUARD'S ALLOWLIST, AND THE DENYLIST THAT WAS MEASURED AND REJECTED.
5495    ///
5496    /// The verbs here take the HOST as an argument, so a runtime value in that position is invisible to
5497    /// the gate and the surface must be marked incomplete. The DNS resolver verbs were missing, and
5498    /// their absence was a GATE BYPASS, not a missed disclosure: `allow Net good.example.com` exited 0
5499    /// over `r.lookup_ip(caller_host)` sitting beside a benign literal, measured against real
5500    /// hickory-resolver 0.26.2.
5501    /// SOUNDNESS R386 — the `sqlite3_*` C API takes SQL, and its absence let a benign SIBLING literal
5502    /// certify arbitrary caller-supplied SQL.
5503    ///
5504    /// R383 recorded this gap as "REAL BUT NOT LIVE" because a C-string literal never reaches `tables`.
5505    /// That is true of an ISOLATED function and is the WRONG SHAPE: the literal only has to come from
5506    /// the same FUNCTION, not the same call. Measured, calibrated first (`deny Db` exits 1):
5507    /// `conn.execute("INSERT INTO users (id) VALUES (1)", [])` beside `sqlite3_exec(db, caller_sql, …)`
5508    /// gave `tables:['users'] incomplete:NONE` and `allow Db users` exited 0.
5509    #[test]
5510    fn db_query_arg_covers_the_sqlite3_sql_bearing_family() {
5511        // Every spelling that TAKES SQL — the whole family, not the one that was measured (R346).
5512        for f in ["sqlite3_exec", "sqlite3_prepare", "sqlite3_prepare_v2", "sqlite3_prepare_v3",
5513                  "sqlite3_prepare16", "sqlite3_prepare16_v2", "sqlite3_prepare16_v3",
5514                  // R386's own boundary, found by a release panel: SQL is arg 1 here too.
5515                  "sqlite3_get_table"] {
5516            assert!(is_db_query_arg(f), "{f} carries SQL — a runtime query there is invisible (R386)");
5517        }
5518        // THE OVER-MASK CONTROLS, and they carry as much weight as the fix. These take no query, so
5519        // masking them would fail `allow Db` closed over nothing. `sqlite3_open*` is the sharpest: it
5520        // takes a FILENAME, so masking it would claim a Db surface for an Fs locator.
5521        for f in ["sqlite3_step", "sqlite3_close", "sqlite3_open", "sqlite3_open_v2", "sqlite3_open16",
5522                  "sqlite3_serialize", "sqlite3_deserialize", "sqlite3_finalize", "sqlite3_reset",
5523                  // the backup/blob handle verbs carry no query either — the other half of the family
5524                  "sqlite3_backup_init", "sqlite3_backup_step", "sqlite3_blob_open", "sqlite3_blob_read"] {
5525            assert!(!is_db_query_arg(f),
5526                    "{f} carries no SQL — masking it claims an incomplete surface over nothing, and for \
5527                     the open* family it would claim a Db surface for a FILENAME");
5528        }
5529        // The pre-existing high-level verbs must survive.
5530        for f in ["execute", "query", "prepare", "prepare_cached", "simple_query"] {
5531            assert!(is_db_query_arg(f), "{f} was already covered and must stay covered");
5532        }
5533    }
5534
5535    /// SOUNDNESS R383 — the METHOD forms whose path is an ARGUMENT. The guard's `!c.method` gate
5536    /// excluded every method form because the path-STAT methods carry the path as their RECEIVER;
5537    /// `OpenOptions::open(path)` is the counter-example, and `allow Fs <lit>` exited 0 over a
5538    /// caller-supplied path because of it.
5539    #[test]
5540    fn fs_path_arg_methods_are_the_receiver_pairs_not_the_leaf() {
5541        // The path-taking pairs, matched on the TAIL so std/tokio/cap_primitives/fs_err all qualify.
5542        for p in ["std::fs::OpenOptions::open", "tokio::fs::OpenOptions::open",
5543                  "cap_primitives::fs::OpenOptions::open", "fs_err::OpenOptions::open",
5544                  "std::fs::DirBuilder::create", "tokio::fs::DirBuilder::create"] {
5545            assert!(is_fs_path_arg_method(p), "{p} takes its path as an ARGUMENT — R383");
5546        }
5547        // THE CONTROLS, and they are the row: every other method on the SAME receivers is a builder
5548        // modifier or a combinator, and `File`'s methods are use-verbs whose path was fixed at open.
5549        // Masking these is the over-mask a denylist would have caused (R379 measured that cost).
5550        for p in ["std::fs::File::read_to_string", "std::fs::File::write", "std::fs::File::write_all",
5551                  "std::fs::File::read", "std::fs::File::seek", "std::path::Path::exists",
5552                  "std::fs::OpenOptions::read", "std::fs::OpenOptions::truncate",
5553                  "std::fs::OpenOptions::map_err", "tokio::fs::OpenOptions::mode"] {
5554            assert!(!is_fs_path_arg_method(p),
5555                    "{p} hides no path — it is a builder modifier, a combinator, or a use-verb whose \
5556                     path was fixed at open. Masking it is the over-mask this allowlist avoids.");
5557        }
5558    }
5559
5560    #[test]
5561    fn net_establishing_allowlist() {
5562        // Host-bearing verbs establish — a runtime value here is invisible, so the gate must fail closed.
5563        for m in ["connect", "connect_timeout", "get", "post", "put", "patch", "delete", "head",
5564                  "request", "send_to", "lookup_host", "to_socket_addrs"] {
5565            assert!(is_net_establishing(m), "`{m}` takes the host as an argument and must establish");
5566        }
5567        // R379: the DNS resolver verbs `classify` already maps to Net. The WHOLE FAMILY, not the one
5568        // spelling that was found — `_lookup` is a suffix test mirroring `classify`'s own.
5569        for m in ["lookup", "lookup_ip", "resolve", "reverse_lookup", "srv_lookup", "mx_lookup",
5570                  "txt_lookup", "ipv4_lookup", "ipv6_lookup", "ns_lookup", "soa_lookup"] {
5571            assert!(is_net_establishing(m),
5572                    "`{m}` resolves a caller-supplied host — R379. Without it, `allow Net <benign \
5573                     literal>` exits 0 over a DNS lookup of a runtime hostname.");
5574        }
5575        // USE-verbs on an already-established connection: the host was fixed at `connect`, so a missing
5576        // literal here hides nothing and must NOT flag — else `connect("h").write(..)` fails closed.
5577        for m in ["write", "read", "send", "flush", "recv", "peek", "write_all", "read_to_end",
5578                  "write_vectored", "shutdown", "status", "headers", "text", "json"] {
5579            assert!(!is_net_establishing(m), "`{m}` is a use-verb on an established connection");
5580        }
5581    }
5582
5583    /// ⟨0.40⟩ SOUNDNESS R817 — an ACCEPT is not a BIND. The two lists answer different questions and must
5584    /// not share a member: a binding verb's literal is withheld and marks nothing, an accepting verb marks
5585    /// the surface incomplete. `accept`/`incoming` used to be binding verbs, which is the defect.
5586    #[test]
5587    fn r817_accepting_is_not_binding() {
5588        for (path, leaf) in [
5589            ("std::net::TcpListener::accept", "accept"),
5590            ("std::net::TcpListener::incoming", "incoming"),
5591            ("std::net::TcpListener::into_incoming", "into_incoming"),
5592            ("tokio::net::TcpListener::accept", "accept"),
5593            ("tokio::net::TcpListener::poll_accept", "poll_accept"),
5594            ("libc::accept", "accept"),
5595            ("libc::accept4", "accept4"),
5596            ("quinn::Endpoint::accept", "accept"),
5597            ("tonic::transport::server::Router::serve", "serve"),
5598            ("tonic::transport::server::Router::serve_with_shutdown", "serve_with_shutdown"),
5599            ("tonic::transport::server::TcpIncoming::new", "new"),
5600        ] {
5601            assert!(is_net_accepting(path, leaf), "`{path}` accepts connections: its peers are unseen");
5602            assert!(!is_net_binding(leaf), "`{leaf}` must not be a binding verb — binding withholds and marks nothing");
5603        }
5604        // CONTROLS — binds mark nothing; a stream accepted on an ESTABLISHED connection (quinn) has a peer
5605        // fixed at the endpoint's accept; a datagram receive is not an accept; `serve`/`new` elsewhere are
5606        // not accepts.
5607        for (path, leaf) in [
5608            ("std::net::UdpSocket::bind", "bind"),
5609            ("std::net::TcpListener::bind", "bind"),
5610            ("libc::listen", "listen"),
5611            ("quinn::Connection::accept_bi", "accept_bi"),
5612            ("quinn::Connection::accept_uni", "accept_uni"),
5613            ("std::net::UdpSocket::recv_from", "recv_from"),
5614            ("tonic::transport::server::Server::serve_with_shutdown", "serve_with_shutdown"),
5615            ("reqwest::Client::new", "new"),
5616        ] {
5617            assert!(!is_net_accepting(path, leaf), "`{path}` does not accept a connection");
5618        }
5619        for m in ["bind", "listen", "bind_to_device"] {
5620            assert!(is_net_binding(m), "`{m}` names a LOCAL address");
5621        }
5622    }
5623
5624    /// R379 — WHY THIS STAYS AN ALLOWLIST, which is NOT this family's usual direction.
5625    ///
5626    /// `candor-denylist-over-allowlist` says narrow a sound over-approximation with a denylist, and
5627    /// R350 made exactly that inversion one list over. It is wrong HERE, for the reason
5628    /// `is_cmd_naming_method` states two doc-blocks above for Exec: a WHOLE-CRATE-Net crate classifies
5629    /// every method as Net, so a denylist of use-verbs masks essentially everything in one. Measured by
5630    /// building the inversion and A/B-ing all 1,545 registry crates: **544 rows gained `incomplete`,
5631    /// none lost it** — `cap-std` 66, `hickory-net` 44 — and the triggers were conversions, accessors
5632    /// and combinators that hide no host.
5633    ///
5634    /// These are the measured leaks, pinned so the inversion cannot be re-attempted without meeting
5635    /// them. `bind` is the sharpest: this file has `is_net_binding` precisely because a bind address
5636    /// is where the process LISTENS, never a destination it reaches.
5637    #[test]
5638    fn the_rejected_denylist_leaks_are_not_establishing() {
5639        for m in ["bind", "into", "from", "from_std", "as_socket", "setsockopt", "getsockopt",
5640                  "map_err", "map", "ok", "try_clone", "complete_io"] {
5641            assert!(!is_net_establishing(m),
5642                    "`{m}` hides no host and must not mark a surface incomplete. It was a MEASURED \
5643                     trigger of the rejected denylist inversion (544 rows gained `incomplete` over the \
5644                     registry, 0 lost) — a whole-crate-Net crate classifies every method as Net, which \
5645                     is why the allowlist is the precise side here. See R379.");
5646        }
5647    }
5648
5649    #[test]
5650    fn fs_path_arg_allowlist() {
5651        // The Fs masking guard's path-naming-fn allowlist — free fns / constructors take the path as a
5652        // string arg (a runtime path there is invisible to the gate). Stat methods (path on the receiver)
5653        // and handle ops carry no path arg and must NOT flag — but they're caught by the caller's
5654        // `!is_method` gate; the allowlist itself just enumerates the path-NAMING leaves.
5655        assert!(is_fs_path_arg("write") && is_fs_path_arg("read") && is_fs_path_arg("read_to_string"));
5656        assert!(is_fs_path_arg("open") && is_fs_path_arg("create") && is_fs_path_arg("create_new"));
5657        assert!(is_fs_path_arg("remove_file") && is_fs_path_arg("rename") && is_fs_path_arg("copy"));
5658        assert!(is_fs_path_arg("create_dir_all") && is_fs_path_arg("canonicalize") && is_fs_path_arg("metadata"));
5659        // handle ops / pure builders take NO path arg — never path-naming.
5660        assert!(!is_fs_path_arg("write_all") && !is_fs_path_arg("flush") && !is_fs_path_arg("read_exact"));
5661        assert!(!is_fs_path_arg("new") && !is_fs_path_arg("sync_all") && !is_fs_path_arg("set_len"));
5662    }
5663
5664    #[test]
5665    fn db_query_arg_allowlist() {
5666        // The Db masking guard's query-bearing-verb allowlist — these take the raw SQL as a string arg
5667        // (a runtime query there is invisible to the gate). Build-then-execute terminals and non-query
5668        // ops carry no SQL string and must NOT flag.
5669        assert!(is_db_query_arg("execute") && is_db_query_arg("query") && is_db_query_arg("query_one"));
5670        assert!(is_db_query_arg("prepare") && is_db_query_arg("batch_execute") && is_db_query_arg("execute_batch"));
5671        assert!(is_db_query_arg("query_row") && is_db_query_arg("query_map") && is_db_query_arg("exec"));
5672        // build-then-execute terminals (query built structurally, no SQL string) must NOT flag.
5673        assert!(!is_db_query_arg("fetch_all") && !is_db_query_arg("load") && !is_db_query_arg("first"));
5674        assert!(!is_db_query_arg("all") && !is_db_query_arg("one") && !is_db_query_arg("stream"));
5675        // connection / lifecycle ops take no SQL — must NOT flag.
5676        assert!(!is_db_query_arg("connect") && !is_db_query_arg("open") && !is_db_query_arg("begin"));
5677        assert!(!is_db_query_arg("commit") && !is_db_query_arg("ping") && !is_db_query_arg("get_conn"));
5678    }
5679}
5680
5681#[cfg(test)]
5682mod fs_kind_tests {
5683    use super::fs_kind;
5684
5685    /// SPEC §2 `fs`. Most of what these assert is what the classifier REFUSES to say: §2 requires the
5686    /// field be "omitted rather than guessed", because an empty or partial `fs` reads as a positive claim
5687    /// ("reads but never writes") — the §4 trust contract's forbidden direction.
5688    #[test]
5689    fn write_verbs() {
5690        for p in ["std::fs::write", "std::fs::create_dir_all", "std::fs::remove_file",
5691                  "File::create", "std::fs::set_permissions", "f::write_all"] {
5692            assert_eq!(fs_kind(p), &["write"], "{p} mutates the disk");
5693        }
5694    }
5695
5696    #[test]
5697    fn read_verbs() {
5698        for p in ["std::fs::read_to_string", "std::fs::read_dir", "std::fs::metadata",
5699                  "File::open", "std::fs::canonicalize", "f::read_to_end"] {
5700            assert_eq!(fs_kind(p), &["read"], "{p} observes without mutating");
5701        }
5702    }
5703
5704    /// A copy/rename reads the source AND writes the destination — one call, both kinds.
5705    #[test]
5706    fn two_locator_verbs_are_both() {
5707        for p in ["std::fs::copy", "std::fs::rename", "std::fs::hard_link"] {
5708            assert_eq!(fs_kind(p), &["read", "write"], "{p}");
5709        }
5710    }
5711
5712    /// THE LOAD-BEARING CASE. A verb that does not reveal direction must contribute NOTHING — not a
5713    /// default, not a guess. Anything here returning a kind would let a function claim "reads but never
5714    /// writes" on the strength of a verb that said neither.
5715    #[test]
5716    fn unrevealing_verbs_make_no_claim() {
5717        for p in ["std::fs::OpenOptions", "some_crate::do_thing", "std::fs::File", "f::seek"] {
5718            assert!(fs_kind(p).is_empty(), "{p} must not claim a direction it did not reveal");
5719        }
5720    }
5721
5722    /// `OpenOptions::open` is `File::open`'s leaf and NOT its verb: the direction lives in the builder
5723    /// chain (`.read(true)`/`.write(true)`), which `fs_kind` cannot see. A `write(true)` builder claiming
5724    /// `["read"]` is the forbidden direction, so the type wins over the leaf here. `File::open` — where
5725    /// `open` DOES mean read — is unaffected, which is the whole reason this is keyed on the type.
5726    #[test]
5727    fn openoptions_open_claims_no_direction_but_file_open_still_reads() {
5728        for p in ["std::fs::OpenOptions::open", "fs_err::OpenOptions::open",
5729                  "tokio::fs::OpenOptions::open"] {
5730            assert!(fs_kind(p).is_empty(),
5731                    "{p}'s direction was set by the builder chain, which this function cannot see");
5732        }
5733        assert_eq!(fs_kind("std::fs::File::open"), &["read"], "`File::open` is unambiguously a read");
5734    }
5735}
5736
5737#[cfg(test)]
5738mod masks_locator_tests {
5739    use super::*;
5740
5741    /// SOUNDNESS R806 — each no-locator DENYLIST must be a SUBSET of the table it subtracts from. A
5742    /// typo'd or stale entry that is not in the table would subtract nothing and read as a decision;
5743    /// a table entry renamed without its denylist twin would silently start masking (the safe
5744    /// direction) — but only this check says which happened.
5745    #[test]
5746    fn every_no_locator_denylist_is_a_subset_of_its_charging_table() {
5747        for n in LIBC_FS_NO_PATH {
5748            assert!(LIBC_FS.contains(n), "LIBC_FS_NO_PATH names `{n}`, which LIBC_FS does not charge");
5749        }
5750        for n in LIBC_EXEC_NO_PROGRAM {
5751            assert!(LIBC_EXEC.contains(n), "LIBC_EXEC_NO_PROGRAM names `{n}`, absent from LIBC_EXEC");
5752        }
5753        for n in LIBC_NET_NO_DESTINATION {
5754            assert!(LIBC_NET.contains(n), "LIBC_NET_NO_DESTINATION names `{n}`, absent from LIBC_NET");
5755        }
5756        for n in PG_DB_VERBS_NO_SQL {
5757            assert!(PG_DB_VERBS.contains(n), "PG_DB_VERBS_NO_SQL names `{n}`, absent from PG_DB_VERBS");
5758        }
5759    }
5760
5761    /// SOUNDNESS R806 — THE DERIVATION, pinned from the table side: every leaf the table charges that is
5762    /// not on the denylist MASKS. So a leaf added to `LIBC_FS` tomorrow is masked with no second edit,
5763    /// which is the property the hand list lacked.
5764    #[test]
5765    fn every_charged_libc_leaf_off_the_denylist_masks() {
5766        for (eff, table, deny) in [
5767            ("Fs", LIBC_FS, LIBC_FS_NO_PATH),
5768            ("Exec", LIBC_EXEC, LIBC_EXEC_NO_PROGRAM),
5769            ("Net", LIBC_NET, LIBC_NET_NO_DESTINATION),
5770        ] {
5771            for leaf in table.iter().filter(|l| !deny.contains(l)) {
5772                for cr in ["libc", "nix"] {
5773                    let path = format!("{cr}::{leaf}");
5774                    assert_eq!(classify(cr, &path), Some(eff), "{path} must still be charged {eff}");
5775                    assert!(masks_locator(eff, cr, &path, leaf, false), "{path} names a locator — must mask");
5776                }
5777            }
5778            for leaf in deny.iter() {
5779                let path = format!("libc::{leaf}");
5780                assert!(!masks_locator(eff, "libc", &path, leaf, false) || is_net_establishing(leaf),
5781                        "{path} is on the no-locator denylist — must not mask via the table");
5782            }
5783        }
5784        // The named members, from the row: the sweep's EXECUTED arms.
5785        for (eff, leaf) in [("Fs", "unlink"), ("Fs", "unlinkat"), ("Fs", "utimensat"), ("Exec", "system"),
5786                            ("Exec", "popen"), ("Exec", "execvp"), ("Exec", "posix_spawn"), ("Net", "getaddrinfo"),
5787                            ("Net", "sendto")] {
5788            assert!(masks_locator(eff, "libc", &format!("libc::{leaf}"), leaf, false), "libc::{leaf}");
5789        }
5790        // Scoped to the syscall crates: the same leaf on an unrelated crate is not this table's to judge.
5791        assert!(!masks_locator("Fs", "mycrate", "mycrate::unlink", "unlink", false));
5792        // rustix spells `sendmsg` WITHOUT an address; libc and nix carry one.
5793        assert!(!masks_locator("Net", "rustix", "rustix::net::sendmsg", "sendmsg", false));
5794        assert!(masks_locator("Net", "libc", "libc::sendmsg", "sendmsg", false));
5795    }
5796
5797    #[test]
5798    fn pg_verbs_take_sql_except_the_named_three() {
5799        for v in PG_DB_VERBS.iter().filter(|v| !PG_DB_VERBS_NO_SQL.contains(v)) {
5800            let path = format!("deadpool_postgres::Client{v}");
5801            let leaf = &v[2..];
5802            assert!(masks_locator("Db", "deadpool_postgres", &path, leaf, true), "{path} takes SQL — must mask");
5803        }
5804        assert!(masks_locator("Db", "tokio_postgres", "tokio_postgres::Client::prepare_typed_cached",
5805                              "prepare_typed_cached", true));
5806        assert!(!masks_locator("Db", "tokio_postgres", "tokio_postgres::Client::transaction", "transaction", true));
5807        assert!(masks_locator("Db", "sqlx_core", "sqlx_core::executor::Executor::prepare_with", "prepare_with", true));
5808        assert!(!masks_locator("Db", "sqlx_core", "sqlx_core::query::Query::fetch_all", "fetch_all", true),
5809                "a Query terminal takes an EXECUTOR at arg 0 — masking it would swallow every literal query");
5810    }
5811}