fix(exports): top-level-call consumer entries no longer masquerade as a named caller - #2506
Merged
Merged
Conversation
… a named caller findCaller falls back to the file node as a calls edge's source for a bare top-level statement with no enclosing function/binding, so the resulting consumer entry's name/file/line were the file node's own values rendered under consumerKind: 'symbol', making a filename read as if it were a real calling function. Adds a third consumerKind, 'topLevelCall', discriminated by the caller node's own kind rather than just the edge kind, and updates both renderers (check.ts, queries-cli/exports.ts) to present it distinctly from a genuine named caller. Closes #2365 docs check acknowledged Impact: 12 functions changed, 19 affected
Contributor
Greptile SummaryThe PR distinguishes bare top-level calls from named-symbol callers throughout export analysis and presentation.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the native advisory writer now mirrors the TypeScript classification, and the persisted value is preserved through the advisory reader and check renderer. Important Files Changed
Reviews (2): Last reviewed commit: "fix(native): deleted-export advisory wri..." | Re-trigger Greptile |
Contributor
Codegraph Impact Analysis7 functions changed → 19 callers affected across 8 files
|
… calls The Rust-side record_deleted_export_advisories had its own independent copy of the file/symbol discriminator and was never updated for the new topLevelCall kind, so a native build's persisted advisory snapshot would still classify a bare top-level call as a named caller after files with such a consumer were purged, reintroducing the exact misleading check output this change removes on the live-query path. docs check acknowledged
Contributor
Author
|
@greptileai please re-review — pushed the native-side advisory-writer fix you flagged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
findCaller(src/domain/graph/builder/call-resolver.ts) falls back to the FILE node as acallsedge's source when a call is a bare top-level statement with no enclosing function/binding.findExternalConsumers(edges.ts) and its mirror inexports.tsdiscriminateconsumerKindpurely off edge kind ('calls'vs'imports-type'), so this genuinely-realcallsedge getsconsumerKind: 'symbol'— but itsname/file/lineare the file node's own values (the file's basename, line0), not a real caller symbol/call-site.codegraph exports/codegraph checkoutput could therefore show something likeconsumer.ts (consumer.ts:0), which reads as ifconsumer.tswere itself a calling function.This was an inherited characteristic of the existing discriminator design (present since #1973, explicitly called out as out-of-scope when #2189 fixed a related misclassification bug), flagged by Greptile on PR #2364 as worth addressing on its own.
Fix
Chose the least invasive of the three options the issue raised: added a third
consumerKindvalue,'topLevelCall', discriminated by additionally selecting the caller node's ownkindcolumn (not just the edge kind) —'calls'edge + file-kind source →'topLevelCall';'calls'edge + real source →'symbol'(unchanged);'imports-type'→'file'(unchanged).Did not pursue the other two options from the issue:
edgestable has no per-edge line column today) or a new synthetic-node scheme — a materially larger change than what this metadata-quality gap warrants.Updated both renderers (
presentation/check.ts,presentation/queries-cli/exports.ts) to present the new kind distinctly ("file.ts (top-level call)") rather than falling through to the genericname (file:line)format used for real named callers.Closes #2365
Test plan
consumerKind: 'symbol'for it, which is now'topLevelCall'"file (top-level call)", not the file's own name as if it were a callerconsumerKind === 'symbol'assertions for genuinely real callers (main/testAddcallingadd/multiply) are untouchedvitest runsuite (5283 passed, 328 files) after rebuilding the native addon (stale in the fresh worktree, unrelated to this TS-only change)tsc --noEmit,biome checkclean