Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

tml-2834: extension-supabase M1 — package (/pack + PSL contract) + examples/supabase walking skeleton - #746

Merged
wmadden merged 36 commits into
mainfrom
tml-2834-extension-supabase-m1-scaffold-package-pack-psl-contract-and
Jun 7, 2026
Merged

wmadden merged 36 commits into
mainfrom
tml-2834-extension-supabase-m1-scaffold-package-pack-psl-contract-and

Conversation

@wmadden

@wmadden wmadden commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Stands up the Supabase integration's walking skeleton: the @prisma-next/extension-supabase package and a runnable examples/supabase app. The skeleton proves the package's core claim end-to-end — the framework treats Supabase's auth.*/storage.* tables as external (no DDL emitted, verified-present) while the app's own public schema migrates and round-trips on the stock Postgres runtime.

What changed

  • Package packages/3-extensions/supabase/ (modeled on pgvector): /pack (real ExtensionPack carrying the contract + spaceId), /runtime (minimal descriptor — not the real SupabaseRuntime, which is M2), a PSL-authored contract (auth + storage namespaces, 4 models, defaultControl: 'external', no roles), and a zero-ops baseline migration.
  • examples/supabase/: composes extensionPacks: [supabasePack], a public.Profile model, stock-runtime db.ts, one handler; gated integration test (.skip) proving migrate/verify + round-trip.
  • bootstrapSupabaseShim (schemas + 4 external tables; no roles/functions — those grow with postgres-rls).
  • Two framework changes — please review closely:
    1. Emitter now emits multi-namespace contracts (relaxes the single-domain-namespace .d.ts assert; flattens first-name-wins). Single-namespace output is byte-identical, locked by tests.
    2. db init/db verify introspect all declared namespaces (was public-only — a bug for composed contracts). Single-namespace behavior unchanged.
  • Classification e2e (packages/3-extensions/supabase/test/): proves introspecting a Supabase DB attributes public.* to the app and auth.*/storage.* as external.

Why

The integration is delivered as a walking skeleton grown one feature at a time; this is its starting state (M1). The two framework changes are operator-approved enablers discovered during the build — both align with existing patterns (pgvector ships migrations + a runtime export; introspection should read declared schemas).

Scope

In: the package, the example, the shim, the proof, the two framework enablers.
Out (deferred to their owning constituents): /contract typed handles + roles (cross-contract-refs / postgres-rls); the real /runtime role-binding (M2); cross-contract FK, RLS, explicit auth.* queries.

Verification

All changed packages typecheck; pnpm lint:deps + pnpm fixtures:check green; supabase package tests (classification e2e + /pack type smoke) green; full integration suite 1039/1039. Merged current origin/main (incl. TML-2836 migration-vocabulary rename + TML-2808 emitted-shape changes) and re-validated.

Refs: TML-2834

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Supabase extension pack for PostgreSQL plus an example app demonstrating Supabase schema, contract and runtime usage
    • Multi-namespace domain support in contract generation
  • Refactor

    • Schema introspection now uses aggregate namespace definitions
    • Improved handling for extension spaces that ship no migrations
  • Tests

    • New integration and e2e tests covering Supabase workflows and multi-namespace contract emission

wmadden and others added 18 commits June 5, 2026 13:48
Shape the M1 slice of the Supabase integration (TML-2834): scaffold
@prisma-next/extension-supabase (/pack + PSL contract + stub /runtime)
and the examples/supabase walking skeleton. The skeleton proves the
framework handles the external Supabase contract correctly — the planner
emits no DDL for the auth.*/storage.* tables and the verifier confirms
they exist — while the app's own public schema migrates and round-trips
on the stock Postgres runtime.

- slice spec + 7-dispatch plan under projects/extension-supabase/slices/
- defer /contract typed handles + roles to cross-contract-refs / postgres-rls
  (they reinvent contract access; likely the wrong abstraction)
- split bootstrapSupabaseShim: M1 ships the schemas+tables increment (the
  verifier fails on a missing external table); roles + auth.*() functions defer
- update umbrella decisions C13/C14 and the project plan M1 section to match

Refs: TML-2834

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Stand up packages/3-extensions/supabase/ with the full build config
(package.json, tsdown, tsconfigs, biome, prisma-next.config) modelled on
pgvector. Exports ./pack (compiling placeholder stub for D3) and ./runtime
(M2 stub). Wires prismaContract('src/contract/contract.prisma',
{ target: postgres, defaultControlPolicy: 'external' }) in
prisma-next.config.ts. Registers the package in architecture.config.json
so pnpm lint:deps is green.

All D1 gates pass: build, typecheck, lint (--error-on-warnings), lint:deps.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Author src/contract/contract.prisma with auth (AuthUser, AuthIdentity)
and storage (StorageBucket, StorageObject) namespaces, using named types
for the uuid/timestamptz column types.

HALT: contract emit fails because assertSingleDomainNamespaceForEmission
throws for multi-namespace contracts (TML-2550). The contract.d.ts
emitter supports only a single domain namespace. Both contract.json and
contract.d.ts cannot be produced until the emitter is extended or the
assertion is relaxed for extension packs.

PSL parsing and JSON canonicalization succeed; only .d.ts generation
throws. Unblocking this requires either extending the emitter to handle
multi-namespace .d.ts or deciding extension packs skip .d.ts.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… first-name-wins)

Interim unblock for the Supabase extension contract, which declares two domain
namespaces (auth + storage). The old assertSingleDomainNamespaceForEmission
guard threw rather than silently dropping namespaces; now we flatten all
namespace models into the emitted d.ts type map with first-bare-name-wins
semantics (matching the documented ORM flatten behaviour).

Single-namespace output is byte-identical — confirmed by pnpm fixtures:check
showing zero drift across all committed contract.json / contract.d.ts fixtures.
The proper per-namespace d.ts redesign remains explicit-namespace-dsl's job.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Runs prisma-next contract emit against the two-namespace Supabase PSL
(auth + storage). Produces contract.json and contract.d.ts in
src/contract/. The contract carries target: postgres, both namespaces
with their four models (AuthUser, AuthIdentity, StorageBucket,
StorageObject), defaultControlPolicy: 'external', and no roles block.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
….ts emission

Round-1 must-fix: `domainNamespacesType` in `generate-contract-dts.ts` was
emitting only `readonly <ns>: { readonly models: … }` per namespace, dropping
the `readonly valueObjects: …` block that the pre-503f7f334 single-namespace
template emitted when a namespace had value objects. This broke the stated
"single-namespace byte-identical" property for any contract carrying value
objects (sql-orm-client, retail-store, mongo-demo, mongo-blog-leaderboard).

Fix: compute a per-namespace `generateValueObjectsDescriptorType` alongside
the per-namespace `modelsType` and include `readonly valueObjects: …` in each
namespace block where the namespace has value objects — exactly matching the
prior single-namespace shape. The flattened top-level `valueObjects` map is
unchanged. Re-emitting the sql-orm-client fixture confirms zero git diff;
`fixtures:check` exits 0 (all re-emitted fixtures byte-identical).

Round-1 should-fix: add two tests to lock in the undercovered behaviours:
(a) first-name-wins collision semantics in the flattened top-level models map
    when two namespaces share the same bare model name;
(b) per-namespace `valueObjects` block is present when a single namespace
    declares value objects — this case would have caught the must-fix at unit
    level before CI.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Replace the D1 placeholder with the real SqlControlExtensionDescriptor.
supabasePack carries the emitted contract.json (imported as a value) in
a ContractSpace with no migrations and headRef.hash = the contract's
storageHash. supabasePackWith(options) replaces contractJson when a
contractOverride is provided (for test use).

The contractSpace is built inline without contractSpaceFromJson to avoid
a shared-plane → migration-plane dep violation (lint:deps enforces
shared cannot import migration). All type coercions use blindCast from
@prisma-next/utils/casts (added as a dep).

Gates:
- build: pack.mjs 1.95 KB gzip (< 5 KB budget)
- typecheck + tsc -p tsconfig.test.json: clean
- lint (biome --error-on-warnings): clean
- lint:deps: 1030 modules, no violations
- fixtures:check: exit 0

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Creates examples/supabase as a private workspace package
(@prisma-next/example-supabase). The app:

- Declares a PSL contract with Profile { id, username } in the public
  namespace (src/contract.prisma), emitted to src/contract.json and
  src/contract.d.ts.
- Wires the Supabase extension pack via extensionPacks: [supabasePack]
  in prisma-next.config.ts. The emitted contract.json records the pack
  as extensionPacks.supabase; the auth/storage namespaces live in the
  pack's own contract space and do not appear in the app's domain.
- Builds the runtime client on the stock @prisma-next/postgres/runtime
  (no extensions array — the pack composes at authoring time only).
- Provides one handler (insertAndReadProfile) that inserts a Profile
  row and reads it back; this is the skeleton's public.profile walk.

All gates green: pnpm emit, pnpm typecheck, pnpm lint:deps, pnpm
fixtures:check.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… (D5)

Adds examples/supabase/test/supabase-bootstrap.ts, the first increment of the
shared Supabase test fixture. Seeds a Postgres/PGlite database with:
  - CREATE SCHEMA auth, storage
  - auth.users, auth.identities, storage.buckets, storage.objects

Columns match the extension-supabase contract exactly so the framework verifier
passes when a composed contract declares those tables as `external`. No roles
and no auth.uid()/jwt()/role() functions — those are the postgres-rls increment.

Location rationale: examples/supabase/test/ is the canonical home because all
future constituents (cross-contract-refs, postgres-rls, explicit-namespace-dsl)
grow the same example and its test directory. D6's test imports the shim via a
local relative path; test/integration tests that need it can mirror the SQL.

Gates: pnpm typecheck (example-supabase), biome lint, pnpm lint:deps all clean.
Smoke: bootstrapSupabaseShim DDL runs against a PGlite DB; SELECT from
auth.users returns 0 rows with all four tables present.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…gration + minimal /runtime descriptor (D5.5)

Two framework-forced changes discovered at D6, both verified against the
pgvector pattern:

1. The migration aggregate loader reads extension spaces from on-disk
   migrations/<space>/ — it needs at least one migration package to build
   a graph with a reachable head ref. The supabase pack now ships a
   zero-ops baseline migration (from=null → storageHash) that establishes
   the head ref without emitting any DDL. The auth.*/storage.* tables are
   external (Supabase-managed); this migration only records that the
   contract space has been "installed".

2. The stock postgres runtime checks that every extensionPacks entry in
   the emitted contract.json has a matching runtime component. A `never`
   stub export fails this check. /runtime is now a minimal
   SqlRuntimeExtensionDescriptor (no codecs, no ops) — just enough to
   pass the component-requirements check. This is NOT the real
   SupabaseRuntime (role-binding, asUser/asAnon) — that stays M2.

Also: the regen-extension-migrations script is updated to support
extensions with PSL-authored contracts at src/contract/contract.json
(vs TypeScript-authored ones at src/contract.json directly).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…(D6)

Walking skeleton integration test that proves the core M1 claim:
when a composed contract declares extensionPacks: [supabasePack], the
framework treats auth.* / storage.* tables as external — no DDL emitted
for them, verifier confirms they exist, and public.profile migrates and
round-trips normally.

Test flow:
1. Start PGlite; seed external tables via bootstrapSupabaseShim.
2. Materialise the supabase extension space on disk — emitContractSpaceArtefacts
   (contract.json + refs/head.json) and materialiseMigrationPackage for the
   zero-ops baseline migration so the aggregate loader can walk the graph.
3. Run db init (plan mode first): asserts plan has CREATE TABLE for
   public.profile and zero ops targeting auth.* / storage.*.
4. Run db init (apply mode): applies the plan.
5. Run db verify: asserts all space schema results pass.
6. Run handler's public.profile insert + read-back; asserts the row.
7. Raw SQL confirms auth.users is reachable in the seeded DB.

Committed describe.skip because of a framework gap (surfaced to operator):
  executeRun and executeDbVerify call familyInstance.introspect({ driver })
  without passing a contract, so the Postgres adapter only introspects the
  public schema. The supabase extension space declares tables in auth and
  storage schemas — those are never read, so db verify reports them as
  "missing" even when bootstrapSupabaseShim has seeded them.
  Fix needed in packages/1-framework/3-tooling/cli/src/control-api/operations/
  db-run.ts (~line 160) and db-verify.ts: pass the aggregate contracts to
  familyInstance.introspect so the Postgres adapter walks all declared
  namespaces. This is a second framework change; operator must approve before
  proceeding. Test ungates at M3 once both the introspect fix and the full
  example are green end-to-end.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
- projects/extension-supabase/trace.jsonl: Drive build-loop trace (44 events,
  7 dispatches / 9 rounds; verify.ts --allow-open integrity-OK). Early events
  were back-filled after I wrongly skipped live emission — the drive-record-traces
  emitter works fine from inside the repo tree (the global-path arktype error was
  ESM resolution, not a real blocker). Live emission from here on.
- spec.md: record the D1.5 emitter relax (Contract-impact) and the D6-discovered,
  framework-forced refinements — the pack ships a zero-ops baseline migration and
  /runtime is a minimal descriptor (both match the pgvector pattern).

Refs: TML-2834

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ti-namespace contracts)

`executeRun` (db init/update) and `executeDbVerify` called
`familyInstance.introspect({ driver })` without a contract, so the
Postgres adapter fell back to introspecting only the `public` schema.
This was correct for single-namespace contracts but wrong for composed
contracts that declare tables in additional schemas (e.g. the Supabase
extension's `auth` and `storage` namespaces).

Fix: after `buildContractSpaceAggregate` resolves, build a merged
synthetic contract whose `storage.namespaces` key set is the union of
every namespace declared across all members (app + extensions), then
pass it to `familyInstance.introspect`. The Postgres adapter's
`extractContractNamespaceIds` reads only `contract.storage.namespaces`
keys — no other fields are consumed — so a structurally minimal object
is sufficient.

Single-namespace contracts are unchanged: when all members share only
`public` (or `__unbound__`), the merged contract has exactly one key
and the adapter takes the same `introspectSchema` path as before.

Operator-approved second framework change for the Supabase M1 skeleton.
Regression-tested: cli.control-policy.postgres, cli.db-verify.*,
cli.db-init.*, cli.db-update.* — all green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…anaged, auth/storage external)

Adds `packages/3-extensions/supabase/test/classification.e2e.test.ts`,
an integration test that seeds a PGlite database with the Supabase
`auth`/`storage` external tables and then runs `db init` + `db verify`
through the control client API.

Specific assertions:

- `public.profile` is app-managed: the migration plan includes a
  `CREATE TABLE` op attributed to the app contract space.
- The supabase extension space carries **zero** plan ops (all tables
  in `auth.*`/`storage.*` have `defaultControlPolicy: external` —
  the planner suppresses DDL for them).
- `db verify` passes for every space: the verifier confirms the external
  tables are present in the database and does not flag them as missing
  or as DDL drift.
- The supabase space schema-verify result has zero issues.

Also adds `vitest.config.ts` for the extension package and wires in
`@prisma-next/driver-postgres` as a dev dependency (needed by
`createControlClient`).

The seed SQL is inlined in the test (same shape as the Supabase
extension contract); `bootstrapSupabaseShim` in `examples/supabase`
remains unchanged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Adds test/pack.resolution.test-d.ts — a type-level smoke test that proves
the /pack subpath resolves and typechecks independently of the example app.

Seven vitest type assertions cover:
- supabasePack extends ControlExtensionDescriptor<'sql', 'postgres'>
- supabasePack.kind / .familyId / .targetId are the expected literals
- supabasePackWith() and supabasePackWith({ contractOverride }) return the
  same type as supabasePack
- [supabasePack] is assignable to ControlExtensionDescriptor<'sql','postgres'>[]
  (the extensionPacks array element type in PrismaNextConfig)

All slice-DoD gates green:
- /pack gzip bundle: 2.25 kB (< 5 kB budget)
- pnpm --filter @prisma-next/extension-supabase build: pass
- pnpm --filter @prisma-next/extension-supabase typecheck: pass
  (tsc -p tsconfig.test.json --noEmit: pass)
- pnpm --filter @prisma-next/extension-supabase lint: pass
- pnpm lint:deps: pass
- pnpm fixtures:check: pass
- pnpm --filter @prisma-next/extension-supabase test: pass
  (1 classification e2e + 7 type assertions with --typecheck)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…pabase-m1-scaffold-package-pack-psl-contract-and
…enerate baseline migration (D8)

Merged origin/main (76 commits: TML-2836 migration-vocabulary rename + read-command
JSON redesign; TML-2808 emitted-contract shape changes). Adapted our slice:
- re-emit the Supabase pack contract + the examples/supabase app contract with the
  merged emitter (storageHash + emitted shape updated to current)
- regenerate the pack's zero-ops baseline migration with the current migration
  vocabulary so it matches the ContractSpace type
- classification e2e adjusted accordingly

All five changed packages typecheck clean; supabase package tests (classification
e2e + /pack smoke) green; lint:deps clean. Single-namespace contracts unaffected.

Refs: TML-2834

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden
wmadden requested a review from a team as a code owner June 6, 2026 14:35
@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a Supabase extension and examples, updates emitter to emit multi-namespace contract DTS, threads aggregate namespaces into CLI introspection, synthesizes head refs for migration-less extension spaces, and adds generated contract artifacts plus tests and fixtures.

Changes

Multi-namespace and migration-less extensions framework

Layer / File(s) Summary
Emitter domain namespace generation
packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts, packages/1-framework/3-tooling/emitter/test/assert-single-domain-namespace-for-emission.test.ts, packages/1-framework/3-tooling/emitter/test/emitter.test.ts, packages/1-framework/3-tooling/emitter/test/generate-contract-dts.multi-namespace.test.ts
Contract DTS generation now flattens models and value objects across all domain namespaces with first-name-wins collision handling, generates per-namespace type structures, removes the single-namespace assertion, and validates via updated tests for single, multiple, collision, and empty-namespace scenarios.
Aggregate namespace collection and synthesized heads
packages/1-framework/3-tooling/migration/src/aggregate/aggregate.ts, packages/1-framework/3-tooling/migration/src/aggregate/check-integrity.ts, packages/1-framework/3-tooling/migration/src/aggregate/loader.ts, packages/1-framework/3-tooling/migration/src/exports/aggregate.ts, packages/1-framework/3-tooling/migration/test/aggregate/check-integrity.test.ts, packages/1-framework/3-tooling/migration/test/aggregate/loader.test.ts
collectAggregateNamespaces() merges storage namespaces across contract spaces; the loader recognizes migration-less extension spaces and synthesizes head refs from contract storage hashes; integrity checks skip head-ref-in-graph violations for spaces with zero packages.
CLI introspection with aggregate contract
packages/1-framework/3-tooling/cli/src/control-api/operations/db-run.ts, packages/1-framework/3-tooling/cli/src/control-api/operations/db-verify.ts
Schema introspection in db run and db verify now passes an aggregate contract constructed from all declared namespaces to the family introspection SPI, enabling multi-namespace discovery.

Supabase extension package

Layer / File(s) Summary
Extension package foundation and config
packages/3-extensions/supabase/package.json, packages/3-extensions/supabase/biome.jsonc, packages/3-extensions/supabase/prisma-next.config.ts, packages/3-extensions/supabase/tsconfig.json, packages/3-extensions/supabase/tsconfig.prod.json, packages/3-extensions/supabase/tsconfig.test.json, packages/3-extensions/supabase/vitest.config.ts, packages/3-extensions/supabase/tsdown.config.ts
New @prisma-next/extension-supabase workspace package with ESM/build/test scripts, TypeScript and Vitest configs, and exports for ./pack, ./runtime, and ./test/utils.
Extension contract schema
packages/3-extensions/supabase/src/contract/contract.prisma
Prisma schema defining auth (AuthUser, AuthIdentity) and storage (StorageBucket, StorageObject) namespaces with scalar aliases and table mappings.
Generated extension contract and descriptors
packages/3-extensions/supabase/src/contract/contract.json, packages/3-extensions/supabase/src/contract/contract.d.ts, packages/3-extensions/supabase/src/pack/index.ts, packages/3-extensions/supabase/src/exports/pack.ts, packages/3-extensions/supabase/src/exports/runtime.ts
Auto-generated contract JSON/DTS for auth/storage, a control pack descriptor backed by the contract JSON (with synthesized head ref and contractOverride support), and a minimal runtime descriptor for postgres runtime compliance.
Extension tests and fixtures
packages/3-extensions/supabase/test/classification.e2e.test.ts, packages/3-extensions/supabase/test/pack.resolution.test-d.ts, packages/3-extensions/supabase/test/supabase-bootstrap.ts
E2E test validating external-schema classification during plan/apply/verify, type-level pack resolution assertions, and a bootstrap fixture for seeding external auth/storage tables.

Supabase example

Layer / File(s) Summary
Example package foundation and app contract
examples/supabase/package.json, examples/supabase/biome.jsonc, examples/supabase/tsconfig.json, examples/supabase/vitest.config.ts, examples/supabase/prisma-next.config.ts, examples/supabase/src/contract.prisma, examples/supabase/src/contract.json, examples/supabase/src/contract.d.ts
Workspace package for @prisma-next/example-supabase with configs and an app-level public.profile contract (UUID id, text username) plus generated JSON/DTS.
Example runtime and handlers
examples/supabase/src/prisma/db.ts, examples/supabase/src/handlers.ts, examples/supabase/test/supabase-bootstrap.ts
Postgres runtime client wired with Supabase runtime extension, typed insertAndReadProfile() handler, and example test bootstrap re-export that delegates to the extension’s test utils.
Example integration test
examples/supabase/test/skeleton.integration.test.ts
Walking-skeleton integration test that seeds external tables, emits extension artefacts, runs db init plan/apply and db verify, performs typed profile insert/read, and validates external table presence.

Repository and discovery wiring

Layer / File(s) Summary
Migration script and architecture config
scripts/regen-extension-migrations.mjs, architecture.config.json
Migration regeneration now locates contract sources at src/contract.json or src/contract/contract.json and copies end-contract artefacts accordingly; architecture config adds package discovery mappings for Supabase pack/runtime exports.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • aqrln

🐰 A rabbit hops through namespaces wide,

I stitch contracts where runtimes hide,
Synthesized heads hum soft and low,
Packs and tests make the garden grow,
Hooray — the migrations hop, let's go!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically summarizes the main objective: adding a Supabase extension package with PSL-authored contract and a working example application. The title directly reflects the core changes across packages/3-extensions/supabase and examples/supabase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tml-2834-extension-supabase-m1-scaffold-package-pack-psl-contract-and

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-author-tools@746

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-runtime@746

@prisma-next/family-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/family-mongo@746

@prisma-next/sql-runtime

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-runtime@746

@prisma-next/family-sql

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/family-sql@746

@prisma-next/extension-arktype-json

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-arktype-json@746

@prisma-next/middleware-cache

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/middleware-cache@746

@prisma-next/mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo@746

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-paradedb@746

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-pgvector@746

@prisma-next/extension-postgis

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-postgis@746

@prisma-next/postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/postgres@746

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-orm-client@746

@prisma-next/sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sqlite@746

@prisma-next/extension-supabase

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-supabase@746

@prisma-next/target-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-mongo@746

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-mongo@746

@prisma-next/driver-mongo

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-mongo@746

@prisma-next/contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract@746

@prisma-next/utils

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/utils@746

@prisma-next/config

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/config@746

@prisma-next/errors

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/errors@746

@prisma-next/framework-components

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/framework-components@746

@prisma-next/operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/operations@746

@prisma-next/ts-render

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/ts-render@746

@prisma-next/contract-authoring

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/contract-authoring@746

@prisma-next/ids

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/ids@746

@prisma-next/psl-parser

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-parser@746

@prisma-next/psl-printer

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/psl-printer@746

@prisma-next/cli

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/cli@746

@prisma-next/cli-telemetry

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/cli-telemetry@746

@prisma-next/emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/emitter@746

@prisma-next/migration-tools

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/migration-tools@746

prisma-next

npm i https://pkg.pr.new/prisma/prisma-next@746

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/vite-plugin-contract-emit@746

@prisma-next/mongo-codec

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-codec@746

@prisma-next/mongo-contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract@746

@prisma-next/mongo-value

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-value@746

@prisma-next/mongo-contract-psl

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract-psl@746

@prisma-next/mongo-contract-ts

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-contract-ts@746

@prisma-next/mongo-emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-emitter@746

@prisma-next/mongo-schema-ir

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-schema-ir@746

@prisma-next/mongo-query-ast

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-query-ast@746

@prisma-next/mongo-orm

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-orm@746

@prisma-next/mongo-query-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-query-builder@746

@prisma-next/mongo-lowering

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-lowering@746

@prisma-next/mongo-wire

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/mongo-wire@746

@prisma-next/sql-contract

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract@746

@prisma-next/sql-errors

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-errors@746

@prisma-next/sql-operations

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-operations@746

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-schema-ir@746

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-psl@746

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-ts@746

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-contract-emitter@746

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-lane-query-builder@746

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-relational-core@746

@prisma-next/sql-builder

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/sql-builder@746

@prisma-next/target-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-postgres@746

@prisma-next/target-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/target-sqlite@746

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-postgres@746

@prisma-next/adapter-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/adapter-sqlite@746

@prisma-next/driver-postgres

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-postgres@746

@prisma-next/driver-sqlite

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/driver-sqlite@746

commit: d6dc61a

@github-actions

github-actions Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 145.06 KB (0%)
postgres / emit 117.07 KB (0%)
mongo / no-emit 76.09 KB (0%)
mongo / emit 70.95 KB (0%)
cf-worker / no-emit 174.63 KB (0%)
cf-worker / emit 143.48 KB (0%)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (2)
packages/1-framework/3-tooling/cli/src/control-api/operations/db-run.ts (1)

276-310: ⚡ Quick win

Extract duplicated buildAggregateIntrospectContract to a shared module.

This function is identical to the one in db-verify.ts (lines 368-389). Consider extracting it to a shared location (e.g., migration-helpers.ts or a new aggregate-introspect.ts module) to avoid duplication and ensure consistent behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/1-framework/3-tooling/cli/src/control-api/operations/db-run.ts`
around lines 276 - 310, The buildAggregateIntrospectContract function is
duplicated; extract it into a single shared module (e.g., migration-helpers or
aggregate-introspect) and export it, then replace the local definitions in both
db-run.ts and db-verify.ts with an import of that exported function; ensure you
keep the same signature (buildAggregateIntrospectContract(aggregate:
ContractSpaceAggregate): Record<string, unknown>), preserve the try/catch and
namespace merging behavior, and update any imports so callers use the new shared
symbol.
examples/supabase/test/skeleton.integration.test.ts (1)

62-63: ⚡ Quick win

Avoid a hard describe.skip for the only E2E proof path.

This permanently removes regression coverage for migrate/verify/runtime integration. Prefer env-gating so it can run in CI lanes when enabled.

Suggested change
-describe.skip('supabase walking skeleton — external-contract migrate/verify + public round-trip', () => {
+const runSupabaseSkeleton = process.env.RUN_SUPABASE_SKELETON_E2E === '1';
+(runSupabaseSkeleton ? describe : describe.skip)(
+  'supabase walking skeleton — external-contract migrate/verify + public round-trip',
+  () => {
   let database: Awaited<ReturnType<typeof createDevDatabase>>;
   let migrationsDir: string;
@@
-});
+  },
+);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/supabase/test/skeleton.integration.test.ts` around lines 62 - 63,
The test suite currently disables the only E2E path by using describe.skip;
change this to an environment-gated describe so the integration tests run when
explicitly enabled (e.g., check process.env.RUN_SUPABASE_E2E or similar) instead
of always skipping. Locate the describe.skip block (the suite name 'supabase
walking skeleton — external-contract migrate/verify + public round-trip') and
the associated createDevDatabase usage, wrap or replace describe.skip with a
conditional that calls describe only when the env var is truthy and otherwise
calls describe.skip (or uses a helper like describeIfIntegration), and document
the required env var in test setup so CI jobs can opt-in.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/supabase/src/prisma/db.ts`:
- Line 3: Update the import path for the Contract type in the module that
currently reads "import type { Contract } from '../contract.d';"—remove the ".d"
suffix so it matches the repository convention (i.e., import type { Contract }
from '../contract'). Ensure the import statement in
examples/supabase/src/prisma/db.ts references '../contract' (extensionless) and
that any tooling/type resolution still picks up the Contract type.

In `@examples/supabase/tsconfig.json`:
- Line 2: Update the tsconfig "extends" entry to use the repo-standard base
reference: replace the string "`@prisma-next/tsconfig/base`" with
"prisma-next/tsconfig/base" in the examples/supabase tsconfig.json so the
"extends" array points to the monorepo's shared config.

In `@packages/1-framework/3-tooling/cli/src/control-api/operations/db-run.ts`:
- Line 296: Replace the bare TypeScript assertion on contract.storage used to
derive namespaces with the project's safe cast utility: import castAs from
'`@prisma-next/utils/casts`' and use castAs<Record<string, unknown> |
undefined>(contract.storage).namespaces (or similar) to assign to namespaces;
update the statement that references contract.storage and the namespaces
variable to use castAs<T> instead of the bare "as" cast so the type compliance
is preserved (refer to symbols contract.storage, namespaces, and castAs<T>).

In `@packages/1-framework/3-tooling/cli/src/control-api/operations/db-verify.ts`:
- Line 375: Replace the bare "as" cast on contract.storage with the project cast
helper: import castAs from '`@prisma-next/utils/casts`' and use castAs<{
namespaces?: Record<string, unknown> }>(contract.storage) to extract .namespaces
(so the expression that produces namespaces uses castAs instead of
(contract.storage as ...)). Ensure the cast type matches the original shape ({
namespaces?: Record<string, unknown> }) and update any imports accordingly.

In `@packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts`:
- Line 71: Replace bare `as` assertions with the project's `castAs<T>` helper:
import castAs from '`@prisma-next/utils/casts`' and change usages like
`Object.entries(ns.models as Record<string, ContractModel>)` to
`Object.entries(castAs<Record<string, ContractModel>>(ns.models))`; do the same
for the other occurrences that currently use `as` (the casts involving
`ContractModel` at the other three sites) so all four raw `as` casts are
replaced with `castAs<T>` calls referencing the same target types.

---

Nitpick comments:
In `@examples/supabase/test/skeleton.integration.test.ts`:
- Around line 62-63: The test suite currently disables the only E2E path by
using describe.skip; change this to an environment-gated describe so the
integration tests run when explicitly enabled (e.g., check
process.env.RUN_SUPABASE_E2E or similar) instead of always skipping. Locate the
describe.skip block (the suite name 'supabase walking skeleton —
external-contract migrate/verify + public round-trip') and the associated
createDevDatabase usage, wrap or replace describe.skip with a conditional that
calls describe only when the env var is truthy and otherwise calls describe.skip
(or uses a helper like describeIfIntegration), and document the required env var
in test setup so CI jobs can opt-in.

In `@packages/1-framework/3-tooling/cli/src/control-api/operations/db-run.ts`:
- Around line 276-310: The buildAggregateIntrospectContract function is
duplicated; extract it into a single shared module (e.g., migration-helpers or
aggregate-introspect) and export it, then replace the local definitions in both
db-run.ts and db-verify.ts with an import of that exported function; ensure you
keep the same signature (buildAggregateIntrospectContract(aggregate:
ContractSpaceAggregate): Record<string, unknown>), preserve the try/catch and
namespace merging behavior, and update any imports so callers use the new shared
symbol.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 54ccc319-149c-41cb-9daf-e08ff9c3fa55

📥 Commits

Reviewing files that changed from the base of the PR and between d6f3968 and d97b587.

⛔ Files ignored due to path filters (6)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • projects/extension-supabase/plan.md is excluded by !projects/**
  • projects/extension-supabase/slices/m1-scaffold-and-skeleton/plan.md is excluded by !projects/**
  • projects/extension-supabase/slices/m1-scaffold-and-skeleton/spec.md is excluded by !projects/**
  • projects/extension-supabase/trace.jsonl is excluded by !projects/**
  • projects/supabase-integration/decisions.md is excluded by !projects/**
📒 Files selected for processing (42)
  • architecture.config.json
  • examples/supabase/biome.jsonc
  • examples/supabase/package.json
  • examples/supabase/prisma-next.config.ts
  • examples/supabase/src/contract.d.ts
  • examples/supabase/src/contract.json
  • examples/supabase/src/contract.prisma
  • examples/supabase/src/handlers.ts
  • examples/supabase/src/prisma/db.ts
  • examples/supabase/test/skeleton.integration.test.ts
  • examples/supabase/test/supabase-bootstrap.ts
  • examples/supabase/tsconfig.json
  • examples/supabase/vitest.config.ts
  • packages/1-framework/3-tooling/cli/src/control-api/operations/db-run.ts
  • packages/1-framework/3-tooling/cli/src/control-api/operations/db-verify.ts
  • packages/1-framework/3-tooling/emitter/src/assert-single-domain-namespace-for-emission.ts
  • packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts
  • packages/1-framework/3-tooling/emitter/test/assert-single-domain-namespace-for-emission.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/3-extensions/supabase/biome.jsonc
  • packages/3-extensions/supabase/migrations/20260605T0000_establish_external_supabase_tables/end-contract.d.ts
  • packages/3-extensions/supabase/migrations/20260605T0000_establish_external_supabase_tables/end-contract.json
  • packages/3-extensions/supabase/migrations/20260605T0000_establish_external_supabase_tables/migration.json
  • packages/3-extensions/supabase/migrations/20260605T0000_establish_external_supabase_tables/migration.ts
  • packages/3-extensions/supabase/migrations/20260605T0000_establish_external_supabase_tables/ops.json
  • packages/3-extensions/supabase/migrations/refs/head.json
  • packages/3-extensions/supabase/package.json
  • packages/3-extensions/supabase/prisma-next.config.ts
  • packages/3-extensions/supabase/src/contract/contract.d.ts
  • packages/3-extensions/supabase/src/contract/contract.json
  • packages/3-extensions/supabase/src/contract/contract.prisma
  • packages/3-extensions/supabase/src/exports/pack.ts
  • packages/3-extensions/supabase/src/exports/runtime.ts
  • packages/3-extensions/supabase/src/pack/index.ts
  • packages/3-extensions/supabase/test/classification.e2e.test.ts
  • packages/3-extensions/supabase/test/pack.resolution.test-d.ts
  • packages/3-extensions/supabase/tsconfig.json
  • packages/3-extensions/supabase/tsconfig.prod.json
  • packages/3-extensions/supabase/tsconfig.test.json
  • packages/3-extensions/supabase/tsdown.config.ts
  • packages/3-extensions/supabase/vitest.config.ts
  • scripts/regen-extension-migrations.mjs
💤 Files with no reviewable changes (1)
  • packages/1-framework/3-tooling/emitter/src/assert-single-domain-namespace-for-emission.ts

Comment thread examples/supabase/src/prisma/db.ts Resolved
Comment thread examples/supabase/tsconfig.json Resolved
…n CI

The M1 proof (external-contract migrate/verify + public.profile round-trip) is
green and stable, and examples/** is already part of test:examples — so the suite
was running as "skipped", guarding nothing. A skipped green test defeats the
walking skeleton's reason to exist: a continuous CI surface that catches
cross-constituent regressions the day they're introduced. Un-skip it.

It asserts M1 behaviour only; later constituents (cross-contract-refs, postgres-rls,
explicit-namespace-dsl) extend the assertions in place. Spec gating notes updated.

Refs: TML-2834

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
wmadden and others added 5 commits June 6, 2026 19:29
…, de-duplicate (PR#746)

Replace the verbatim-duplicated `buildAggregateIntrospectContract` free function (which
lived in both `db-run.ts` and `db-verify.ts`, swallowed errors, and cast `storage` as
`Record<string,unknown>`) with a single `collectAggregateNamespaces` exported from
`@prisma-next/migration-tools/aggregate`.

The new helper calls `member.contract().storage.namespaces` directly — the field is
typed `Readonly<Record<string, StorageNamespace>>` on `StorageBase`, so no casting is
needed. The try/catch is gone: by the time either CLI command reaches introspection the
aggregate has already passed `buildContractSpaceAggregate` with `checkContracts: true`,
so every `member.contract()` call is safe.

Behaviour is unchanged: introspection still walks all declared namespaces (app +
composed extensions); single-namespace contracts still introspect only their namespace.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…p Supabase no-op baseline (PR#746)

Extension spaces that declare only external schema (e.g. `auth.*` /
`storage.*` tables owned by Supabase) have no DDL migrations to ship
and no on-disk migration graph to walk. The previous workaround was a
zero-ops baseline migration solely to give the loader an edge so the
head ref appeared in the graph. The reviewer correctly flagged this as
a smell.

Loader (`loader.ts`): when `readMigrationsDir` returns zero packages
AND zero load-time problems for an extension space, treat the space as
migration-less. Synthesize its head ref from the on-disk
`contract.json`'s `storage.storageHash` (the same approach
`loadAppSpace` uses for the app), and mark the state with
`hasSynthesizedHead: true`.

Integrity check (`check-integrity.ts`): when `hasSynthesizedHead` is
`true` for a space, skip the `headRefMissing` and `headRefNotInGraph`
checks. The graph is empty by design for these spaces; the planner's
synth strategy handles them (zero ops). Migration-backed spaces (pgvector
etc.) are unaffected — the `isMigrationless` condition only triggers when
both `packages.length === 0` AND `problems.length === 0`, so a space
whose packages failed to load still goes through the full head-ref check.

Pack (`extension-supabase/src/pack/index.ts`): set `migrations: []`
and derive `headRef` directly from `contractJson.storage.storageHash`.
Delete the entire `packages/3-extensions/supabase/migrations/` tree.

Tests: update `classification.e2e.test.ts` and
`examples/supabase/test/skeleton.integration.test.ts` to stop calling
`materialiseMigrationPackage`. Add four loader tests that cover the new
path: head-ref synthesis, no integrity violations for migration-less
spaces, and correct non-migration-less behaviour for spaces with
unloadable packages.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…n, share shim, slim /pack type test

③ Rename emitter test: assert-single-domain-namespace-for-emission.test.ts →
   generate-contract-dts.multi-namespace.test.ts (the method in the old name
   was deleted; the test now exercises generateContractDts multi-namespace emission).

⑤ Derive the supabase pack version from its own package.json via
   `import packageJson from '../../package.json' with { type: 'json' }`
   so it stays in sync automatically with the package version field.

⑥ Move bootstrapSupabaseShim into packages/3-extensions/supabase/test/supabase-bootstrap.ts
   (uses pg directly; interface takes connectionString: string) and export it as
   the @prisma-next/extension-supabase/test/utils subpath. Add pg + @types/pg as devDeps
   and a tsdown entry so the dist is built. The example's supabase-bootstrap.ts now
   re-exports from that subpath. The inlined seed SQL in classification.e2e.test.ts
   is removed — both consumers share the single definition.

⑦ Consolidate pack.resolution.test-d.ts: drop the data-echo assertions (.kind,
   .familyId, .targetId literal checks); keep one test with two toExtend assertions
   that actually verify the assignability contract.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…pabase-m1-scaffold-package-pack-psl-contract-and
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Comment thread examples/supabase/src/handlers.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
examples/supabase/test/skeleton.integration.test.ts (1)

104-107: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use the real Supabase contract.d.ts artifact here.

emitContractSpaceArtefacts() always writes contract.d.ts, but this test feeds it a stub string. That means the walking-skeleton still passes if the packaged Supabase DTS is missing or stale, which weakens the PR's “ships emitted contract artifacts” proof. Thread the generated DTS through from the pack descriptor or import the emitted file directly instead of hardcoding a placeholder.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/supabase/test/skeleton.integration.test.ts` around lines 104 - 107,
The test currently passes a hardcoded stub for contractDts to
emitContractSpaceArtefacts which hides missing/stale Supabase DTS; change the
test to pass the real generated DTS instead of the placeholder. Locate where the
pack descriptor or generated artifacts are produced in the test setup (or read
the emitted contract.d.ts from the build output), and supply that value as the
contractDts argument to emitContractSpaceArtefacts alongside space.contractJson
and space.headRef so the real Supabase contract.d.ts is validated; ensure the
test fails if the DTS is unavailable.
🧹 Nitpick comments (1)
examples/supabase/test/skeleton.integration.test.ts (1)

143-167: ⚡ Quick win

Tighten the plan assertions to the actual target object.

Line 146 lets any createTable op satisfy the public.profile check, and the auth/storage guard only inspects id/label substrings. A planner regression can therefore still pass this test while routing DDL to the wrong object. Assert the exact target table/namespace from the operation metadata, or at minimum match public.profile explicitly in one place instead of relying on generic display strings.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/supabase/test/skeleton.integration.test.ts` around lines 143 - 167,
The test currently allows any createTable op (via op.id substring) and only
substring-matches auth/storage, so update the assertions to check the
operation's explicit target metadata instead of display strings: when scanning
operations (the operations array and existing hasProfileCreate logic), find a
createTable op whose target/schema/name (e.g., op.target, op.object, or
op.metadata fields that represent schema/name) exactly equals "public" and
"profile" (or a single "public.profile" identifier) and assert that exists;
likewise replace the auth/storage filter to check the operation's
schema/namespace field for exact equality to "auth" or "storage" (not substring
of id/label) before asserting zero such ops (adjust the expect calls that
currently reference hasProfileCreate and authOrStorageOps to use these stricter
checks).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@examples/supabase/test/skeleton.integration.test.ts`:
- Around line 104-107: The test currently passes a hardcoded stub for
contractDts to emitContractSpaceArtefacts which hides missing/stale Supabase
DTS; change the test to pass the real generated DTS instead of the placeholder.
Locate where the pack descriptor or generated artifacts are produced in the test
setup (or read the emitted contract.d.ts from the build output), and supply that
value as the contractDts argument to emitContractSpaceArtefacts alongside
space.contractJson and space.headRef so the real Supabase contract.d.ts is
validated; ensure the test fails if the DTS is unavailable.

---

Nitpick comments:
In `@examples/supabase/test/skeleton.integration.test.ts`:
- Around line 143-167: The test currently allows any createTable op (via op.id
substring) and only substring-matches auth/storage, so update the assertions to
check the operation's explicit target metadata instead of display strings: when
scanning operations (the operations array and existing hasProfileCreate logic),
find a createTable op whose target/schema/name (e.g., op.target, op.object, or
op.metadata fields that represent schema/name) exactly equals "public" and
"profile" (or a single "public.profile" identifier) and assert that exists;
likewise replace the auth/storage filter to check the operation's
schema/namespace field for exact equality to "auth" or "storage" (not substring
of id/label) before asserting zero such ops (adjust the expect calls that
currently reference hasProfileCreate and authOrStorageOps to use these stricter
checks).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 98de6bdc-0f94-46f3-9cae-ba1fdd4bb083

📥 Commits

Reviewing files that changed from the base of the PR and between 26c31f0 and a7ec0f8.

⛔ Files ignored due to path filters (2)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • projects/extension-supabase/trace.jsonl is excluded by !projects/**
📒 Files selected for processing (17)
  • examples/supabase/test/skeleton.integration.test.ts
  • examples/supabase/test/supabase-bootstrap.ts
  • packages/1-framework/3-tooling/cli/src/control-api/operations/db-run.ts
  • packages/1-framework/3-tooling/cli/src/control-api/operations/db-verify.ts
  • packages/1-framework/3-tooling/emitter/test/generate-contract-dts.multi-namespace.test.ts
  • packages/1-framework/3-tooling/migration/src/aggregate/aggregate.ts
  • packages/1-framework/3-tooling/migration/src/aggregate/check-integrity.ts
  • packages/1-framework/3-tooling/migration/src/aggregate/loader.ts
  • packages/1-framework/3-tooling/migration/src/exports/aggregate.ts
  • packages/1-framework/3-tooling/migration/test/aggregate/check-integrity.test.ts
  • packages/1-framework/3-tooling/migration/test/aggregate/loader.test.ts
  • packages/3-extensions/supabase/package.json
  • packages/3-extensions/supabase/src/pack/index.ts
  • packages/3-extensions/supabase/test/classification.e2e.test.ts
  • packages/3-extensions/supabase/test/pack.resolution.test-d.ts
  • packages/3-extensions/supabase/test/supabase-bootstrap.ts
  • packages/3-extensions/supabase/tsdown.config.ts
💤 Files with no reviewable changes (1)
  • packages/1-framework/3-tooling/emitter/test/generate-contract-dts.multi-namespace.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/3-extensions/supabase/package.json
  • packages/3-extensions/supabase/test/classification.e2e.test.ts

wmadden and others added 6 commits June 6, 2026 20:56
… on graph emptiness (PR#746)

Remove the `isMigrationless` branch from `loadExtensionSpace`: extension
spaces now read `refs/head.json` uniformly from disk, the same as any
migration-backed extension. The Supabase pack already writes its head ref
via `emitContractSpaceArtefacts`, so the walking-skeleton test stays green
without any test-side changes.

Remove `hasSynthesizedHead` from `IntegritySpaceState`. The field conflated
"how we got the head ref" with "is there a migration graph to check against",
which are independent. Replace the integrity gate:
- `headRefMissing` now fires for ALL non-app spaces when `head.json` is
  absent — a missing head ref is always an authoring error.
- `headRefNotInGraph` is gated on `member.packages.length > 0`; empty-graph
  spaces (no packages) skip this check because the graph reachability test
  is meaningless with nothing to walk.

Also delete the `extractStorageHashFromRaw` and `safeCallRaw` helpers that
were only used by the removed branch.

Update the four loader tests that asserted synthesis behaviour to instead
assert uniform disk reads. Update the `check-integrity.test.ts` literals to
drop `hasSynthesizedHead`. Fix the "rethrows on unexpected graph() failure"
test to give the faulty member a package so the graph check is triggered.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…pabase-m1-scaffold-package-pack-psl-contract-and
…mitter bare casts

- examples/supabase/src/handlers.ts: drop the `db.sql['profile']` bracket
  workaround + defensive nil-check. The typed surface has `profile` as a named
  property (the contract.d.ts emits `roots: { profile: ... }`), so
  `db.sql.profile` typechecks fine — the index-signature workaround was
  unnecessary (D4 implementer's report was wrong).
- examples/supabase/src/prisma/db.ts: `'../contract.d'` → `'../contract'` to
  match the modern repo convention (retail-store, mongo-demo).
- examples/supabase/test/skeleton.integration.test.ts: bump the per-`it`
  timeout from `timeouts.spinUpPpgDev` (30s) to 4× that. The test does seed +
  materialise + dbInit (plan + apply) + dbVerify + connect runtime + insert +
  read — substantially more than a DB spin-up. 4× gives cold CI headroom.
- packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts: replace
  the four bare `as` casts (CodeRabbit) with `blindCast<T, Reason>` per the
  no-bare-casts repo policy. Emitter output is byte-identical (fixtures:check
  green); emitter tests 162/162.

Refs: TML-2834

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/supabase/src/handlers.ts`:
- Around line 5-6: The handler currently does an unfiltered select after
inserting which will return all rows; update the logic in the function (where
you call db.sql.profile.insert and runtime.execute) to use the SQL builder's
returning(...) on db.sql.profile.insert([{ username }]) and return the
runtime.execute(...) of that insert with .returning('id', 'username').build()
instead of calling db.sql.profile.select('id', 'username') so only the newly
inserted row(s) are returned.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 65c83ddd-1c18-424e-83be-2720777f7842

📥 Commits

Reviewing files that changed from the base of the PR and between 5eb431c and fe7fabe.

⛔ Files ignored due to path filters (1)
  • projects/extension-supabase/trace.jsonl is excluded by !projects/**
📒 Files selected for processing (4)
  • examples/supabase/src/handlers.ts
  • examples/supabase/src/prisma/db.ts
  • examples/supabase/test/skeleton.integration.test.ts
  • packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • examples/supabase/src/prisma/db.ts
  • examples/supabase/test/skeleton.integration.test.ts
  • packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts

Comment thread examples/supabase/src/handlers.ts Resolved
wmadden and others added 4 commits June 6, 2026 21:24
…or upgrade instructions

PR adds the new @prisma-next/extension-supabase package + examples/supabase. Two enabling framework changes (multi-namespace emit; introspect all declared namespaces) are forward-compatible — single-namespace contracts emit byte-identical output and existing extension packs are unaffected.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ile (PR#746)

CodeRabbit caught that the prior insert + unfiltered select would return all profile rows once the table is non-empty — the integration test only passed by coincidence (table starts empty). Use the SQL builder's .returning(...) on the insert so only the newly-inserted row(s) come back, matching the prisma-next-demo idiom.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: Will Madden <[email protected]>
wmadden and others added 2 commits June 7, 2026 09:01
Clean up as we go — CodeRabbit flagged these in R5; I'd dismissed them as pre-existing (they predate this PR), but per repo policy bare `as` should not exist in production code. Three sites: the two `notOk(failure) as DbInitResult | DbUpdateResult` widenings in db-run.ts (failure-path return) and the `projectedSchema as never` opaque-IR pass-through in db-verify.ts.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ent (PR#746)

Two review comments:

1) bootstrapSupabaseShim now takes 'client: Client' instead of 'connectionString: string'. The shim no longer owns the client lifecycle — callers pass their own (already-connected) client so it can be reused across other test setup steps (or bound to a transaction). Both consumers (classification.e2e + skeleton.integration) wrap with the test-utils 'withClient' helper.

2) Rewrote the 'synth strategy (zero ops)' comment in check-integrity.ts in plain English: 'When a space ships no migrations, the planner emits no DDL for it — the database is treated as already at the declared state.'

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant