Skip to content

feat(vnext): prepare local relation evidence - #191

Merged
Light2Dark merged 1 commit into
dev-refactorfrom
codex/vnext-local-relation-site
Jul 25, 2026
Merged

feat(vnext): prepare local relation evidence#191
Light2Dark merged 1 commit into
dev-refactorfrom
codex/vnext-local-relation-site

Conversation

@Light2Dark

@Light2Dark Light2Dark commented Jul 25, 2026

Copy link
Copy Markdown
Member

Summary

  • add a package-private prepared statement handle that composes authenticated query-site and CTE-visibility evidence
  • preserve qualified, inactive, ambiguous, opaque, and resource-limited states without inventing local candidates
  • authenticate complete CTE layout results so active-statement resource failures survive orchestration
  • add four-dialect integration coverage and cold/warm performance baselines

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

  • 1,691 passing unit tests plus one governed expected failure
  • all five TypeScript configurations, oxlint, integrity, package smoke, worker placement, and browser suites pass
  • changed coverage: 97.05% statements, 95.77% branches, 100% functions, 97.04% lines
  • warm projection: approximately 0.65 ms for a 10 KiB statement and 0.32 ms for 256 CTEs

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.

  • New Features
    • Added prepareSqlLocalRelationStatement and analyzeSqlLocalRelationSite for deterministic, cacheable local evidence (results are frozen).
    • Propagated authenticated CTE layout through relation-query-site, including active-statement resource failures.
    • Added isSqlStatementSlotSnapshotFor and authenticated layout registration/lookup to validate provenance.
    • Added bench:local-relation-site plus tests and benches across PostgreSQL, DuckDB, BigQuery, and Dremio.

Written for commit 74e9edf. Summary will update on new commits.

Review in cubic

@Light2Dark
Light2Dark marked this pull request as ready for review July 25, 2026 03:58
@Light2Dark
Light2Dark requested a review from Copilot July 25, 2026 03:58
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 97.04% (🎯 91%) 920 / 948
🔵 Statements 97.05% (🎯 91%) 924 / 952
🔵 Functions 100% (🎯 90%) 91 / 91
🔵 Branches 95.77% (🎯 85%) 703 / 734
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/vnext/cte-layout.ts 96.44% 95.02% 100% 96.42% 393, 548, 562-564, 784, 879-881, 924, 1334, 1380, 1599-1602, 1694, 1776, 1824-1826
src/vnext/local-relation-site.ts 96.55% 96.15% 100% 96.55% 187
src/vnext/relation-query-site.ts 100% 100% 100% 100%
src/vnext/statement-index.ts 98.13% 96.58% 100% 98.13% 281, 677, 867, 888, 1001, 1056
Generated in workflow #734 for commit 74e9edf by the Vitest Coverage Report Action

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + analyzeSqlLocalRelationSite to 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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Re-trigger cubic

@Light2Dark
Light2Dark merged commit 9b7851c into dev-refactor Jul 25, 2026
10 checks passed
@Light2Dark
Light2Dark deleted the codex/vnext-local-relation-site branch July 25, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants