From 370c702784f3fee7575e8817ffc43fbacfd47197 Mon Sep 17 00:00:00 2001 From: Brian Searls Date: Wed, 19 Aug 2026 05:23:15 +0000 Subject: [PATCH] Delete 18 unreachable pub fns from cli_run.rs Zero call sites in Rust, zero references in the .dag corpus, and not registered as host builtins. Verified with a discriminating control: known-live host builtins score dispatch=2-3 / dag=3-81 against the interpreter dispatch table and the corpus; all 18 score 0 / 0. SCOPE CORRECTION, recorded because the first attempt was wrong. The initial census found 36 candidates. Half of them -- 18 -- carry `#[cfg(feature = "test_hooks")]` or `#[cfg(any(test, feature = "interp_test_witness"))]` and are conditionally compiled test hooks, NOT dead code. A call-site scan cannot see that, because the callers live behind the same feature gate. Those 18 are kept, and `cargo check --features test_hooks` is now part of this change's evidence rather than an assumption. The first deletion script was also mechanically wrong in a way worth naming: it walked back over `//` comments but stopped at attribute lines, so removing a function left its `#[cfg(...)]` attribute orphaned, which then bound to the NEXT function and made it conditional. That produced three "cannot find function in this scope" errors against symbols that were still present in the file. The span finder now walks comments and attributes together, counts braces rather than guessing at the first column-0 `}`, and refuses outright if any span contains another top-level item. WHY THESE COULD ACCUMULATE UNSEEN: `cargo check -p v1-compiler --all-targets` does not compile on main -- `compiler_tests.rs:1615` imports `crate::v1_tests_claim_caret_parse_smoke_test`, a module deleted by the #8146 suite cutover. The crate's test targets have not built since, so nothing reported these as unused, and `-D warnings` on `--bin` cannot see a `pub fn` in a lib. That defect is NOT fixed here; it is reported as its own finding. Co-Authored-By: Claude Opus 5 (1M context) --- src/v1/stage0/src/cli_run.rs | 320 ----------------------------------- 1 file changed, 320 deletions(-) diff --git a/src/v1/stage0/src/cli_run.rs b/src/v1/stage0/src/cli_run.rs index c3cdf9a5997..8deaa162aa5 100644 --- a/src/v1/stage0/src/cli_run.rs +++ b/src/v1/stage0/src/cli_run.rs @@ -2113,18 +2113,6 @@ pub(crate) fn string_list_data_from_module_source( panic!("lens table reader: no `data {data_name}` def in {module_rel_path}") } -/// Read a `List` data table from a live `.dag` lens authority on disk. -pub fn lens_string_list_data( - module_rel_path: &str, - data_name: &str, - allow_empty: bool, -) -> Vec { - let path = workspace_root().join(module_rel_path); - let content = std::fs::read_to_string(&path) - .unwrap_or_else(|e| panic!("lens table reader: failed to read {}: {e}", path.display())); - string_list_data_from_module_source(module_rel_path, &content, data_name, allow_empty) -} - /// Project a `List` data literal out of the ci_layer_roots authority's SOURCE TEXT via the /// real front-end (`tokenize` + `parse`) — no second hand-rolled scanner. pub(crate) fn string_list_data_from_ci_layer_roots_source( @@ -2995,14 +2983,6 @@ pub fn compile_clean_pipeline_has_hard_errors(diagnostics: &im::Vector>>) -> bool { - if compile_clean_policy_read_refuses_gate() { - return true; - } - diagnostics.iter().any(compile_clean_diagnostic_is_hard) -} - /// `ResolvedPipelineResult` / `im::Vector` adapter for compile-clean checks. pub fn compile_clean_im_vector_has_hard_errors(diagnostics: &im::Vector>) -> bool { if compile_clean_policy_read_refuses_gate() { @@ -3011,34 +2991,6 @@ pub fn compile_clean_im_vector_has_hard_errors(diagnostics: &im::Vector>) -> usize { - diagnostics - .iter() - .filter(|d| compile_clean_diagnostic_is_hard(d)) - .count() -} - -pub fn compile_clean_im_vector_advisory_count(diagnostics: &im::Vector>) -> usize { - diagnostics - .iter() - .filter(|d| compile_clean_diagnostic_is_advisory(d)) - .count() -} - -pub fn compile_clean_vec_hard_error_count(diagnostics: &Rc>>) -> usize { - diagnostics - .iter() - .filter(|d| compile_clean_diagnostic_is_hard(d)) - .count() -} - -pub fn compile_clean_vec_advisory_count(diagnostics: &Rc>>) -> usize { - diagnostics - .iter() - .filter(|d| compile_clean_diagnostic_is_advisory(d)) - .count() -} - fn format_compile_clean_hard_diagnostic_line(d: &Rc) -> String { let span = diagnostic_to_span(d.diagnostic.clone()); let msg = diagnostic_to_message(d.diagnostic.clone()); @@ -4860,19 +4812,6 @@ pub fn import_closure_from_adjacency( result } -/// Host realization of `v2.lens.module_graph.import_closure` over modeled fact rows. -/// Authority: `src/v2/lens/module_graph.dag` — this is the consumer repoint surface for -/// `cli_run.rs` resolve/reconcile (Phase 1 de-fork); fact extraction stays on the existing -/// `import_resolution_facts` / `module_declaration_facts` builtins. -pub fn import_closure_from_facts( - entry_path: &str, - edges: &[ImportResolutionFactRaw], - nodes: &[ModuleDeclarationFactRaw], -) -> Vec { - let adjacency = build_import_adjacency(edges, nodes); - import_closure_from_adjacency(entry_path, &adjacency) -} - /// Pre-built `import_resolution_facts` / `module_declaration_facts` rows for one pool-root /// set. Built once per `MultiEntryIndex` / resolve pass so closure queries do not re-scan the /// corpus on every `resolve_transitively` call (Phase 1 perf receipt, DESIGN §2). @@ -7548,12 +7487,6 @@ fn record_provider_bootstrap_store_skip() { PROVIDER_BOOTSTRAP_STORE_SKIPS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); } -/// Observed count of bootstrap-window store skips — the countable half of the -/// disclosed refusal (§5). -pub fn provider_bootstrap_store_skip_count() -> usize { - PROVIDER_BOOTSTRAP_STORE_SKIPS.load(std::sync::atomic::Ordering::SeqCst) -} - pub(crate) fn with_cross_process_provider_routing_suppressed(f: F) -> R where F: FnOnce() -> R, @@ -9121,19 +9054,6 @@ pub fn is_census_heads_fn_stand_in(node: &Rc) -> bool { || STRIPPED_FN_BODY_MARKER.with(|marker| Rc::ptr_eq(node, marker)) } -/// Optional query helper for non-inference traversals. Loud refusal on inference is -/// enforced by `ExprErrorKind::CensusHeadsBodyStripped` in `infer_expr`, not this API. -pub fn census_heads_body_traversal_refusal(node: &Rc) -> Option { - if is_census_heads_fn_stand_in(node) { - Some(format!( - "census heads-only pool parse refused: body traversal hit stand-in '{}'", - CENSUS_HEADS_FN_STAND_IN_NAME - )) - } else { - None - } -} - #[cfg(any(test, feature = "interp_test_witness"))] pub fn census_heads_fn_stand_in_for_test() -> Rc { stripped_fn_body_marker() @@ -10895,20 +10815,6 @@ fn typed_module_cache_cap_derivation() -> (usize, String, bool) { (cap, source_label, degraded) } -/// Host-budget-derived cap on `typed_module_cache` entries for the private -/// per-index store (width=1 drain path). `GUNBC_TYPED_MODULE_CACHE_MAX_ENTRIES` -/// is an operator/test probe: still clamped to `1..CEIL` (never unbounded); a -/// malformed override falls through to the derived cap (fail-closed). -/// -/// This is the pure, un-cached derivation — kept for direct env-override -/// tests. Runtime call sites must go through `typed_module_cache_cap` -/// instead, which samples this exactly once per index lifetime; re-deriving -/// from a live host-shared signal on every insert was the 2026-07-21 fleet -/// OOM incident (see the doc comment on `MultiEntryIndex::typed_module_cache_cap`). -pub fn typed_module_cache_max_entries() -> usize { - typed_module_cache_cap_derivation().0 -} - /// The typed-cache cap for `index`, sampled exactly ONCE for this index's /// lifetime (a run-start fact, never re-read per insert). On first call, if /// the budget source is degraded (no private cgroup limit found), emits a @@ -18170,78 +18076,6 @@ pub(crate) fn resolve_entry_file_under_roots( )) } -pub fn wet_hermetic_scaffold_roster_entry_prefix( - source_roots: &[String], -) -> Result { - let entry = - resolve_entry_file_under_roots(source_roots, WET_HERMETIC_EQUIVALENCE_WITNESS_ENTRY)?; - let (graph, source_indices) = resolve_entry_graph_shared(source_roots, &entry)?; - let sources = load_sources_for_entry(source_roots, &entry)?; - let entry_source = sources - .iter() - .find(|s| s.path == entry || s.path.ends_with(WET_HERMETIC_EQUIVALENCE_WITNESS_ENTRY)) - .ok_or_else(|| format!("{entry}: missing from entry closure"))?; - let entry_module = extract_module_path(&entry_source.content) - .ok_or_else(|| format!("{entry}: missing module declaration"))?; - let typed_module = entry_typed_module(&graph, &source_indices, &entry_module)?; - let si = Rc::new((*source_indices).clone()); - for item in typed_module.items.iter() { - if item.body.is_none() { - continue; - } - let decl_name = authored_name_at(si.clone(), item.clone()); - if decl_name != WET_HERMETIC_SCAFFOLD_ROSTER_PREFIX_DATA { - continue; - } - let body = item.body.as_ref().ok_or_else(|| { - format!("{entry}: data '{WET_HERMETIC_SCAFFOLD_ROSTER_PREFIX_DATA}' missing body") - })?; - return literal_string_from_expr(body).ok_or_else(|| { - format!( - "{entry}: data '{WET_HERMETIC_SCAFFOLD_ROSTER_PREFIX_DATA}' must be a string literal" - ) - }); - } - Err(format!( - "{entry}: missing data '{WET_HERMETIC_SCAFFOLD_ROSTER_PREFIX_DATA}'" - )) -} - -pub fn is_governed_service_representative_row(row: &DiscoveryRow, prefix: &str) -> bool { - !prefix.is_empty() && row.entry.contains(prefix) -} - -pub fn wet_hermetic_discovery_outcome_divergences( - wet: &[DiscoveryWitnessOutcome], - hermetic: &[DiscoveryWitnessOutcome], -) -> Vec { - let mut divergences = Vec::new(); - if wet.len() != hermetic.len() { - divergences.push(format!( - "roster size mismatch: wet={} hermetic={}", - wet.len(), - hermetic.len() - )); - return divergences; - } - for (w, h) in wet.iter().zip(hermetic.iter()) { - if w.entry != h.entry || w.function != h.function { - divergences.push(format!( - "roster order mismatch: wet=({},{}) hermetic=({},{})", - w.function, w.entry, h.function, h.entry - )); - continue; - } - if w.outcome != h.outcome { - divergences.push(format!( - "{} ({}): wet={:?} hermetic={:?}", - w.function, w.entry, w.outcome, h.outcome - )); - } - } - divergences -} - fn proc_status_kb_field(prefix: &str) -> Option { let status = std::fs::read_to_string("/proc/self/status").ok()?; let line = status.lines().find(|l| l.starts_with(prefix))?; @@ -18331,20 +18165,6 @@ pub fn peak_rss_vhwm_bytes() -> Option { } } -/// `memory.events` `high` counter from the process leaf cgroup, when readable. -pub fn cgroup_memory_events_high() -> Option { - let dir = crate::memory_governor::leaf_cgroup_dir()?; - let raw = crate::memory_governor::read_cgroup_raw(&dir, "memory.events")?; - raw.lines().find_map(|line| { - let mut parts = line.split_whitespace(); - let key = parts.next()?; - if key != "high" { - return None; - } - parts.next()?.parse().ok() - }) -} - pub fn floor_discovery_path_excluded(path: &str) -> bool { matching_discovery_exclusion_substring(path).is_some() } @@ -29808,134 +29628,6 @@ pub struct BareRefReachability { pub cross_subtree_unique_sites: usize, } -/// Count bare-reference reachability for `name` using the same nearest-wins producer as -/// `reference_resolution_facts` (import-less files only). -pub fn bare_ref_reachability_for_name( - pool_roots: &[String], - importer_roots: &[String], - exclude_substrings: &[String], - name: &str, -) -> BareRefReachability { - let abs_pool_roots = pool_roots_abs(pool_roots); - let abs_importer_roots = pool_roots_abs(importer_roots); - let mut decl_index: HashMap> = HashMap::new(); - let mut module_names: std::collections::HashSet = std::collections::HashSet::new(); - let mut seen_modules: std::collections::HashSet = std::collections::HashSet::new(); - let mut pool_trees: HashMap, bool)> = - HashMap::new(); - for root in &abs_pool_roots { - let root_path = Path::new(root); - if !root_path.is_dir() { - continue; - } - let mut files: Vec = Vec::new(); - collect_dag_files_tolerant(root_path, &mut files); - files.sort(); - for file in files { - let rel = rel_path_for_layer_import(&file); - let content = match std::fs::read_to_string(&file) { - Ok(c) => c, - Err(_) => continue, - }; - let module_name = match extract_module_path(&content) { - Some(m) => m, - None => continue, - }; - let tree = match parse_module_node_tolerant(&rel, &content) { - Some(t) => t, - None => continue, - }; - let has_imports = !extract_import_paths(&content).is_empty(); - if seen_modules.insert(module_name.clone()) { - module_names.insert(module_name.clone()); - for decl_name in collect_module_decl_names(&tree) { - decl_index - .entry(decl_name) - .or_default() - .insert(module_name.clone()); - } - } - pool_trees - .entry(rel) - .or_insert((module_name, tree, has_imports)); - } - } - - let mut stats = BareRefReachability::default(); - for root in &abs_importer_roots { - let root_path = Path::new(root); - if !root_path.is_dir() { - continue; - } - let mut files: Vec = Vec::new(); - collect_dag_files_tolerant(root_path, &mut files); - files.sort(); - for file in files { - let rel = rel_path_for_layer_import(&file); - if is_excluded_import_path(&rel, exclude_substrings) { - continue; - } - let (self_module, tree) = match pool_trees.get(&rel) { - Some((_, _, true)) => continue, - Some((m, t, false)) => (m.clone(), t.clone()), - None => { - let content = match std::fs::read_to_string(&file) { - Ok(c) => c, - Err(_) => continue, - }; - if !extract_import_paths(&content).is_empty() { - continue; - } - let module_name = match extract_module_path(&content) { - Some(m) => m, - None => continue, - }; - match parse_module_node_tolerant(&rel, &content) { - Some(t) => (module_name, t), - None => continue, - } - } - }; - let mut bare: std::collections::HashSet = std::collections::HashSet::new(); - let mut chains: Vec> = Vec::new(); - for item in tree.children.iter() { - collect_node_refs(item, &mut bare, &mut chains); - } - if !bare.contains(name) { - continue; - } - let Some(mods) = decl_index.get(name) else { - continue; - }; - if mods.contains(&self_module) { - continue; - } - let mut best_len = 0usize; - let mut winners: Vec<&String> = Vec::new(); - for m in mods.iter() { - let shared = module_prefix_shared_len(&self_module, m); - if winners.is_empty() || shared > best_len { - best_len = shared; - winners.clear(); - winners.push(m); - } else if shared == best_len { - winners.push(m); - } - } - match winners.len() { - 0 => {} - 1 => { - if module_prefix_shared_len(&self_module, winners[0]) == 0 { - stats.cross_subtree_unique_sites += 1; - } - } - _ => stats.ambiguous_sites += 1, - } - } - } - stats -} - #[cfg(test)] mod reference_edge_producer_tests { use super::reference_resolution_facts; @@ -30686,10 +30378,6 @@ pub fn commit_witness_claim_roster_unresolvable_count() -> i64 { defects.len() as i64 } -pub fn commit_witness_claim_roster_holds() -> bool { - commit_witness_claim_roster_unresolvable_count() == 0 -} - pub fn non_fold_residue_wildcard_red_fixture_holds() -> bool { let fixture = vec![( "m.dag".to_string(), @@ -31245,14 +30933,6 @@ pub fn non_fold_residue_coproduct_universe_count() -> i64 { nfr_build_report().coproduct_universe as i64 } -pub fn non_fold_residue_live_sites() -> &'static [String] { - &nfr_build_report().sites -} - -pub fn non_fold_residue_roster_size() -> i64 { - non_fold_residue_roster_entries().len() as i64 -} - #[cfg(test)] mod nfr_tests { use super::*;