Skip to content

feat(vnext): expose statement boundaries#201

Merged
Light2Dark merged 1 commit into
dev-refactorfrom
codex/vnext-statement-boundaries
Jul 25, 2026
Merged

feat(vnext): expose statement boundaries#201
Light2Dark merged 1 commit into
dev-refactorfrom
codex/vnext-statement-boundaries

Conversation

@Light2Dark

@Light2Dark Light2Dark commented Jul 25, 2026

Copy link
Copy Markdown
Member

Summary

  • expose synchronous, revision-stamped statementBoundaryAt and statementBoundariesIntersecting session queries
  • preserve exact/no-code/opaque lexical states without leaking the private statement index
  • add scanner-owned code spans that exclude separator trivia and form a strict hasCode discriminated union
  • validate request envelopes as own data properties without invoking host accessors
  • retain incremental index reuse and shift code spans with exact UTF-16 coordinates
  • add public type, package smoke, hostile-input, affinity, opacity, masking, intersection, and documentation coverage

Verification

  • 43 test files; 2,045 passed and 1 expected failure
  • changed coverage: 97.92% statements, 96.12% branches, 100% functions, 98.07% lines
  • all source/test/strict/loose/demo TypeScript configurations pass
  • oxlint, test integrity, build, and runtime export smoke pass
  • cold point lookup measured 3.59 ms at 1 MiB and 42.67 ms at the 16 MiB source ceiling; warm viewport intersection measured 0.075–0.096 ms
  • two independent exact-head adversarial reviews approve c901544ff41480bb1e7ea2ddcab3af477dc8103f

Summary by cubic

Expose synchronous, revision-stamped statement boundary queries in the vNext session API so editors and runners can locate executable SQL without re-lexing. Adds an exact/opaque boundary model with precise UTF-16 ranges and a code span for execution.

  • New Features
    • Added session.statementBoundaryAt({ affinity, position }) and session.statementBoundariesIntersecting({ from, to }); results are frozen and include the current revision.
    • Exact boundaries expose extent, source, optional terminator, lexical endState, and a code span that excludes separator trivia; discriminated by hasCode.
    • Opaque boundaries report a reason for non-executable regions (procedural blocks, custom delimiters, resource limits).
    • All ranges map to the original document’s UTF-16 positions and respect masked embedded regions.
    • Inputs are strictly validated (own data properties only); invalid requests throw SqlSessionError with invalid-statement-boundary-request.
    • Exported new types via @marimo-team/codemirror-sql/vnext: SqlStatementBoundary*, SqlStatementAffinity, SqlStatementLexicalEnd, and related request/result shapes.

Written for commit c901544. Summary will update on new commits.

Review in cubic

@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 98.07% (🎯 91%) 1119 / 1141
🔵 Statements 97.92% (🎯 91%) 1135 / 1159
🔵 Functions 100% (🎯 90%) 112 / 112
🔵 Branches 96.12% (🎯 85%) 918 / 955
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/vnext/index.ts 0% 0% 0% 0%
src/vnext/session.ts 98% 96.26% 100% 98.09% 156, 634, 677, 1108, 1146, 1228, 1555-1558, 1586-1590, 1690-1693, 1702-1708, 1715-1718, 1722-1726, 1794-1797, 2299-2302
src/vnext/statement-boundary-types.ts 0% 0% 0% 0%
src/vnext/statement-index.ts 97.68% 95.83% 100% 97.94% 286, 690, 889, 910, 1023, 1088-1090, 1100, 1112
src/vnext/types.ts 100% 100% 100% 100%
Generated in workflow #762 for commit c901544 by the Vitest Coverage Report Action

@Light2Dark
Light2Dark marked this pull request as ready for review July 25, 2026 18:05
@Light2Dark
Light2Dark merged commit b0a76da into dev-refactor Jul 25, 2026
8 checks passed
@Light2Dark
Light2Dark deleted the codex/vnext-statement-boundaries branch July 25, 2026 18: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.

1 participant