feat(vnext): add incremental statement indexing#175
Merged
Conversation
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR adds an incremental SQL statement-index update path (while keeping the full scan as the correctness oracle), introduces a lazy per-session statement-index cache with explicit invalidation/reuse rules, and updates the vNext dialect API to use opaque built-in factory handles rather than structural caller-defined dialect objects.
Changes:
- Add
updateSqlStatementIndexplus supporting utilities to incrementally rescan from a conservative restart point and opportunistically reuse an unchanged suffix. - Add a private, lazy statement-index cache to sessions and update it incrementally for trusted identity-source edits; invalidate on profile changes or non-trusted document mutations.
- Replace public structural dialect definitions with built-in opaque dialect singleton factories (
duckdbDialect(), etc.) and reject fabricated/copied handles.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/vnext-types/session.test-d.ts | Updates type-level API expectations (opaque dialects; statement index remains non-public in types). |
| src/vnext/types.ts | Introduces SqlDialect as an opaque branded handle and updates service options to accept SqlDialect[]. |
| src/vnext/statement-index.ts | Refactors scanning into a reusable core and adds updateSqlStatementIndex for incremental updates + suffix reuse. |
| src/vnext/session.ts | Adds built-in dialect factories + runtime metadata resolution; adds per-session statement-index cache and incremental updating. |
| src/vnext/index.ts | Exposes built-in dialect factories and updates exported types. |
| src/vnext/tests/statement-index.bench.ts | Adds benchmarks for full scans, incremental edits, prefix shifts, and resource-cap recovery. |
| src/vnext/tests/session.test.ts | Updates dialect tests for opaque handles and adds coverage for session statement-index caching/incremental behavior. |
| src/vnext/tests/incremental-statement-index.test.ts | Adds extensive differential and randomized tests to validate incremental updates against the full oracle. |
| SQL_EDITOR_RESEARCH.md | Updates research notes to reflect the opaque handle approach for stable API design. |
| scripts/package-smoke.mjs | Updates smoke tests/consumer snippets to use built-in dialect factories. |
| package.json | Adds a bench:statement-index script to run the new Vitest benchmark. |
| docs/vnext/statement-index.md | Documents incremental update behavior and session cache semantics. |
| docs/vnext/source-coordinates.md | Documents analysis-text/value-based reuse rules and constraints for transformed sources. |
| docs/vnext/session-primitives.md | Updates examples and documents dialect-handle registration semantics and cache behavior. |
| docs/adr/0001-language-service-and-session.md | Updates ADR to reflect opaque dialect handles and incremental statement-index/cache behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Light2Dark
force-pushed
the
codex/vnext-incremental-statement-index
branch
from
July 24, 2026 15:36
2e83d17 to
ce94176
Compare
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
Correctness and safety
Validation
Review
Two independent exact-SHA reviewers approve 2e83d17 with no unresolved blocker, high, or medium findings.
Summary by cubic
Adds incremental statement indexing with a lazy, per-session cache so edits update indexes in microseconds, while a full scan remains the correctness fallback. Replaces caller-defined dialect objects with built-in opaque dialect handles that bind lexical behavior internally.
New Features
duckdbDialect(),postgresDialect(),bigQueryDialect(),dremioDialect(); handles are validated, local to the package instance, and don’t cross workers/processes.pnpm run bench:statement-index; extensive unit, randomized differential, and session cache tests.Migration
defineSqlDialect(...)andSqlDialectDefinitionwith built-in handles andSqlDialect.createSqlLanguageService({ dialects: [defineSqlDialect({ id: "duckdb", displayName: "DuckDB" })] })createSqlLanguageService({ dialects: [duckdbDialect()] }).idstring in document context:{ dialect: dialect.id }.@marimo-team/codemirror-sql/vnextinstance (handles don’t cross workers/processes).Written for commit ce94176. Summary will update on new commits.