Implement sql support#91
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class SQL (.sql) language support across indexing, navigation, graphing, and PR review reporting—while explicitly avoiding application-code string → SQL dependency edges except through review-context heuristics.
Changes:
- Introduces SQL statement fact extraction + role classification, plus an SQL artifact graph (candidates + provenance).
- Adds SQL-to-SQL file dependency edges and SQL symbol/navigation support (go-to-definition + find-references within SQL files).
- Extends review reports and CLI output to optionally include SQL review context and SQL artifact facts.
Reviewed changes
Copilot reviewed 53 out of 54 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/sql-review-context.test.ts | Adds tests for SQL review-context inclusion/guardrails. |
| tests/sql-fact-extraction.test.ts | Adds comprehensive SQL statement fact extraction tests. |
| tests/sql-artifact-graph.test.ts | Tests SQL artifact graph + SQL-to-SQL edge behavior (incl. incremental). |
| tests/samples/sql/graph/report.sql | SQL graph fixture: simple query referencing users. |
| tests/samples/sql/graph/qualified_schema.sql | SQL graph fixture: schema-qualified table definition. |
| tests/samples/sql/graph/qualified_report.sql | SQL graph fixture: schema-qualified query. |
| tests/samples/sql/graph/app.ts | Fixture to assert SQL doesn’t link arbitrary app code. |
| tests/samples/sql/graph/002_alter_users.sql | SQL graph fixture: alters users. |
| tests/samples/sql/graph/001_create_users.sql | SQL graph fixture: defines users. |
| tests/samples/sql/facts/seed.sql | Fact extraction fixture: seed insert. |
| tests/samples/sql/facts/schema.sql | Fact extraction fixture: schema snapshot with constraints/view/index. |
| tests/samples/sql/facts/query.sql | Fact extraction fixture: query + join. |
| tests/samples/sql/facts/migration.sql | Fact extraction fixture: migration alter + drop. |
| tests/samples/sql/facts/dump.sql | Fact extraction fixture: dump-like write. |
| tests/references.test.ts | Adds SQL find-references coverage. |
| tests/project-file-discovery.test.ts | Ensures .sql files are discovered by default. |
| tests/native-parser-ownership.test.ts | Adds native ownership coverage for SQL fixtures. |
| tests/languages/sql.test.ts | Adds SQL language registration, chunking, indexing, and native-only assertions. |
| tests/goto.test.ts | Adds SQL go-to-definition coverage. |
| tests/cli-regressions.test.ts | Adds CLI regression for --sql-artifacts JSON output. |
| src/util/projectFiles.ts | Includes .sql in default project discovery patterns. |
| src/sql/types.ts | Defines SQL roles, fact kinds, truth tiers, and review bridge reasons. |
| src/sql/sourceGraph.ts | Builds SQL module index + SQL-to-SQL dependency edges with caching. |
| src/sql/review.ts | Implements SQL PR review context collection (changed files/literals). |
| src/sql/navigation.ts | Implements SQL go-to-definition + find-references within SQL files. |
| src/sql/index.ts | Exposes SQL submodule public exports. |
| src/sql/graph.ts | Projects SQL statement facts into an SQL artifact graph (candidates + provenance). |
| src/sql/extractFacts.ts | Implements statement splitting + fact extraction for common DDL/DML/query patterns. |
| src/sql/classifySqlFile.ts | Classifies SQL file roles (schema snapshot/migration/seed/etc.). |
| src/review.ts | Adds sqlContext to buildReviewReport output. |
| src/languages/definitions/sql.ts | Registers SQL language definition + queries for chunking. |
| src/languages/all.ts | Registers SQL in the global language registry. |
| src/languages.ts | Exposes SQL support via SQL_SUPPORT. |
| src/indexer/types.ts | Adds SQL-relevant symbol kinds (table/view/index/constraint/routine). |
| src/indexer/navigation.ts | Hooks SQL navigation into generic go-to/refs flows. |
| src/indexer/build-index.ts | Uses SQL-specific module indexing and primes SQL fact cache for graph edges. |
| src/index.ts | Exports SQL APIs/types from the package entrypoint. |
| src/graphs/symbol-graph.ts | Normalizes new symbol kinds for symbol graph output. |
| src/graph-edge-collector.ts | Routes .sql files through SQL edge collection; avoids edge caching for SQL. |
| src/graph-builder.ts | Recomputes relevant SQL edges when SQL definitions change (incremental correctness). |
| src/cli/help.ts | Documents --sql-artifacts flag. |
| src/cli.ts | Adds --sql-artifacts to include SQL artifact graph in JSON output. |
| README.md | Documents SQL support and its intentional scope limits. |
| packages/codegraph-native/src/tests.rs | Adds SQL native parser smoke coverage. |
| packages/codegraph-native/src/languages.rs | Adds SQL to native language list and maps to tree-sitter-sequel. |
| packages/codegraph-native/Cargo.toml | Adds tree-sitter-sequel dependency. |
| packages/codegraph-js-fallback/package.json | Adds JS fallback grammar dependency @derekstride/tree-sitter-sql. |
| package-lock.json | Updates lockfile for new JS fallback dependency. |
| docs/superpowers/plans/2026-05-12-sql-schema-graph-support.md | Updates plan doc to reflect revised SQL approach. |
| docs/scenario-catalog.md | Documents SQL scenarios and adds SQL coverage entries. |
| docs/library-api.md | Documents SQL artifact APIs and sqlContext in review output. |
| docs/language-parity.md | Adds SQL to parity matrix + notes about semantics/scope. |
| docs/cli.md | Documents --sql-artifacts output and sqlContext in review JSON. |
| codegraph-skill/codegraph/SKILL.md | Updates skill doc to describe SQL support and flags. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 53 out of 54 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
src/sql/review.ts:86
collectChangedSqlLiteralObjectsdoes an O(changedFiles × sqlObjectNames) regex scan, constructing a newRegExpfor every object name and testing it against each changed file's full source. If a repo has many SQL facts, this can become a bottleneck. Consider precomputing patterns once, short-circuiting based on a cheap substring check, or building a single combined matcher (e.g., tokenizing identifiers in the changed source and intersecting with the known object-name set).
lzehrung
added a commit
that referenced
this pull request
May 14, 2026
* feat: add SQL artifact graph support * feat: promote SQL to language support * fix: harden SQL native support * fix: refresh SQL graph dependencies incrementally * fix: improve SQL reference matching * fix: broaden SQL statement fact coverage * feat: add practical SQL qualified navigation * fix: address SQL PR review findings * fix: address follow-up SQL review comments * fix: tighten SQL review heuristics * fix: record precise SQL statement ranges * fix: tighten SQL edge precision * fix: repair SQL basename navigation fallback * fix: cache SQL graph edges by corpus * fix: tighten SQL update literal hints * fix: avoid SQL rename target dependency edges * fix: avoid ambiguous SQL prefix navigation * fix: persist SQL graph cache signatures * fix: align SQL graph edge resolution * Address SQL review performance feedback * Bound SQL corpus reads
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.
No description provided.