pub fn compute_dead_code<S: BuildHasher>(
graph: &RepoGraph,
entry_def_indices: &HashSet<DefIndex, S>,
include_test_paths: bool,
) -> DeadCodeReportExpand description
Compute the set of definitions unreachable from any entry point.
Returns dead clusters (connected components in the unreachable subgraph), sorted by size descending.
§Algorithm
- Optionally filter test paths from
entry_def_indices(wheninclude_test_pathsisfalse). Test-path heuristic: the file path containstest_,_test,tests/,spec/,specs/, orbench. - Build full forward + reverse adjacency from
RepoGraph::def_edges(the untruncated edge list) as a Compressed Sparse Row (CSR) pair of (starts,dst)Vec<u32>arrays — bounded O(E) memory rather than the O(n_defs * avg_fanout) of duplicatedVec<Vec<DefIndex>>that crashed at kernel scale (I#61). The BFS does NOT useRepoGraph::def_callees/RepoGraph::def_callers: those are display-oriented neighbor lists capped at [MAX_NEIGHBORS] per node, which dropped hub callees from the live set and produced false-positive dead reports (I#57). - BFS forward over the full forward adjacency from the entry seeds -> reachable set.
- Complement
(all_defs - reachable)= dead set. - Connected-components on the dead subgraph via the full forward + reverse adjacency treated as undirected (union-find).
- For each cluster: pick the highest-rank def as the cluster root;
size= member count;total_lines= sum of(end_line - start_line)per member. - Sort clusters by size descending.