ISS-141 - feat: overlay system — merge remote base graph with local branch diffs#334
Open
patelatharva wants to merge 4 commits into
Open
ISS-141 - feat: overlay system — merge remote base graph with local branch diffs#334patelatharva wants to merge 4 commits into
patelatharva wants to merge 4 commits into
Conversation
amartinezjr0310310-cyber
approved these changes
May 22, 2026
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.
feat: overlay system — merge remote base graph with local branch diffs
Summary
Adds an overlay architecture that lets teams share a single pre-built base graph (main/development branch, built once by CI) while each developer only indexes their feature-branch diffs locally. LLM queries see a seamless, merged view of both databases — no full re-index needed per developer.
Existing local-only
CodeGraph.init()/open()behavior is completely unaffected; the overlay is opt-in via a newCodeGraph.openOverlay()static method.Motivation
Full-repo indexing is expensive. On large codebases every developer re-indexes the same unchanged files. The overlay system eliminates that redundancy:
.dbfile.This pull request addresses this issue:
#141
Architecture
Merge semantics in
OverlayQueryEngine:Changes
src/overlay/types.tsRemoteGraphConfigandBranchDiffResultinterfacessrc/overlay/remote-client.tsRemoteGraphClient— fetch, TTL cache, open base graphsrc/overlay/branch-diff.tsBranchDiffIndexer— git merge-base + diff detectionsrc/overlay/overlay-engine.tsOverlayQueryEngine extends QueryBuilder— merged readssrc/overlay/index.tssrc/index.tsopenOverlay(),remoteClientcleanup, re-exports__tests__/overlay.test.tspackage-lock.jsonTotal: 8 files changed, +2,183 lines, -2 lines
New Public API
Key Design Decisions
OverlayQueryEngine extends QueryBuilder— drop-in compatible with all existing consumers (GraphTraverser, ContextBuilder, ReferenceResolver, MCP tools). No changes needed downstream.FK constraints disabled on overlay DB — overlay edges legitimately reference nodes in the base DB (a separate SQLite file).
PRAGMA foreign_keys = OFFis scoped only to the overlay connection.Merge-base diffing — uses
git merge-base+git diff --name-statusso only the developer's actual changes appear, regardless of upstream commits since the branch point. Handles renamed files (R status) as add + delete.Write isolation — all write operations (
insertNode,insertEdge,indexFile, etc.) go to the overlay DB only. The base DB is read-only.Stale edge filtering — base edges that reference overlay or deleted files are detected and excluded from results, preventing ghost references.
Test Coverage
74 new tests across 5 suites, 0 regressions (811 total pass):
findNodesByExactName,findNodesByNameSubstring,searchNodesmergingTests use real SQLite databases and real git repos (created via
mkdtempSync+git init), matching the project's existing test conventions. No mocking.How to Test
Backward Compatibility
CodeGraph.init(),open(),initSync(),openSync()paths are untouched.src/overlay/, new static method onCodeGraph, new re-exports.src/index.ts(+123 lines for imports, re-exports, theopenOverlay()method, andclose()cleanup).