Skip to content

Commit 1ee9a05

Browse files
authored
feat(vnext): sketch relation completion contracts (#183)
## Summary - add package-private provisional contracts for relation catalog search, epochs, path authority, dialect-owned decoding/rendering, completion results, and session lifecycle - migrate catalog search paths from dot-joined strings to decoded identifier-component paths with quote provenance - add a runtime-free marimo-shaped core fixture covering atomic document/context/region transactions, providers, subscriptions, completion results, and negative type guarantees - add a separate CodeMirror fixture requiring explicit disposal for custom rich-info resources These declarations intentionally remain outside the `./vnext` public export surface until the complete vertical slice, two provider shapes, hostile decoding, packed marimo integration, and lifecycle/performance gates pass. ## Design constraints - provider authoring is strongly typed, but runtime ingress will be erased to `unknown` and strictly decoded - providers return decoded role-bearing canonical paths and positive addressability evidence; only dialect runtime data may decode SQL identifiers or render insertion text - provider requests contain only bounded catalog/query data; provider cancellation is passed separately - consumer results do not expose epochs, scheduler work IDs, deadlines, configuration identity, or terminal-vs-soft loading causes - every `catalog-loading` issue carries a bounded remaining intent lease - custom CodeMirror rich info must return `{ dom, destroy }`, enabling late-result draining and React-root unmounting ## Validation - `pnpm run typecheck` - `pnpm exec oxlint` - `pnpm run test:integrity` - `pnpm test` — 1,248 passed, 1 expected failure - `pnpm run test:browser` — 7 passed - `pnpm run test:package` - changed coverage — 100% statements, branches, functions, and lines - exact-head adversarial approval from SQL/API and marimo ergonomics reviewers at `d5a38af2804c928bc8acf7f7a0ae91a759f3de24` Part of #169. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds provisional, strongly typed contracts for SQL relation completion, including catalog search, dialect decoding/rendering, completion items/results, and session lifecycle. Migrates identifier handling to decoded `SqlIdentifierPath` components and adds a disposable CodeMirror resolver for custom info. Part of #169. - New Features - Relation catalog contracts: search request/response, epochs, coverage (complete/partial/paginated), provider reports. - Dialect runtime for identifier decode/render and CTE identifier equality. - Completion model for CTEs and catalog relations, with issues and ready/unavailable/cancelled/failed results. - Session API with transactional updates, completion, change events, and disposal. - CodeMirror `SqlCompletionInfoResolver` returning `{ dom, destroy }`. - Export `SqlIdentifierComponent` and `SqlIdentifierPath` from `src/vnext/index.ts`. - Migration - Replace dot-joined search paths with `SqlIdentifierPath`; use `SqlIdentifierComponent` for all name parts. - Providers are async, take `AbortSignal` separately, and return decoded paths (no SQL insert text); rendering moves to the dialect runtime. - Embedded regions are readonly; document updates must pass the full `embeddedRegions` set. - Incomplete completion lists must include at least one issue; `catalog-loading` issues include `remainingIntentLeaseMs`. <sup>Written for commit 2d0bade. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/marimo-team/codemirror-sql/pull/183?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. -->
1 parent 88f9c6f commit 1ee9a05

6 files changed

Lines changed: 803 additions & 1 deletion

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { SqlRelationCompletionItem } from "../relation-completion-types.js";
2+
3+
// Provisional CodeMirror-only boundary; the framework-independent core stays DOM-free.
4+
export interface SqlCompletionInfoResolverContext {
5+
readonly signal: AbortSignal;
6+
}
7+
8+
export interface SqlDisposableCompletionInfo {
9+
readonly dom: Node;
10+
readonly destroy: () => void;
11+
}
12+
13+
export type SqlCompletionInfoResolver = (
14+
item: SqlRelationCompletionItem,
15+
context: SqlCompletionInfoResolverContext,
16+
) =>
17+
| SqlDisposableCompletionInfo
18+
| null
19+
| Promise<SqlDisposableCompletionInfo | null>;

src/vnext/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export type {
1616
SqlDocumentReplacement,
1717
SqlDocumentSession,
1818
SqlDocumentUpdate,
19+
SqlIdentifierComponent,
20+
SqlIdentifierPath,
1921
SqlLanguageService,
2022
SqlLanguageServiceOptions,
2123
SqlPlainData,

0 commit comments

Comments
 (0)