Repository navigation
Close out cross-contract-refs: migrate docs, record shipped, delete workspace (TML-2500 M4) - #770
Conversation
…+ ADR 226 + authoring rulecard) Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: Will Madden <[email protected]>
…rable docs Replace the fictional `source: 'local'|'space'` / `TargetFieldRef` union with the real presence-based `spaceId?` shape from `ForeignKeyReference`. Use `__unbound__` (IR/DDL sentinel) in planner/DDL contexts; leave `__unspecified__` (parser sentinel) in PSL-authoring contexts. Update the ADR grammar example from `User` to `AuthUser` for consistency. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: Will Madden <[email protected]>
Flip the umbrella status row to ✅ Done & closed (M1–M3b PR numbers), fix supabase:auth.User → supabase:auth.AuthUser, repoint the project-dir link in the umbrella and the durable dangling link in the supabase extension README to the new subsystem doc + ADR 226. Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ounding, model-tier, test-claims) Three process lessons from the TML-2500 cross-contract-refs retro: - drive/spec/README.md: executors must re-verify illustrative snippets against shipped code before treating them as fact - drive/calibration/model-tier.md: worked example — M3b dispatches inherited orchestrator tier silently for a full milestone - drive/calibration/dod.md: test-dispatch briefs must state what the test proves and on the right surface (claims-preserved AC) Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The project's durable knowledge migrated to canonical surfaces in M4.1 (subsystem doc § Cross-contract FK references, ADR 226, and the cross-contract-fk-authoring rulecard); the umbrella tracker records it shipped (M4.2); and the final-retro lessons landed in drive/ calibration surfaces (M4.3). The transient project workspace — specs, plans, slice artefacts, reviews, learnings, trace — has served its purpose and is removed here. Closes the cross-contract-refs project. All implementation milestones merged: M1 #745, M2 #752, M3a #756, M3b #765. Signed-off-by: Will Madden <[email protected]>
|
Warning Review limit reached
More reviews will be available in 9 minutes and 54 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR documents the framework design and authoring model for cross-contract foreign-key references. It introduces ADR 226, authoring conventions, ecosystem integration guidance, and supporting process/validation updates. All changes are documentation-only with no code changes. ChangesCross-contract foreign-key references: design and authoring documentation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
| The FK reference carrier in Contract IR (`ForeignKeyReference`) uses a presence-based optional `spaceId` to distinguish local from cross-space references: | ||
|
|
||
| ```ts | ||
| export class ForeignKeyReference extends SqlNode { | ||
| readonly namespaceId: NamespaceId; // UNBOUND_NAMESPACE_ID ('__unbound__') for single-namespace refs | ||
| readonly tableName: string; | ||
| readonly columns: readonly string[]; | ||
| declare readonly spaceId?: string; // absent = local; present = cross-space | ||
| } | ||
| ``` |
There was a problem hiding this comment.
This is too low-level for subsystem docs, this belongs in an ADR.
There was a problem hiding this comment.
Fixed in 36ccbfc — removed the ForeignKeyReference class block and the presence-based-discrimination internals from the subsystem doc, replaced with a plain behavioral description plus the existing ADR 226 link. The IR-level detail lives in ADR 226 where it belongs.
|
|
||
| #### Resolution rule | ||
|
|
||
| Cross-space resolution happens at the lowering boundary (Contract IR → Schema IR). The same aggregate the framework already builds from `extensionPacks` is the resolver — there is no separate PSL `use` directive or TS resolver call. If the named space is not in the aggregate, lowering fails fast with a diagnostic naming the missing pack. |
There was a problem hiding this comment.
This is unintelligible jargon
There was a problem hiding this comment.
Fixed in 36ccbfc — rewrote it without the IR-plane jargon: "When the contract is compiled, each cross-space reference is resolved against the loaded extension contracts — the same set declared in extensionPacks. A reference to a space that isn't declared, or to a model/column that doesn't exist in it, fails fast with a diagnostic that names the missing pack."
|
|
||
| ```ts | ||
| import { AuthUser } from '@prisma-next/extension-supabase/contract'; | ||
| import supabasePack from '@prisma-next/extension-supabase/pack'; |
There was a problem hiding this comment.
| import supabasePack from '@prisma-next/extension-supabase/pack'; | |
| import supabaseExtension from '@prisma-next/extension-supabase/pack'; |
There was a problem hiding this comment.
Applied in 36ccbfc — renamed the import binding to supabaseExtension and propagated it to the extensionPacks: [supabaseExtension] usage in the same example so it stays consistent.
There was a problem hiding this comment.
You're right — it shouldn't be a rule. Deleted .agents/rules/cross-contract-fk-authoring.mdc in 36ccbfc. The authoring how-to it carried duplicated the subsystem doc's authoring section; the one genuinely-useful part (native-type matching: @db.X is a types-block constructor, not a field attribute) is folded into the subsystem doc's authoring section as a "Native-type matching" note. The three references to the rulecard (subsystem doc + two in ADR 226) are repointed/removed.
Lead with the decision + a grounding example (the PSL an author writes and the DDL it produces), build the design as connected narrative rather than a flat list, and move rejected options into an "Alternatives considered" section at the end so the body stays focused on what was decided. Strip references that don't belong in long-lived documentation: the Linear ticket from Status, "before this work / pre-226 / v0.1" project-phase framing, and the prior-work reference in the AST note. Technical content (presence-based spaceId discrimination, the __unbound__/__unspecified__ layer split, the colon-prefix grammar, native-type matching) is unchanged. Signed-off-by: Will Madden <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@docs/architecture` docs/adrs/ADR 226 - Cross-contract foreign-key
references.md:
- Around line 87-91: Add a language tag to the fenced code block containing the
grammar for "type_ref ::= [ <space>: ] <namespace>. <name> ..." so the fence
becomes e.g. ```text or ```ebnf (or another appropriate language identifier) to
satisfy MD040; locate the fence around the type_ref grammar and prepend the
chosen language after the opening backticks.
In `@packages/3-extensions/supabase/README.md`:
- Around line 63-65: Update this README.md to remove transient "projects/..."
links and replace them with stable documentation/package references: change the
`projects/postgres-rls/spec.md` link used in the "postgres-rls" line to the
durable package or architecture spec for RLS, replace the
`projects/explicit-namespace-dsl/spec.md` link referenced in
"explicit-namespace-dsl", and repoint the `ADR 226` and cross-contract FK link
(`supabase:auth.AuthUser`) to the canonical ADR or architecture docs location;
do the same for the other occurrences noted at lines 71-72 so the README only
references long-lived docs or package docs rather than any `projects/` paths.
🪄 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: b881d666-c133-46ee-9938-8964a87ccd65
⛔ Files ignored due to path filters (13)
projects/cross-contract-refs/plan.mdis excluded by!projects/**projects/cross-contract-refs/rollups/2026-06-05-opening.mdis excluded by!projects/**projects/cross-contract-refs/slices/M1/plan.mdis excluded by!projects/**projects/cross-contract-refs/slices/M1/spec.mdis excluded by!projects/**projects/cross-contract-refs/slices/M2/plan.mdis excluded by!projects/**projects/cross-contract-refs/slices/M2/spec.mdis excluded by!projects/**projects/cross-contract-refs/slices/M3a/plan.mdis excluded by!projects/**projects/cross-contract-refs/slices/M3a/spec.mdis excluded by!projects/**projects/cross-contract-refs/slices/M3b/plan.mdis excluded by!projects/**projects/cross-contract-refs/slices/M3b/spec.mdis excluded by!projects/**projects/cross-contract-refs/spec.mdis excluded by!projects/**projects/cross-contract-refs/trace.jsonlis excluded by!projects/**projects/supabase-integration/README.mdis excluded by!projects/**
📒 Files selected for processing (7)
.agents/rules/cross-contract-fk-authoring.mdcdocs/architecture docs/adrs/ADR 226 - Cross-contract foreign-key references.mddocs/architecture docs/subsystems/6. Ecosystem Extensions & Packs.mddrive/calibration/dod.mddrive/calibration/model-tier.mddrive/spec/README.mdpackages/3-extensions/supabase/README.md
| - **RLS authoring + policies** — [`postgres-rls`](../../../projects/postgres-rls/spec.md) (`.rls(...)` builder, PSL `policy { … }` blocks, content-addressed wire names, `pg_policies` verifier). | ||
| - **Cross-contract FK to `auth.users`** — [`cross-contract-refs`](../../../projects/cross-contract-refs/spec.md) (`supabase:auth.User` PSL grammar; cross-space references in the TS builder). | ||
| - **Cross-contract FK to `auth.users`** — [cross-contract FK references](../../../docs/architecture%20docs/subsystems/6.%20Ecosystem%20Extensions%20%26%20Packs.md) (`supabase:auth.AuthUser` PSL grammar; cross-space references in the TS builder). See also [ADR 226](../../../docs/architecture%20docs/adrs/ADR%20226%20-%20Cross-contract%20foreign-key%20references.md). | ||
| - **Explicit namespace-qualified queries** (`db.sql.auth.users`) — [`explicit-namespace-dsl`](../../../projects/explicit-namespace-dsl/spec.md). |
There was a problem hiding this comment.
Replace remaining projects/ links with durable docs references in this README.
This package README is long-lived, but it still links to transient projects/... artifacts. Please repoint these to stable architecture/package docs to avoid future dead links after workspace cleanup.
Based on learnings: “Ensure that all READMEs and system documentation under any 'packages' or 'docs' directory do not reference transient project artifacts located under a 'projects' directory.”
Also applies to: 71-72
🤖 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/3-extensions/supabase/README.md` around lines 63 - 65, Update this
README.md to remove transient "projects/..." links and replace them with stable
documentation/package references: change the `projects/postgres-rls/spec.md`
link used in the "postgres-rls" line to the durable package or architecture spec
for RLS, replace the `projects/explicit-namespace-dsl/spec.md` link referenced
in "explicit-namespace-dsl", and repoint the `ADR 226` and cross-contract FK
link (`supabase:auth.AuthUser`) to the canonical ADR or architecture docs
location; do the same for the other occurrences noted at lines 71-72 so the
README only references long-lived docs or package docs rather than any
`projects/` paths.
Source: Learnings
There was a problem hiding this comment.
Good catch, and the rule is right — but these point to sibling projects that haven't shipped yet (postgres-rls, explicit-namespace-dsl, the umbrella, extension-supabase), so there's no durable doc to repoint them at. The cross-contract-refs link on the line above was repointed to ADR 226 because that project just shipped its durable docs. The pattern this close-out follows is: each durable→project link gets repointed at that project's own close-out (which is what just happened here for cross-contract-refs). Repointing the others now would mean pointing at docs that don't exist yet. Flagging to the operator to confirm — left as-is for now since they're live (not yet dead) links to shaped-but-unshipped work.
There was a problem hiding this comment.
@wmadden-electric, that makes sense — the pattern is sound. Links to in-progress sibling projects are live references with no durable target to substitute yet; repointing at close-out is the right moment. I'll record the nuance so future reviews don't flag these prematurely.
🐇 ~
✏️ Learnings added
Learnt from: wmadden-electric
Repo: prisma/prisma-next PR: 770
File: packages/3-extensions/supabase/README.md:63-65
Timestamp: 2026-06-08T14:47:33.413Z
Learning: In `packages/3-extensions/supabase/README.md` (and similar package READMEs in prisma/prisma-next), `projects/` links to sibling projects that have **not yet shipped** are acceptable — there is no durable doc to repoint them to yet. The convention is: each `projects/` link gets repointed to its canonical durable doc (ADR, subsystem doc, or package README) only at that project's own close-out PR. Do not flag unshipped-project links as violations of the "no transient project references" rule; only flag them once the project has shipped and the durable doc exists.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
🧠 Learnings used
Learnt from: wmadden
Repo: prisma/prisma-next PR: 746
File: examples/supabase/tsconfig.json:2-2
Timestamp: 2026-06-06T19:15:12.496Z
Learning: In the prisma-next monorepo, tsconfig.json files should extend the base config using the scoped package name with the `@` prefix: `"extends": ["prisma-next/tsconfig/base"]`. Do NOT use `"prisma-next/tsconfig/base"` (without `@`) — that will fail to resolve. Do not reference relative paths to the root tsconfig.base.json; prefer the package-based extension for maintainability across the monorepo.
Learnt from: CR
Repo: prisma/prisma-next PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-06-08T11:12:59.729Z
Learning: Applies to **/*.{md,mdc} : Keep docs current (READMEs, rules, links): `.agents/rules/doc-maintenance.mdc`.
Learnt from: wmadden
Repo: prisma/prisma-next PR: 51
File: agent-os/specs/2025-12-05-db-init-command/verifications/branch-3-runner.md:20-20
Timestamp: 2025-12-28T05:53:44.429Z
Learning: In code reviews across the repository, preserve the domain-specific term "SQL family instance" when referring to an instantiated SqlControlFamilyInstance that provides control-plane operations. Do not replace it with generic terms like "database connection" or "configuration". Treat this phrase as an architectural concept consistently used throughout the codebase.
Learnt from: wmadden
Repo: prisma/prisma-next PR: 193
File: packages/1-framework/2-authoring/psl-parser/README.md:57-57
Timestamp: 2026-03-01T16:19:49.924Z
Learning: Do not reference transient project artifacts (e.g., under projects/ such as specs, plans, milestone documents) from durable system documentation (package READMEs, architecture/docs under docs/). Remove or replace these references with links to stable architecture docs or package-level documentation that ages well as milestones evolve. Apply this pattern to all Markdown documentation files (READMEs and docs) across the repo.
Learnt from: wmadden
Repo: prisma/prisma-next PR: 193
File: packages/2-sql/2-authoring/contract-psl/README.md:72-73
Timestamp: 2026-03-01T16:20:08.178Z
Learning: Ensure that all READMEs and system documentation under any 'packages' or 'docs' directory do not reference transient project artifacts located under a 'projects' directory. Project planning docs, specs, and milestones are ephemeral and should not be linked from durable documentation. If cross-references are necessary, link only to stable, versioned, or archived artifacts, and clearly indicate any transient references to aid long-term maintenance.
Learnt from: wmadden
Repo: prisma/prisma-next PR: 234
File: packages/3-extensions/sql-orm-client/README.md:22-24
Timestamp: 2026-03-23T10:03:25.419Z
Learning: In prisma/prisma-next documentation (e.g., READMEs and architecture docs), treat `ExecutionPlan` and `SqlQueryPlan` as intentionally distinct types and do not recommend collapsing/merging them into a single term. `ExecutionPlan` is a contract-level type from `prisma-next/contract`, while `SqlQueryPlan` is a lane-level type from `prisma-next/sql-relational-core` that carries the AST, params, and meta; both are actively used and map to different architectural layers.
…stem doc, drop rulecard - Remove ForeignKeyReference class block from subsystem doc (ADR-level detail); replace with a plain behavioral sentence + ADR 226 link - Rewrite "lowering boundary (Contract IR → Schema IR)" jargon as plain English - Rename supabasePack → supabaseExtension in TS examples (import + extensionPacks usage) - Add native-type matching subsection to authoring surfaces (PSL @db.X type-constructor rule, Postgres rejection, TS field builder guidance) - Delete .agents/rules/cross-contract-fk-authoring.mdc; run pnpm rules:sync to remove symlinks - Remove trailing rulecard reference from subsystem doc authoring section - Remove two cross-contract-fk-authoring rulecard references from ADR 226 Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: Will Madden <[email protected]>
…c hygiene) Signed-off-by: Will Madden <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…upabase README diff TML-2500 M4 updated packages/3-extensions/supabase/README.md (link from old project spec to canonical docs + ADR 226). The check:upgrade-coverage gate requires the instructions.md to be touched whenever packages/3-extensions/ is in the diff; adds the HTML comment noting this is an incidental docs-only change. Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: Will Madden <[email protected]>
This is the documentation + close-out milestone (M4) for the cross-contract-refs project. All four implementation milestones have merged — M1 #745, M2 #752, M3a #756, M3b #765 — shipping cross-contract-space foreign-key references end-to-end. This PR migrates the project's durable knowledge into the canonical doc surfaces, records the project as shipped in the umbrella tracker, lands the final-retro lessons, and deletes the transient project workspace.
What shipped (recap, for the reader without context)
An app contract can now declare a foreign key from a local model to a model owned by an extension's contract space. The headline example, live in
examples/supabase:The planner lowers this to a real Postgres FK (
REFERENCES "auth"."users"("id") ON DELETE CASCADE), and a hermetic integration test proves the cascade fires against a live database.Where the knowledge landed (M4.1)
The design knowledge that lived in the transient
projects/cross-contract-refs/workspace migrated to three canonical, self-contained surfaces:docs/architecture docs/subsystems/6. Ecosystem Extensions & Packs.md(the extension hub). Records the current shape: the presence-based optionalspaceIddiscriminator onForeignKeyReference, dependency-graph construction, namespace-ownership rules, the aggregate-loader resolution rule, and the__unbound__DDL-qualification consequence.docs/architecture docs/adrs/ADR 226 - Cross-contract foreign-key references.md. Records the decisions: presence-based discrimination (chosen so local-FK JSON stays byte-identical), implicitextensionPacksresolution, the DAG + reverse-reference rejection, namespace ownership, Option-B non-navigable relations, the colon-prefix PSL grammar, and no-diagnostic cascade. Cross-links ADR 212 / 221 / 225..agents/rules/cross-contract-fk-authoring.mdc. The actionable Do/Don't for authoring a cross-contract FK, including the hard-won M3b lesson that the FK source column must match the target's native type (types { Uuid = String @db.Uuid }), and that@db.Xis type-constructor syntax (only valid inside atypes {}block), not a field attribute.Bookkeeping (M4.2)
projects/supabase-integration/README.md) status row flipped to ✅ Done & closed with the four PR links, and its link repointed from the (now-deleted) project spec to the durable subsystem doc.packages/3-extensions/supabase/README.mdpointing into the project dir — repointed to ADR 226 / the subsystem doc.Final retro (M4.3)
Per the mandatory-final-retro invariant, the process lessons from this project's execution landed in durable
drive/calibration surfaces:drive/spec/README.md— spec illustrative snippets (PSL grammar, IR shapes) must be re-verified against shipped code before execution, not copied as fact. (This project hit it four times.)drive/calibration/model-tier.md— a worked example confirming the existing "pin the dispatch tier explicitly, don't inherit" rule.drive/calibration/dod.md— test-dispatch briefs need a "claims preserved" acceptance criterion: state what the test proves, on the right surface.Definition of Done — verified
__unbound__unqualified REFERENCES)pg_constraint, verifier clean)pnpm lint:depsclean)All slices merged; mandatory final retro complete; durable docs landed; no open ADRs blocking.
Deletion
projects/cross-contract-refs/is removed. Verified before deletion: trace integrity passes (89 events, 9 dispatches, all round/dispatch pairs matched); no durable file (packages/,examples/,docs/,.agents/) references the deleted path;pnpm build+pnpm typecheckunaffected (nothing imports fromprojects/). References to cross-contract-refs that remain in other project workspaces (supabase-integration,postgres-rls, etc.) are transient-to-transient and get cleaned at those projects' own close-outs.Validation
pnpm typecheck: 138/138pnpm lint: 79/79pnpm lint:rules:symlinks: clean (the new rulecard wired)pnpm build: cleanRefs: TML-2500.
🤖 Generated with Claude Code
Summary by CodeRabbit