Conversation
There was a problem hiding this comment.
Pull request overview
Adds a derived forward/reverse adjacency index to ProjectIndex and routes common in-memory graph reads (deps, rdeps, path) through it instead of repeatedly scanning graph.edges. CLI graph-query commands now reuse the indexed ProjectIndex graph when no explicit collectGraph is injected, and SQLite canned dependency-chain / affected-functions traversals walk file_edges via indexed stepwise neighbor queries rather than loading every edge into memory.
Changes:
- New
src/graphs/adjacency.tsbuilds forward/reverseMap<FileId, FileId[]>indexes preserving edge order;ProjectIndexnow exposes an optionalgraphAdjacency. getDependencies/getReverseDependencies/getShortestPathaccept anadjacencyoption; CLIdeps/rdeps/path/cycles/unresolvedload via the index-backed path with discovery/native/graph/worker options propagated.src/sqlite.tsreplacesloadFileEdges+ in-memory BFS with stepwise indexedSELECT ... WHERE to_type='file' AND from_path/to_path = ?queries through a sharedbfsFileTraversal.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/graphs/adjacency.ts | New helper module building/querying forward+reverse file adjacency. |
| src/graphs/queries.ts | Routes BFS/shortest-path through adjacency, with optional injected index. |
| src/indexer/types.ts | Adds optional graphAdjacency field on ProjectIndex. |
| src/indexer/build-index.ts | Populates graphAdjacency on all ProjectIndex return paths. |
| src/cli/graphQueries.ts | loadGraph now prefers buildProjectIndex and returns adjacency alongside graph. |
| src/cli.ts | Threads discovery/native/graph/worker options into indexOptions for graph-query commands. |
| src/sqlite.ts | Removes loadFileEdges/inline BFS; adds indexed neighbor queries and shared bfsFileTraversal. |
| tests/graph-queries.test.ts | Performance-shape test asserting adjacency is built once per query. |
| tests/cli-command-modules.test.ts | Verifies graph-query commands use buildProjectIndex path and indexed adjacency. |
| tests/cli-regressions.test.ts | Ensures unresolved honors codegraph.config.json discovery ignores. |
| tests/sqlite.test.ts | Adds regressions for cyclic file traversal and incremental edge updates. |
| docs/how-it-works.md, docs/cli.md | Document the optimized read paths. |
| docs/superpowers/plans/2026-05-17-read-performance.md | New implementation plan document. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
ProjectIndexand route common in-memory reads through it.deps,rdeps,path,cycles, andunresolvedwhile preserving injected collector test seams.Accuracy safeguards
Graphvalues and avoids stale mutable graph caches.Verification
npm run buildnpm run lintnpm run test:ci(161 files, 1557 tests)node .\dist\cli.js deps src/index.ts --jsonnode .\dist\cli.js rdeps src/index.ts --jsonnode .\dist\cli.js path src/cli.ts src/index.ts --jsonnode .\dist\cli.js search "sqlite graph" --json