Repository navigation
fix(architecture): stop a file's import-only callees from adding weight - #43
Merged
Merged
Conversation
codegraph lists a file's imported symbols among the file node's callees, so a function imported and called only from inside one of the file's functions weighed 2 on the file edge. With per-definition JSON each slice carries edges[] with a kind; importOnlyIds drops callees reached only by imports edges, while top-level calls (a calls edge to the same target) are kept. npm codegraph has no edges[], so it still counts the import.
inth3shadows
added a commit
that referenced
this pull request
Sep 27, 2026
…#46) Two defects in `--architecture`'s per-symbol CLI probes. They were found by comparing the probes against codegraph's index directly (groundwork for the direct index read, next PR). - **Import nodes were probed by name.** An import statement's node has no callee edges: 0 of 3,659 on codegraph's repo, 0 of 715 on terse. But its text as a name (`terse.capture`, `../src/mcp/tools`) resolves to *another* symbol and borrows its callees, which fabricates file edges. `probeFileEdges` now skips import nodes; this also removes thousands of wasted probes on TS repos. - **#43's import-only filter dropped real calls.** It trusted per-definition `edges[]`, but that list holds ONE edge per callee (whichever codegraph found first). So an `imports` entry can hide an `instantiates`/`references` edge to the same target (codegraph's repo: a test that imports and instantiates `ToolHandler` lost the edge). The filter is removed from the CLI path: an import-only callee now overcounts its file edge by 1 instead of a real call going missing. TECHNICAL.md Known Limitations is rewritten to match. Regression tests: both shapes from the real failures (`probeSymbolCallees` keeps an imported callee whose one listed edge is `imports`; `probeFileEdges` never probes an import node). Local: `node test/run.js` 188 passed, 0 failed (fork codegraph); `--check` on `docs/architecture.svg` is up to date.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up (d) from #39's review.
codegraph lists every symbol a file imports among the file node's callees (
importsedges). So a functionmain.tsimports and calls only inside its ownrun()weighed 2 onmain.ts → alpha.ts: 1 for the call, 1 for the import.edges[]with a kind per edge. NewimportOnlyIdsreturns callees whose every edge isimports, andprobeSymbolCalleesdrops them on the id-matched and same-named-file routes.gamma();, or one inside an anonymous callback) is acallsedge to the same target, so it is kept.edges, so nothing changes there. TECHNICAL.md Known Limitations documents the fork/npm weight difference.Measured on a TS fixture: master drew weight 5, this draws 4 (the 4 real calls). This repo's CommonJS
docs/architecture.svgis unchanged:--checkpasses locally.Local:
node test/run.js183 passed, 0 failed (fork codegraph).