Skip to content

feat(vnext): complete SQL editor overhaul - #202

Merged
Light2Dark merged 25 commits into
dev-refactorfrom
codex/vnext-final-overhaul
Jul 26, 2026
Merged

feat(vnext): complete SQL editor overhaul#202
Light2Dark merged 25 commits into
dev-refactorfrom
codex/vnext-final-overhaul

Conversation

@Light2Dark

@Light2Dark Light2Dark commented Jul 25, 2026

Copy link
Copy Markdown
Member

Summary

Completes the final batched vNext SQL language-service overhaul milestone.

  • adds authenticated parser-neutral query binding models and bounded
    node-sql-parser normalization in the isolated worker protocol
  • adds public batched column and namespace catalog providers with stable
    provenance, epochs, bounded caches, cancellation, partial/loading/failure
    states, and hostile-response validation
  • integrates relation, namespace, and physical-column completion into document
    sessions and the CodeMirror adapter
  • adds exact statement gutter behavior and insertion-point completion gating
    for embedded marimo expressions while preserving external sources
  • adds correlated outer-scope column completion with conservative derived-table
    isolation
  • expands the marimo compile-time migration fixture and architecture/authority
    documentation

Review hardening

All 27 Cubic comments were reproduced and addressed. Two final adversarial
reviews found and closed seven additional issues:

  • revoked proxies, decoder exceptions, exact response variants, structural
    identity comparisons, and blank namespace path components
  • generation-linearized cancellation and disposal in both catalog coordinators,
    including reentrant abort listeners
  • source-authenticated identifiers, aliases, CTE scope, derived ranges, compound
    blocks, and ON/USING visibility
  • exact statement bounds, one end-to-end response budget, the 64-relation
    deterministic partial cap, incomplete aliases, and line-comment boundaries
  • stale completion-gate callbacks, external-source preservation, and
    failure-safe browser cleanup

CTE and derived-table output-column inference remains an explicit next-major
cutover gap; vNext does not incorrectly route those logical relations to the
physical catalog provider.

Correctness and performance

  • original-document UTF-16 ranges and exact replacement edits
  • explicit partial/unsupported results instead of guessed semantics
  • revision, cancellation, owner disposal, scope, dialect, and epoch checks
  • no raw parser AST crosses or persists beyond the adapter/worker boundary
  • complete-only bounded catalog caches
  • deterministic ordering and deduplication
  • maximum-shape query-model validation reduced from about 888 ms to about
    6.4 ms
  • framework-independent packed core: 187,989 raw bytes and 50,590 gzip bytes,
    within the unchanged 184 KiB raw and 50 KiB gzip limits

Verification

  • 2,286 unit tests passed; 1 intentional expected failure
  • repository coverage:
    • 96.58% statements
    • 96.71% lines
    • 98.01% functions
    • 94.43% branches
  • changed vNext coverage:
    • 97.79% statements
    • 98.08% lines
    • 99.46% functions
    • 96.62% branches
  • every changed runtime file passes the 95% per-file
    statements/branches/functions/lines gate
  • strict TypeScript configurations, oxlint, and test-integrity checks pass
  • 14 browser tests pass in Chromium
  • build, demo build, packed-consumer smoke, parser-isolation/CSP checks, and
    isolated-worker placement audit pass

Advances the next-major implementation milestone tracked in #169.

@github-actions

github-actions Bot commented Jul 25, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 98.08% (🎯 91%) 3941 / 4018
🔵 Statements 97.79% (🎯 91%) 4123 / 4216
🔵 Functions 99.46% (🎯 90%) 560 / 563
🔵 Branches 96.62% (🎯 85%) 3090 / 3198
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/vnext/column-catalog-batch-coordinator.ts 99.37% 95.95% 96.96% 99.33% 530-533
src/vnext/column-catalog-boundary.ts 100% 100% 100% 100%
src/vnext/column-catalog-types.ts 0% 0% 0% 0%
src/vnext/column-completion.ts 100% 97.56% 100% 100%
src/vnext/column-query-site.ts 98.16% 95.73% 100% 99.48% 416, 515, 534, 543
src/vnext/index.ts 0% 0% 0% 0%
src/vnext/local-relation-site.ts 100% 100% 100% 100%
src/vnext/namespace-catalog-boundary.ts 96.84% 96.77% 100% 99.38% 105, 160, 265, 275, 291, 496
src/vnext/namespace-catalog-coordinator.ts 98.46% 98.88% 96.42% 98.34% 153, 463-466
src/vnext/namespace-catalog-types.ts 0% 0% 0% 0%
src/vnext/namespace-completion.ts 100% 100% 100% 100%
src/vnext/node-sql-parser-adapter.ts 96.42% 96.49% 100% 96.36% 81, 108, 153, 245-249
src/vnext/node-sql-parser-browser-executor.ts 97.73% 96.52% 100% 97.72% 475, 560, 657, 683, 917, 963-967, 1071
src/vnext/node-sql-parser-browser-worker-endpoint.ts 98.14% 96.55% 100% 98.14% 184, 335
src/vnext/node-sql-parser-query-bindings.ts 96.23% 95.57% 100% 96.12% 98, 105, 280, 434, 732, 776, 939, 951, 978, 1040, 1082, 1095, 1103, 1139-1143, 1223-1225, 1249
src/vnext/node-sql-parser-wire.ts 96.39% 97.72% 100% 96.36% 92, 225, 236, 378-380
src/vnext/query-binding-model.ts 99.05% 98.25% 100% 99.02% 356, 830, 836
src/vnext/relation-completion-types.ts 100% 100% 100% 100%
src/vnext/relation-completion.ts 98.46% 95.74% 100% 99.19% 174, 286
src/vnext/session.ts 96.92% 95.35% 98.88% 97.26% 196, 686, 798, 841, 1316-1320, 1359, 1397, 1493, 1530, 1558, 1602-1605, 1905-1911, 1914-1917, 1933-1937, 1970-1973, 2018-2021, 2045-2049, 2126-2129, 2138-2144, 2151-2154, 2158-2162, 2240-2244, 2276-2279, 2315-2318, 2858-2861
src/vnext/types.ts 100% 100% 100% 100%
src/vnext/codemirror/index.ts 0% 0% 0% 0%
src/vnext/codemirror/sql-editor.ts 98.77% 96.88% 100% 99.34% 468, 642, 646, 720
src/vnext/codemirror/statement-gutter.ts 96.61% 96.36% 100% 98.18% 104, 136
Generated in workflow #769 for commit 8eaae1e by the Vitest Coverage Report Action

@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.

All reported issues were addressed across 61 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/vnext/column-catalog-boundary.ts Outdated
Comment thread src/vnext/codemirror/sql-editor.ts
Comment thread src/vnext/column-completion.ts
Comment thread src/vnext/session.ts Outdated
Comment thread src/vnext/local-relation-site.ts
Comment thread src/vnext/node-sql-parser-query-bindings.ts Outdated
Comment thread src/vnext/__tests__/namespace-catalog-boundary.test.ts
Comment thread src/vnext/codemirror/browser_tests/statement-gutter.test.ts
Comment thread src/vnext/__tests__/namespace-catalog-coordinator.bench.ts Outdated
Comment thread src/vnext/namespace-catalog-boundary.ts
@Light2Dark

Copy link
Copy Markdown
Member Author

Addressed all 27 review threads in b139e7b.

Highlights:

  • hostile provider/AST values now fail closed, including revoked proxies and
    decoder exceptions
  • both catalog coordinators are linearized against reentrant supersession and
    disposal from abort listeners
  • query bindings are authenticated against lexical identifiers, aliases,
    block/range ownership, CTE visibility, and join scope
  • correlated outer relations are available in expression subqueries while
    ordinary derived tables remain isolated
  • completion enforces exact statement bounds, one total response budget, the
    64-relation partial cap, incomplete aliases, and comment boundaries
  • SQL gate transitions close stale SQL options without racing newer state or
    removing configured external sources
  • benchmark/test setup and browser resource cleanup are failure-safe

Two final adversarial reviews found seven additional cross-layer issues; those
were also fixed and regression-tested. CTE/derived output-column inference is
now documented honestly as a remaining gap rather than routing logical
relations to the physical catalog provider.

Final local verification:

  • unit: 2,280 passed, 1 intentional expected failure
  • browser: 14 passed
  • changed coverage: 97.83% statements / 96.76% branches / 99.46% functions /
    98.10% lines; every changed runtime file exceeds 95% in every metric
  • repository coverage: 96.59% statements / 94.47% branches / 98.01% functions /
    96.72% lines
  • max-shape binding validation: about 6.4 ms, down from about 888 ms
  • packed core: 187,805 / 188,416 raw bytes and 50,506 / 51,200 gzip bytes
  • typecheck, oxlint, integrity, build/demo, package smoke, parser isolation,
    strict CSP, and worker placement all pass

@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.

2 issues found across 29 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/vnext/column-query-site.ts">

<violation number="1" location="src/vnext/column-query-site.ts:538">
P2: Column completion inside PostgreSQL `LATERAL` subqueries omits preceding outer relations while reporting complete coverage. The new `FROM` exclusion treats LATERAL like an ordinary derived table; distinguish LATERAL and collect only preceding parent relations (or mark this scope partial/unavailable).</violation>
</file>

<file name="src/vnext/node-sql-parser-query-bindings.ts">

<violation number="1" location="src/vnext/node-sql-parser-query-bindings.ts:752">
P1: Recursive CTE bodies can be completed as physical tables: this visits the CTE body before its own declaration is visible, so `FROM x` in `WITH RECURSIVE x AS (...)` becomes a complete `named` binding. Model recursive visibility explicitly, or downgrade that binding/coverage with `recursive-cte-uncertainty` rather than publishing false relation evidence.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/vnext/node-sql-parser-query-bindings.ts Outdated
Comment thread src/vnext/column-query-site.ts Outdated

@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.

All reported issues were addressed across 5 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread src/vnext/node-sql-parser-query-bindings.ts Outdated
Comment thread src/vnext/column-query-site.ts Outdated

@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.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/vnext/__tests__/session.test.ts">

<violation number="1" location="src/vnext/__tests__/session.test.ts:603">
P2: Adding shouldAdvanceTime: true makes performance.now() auto-advance based on real wall clock time, which can introduce flakiness into tests that rely on precise fake-timer timing for budget calculations. The default vi.useFakeTimers() already gives full control over time advancement.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread src/vnext/__tests__/session.test.ts
@Light2Dark
Light2Dark merged commit e95be82 into dev-refactor Jul 26, 2026
9 checks passed
@Light2Dark
Light2Dark deleted the codex/vnext-final-overhaul branch July 26, 2026 06:22
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.

1 participant