feat(vnext): prepare local relation evidence - #191
Merged
Conversation
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR adds a cacheable, package-private “prepared” local-relation statement handle that authenticates its provenance (source/index/slot/dialect + CTE layout) and enables deterministic per-position local relation-site analysis across dialects, while preserving opaque/ambiguous/resource-limited states.
Changes:
- Introduces
prepareSqlLocalRelationStatement+analyzeSqlLocalRelationSiteto separate immutable preparation from cursor-position projection. - Extends CTE-layout provenance/authentication to preserve and propagate an authenticated
"active-statement"resource-limit failure through orchestration. - Adds multi-dialect integration tests plus a vitest benchmark and script for cold/warm local-relation-site performance.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/vnext/statement-index.ts | Adds isSqlStatementSlotSnapshotFor and refactors exact-slot provenance checks to reuse it. |
| src/vnext/relation-query-site.ts | Switches to authenticated CTE layout resolution and preserves authenticated resource-limit failures in query-site results. |
| src/vnext/local-relation-site.ts | New prepared-statement handle + position-based analysis that projects CTE visibility only when unqualified. |
| src/vnext/cte-layout.ts | Registers/authenticates full layouts (including a specific active-statement resource failure) and adds resolveAuthenticatedSqlCteLayout. |
| src/vnext/tests/query-site.test.ts | Verifies authenticated CTE resource-limit failures survive through recognizeSqlRelationQuerySiteWithCteLayout. |
| src/vnext/tests/local-relation-site.test.ts | Adds four-dialect integration coverage for preparation + local visibility projection and failure-closed behavior (including hostile proxies). |
| src/vnext/tests/local-relation-site.bench.ts | Adds cold/warm benchmarks for 10 KiB and max-CTE statements. |
| package.json | Adds bench:local-relation-site script. |
💡 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
Why
The relation-completion session needs one immutable artifact it can cache per
source, statement slot, and dialect. Keeping preparation separate from
position projection avoids rebuilding CTE layout state as the cursor moves,
while the opaque handle prevents stale or independently mixable evidence from
crossing sessions.
This remains package-private until the catalog and end-to-end completion slice
prove the public API described by ADR 0005.
Evidence
Roadmap: #169
Summary by cubic
Introduce a package-private prepared statement that authenticates query-site and CTE visibility to power local relation completion. It preserves qualified/inactive/opaque/ambiguous/resource-limited states and adds four-dialect coverage; supports #169.
prepareSqlLocalRelationStatementandanalyzeSqlLocalRelationSitefor deterministic, cacheable local evidence (results are frozen).relation-query-site, including active-statement resource failures.isSqlStatementSlotSnapshotForand authenticated layout registration/lookup to validate provenance.bench:local-relation-siteplus tests and benches across PostgreSQL, DuckDB, BigQuery, and Dremio.Written for commit 74e9edf. Summary will update on new commits.