| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…ables Rust struct/enum/trait definitions (and equivalent type-definition kinds in other languages) have fan_in=0 by design — they are consumed via type annotations and struct literals, neither of which produces a call edge. The classifier previously sent these through `classifyDeadSubRole`, which returned `dead-ffi` for any `.rs` file (FFI extension check). Fix: extend the existing `constant` heuristic to cover all annotation-only kinds (`struct`, `enum`, `trait`, `type`, `interface`, `record`). When the same file has at least one active callable (function/method with fanIn > 0 or fanOut > 0), these type definitions are almost certainly live — classify them as `leaf` instead of dead. Changes: - `src/graph/classifiers/roles.ts`: add TYPE_DEF_KINDS set; check it in classifyUnreferencedNode alongside the existing constant check - `src/features/structure.ts`: extract ANNOTATION_ONLY_KINDS constant; use it in buildActiveFilesSet (exclude type defs from "active" count) and buildClassifierInput (pass hasActiveFileSiblings for type defs) - `crates/codegraph-core/src/graph/classifiers/roles.rs`: mirror both changes in the Rust native classifier (TYPE_DEF_KINDS constant, classify_node guard, compute_active_files exclusion, classify_rows is_annotation_only check) - `tests/unit/roles.test.ts`: two new tests for #1584 — one verifying struct/enum/trait classify as leaf with active siblings, one verifying they remain dead with no active siblings docs check acknowledged Closes #1584
Greptile SummaryThis PR fixes a false-positive dead-symbol classification for Rust struct/enum/trait definitions (and equivalent type/interface/record kinds in other languages). Since these forms are consumed via type annotations and struct literals rather than call edges, they always have fan_in=0, causing the old classifier to incorrectly route them through classifyDeadSubRole.
Confidence Score: 5/5The fix is logically correct and well-tested; safe to merge. Both the TypeScript and Rust classifiers receive consistent, symmetric changes. The incremental classification path shares the same helper functions and is correctly updated. New tests cover the main scenario and its boundary. The inline annotation_only slice in compute_active_files that manually copies TYPE_DEF_KINDS is a future-maintenance concern, not a current defect. crates/codegraph-core/src/graph/classifiers/roles.rs — the compute_active_files function uses a local duplicate of TYPE_DEF_KINDS rather than referencing the constant directly. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Node: fan_in = 0, not exported] --> B{is_annotation_only?}
B -- "kind == constant OR kind in TYPE_DEF_KINDS" --> C{has_active_file_siblings?}
B -- "regular callable" --> D[classifyDeadSubRole]
C -- "yes" --> E[leaf]
C -- "no" --> D
D --> F[dead-leaf / dead-ffi / dead-unresolved]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Node: fan_in = 0, not exported] --> B{is_annotation_only?}
B -- "kind == constant OR kind in TYPE_DEF_KINDS" --> C{has_active_file_siblings?}
B -- "regular callable" --> D[classifyDeadSubRole]
C -- "yes" --> E[leaf]
C -- "no" --> D
D --> F[dead-leaf / dead-ffi / dead-unresolved]
Reviews (5): Last reviewed commit: "fix: resolve merge conflicts with main" | Re-trigger Greptile |
Sorry, something went wrong.
Codegraph Impact Analysis6 functions changed → 8 callers affected across 3 files
|
Sorry, something went wrong.
|
Addressed both P2s:
|
Sorry, something went wrong.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Test plan
Closes #1584