You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(vnext): make embedded regions atomic session inputs (#184)
## Summary
- make embedded regions a public, atomic input to document open and
update transactions
- require every text mutation to carry the complete post-edit region set
while preserving omission and explicit-clear semantics for non-document
updates
- mask embedded regions before statement analysis, with separate source
sequencing and conservative cache reuse
- align runtime decoding with TypeScript structural typing by copying
only declared own data fields and leaving host metadata opaque
- migrate the provisional completion contract and packed consumers to
the real session transaction types
## Correctness and consumer behavior
- text, context, dialect, regions, revision, sequences, and statement
cache commit or roll back together
- stale revisions are rejected before candidate payload inspection;
disposal dominates hostile/reentrant failures
- region ranges use resulting-document UTF-16 coordinates and include
complete non-SQL delimiters such as marimo's `{df}`
- source snapshots and normalized regions are owned and frozen;
same-value source transactions still advance revision/source sequence
- incremental statement indexing remains limited to identity-to-identity
edits; changed masked analysis rebuilds lazily
- structurally richer marimo region/envelope values compile and run
without invoking or retaining extra host fields
- removed outer `kind` and contradictory document fields remain
explicitly forbidden in both types and runtime
## Validation
- `pnpm run typecheck`
- `pnpm exec oxlint`
- `pnpm run test:integrity`
- `pnpm test` — 1,264 passed, 1 expected failure
- `pnpm run test:browser` — 7 passed
- `pnpm run test:package` with typed and runtime nonempty embedded
regions
- `pnpm run test:worker-placement`
- `pnpm run demo`
- changed coverage — 98.70% statements, 97.42% branches, 100% functions,
98.69% lines
- pre-rebase review/fix/re-review loop across SQL/API, marimo
ergonomics, and concurrency/performance perspectives
- fresh exact-head approval from all three reviewers at
`ff35130197fcf69a10d42d195c8dd6324f6d5ed9`
Part of #169.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Make embedded regions a first-class, atomic session input in vNext.
Document edits now require the complete post-edit region set, masking
happens before analysis, and cache reuse is tied to a separate source
sequence. Part of #169.
- **New Features**
- Embedded regions are accepted on open and update; document mutations
must include the full resulting `embeddedRegions`. Region-only and
context-only updates are supported.
- Region ranges use resulting-document UTF-16 and include full non-SQL
delimiters (e.g., marimo `{df}`); masking is length-preserving and runs
before statement analysis.
- Unchanged text+regions reuse the immutable source and statement index
via a separate source sequence; only identity-to-identity edits reuse
incrementally. Changed masked analysis invalidates the cache unless
analysis text is equal.
- Inputs are structural: only declared own data fields are read; host
metadata and extras stay opaque. Context accessors and non-enumerable
properties are rejected. Stale revisions are rejected before payload
inspection; disposal dominates hostile/reentrant failures.
- Optional `document`/`embeddedRegions`/`context` fields: `undefined` is
treated as omission at runtime for compatibility with and without
`exactOptionalPropertyTypes`.
- **Migration**
- Update `session.update` calls:
- Context-only: `{ baseRevision, context }` (no `kind`; `context` must
be defined by types).
- Document mutation: `{ baseRevision, document: {...}, embeddedRegions:
[...] }` (regions required).
- Region-only: `{ baseRevision, embeddedRegions: [...] }`.
- Open with regions: `service.openDocument({ text, context,
embeddedRegions })`.
- Use `SqlEmbeddedRegion` and `SqlDocumentUpdate` from
`@marimo-team/codemirror-sql/vnext`; stop importing `SqlEmbeddedRegion`
from `./source`.
<sup>Written for commit db6eeee.
Summary will update on new commits.</sup>
<a
href="https://cubic.dev/pr/marimo-team/codemirror-sql/pull/184?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Copy file name to clipboardExpand all lines: package.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -13,10 +13,11 @@
13
13
},
14
14
"scripts": {
15
15
"dev": "vite",
16
-
"typecheck": "pnpm run typecheck:src && pnpm run typecheck:tests && pnpm run typecheck:vnext-tests && pnpm run typecheck:demo",
16
+
"typecheck": "pnpm run typecheck:src && pnpm run typecheck:tests && pnpm run typecheck:vnext-tests && pnpm run typecheck:vnext-tests:loose-optional && pnpm run typecheck:demo",
0 commit comments