Repository navigation
TML-2503: reconcile extension-supabase spec/plan to as-built (slice A) - #839
Conversation
…(ADR 230) The runtime half shipped under runtime-target-layer (ADR 230), so the spec/plan were stale. Reconcile them to reality and lay out the remaining slices. - spec.md: add an "As-built & remaining scope" section; fix the runtime surface (single-param supabase<TContract>, async asUser, session-coupled connections — not SET LOCAL/withRawConnection); /contract ships model handles only (no roles/RoleRef export); fix FRs/ACs; supabase:auth.AuthUser - plan.md: mark scaffold + runtime slices done; re-plan remaining slices A–E with explicit gates (postgres-rls verticals, namespace close-out) - decisions.md C5: settle the /contract design — keep model handles, drop the roles/RoleRef hand-export (roles via PSL aggregate + PostgresRole IR) Reviewed (opus): APPROVE-WITH-NITS; nits applied (handle name, PSL-grammar forward-reference, slice terminology). Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: willbot <[email protected]>
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (3)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Main shipped the 0.14.0 publish bump (#843) and several follow-ups (TML-2916 #838, TML-2503 #839, TML-2787 #683, TML-2893 #849, ci-fix #847) while slice 1 was in review. Merge to pick them up. Resolution: - `skills/extension-author/.../0.13-to-0.14/instructions.md` — union of the slice's TML-2919 entry and main's TML-2916 entry as two distinct HTML-comment blocks, matching the file's per-ticket convention. Per the skill spec's rebase scenario (lines 122-130): existing entries in the just-shipped 0.13-to-0.14 directory may stay in place; we do not relocate the TML-2919 entry to 0.14-to-0.15. - Lockfile + example fixtures + apps + all other non-slice files — take main's side cleanly (the branch hadn't touched them; auto-merge resolved to main's content). `pnpm install` confirms the lockfile is consistent. - No `src/` conflicts — only the one instructions.md conflict above. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…ot (slice D) (prisma#845) ## Linked issue Refs [TML-2503](https://linear.app/prisma-company/issue/TML-2503). Slice D of extension-supabase (slice A merged in prisma#839). Slice contract: `projects/extension-supabase/slices/d-service-role-internal-namespaces/spec.md`; design in decision **C15**. ## At a glance ```ts const admin = db.asServiceRole(); admin.sql.public.profile… // primary root (app contract) — unchanged admin.supabase.sql.auth.users.select({ … }) // secondary root (extension contract) admin.supabase.orm.auth.AuthUser.find({ … }) db.asAnon().supabase // ✗ not on the type — service_role only ``` ## Decision Admin access to Supabase-internal tables (`auth.*`, `storage.*`) is exposed as a **separate secondary root** `db.asServiceRole().supabase` — **not** by merging the extension contract into the app contract (a first attempt did that; rejected in review). The `.supabase` facet is the extension contract's **own intact** `ExecutionContext` + a second `SupabaseRuntimeImpl` bound to it, **sharing the app runtime's driver/pool + the `service_role` session**, with marker-verification off (the `external` extension contract owns no app-space marker). `asServiceRole().sql`/`.orm` stay app-contract-only; `asUser`/`asAnon` are unchanged (no `.supabase`). ## Why a separate root, not a merge The runtime is **contract-bound by `storageHash`**: `SqlFamilyAdapter.validatePlan` asserts `plan.meta.storageHash === context.contract.storage.storageHash`. A plan built against the extension contract carries the extension's hash and can't run on the app runtime — so the two roots are genuinely separate (own context + own runtime), sharing only the driver/pool. Merging two `Contract`s also breaks codec-registry uniqueness and the marker check. Two intact contexts/runtimes sharing one pool is the ADR 230 pattern. ## Behavior changes & evidence - `db.asServiceRole().supabase.{sql,orm}` query the extension contract; `asServiceRole().sql`/`.orm` are app-only; `asUser`/`asAnon` have no `.supabase`. Impl: `packages/3-extensions/supabase/src/runtime/supabase.ts` (`SupabaseInternalDb`, `ServiceRoleDb`, `buildExtensionContract`, `extContext`/`extRuntime`). Evidence: `examples/supabase/test/explicit-namespace-query.integration.test.ts` (reads `auth.users` via `.supabase.sql` **and** `.orm`; SQL targets `"auth"."users"`; `current_setting('role') = 'service_role'`) + `service-role-namespaces.test-d.ts` (type-level: secondary root carries `auth`/`storage`; primary root + `asAnon`/`asUser` do not). ## Reviewer notes - **Independent opus review: APPROVE-WITH-NITS** — confirmed one shared pool (no double-close), `service_role` binding intact on the ext path, marker-verify correctly scoped (ext off, app on), no `auth.*` leak to anon/user, per-contract `validatePlan`. The one acted nit (doc comment explaining `SupabaseInternalDb` omits `transaction`) is applied. - This single commit **replaces an earlier merge approach** (force-pushed away) — the diff is the net secondary-root design. - `ext-contract-type.ts` is a no-`as` type alias naming the extension `Contract` distinctly from the framework `Contract` (keeps `lint:casts` delta 0). - **v1 limitation (documented):** no single `transaction` spanning the app root and `.supabase` (separate runtimes, unpinned connections). The principled fix — a `Runtime` bound to the **aggregate contract** — is recorded as future direction in C15 + `deferred.md`. ## Testing performed `pnpm exec turbo run typecheck test lint --filter @prisma-next/example-supabase --filter @prisma-next/extension-supabase` — green (example suite 9 tests, incl. the `.supabase` sql+orm reads). `pnpm lint:casts` delta 0; `pnpm lint:deps` clean. CI re-running on push. ## Skill update n/a — the only user-facing surface change (the `asServiceRole().supabase` admin root) is documented in decision C15 + `overview.md`; no CLI/config/error-code change. ## Checklist - [x] All commits are signed off (`git commit -s`). - [x] I read CONTRIBUTING.md and the change is scoped to one logical concern. - [x] Tests are updated (integration + type-level). - [x] PR title is Linear-prefixed. - [x] **Skill update** filled in. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added an additive `db.asServiceRole().supabase` admin root that enables service-role access to Supabase internal namespaces (e.g., `auth`, `storage`) via `.sql` and `.orm`, while keeping the primary `asServiceRole()` surface restricted to `public`. * **Tests** * Added integration coverage for internal-namespace reads, emitted SQL targeting, and role-scoped execution for both app and internal surfaces. * Added compile-time typing checks for `service_role`, `anon`, and user/JWT namespace visibility. * **Documentation** * Updated upgrade instructions to describe the new secondary `.supabase` surface and related exported types. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: willbot <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
Linked issue
Refs TML-2503. First slice of the final integration project — a docs-only reconciliation. The runtime half shipped early under runtime-target-layer (ADR 230), so the spec/plan had drifted from reality.
At a glance
The spec now opens with an as-built/remaining-scope section instead of describing a runtime that no longer matches the code:
Decision
Docs-only. Reconcile the
extension-supabaseartifacts to as-built reality and re-plan the remaining work:spec.md— fix the runtime surface (single-paramsupabase<TContract>, asyncasUser, session-coupled connections — notSET LOCAL/withRawConnection/execute()-override);/contractships model handles only (noroles/RoleRef); corrected FRs/ACs;supabase:auth.AuthUser.plan.md— scaffold + runtime slices marked done; remaining slices A–E with explicit gates (postgres-rls verticals, namespace close-out).decisions.mdC5 — settle the/contractdesign: keepextensionModel-branded model handles, drop theroles/RoleRefhand-export (roles resolve via PSLroles=[…]aggregate + postgres-rls'sPostgresRoleIR).How it was produced
Drive process: sonnet-mid implementer authored the reconciliation from a verified ground-truth brief; opus-high review pass returned APPROVE-WITH-NITS; nits applied (handle name
auth.User→auth.AuthUser, a forward-reference noting the PSL policy grammar is postgres-rls's call to pin, and slice-terminology consistency).Reviewer notes
git diff --name-only= the 3 files).policy { operation = … }form on purpose — postgres-rls's own spec hasn't yet pinned single-block vs. per-operationpolicy_selectkeywords, so a forward-reference note flags it rather than this spec unilaterally inventing the grammar. Slice B settles it.auth.usersquery) is functionally unblocked (namespace surface merged) but formally gated on explicit-namespace-dsl close-out; E is docs + real-Supabase acceptance.Testing performed
n/a — documentation only.
Skill update
n/a — internal planning docs only; no user-facing surface change.
Checklist
git commit -s).