Repository navigation
TML-2777: control policy — gate migration DDL on each object's control policy - #693
Conversation
📝 WalkthroughWalkthroughThis PR introduces generic control policy call filtering for schema migrations. A new ChangesControl Policy Call Filtering Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
size-limit report 📦
|
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
abe8ac4 to
f61b22c
Compare
wmadden
left a comment
There was a problem hiding this comment.
Do a full review with the architect. This is introducing contractions that muddy our ubiquitous language. The property key may be control but it determines the "control policy". You don't "resolve control", you resolve the control policy
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.ts (1)
890-955:⚠️ Potential issue | 🟠 Major | ⚡ Quick winRun the control gate before raising operation-class conflicts.
This ordering can reject plans that should succeed with suppressed calls. The recipe strategies called out below can emit helper
dataTransform/setNotNullsteps for a missing object; undertoleratedorexternal,gateCallsByControlPolicy()should drop those steps, butkeepIfAllowed()records conflicts first andreturn notOk(conflicts)exits before the control gate runs.🤖 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-targets/3-targets/postgres/src/core/migrations/issue-planner.ts` around lines 890 - 955, The conflict check is happening before control gating, so dropped steps that should be suppressed by gateCallsByControlPolicy still produce conflicts; to fix, run gateCallsByControlPolicy first and then perform the operation-class conflict filtering on the gated calls: call gateCallsByControlPolicy(...) (using the same resolveSubject/options.toContract) to obtain gated.calls and gated.warnings, then build combinedBucketable/from those gated.calls and apply the keepIfAllowed/conflictForDisallowedCall logic against that gated set (or skip keepIfAllowed entirely if gate already removed disallowed steps); update the function references where conflicts are pushed (keepIfAllowed, conflictForDisallowedCall, allowedOperationClasses, gateCallsByControlPolicy, conflicts) so the early return notOk(conflicts) only happens after control gating has been applied.
🧹 Nitpick comments (1)
packages/2-sql/9-family/test/control-policy-ddl-gate.test.ts (1)
86-205: ⚡ Quick winConsider adding direct unit coverage for the warning/gating core.
This foundation test exercises
schemaIssueDdlIntent,controlPolicyAllowsDdlIntent,shouldEmitSchemaIssue, andresolveControlForSchemaIssue, but notgateCallsByControlPolicyorwarningForSuppressedSchemaIssue— the functions that produce thecontrol_managed_in_external_spacediagnostic and perform warning dedup. These are currently only validated indirectly via the postgres planner suite; a local unit (including the external-floor managed-override path and the dedup key) would pin the foundation behavior independently.Want me to draft these unit tests?
🤖 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/2-sql/9-family/test/control-policy-ddl-gate.test.ts` around lines 86 - 205, Add unit tests that directly exercise gateCallsByControlPolicy and warningForSuppressedSchemaIssue (in addition to the existing tests for schemaIssueDdlIntent, controlPolicyAllowsDdlIntent, shouldEmitSchemaIssue, and resolveControlForSchemaIssue). Specifically, add cases that: 1) verify the control_managed_in_external_space diagnostic is produced when a managed table exists in an external enum/namespace (exercise the external-floor managed-override path), and 2) verify warning deduplication by calling warningForSuppressedSchemaIssue multiple times with the same dedup key and asserting duplicates are suppressed. Use the same helpers (e.g., makeContract, SqlStorage build) and the existing SchemaIssue shapes to construct controlled scenarios; assert both the presence/absence of DDL gating via gateCallsByControlPolicy and the dedup behavior of warningForSuppressedSchemaIssue.
🤖 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 `@packages/2-sql/9-family/src/core/migrations/control-policy-ddl-gate.ts`:
- Around line 206-217: The function shouldEmitFieldEvent currently
short-circuits when contract.defaultControl === 'external', preventing per-table
managed overrides from reaching the control-policy gate; remove that early
return and always compute table = ctx.newTable ?? ctx.priorTable, compute
control = effectiveControl(table?.control, contract.defaultControl), then call
the existing gate logic (controlPolicyAllowsDdlIntent or the
gateCallsByControlPolicy path that uses fieldEventDdlIntent(event)) so
table-level managed overrides are evaluated and allowed to emit the
control_managed_in_external_space warning while still suppressing the call when
appropriate.
In
`@packages/3-targets/3-targets/postgres/src/core/migrations/control-policy-ddl-resolve.ts`:
- Around line 67-99: In postgresCallDdlIntent update the branch handling
'addEnumValues' so it returns 'alter' instead of 'create' (locate the switch in
function postgresCallDdlIntent and the case 'addEnumValues')—this ensures ALTER
TYPE ... ADD VALUE is treated as an alter operation and won't be incorrectly
allowed through as a create by the managed/tolerated policy logic.
In
`@packages/3-targets/3-targets/postgres/test/migrations/control-policy-planner.test.ts`:
- Around line 8-10: The tests currently call planIssues() directly and skip the
planner-level logic in planner.ts; add at least one integration test that uses
createPostgresMigrationPlanner().plan() (not planIssues) to exercise the gating
and merging behavior from planFieldEventOperations(), ensure
gatedFieldEvents.warnings are merged into the planner result, and assert that
PostgresPlanResult.warnings contains those warnings; implement the test by
constructing a planner via createPostgresMigrationPlanner(), provide a codec
hook that triggers a gated warning from planFieldEventOperations(), call
planner.plan(), and assert the returned result includes the merged warnings.
---
Outside diff comments:
In `@packages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.ts`:
- Around line 890-955: The conflict check is happening before control gating, so
dropped steps that should be suppressed by gateCallsByControlPolicy still
produce conflicts; to fix, run gateCallsByControlPolicy first and then perform
the operation-class conflict filtering on the gated calls: call
gateCallsByControlPolicy(...) (using the same resolveSubject/options.toContract)
to obtain gated.calls and gated.warnings, then build combinedBucketable/from
those gated.calls and apply the keepIfAllowed/conflictForDisallowedCall logic
against that gated set (or skip keepIfAllowed entirely if gate already removed
disallowed steps); update the function references where conflicts are pushed
(keepIfAllowed, conflictForDisallowedCall, allowedOperationClasses,
gateCallsByControlPolicy, conflicts) so the early return notOk(conflicts) only
happens after control gating has been applied.
---
Nitpick comments:
In `@packages/2-sql/9-family/test/control-policy-ddl-gate.test.ts`:
- Around line 86-205: Add unit tests that directly exercise
gateCallsByControlPolicy and warningForSuppressedSchemaIssue (in addition to the
existing tests for schemaIssueDdlIntent, controlPolicyAllowsDdlIntent,
shouldEmitSchemaIssue, and resolveControlForSchemaIssue). Specifically, add
cases that: 1) verify the control_managed_in_external_space diagnostic is
produced when a managed table exists in an external enum/namespace (exercise the
external-floor managed-override path), and 2) verify warning deduplication by
calling warningForSuppressedSchemaIssue multiple times with the same dedup key
and asserting duplicates are suppressed. Use the same helpers (e.g.,
makeContract, SqlStorage build) and the existing SchemaIssue shapes to construct
controlled scenarios; assert both the presence/absence of DDL gating via
gateCallsByControlPolicy and the dedup behavior of
warningForSuppressedSchemaIssue.
🪄 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: 72218e61-8529-4190-8c2f-7cee50576719
⛔ Files ignored due to path filters (2)
projects/control-policy/slices/planner-dispatch/plan.mdis excluded by!projects/**projects/control-policy/slices/planner-dispatch/spec.mdis excluded by!projects/**
📒 Files selected for processing (8)
packages/2-sql/9-family/src/core/migrations/control-policy-ddl-gate.tspackages/2-sql/9-family/src/core/migrations/field-event-planner.tspackages/2-sql/9-family/src/exports/control.tspackages/2-sql/9-family/test/control-policy-ddl-gate.test.tspackages/3-targets/3-targets/postgres/src/core/migrations/control-policy-ddl-resolve.tspackages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.tspackages/3-targets/3-targets/postgres/test/migrations/control-policy-planner.test.ts
f61b22c to
bcdb53b
Compare
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Per-node gate in the SQL family migration seam (field-event planner, issue planner, call-level filter): managed keeps full CREATE/ALTER/DROP, tolerated allows CREATE-if-missing only, external/observed emit nothing. When defaultControl is external, suppress all DDL in the contract space and surface a warn diagnostic if a per-object managed override would have emitted DDL; the plan still succeeds. Signed-off-by: Will Madden <[email protected]>
Replace five bare `as` casts in the control-policy DDL gate and the
Postgres call resolver with type-safe narrowing:
- the two `ns.enum as Record<...>` index casts drop the cast entirely
because the namespace `enum` slot is already typed as
`Readonly<Record<string, PostgresEnumStorageEntry>>`
- the `rawSql` intent classifier reads `call.op` directly, since the
switch over `factoryName` narrows the call to `RawSqlCall`
- the `call as {...field?}` coordinate read becomes a `postgresCallFields`
accessor that narrows the discriminated union per field via `in`
- the partial `StrategyContext` cast is replaced by a local
storage-based `ddlSchemaNameForNamespace` helper (identical logic to
resolveDdlSchemaForNamespace) so no fabricated context is needed
Type-safety only; behaviour unchanged. Keeps the lint:casts ratchet at
delta 0.
Signed-off-by: Will Madden <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…elper Introduce a free-function `isStorageTable` type guard beside the existing `isPostgresEnumStorageEntry`, and a shared `storageTableAt` lookup helper, so the migration control-policy resolvers stop hand-rolling byte-identical `instanceof StorageTable` table lookups in two packages. Signed-off-by: Will Madden <[email protected]>
Rebuild the per-node control-policy DDL gate on the framework migration taxonomy instead of a parallel one. Each control policy now maps to a set of allowed `MigrationOperationClass` values (managed=all, tolerated=additive-only, external/observed=none) and gating reads `call.operationClass` directly, so the bespoke `DdlIntent` axis and its two `factoryName`/`SchemaIssue` derivations are gone. The `external` namespace floor is now a single, fail-closed enforcement point: under an external default every op is dropped, including ops whose subject does not resolve and the lifted codec field-event ops — the safe default on an unrecognised op is suppress, not emit. Delete the dead `SqlPlannerControlWarning` diagnostic and all its plumbing (it was produced, threaded onto plan results, and read by nobody; the framework success result has no warnings channel). Surfacing the mis-declaration diagnostic is deferred to a follow-up; this slice ships the floor behaviour (zero DDL into an external namespace, plan still proceeds). Rename the modules to `control-policy.ts` in each package, rename the policy-meaning identifiers off the ambiguous bare `control` onto `controlPolicy`, drop the `gate*` jargon in favour of `filterCallsByControlPolicy`, and consolidate subject resolution onto the single op-call path. Signed-off-by: Will Madden <[email protected]>
…ive policies The operationClass reframe gated tolerated on `["additive"]`, but additive covers additive ALTERs on existing objects (addColumn, createIndex, constraint adds, additive setDefault). operationClass is a danger axis, not a create-vs-modify lifecycle axis, so it cannot express tolerated. That let tolerated emit ALTERs on existing objects, contradicting its create-if-absent contract. Gate tolerated on a "creates a whole new top-level storage object" predicate instead. The target resolves a `createsNewObject` flag from an explicit, fail-closed set of object-creation factory calls (createTable, createEnumType, createSchema); any call not in the set — including unrecognised or extension-contributed ops — is treated as not object-creation and suppressed under tolerated. This is a single yes/no question, not a revived lossy create/alter/drop classification with a permissive default. Generalise the fail-closed floor beyond external: a call is kept only when its effective control policy positively allows it, so observed (no DDL) drops unresolved-subject ops (e.g. createExtension) just like external, and tolerated drops anything not provably object-creation (including unresolved subjects). The external default remains an un-overridable floor. Remove the now-unused exports resolveControlPolicyForSchemaIssue, resolveNamespaceId, and controlPolicyAllowedOperationClasses (and the helpers they pulled in). Restore AC1: tolerated emits createTable for an absent table and emits nothing for an existing table missing a column or with drift. Signed-off-by: Will Madden <[email protected]>
…fensive instanceof Rename ResolvedControlSubject to ControlPolicySubject (and resolveSubject to resolveControlPolicySubject / resolvePostgresCallControlPolicySubject) so the type names the object a control policy governs rather than inventing vague jargon; rewrite the doc comment off the "control-relevant facts" phrasing. Trust the validated contract in storageTableAt: the indexed access is already typed StorageTable | undefined, so return it directly and delete the now-unused isStorageTable instanceof guard. Use the ifDefined helper for the optional-property spreads in the postgres control-policy resolver. Add a planner-level test driving createPostgresMigrationPlanner().plan(...) end-to-end to prove a tolerated table's non-create add-column is suppressed through the real planner entry point. Signed-off-by: Will Madden <[email protected]>
634fd4e to
5ebc21a
Compare
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 `@packages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.ts`:
- Around line 932-941: The control-policy filtering currently applied by
filterCallsByControlPolicy (using resolvePostgresCallControlPolicySubject) runs
after mapIssueToCall, so unsupported unmanaged issues are already turned into
hard conflicts; fix by resolving control-policy subjects earlier and skipping
conflict generation for suppressed issues: either call
resolvePostgresCallControlPolicySubject for each issue before mapIssueToCall and
skip mapping when the control policy marks the subject as
tolerated/external/observed, or add control-aware checks inside mapIssueToCall
(and specifically inside the non-missing branches that produce conflicts and the
type_values_mismatch branch) to suppress creating conflict calls when the
control policy indicates they should be ignored. Ensure you update references to
filterCallsByControlPolicy/mapIssueToCall and the resolver
resolvePostgresCallControlPolicySubject accordingly so suppressed issues never
reach conflict-generation code 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: 9ad29a87-204c-41b4-84b2-a93db4aa5e67
📒 Files selected for processing (9)
packages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/ir/sql-storage.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/9-family/src/core/migrations/control-policy.tspackages/2-sql/9-family/src/exports/control.tspackages/2-sql/9-family/test/control-policy.test.tspackages/3-targets/3-targets/postgres/src/core/migrations/control-policy.tspackages/3-targets/3-targets/postgres/src/core/migrations/issue-planner.tspackages/3-targets/3-targets/postgres/src/core/migrations/planner.ts
…ect's control policy (prisma#694) ## At a glance **Control policy** is a per-object setting that says *how much the framework manages a given database object* — from `managed` (fully owned) to `external` (known about but never touched — think Supabase's `auth.users`). The policy lives on the contract IR already (slice 1). **This PR teaches the schema verifier to react to it**, instead of demanding every object match the contract exactly. The motivating case: an app declares a foreign key into Supabase's `auth.users` and marks that table `external`. The verifier should confirm the columns the app *declared* are present and shape-compatible — but ignore the dozens of columns Supabase adds that the app never mentioned. Today the verifier treats every object as `managed`, so any such divergence is an error. After this PR it branches on `effectiveControl(node.control, contract.defaultControl)` and maps the **existing** issue kinds onto pass / warn / fail / suppressed — no new issue kinds, no result-shape change: | Live-vs-declared | `managed` | `tolerated` | `external` | `observed` | |---|---|---|---|---| | Declared column missing | fail | fail | fail | warn | | Declared column type-incompatible | fail (exact) | fail (exact) | fail (compatible-shape) | warn | | Extra column | fail | suppress | suppress | warn | | Extra constraint / index | fail | fail | suppress | warn | | Enum value drift | fail | fail | suppress | warn | | Object absent entirely | fail | fail | fail | warn | ## The decision **Strict by default.** A non-`managed` policy does *not* soften checks on the columns you actually declared — `tolerated` and `external` still **fail** on a declared column that's missing or type-incompatible; they only relax what they say about *undeclared* extras. Only `observed` downgrades everything to `warn`. The reasoning is one-directional and the deciding factor: **loosening a check later (fail → warn) is a non-breaking change, but tightening one (warn → fail) turns previously-green builds red.** Starting strict keeps the cheaper evolution path open. Two supporting decisions follow the same instinct: - **Conservative compatible-shape for `external`:** Postgres's `columnsCompatible` is identical-or-explicitly-listed, and the list is empty in v0.1 — so `varchar` vs `text` is still a `fail` today. Widening the compatible set later is additive and safe. - **`external` requires existence:** an `external` object (or enum) that is absent entirely is a `fail` — declaring an external dependency that isn't there is a real error, not a tolerable divergence. ## How it works The severity mapping is one small pure pair — `verifierDisposition` / `classifyVerifierIssueKind` — placed in the framework-agnostic `@prisma-next/contract` foundation package so both the SQL and Mongo families consume the *same* table with no upward import (mirroring the `effectiveControl` precedent from slice 1). Each family base calls it through thin `pushControlled*` emit helpers. The compatible-shape relation is a **target-supplied hook**: abstract on the family base, concrete `postgresColumnsCompatible` on Postgres, threaded through both the migration-verify and runtime-verify paths so they agree. Enum (`PostgresEnumStorageEntry`) verification dispatches through the same table — the proof that target-contributed node kinds flow through one dispatch rather than a parallel hardcoded path. ## Scope **In:** four-way severity/suppression dispatch on the SQL + Mongo family verifier bases; the target-supplied compatible-shape hook + the conservative Postgres relation; enum dispatch; per-policy tests for both families. **Out (unchanged):** planner DDL gating (prisma#693), TS/PSL authoring (prisma#692 / slice 5), and widening the compatible-pair list. **Testing:** `pnpm typecheck` (contract, family-sql, target-postgres, adapter-postgres); package tests (contract 159, family-sql 309, target-postgres 331, adapter-postgres 537 + 4 expected-fail) with real status assertions per policy for SQL, Mongo, and enums; `pnpm lint:deps` clean, `pnpm lint:casts` delta 0. ## Alternatives considered - **Loosen by default** (let `tolerated`/`external` soften checks on declared columns too). Rejected on the one-directional argument above: we can always relax later without breaking anyone; we cannot tighten without breaking green builds. - **Introduce new `SchemaIssue` kinds for tolerated/external divergence.** Rejected: reusing the existing kinds plus a disposition keeps the result shape stable and avoids forcing every issue consumer to learn a new vocabulary. - **Aggressive compatible-shape** (treat `varchar`/`text`, `int4`/`int8`, etc. as compatible out of the gate). Deferred: starting from exact-equality and widening additively is safe; starting wide and narrowing is not. **Acknowledged transitional shapes (not blocking):** `PostgresSchemaVerifier.verifyCommonSqlSchema` is still an empty SPI-migration stub, so the class-based `columnsCompatible` is reached via the `verifySqlSchema` function option rather than the abstract method — two seams for one concept, to consolidate when the SPI migration lands. Whole extra tables/collections still `fail` under `tolerated`/`external` (the severity table is column/constraint-grained) — defensible under strict-by-default. --------- Signed-off-by: Will Madden <[email protected]> Co-authored-by: Will Madden <[email protected]>
At a glance
Control policy is a per-object setting that says how much the framework's migration machinery is allowed to touch a given database object — from
managed(fully owned: create, alter, drop) toexternal(known about but never emitted — think Supabase'sauth.users). The policy lives on the contract IR already (slice 1). This PR teaches the migration planner to obey it. Before, the planner treated every object as fully owned and emitted whatever DDL the diff implied. Now it consultseffectiveControl(node.control, contract.defaultControl)for each object first:managedCREATE/ALTER/DROP(unchanged from today)toleratedCREATEif missing — neverALTER/DROPexternalobservedSo a table marked
externalproduces no migration DDL, even when the live database differs from the contract — which is exactly what you want for a table some other system owns.The decision
On top of the per-object gate sits an un-overridable safety floor: when a contract space's
defaultControlisexternal, the planner emits zero DDL into that space's namespaces even if an object inside carries a per-objectcontrol: 'managed'. A per-object override cannot escalate above the namespace floor. When the floor suppresses DDL that amanageddeclaration would otherwise have produced, the planner emits awarn-level diagnostic (control_managed_in_external_space) naming the object and namespace — and lets the plan proceed.We chose
warn, notfail: the safe thing has already happened (nothing leaked into the external schema), so halting the entire plan would be heavier than a single mis-declaration warrants. And we made the floor un-overridable on purpose — anexternalspace is precisely where a straymanagedobject must not be able to punch a hole.How it works
The per-node gate is a pure function of effective control, placed on the SQL family seam so any SQL target inherits it; Postgres supplies the concrete planner wiring. The external-namespace floor is computed per namespace from the space's
defaultControl, independent of the per-object values beneath it. Thewarndiagnostic is attached to the concretePostgresPlanResult. Unit tests cover all four policy gates plus the mis-declaration (managed-in-external) case with real assertions.Scope
In: per-node DDL gate (SQL family seam + Postgres planner), the external-namespace floor, the
warn-level conflict diagnostic, and unit tests for all four policies + the mis-declaration case.Out (unchanged): verifier comparison strategies (#694), TS/PSL authoring (#692 / slice 5), the Mongo planner, and introspection defaulting.
Known follow-up (out of scope, tracked): the
warndiagnostic is produced onPostgresPlanResult, but the frameworkMigrationPlannerResultsuccess variant has nowarningsfield yet, so nothing surfaces it to a user end-to-end. Wiring it through the framework result type + CLI is tracked in TML-2792.Testing:
pnpm typecheck(family-sql,target-postgres), package tests (family-sql 309/309, target-postgres 339/339),pnpm lint:castsdelta 0,pnpm lint:deps— all green.Alternatives considered
failinstead ofwarnfor managed-in-external. Rejected: the unsafe outcome was already prevented, so a hard failure over-penalises a recoverable mis-declaration.managed. Rejected: that defeats the purpose of marking a whole spaceexternal— the floor exists so a single mis-declared object can't escalate the space back into "framework emits DDL here."ascasts (the first implementation). Replaced: an independent review flagged 5 net-new bare casts tripping thelint:castsratchet; they were eliminated by narrowing (typed accessors / discriminated-union narrowing), leaving the ratchet delta at 0 with noblindCast.Summary by CodeRabbit
Release Notes
New Features
Tests