feat: find_dead_symbols — confidence-tiered dead/test-only-code detector with reason codes #24

Open
opened 2026-07-20 22:38:01 +02:00 by buildagent · 1 comment
Member

Rank 3 of the 2026-07-20 index-data brainstorm (_prdoc/records/brainstorm-2026-07-20-index-data-catalog.md). Four of six lenses independently converged here.

What: dead-code detector whose PRODUCT is the reason trail, not the raw list: each candidate labeled with why it survived suppression (dyn-dispatch trait impl, std-trait name, #[tool]/framework handler, method-call ambiguity, alias-qualified miss) or why it's believed dead. Includes the compiler-invisible "test-only prod code" class (prod symbols kept alive solely by test refs, via roles bit 32).

Why: naive ref_count=0 is worthless — 1,413 hits, 1.6% precision. The validated suppression cascade lands on exactly 4 genuinely dead symbols in this repo (all four deleted in v0.5.19 after grep verification: Writer::upsert_file/apply_stat_touch/delete_path, span_of). Test-only class: 90 raw → 41 true findings incl. open_in_memory (pub API, all uses inside #[cfg(test)]).

Caveat baked in: roles_is_zero is referenced only inside a #[serde(skip_serializing_if)] attribute STRING — ref-based analysis alone MUST NOT claim "safe to delete"; the FTS pass (see safe_delete issue) is the verification step.

Cost: small — SQL cascade over existing columns + one FTS pass; no new data.

Rank 3 of the 2026-07-20 index-data brainstorm (`_prdoc/records/brainstorm-2026-07-20-index-data-catalog.md`). Four of six lenses independently converged here. **What**: dead-code detector whose PRODUCT is the reason trail, not the raw list: each candidate labeled with why it survived suppression (dyn-dispatch trait impl, std-trait name, `#[tool]`/framework handler, method-call ambiguity, alias-qualified miss) or why it's believed dead. Includes the compiler-invisible "test-only prod code" class (prod symbols kept alive solely by test refs, via roles bit 32). **Why**: naive `ref_count=0` is worthless — 1,413 hits, 1.6% precision. The validated suppression cascade lands on exactly **4 genuinely dead symbols** in this repo (all four deleted in v0.5.19 after grep verification: `Writer::upsert_file`/`apply_stat_touch`/`delete_path`, `span_of`). Test-only class: 90 raw → 41 true findings incl. `open_in_memory` (pub API, all uses inside `#[cfg(test)]`). **Caveat baked in**: `roles_is_zero` is referenced only inside a `#[serde(skip_serializing_if)]` attribute STRING — ref-based analysis alone MUST NOT claim "safe to delete"; the FTS pass (see safe_delete issue) is the verification step. **Cost**: small — SQL cascade over existing columns + one FTS pass; no new data.
Author
Member

Triage: P2 — candidate discovery, not deletion authority

Keep this issue, but narrow its contract to dead_symbol_candidates. It should rank suspicious dead/test-only symbols with reason codes and suppression evidence, then direct the agent to safe_delete for per-symbol verification.

Do not emit a repository-wide “safe to delete” list: reflection, framework registration, serialization/configuration strings, generated code, and unresolved dispatch make that claim indefensible. Reuse the production-ready text-evidence semantics from #25; text hits are evidence, not proven runtime uses.

Recommended acceptance addition: every candidate carries visibility, production/test inbound counts, unresolved-name risk, text occurrence files, resolution confidence, and the exact next preflight call.

### Triage: P2 — candidate discovery, not deletion authority Keep this issue, but narrow its contract to `dead_symbol_candidates`. It should rank suspicious dead/test-only symbols with reason codes and suppression evidence, then direct the agent to `safe_delete` for per-symbol verification. Do not emit a repository-wide “safe to delete” list: reflection, framework registration, serialization/configuration strings, generated code, and unresolved dispatch make that claim indefensible. Reuse the production-ready text-evidence semantics from #25; text hits are evidence, not proven runtime uses. Recommended acceptance addition: every candidate carries visibility, production/test inbound counts, unresolved-name risk, text occurrence files, resolution confidence, and the exact next preflight call.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
h-dv/code-index#24
No description provided.