Summary
While validating #2032's transitive-reachability dead-code fix by running codegraph roles --role dead -T on this repo's own src/, I found that the bulk of the newly-flagged-dead nodes (50 of 53 in the final delta) come from directories that are clearly test infrastructure but aren't excluded by -T:
tests/benchmarks/resolution/fixtures/** — the hand-authored, per-language (34 languages) resolution-precision fixture projects documented in CLAUDE.md's Test Structure section (expected-edges.json manifests).
tests/benchmarks/resolution/tracer/** — the dynamic call tracers (loader-hook.mjs, python-tracer.py, lua-tracer.lua, r-tracer.R, php-tracer.php, etc.).
tests/fixtures/sample-project/** — the ES-module sample fixture (math.js/utils.js/index.js).
None of these filenames match TEST_FILE_PATTERNS (%.test.%, %.spec.%, %__test__%, %__tests__%, %.stories.% in src/graph/classifiers/roles.ts / the mirrored Rust TEST_FILE_PATTERNS) — they're plain source files (main.c, service.ml, validators.gleam, reflection.kt, ...) that happen to live under a tests/ directory, which the current filename-suffix-only heuristic doesn't check for.
Why this matters
These fixtures are deliberately tiny, self-contained per-language snippets with no genuine external entry point recognized by codegraph's own root-detection (no CLI/MCP/exported-and-called-cross-file signal) — they exist purely to exercise parser extraction precision/recall. Before #2032, direct fan-in alone kept most of their internal call chains classified non-dead; #2032's stricter reachability check (correctly) now flags almost everything in these disconnected components as dead, since nothing in them is a confirmed-live root by any of codegraph's own criteria.
This isn't a bug in #2032's logic — it's a pre-existing gap in -T's test-file detection becoming more visible now that dead-code classification is stricter. It affects any analysis that relies on -T to scope to "real" application code (roles --role dead -T, triage -T, audit -T, etc.), not just the new reachability pass.
Suggested fix
Extend the test-file exclusion heuristic (TEST_FILE_PATTERNS / testFilterSQL in src/db/index.ts and the mirrored Rust TEST_FILE_PATTERNS/test_file_filter_col in crates/codegraph-core/src/graph/classifiers/roles.rs) to also recognize path-based test/fixture markers, e.g. any path segment matching tests/, fixtures/, __fixtures__/, or similar — needs care to avoid over-broadly excluding legitimately-shipped code that happens to live under a test-utils-style production directory.
Related
Summary
While validating #2032's transitive-reachability dead-code fix by running
codegraph roles --role dead -Ton this repo's ownsrc/, I found that the bulk of the newly-flagged-dead nodes (50 of 53 in the final delta) come from directories that are clearly test infrastructure but aren't excluded by-T:tests/benchmarks/resolution/fixtures/**— the hand-authored, per-language (34 languages) resolution-precision fixture projects documented inCLAUDE.md's Test Structure section (expected-edges.jsonmanifests).tests/benchmarks/resolution/tracer/**— the dynamic call tracers (loader-hook.mjs,python-tracer.py,lua-tracer.lua,r-tracer.R,php-tracer.php, etc.).tests/fixtures/sample-project/**— the ES-module sample fixture (math.js/utils.js/index.js).None of these filenames match
TEST_FILE_PATTERNS(%.test.%,%.spec.%,%__test__%,%__tests__%,%.stories.%insrc/graph/classifiers/roles.ts/ the mirrored RustTEST_FILE_PATTERNS) — they're plain source files (main.c,service.ml,validators.gleam,reflection.kt, ...) that happen to live under atests/directory, which the current filename-suffix-only heuristic doesn't check for.Why this matters
These fixtures are deliberately tiny, self-contained per-language snippets with no genuine external entry point recognized by codegraph's own root-detection (no CLI/MCP/exported-and-called-cross-file signal) — they exist purely to exercise parser extraction precision/recall. Before #2032, direct fan-in alone kept most of their internal call chains classified non-dead; #2032's stricter reachability check (correctly) now flags almost everything in these disconnected components as dead, since nothing in them is a confirmed-live root by any of codegraph's own criteria.
This isn't a bug in #2032's logic — it's a pre-existing gap in
-T's test-file detection becoming more visible now that dead-code classification is stricter. It affects any analysis that relies on-Tto scope to "real" application code (roles --role dead -T,triage -T,audit -T, etc.), not just the new reachability pass.Suggested fix
Extend the test-file exclusion heuristic (
TEST_FILE_PATTERNS/testFilterSQLinsrc/db/index.tsand the mirrored RustTEST_FILE_PATTERNS/test_file_filter_colincrates/codegraph-core/src/graph/classifiers/roles.rs) to also recognize path-based test/fixture markers, e.g. any path segment matchingtests/,fixtures/,__fixtures__/, or similar — needs care to avoid over-broadly excluding legitimately-shipped code that happens to live under atest-utils-style production directory.Related