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

refactor(contract): rename effectiveControl → effectiveControlPolicy (TML-2797) - #699

Merged
wmadden merged 1 commit into
mainfrom
tml-2797-rename-effective-control-policy
Jun 2, 2026
Merged

wmadden merged 1 commit into
mainfrom
tml-2797-rename-effective-control-policy

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

At a glance

// before
import { effectiveControl } from '@prisma-next/contract/types';
const policy = effectiveControl(table.control, contract.defaultControl);

// after
import { effectiveControlPolicy } from '@prisma-next/contract/types';
const policy = effectiveControlPolicy(table.control, contract.defaultControl);

A pure mechanical rename of one exported function. No behaviour change.

The decision

The control-policy primitive (ControlPolicy = 'managed' | 'tolerated' | 'external' | 'observed') introduced a resolver named effectiveControl. Reading the slice PRs as a fresh team member, "control" is overloaded: the codebase already uses control plane (the migration/verification side of the system) as a load-bearing term, and the contract was using bare "control" as shorthand for "control policy". The collision makes call-sites like effectiveControl(node.control, …) read ambiguously.

This renames the resolver to effectiveControlPolicy so the name says what it returns — the effective ControlPolicy for a storage-plane node.

Why land it separately, first

effectiveControl is defined in @prisma-next/contract (already on main) and consumed by three open PRs in flight — the verifier dispatch (#694), the planner dispatch (#693), and the target serializers. If each PR renamed the merged definition independently, they would three-way-conflict on the substrate file.

Landing the rename as its own small PR to main and rebasing the three open PRs onto it removes that hazard: each rework then only touches its own consumption.

Scope

In:

  • effectiveControl → effectiveControlPolicy (function + re-export in contract/src/exports/types.ts)
  • the merged consumers/tests (contract unit test; postgres/sqlite/mongo serializer round-trip tests)

Out (handled inside each slice's own rework, per their review artifacts): DdlIntent, tableControl/collectionControl, verifierDisposition, gateCallsByControlPolicy, and the .control IR field name itself.

Verification

  • @prisma-next/contract rebuilt — dist/types.d.mts now exports effectiveControlPolicy.
  • Tests green: contract (153), target-postgres (358), target-sqlite (99), target-mongo (398).
  • Typecheck green across all four packages.
  • No stale effectiveControl token remains in the tree.

Alternatives considered

Linear: TML-2797

Summary by CodeRabbit

  • Refactor
    • Internal improvements to control policy function naming and organization for enhanced code clarity across the framework.

@wmadden-electric
wmadden-electric requested a review from a team as a code owner June 2, 2026 14:37
@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@wmadden-electric, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 21 minutes and 47 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 69f6385d-253b-4e01-8720-5195e3a35822

📥 Commits

Reviewing files that changed from the base of the PR and between 63f5b97 and fcc91c9.

📒 Files selected for processing (6)
  • packages/1-framework/0-foundation/contract/src/control-policy.ts
  • packages/1-framework/0-foundation/contract/src/exports/types.ts
  • packages/1-framework/0-foundation/contract/test/control-policy.test.ts
  • packages/3-mongo-target/1-mongo-target/test/mongo-target-contract-serializer.test.ts
  • packages/3-targets/3-targets/postgres/test/postgres-contract-serializer.test.ts
  • packages/3-targets/3-targets/sqlite/test/sqlite-contract-serializer.test.ts
📝 Walkthrough

Walkthrough

The PR renames the exported helper function effectiveControl to effectiveControlPolicy in the contract foundation module, updates its re-export in the types barrel, and propagates the function name change across the control-policy test suite and dependent serializer tests in mongo-target and targets (Postgres and SQLite packages).

Changes

Function Rename and Test Updates

Layer / File(s) Summary
Function rename and export update
packages/1-framework/0-foundation/contract/src/control-policy.ts, packages/1-framework/0-foundation/contract/src/exports/types.ts
The exported function effectiveControl is renamed to effectiveControlPolicy with the same parameter list and precedence logic (nodeControl → defaultControl → 'managed'), and the re-export is updated to match.
Control-policy test suite update
packages/1-framework/0-foundation/contract/test/control-policy.test.ts
The test suite is updated to import and validate effectiveControlPolicy, with all precedence and per-policy resolution assertions retained under the new function name.
Dependent serializer test updates
packages/3-mongo-target/1-mongo-target/test/mongo-target-contract-serializer.test.ts, packages/3-targets/3-targets/postgres/test/postgres-contract-serializer.test.ts, packages/3-targets/3-targets/sqlite/test/sqlite-contract-serializer.test.ts
Mongo-target, Postgres, and SQLite contract serializer tests are updated to import and call effectiveControlPolicy for effective control assertions during serialize/deserialize round-trip and per-collection/per-node control validation.

Possibly related PRs

  • prisma/prisma-next#691: Appears to be the PR that introduced the original effectiveControl function before this rename refactor.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A name becomes clearer, more precise,
effectiveControl finds its voice:
effectiveControlPolicy rings thrice true,
through exports, tests, and targets too—
the precedence holds, the logic stays,
just names refreshed for clearer days! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: a mechanical rename of the exported function from effectiveControl to effectiveControlPolicy, with the tracking ticket reference included.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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-2797-rename-effective-control-policy

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.

❤️ Share

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

…(TML-2797)

The contract used bare "control" as shorthand for "control policy", which
collides with the existing "control plane" vocabulary. Rename the resolver
to effectiveControlPolicy so the ubiquitous language is unambiguous.

Landing this on main ahead of the slice-2/3/4 reworks avoids three-way
conflicts on the merged substrate file when each open PR adopts the name.

Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric force-pushed the tml-2797-rename-effective-control-policy branch from 63f5b97 to fcc91c9 Compare June 2, 2026 14:39
@wmadden-electric
wmadden-electric enabled auto-merge (squash) June 2, 2026 14:39
@pkg-pr-new

pkg-pr-new Bot commented Jun 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/cli-telemetry

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: fcc91c9

@wmadden
wmadden disabled auto-merge June 2, 2026 14:43
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 135.67 KB (0%)
postgres / emit 108.02 KB (0%)
mongo / no-emit 75.76 KB (0%)
mongo / emit 70.75 KB (0%)
cf-worker / no-emit 164.62 KB (0%)
cf-worker / emit 133.79 KB (0%)

@wmadden
wmadden merged commit 9bf2531 into main Jun 2, 2026
20 checks passed
@wmadden
wmadden deleted the tml-2797-rename-effective-control-policy branch June 2, 2026 14:43
wmadden-electric pushed a commit that referenced this pull request Jun 3, 2026
…-2800)

Substrate-first field rename completing the ubiquitous-language pass
started in #699 (effectiveControl → effectiveControlPolicy). No behaviour change.

Signed-off-by: Will Madden <[email protected]>
medz pushed a commit to medz/prisma-next that referenced this pull request Jun 5, 2026
…-2800) (prisma#707)

## At a glance

```ts
// before
const contract = defineContract({ ..., defaultControl: 'tolerated' });

// after
const contract = defineContract({ ..., defaultControlPolicy: 'tolerated' });
```

A pure mechanical rename of the contract-level default field. No
behaviour change.

## The decision

The control-policy primitive (`ControlPolicy = 'managed' | 'tolerated' |
'external' | 'observed'`) introduced a contract-level default named
`defaultControl`. Reading the merged slice PRs as a fresh team member,
"control" is overloaded: the codebase already uses **control plane** as
a load-bearing term, and the contract was using bare "control" as
shorthand for "control **policy**". This rename completes the
[`effectiveControl →
effectiveControlPolicy`](prisma#699)
cleanup landed in prisma#699 — the field-name half of the same
ubiquitous-language pass.

After this PR, every policy-bearing identifier on the storage plane
reads `…ControlPolicy` rather than bare `…Control` (the per-node
`.control` IR field is the deliberate exception — renaming it would
change every node's serialized contract hash, see "Alternatives
considered").

## Scope

In:
- `defaultControl` → `defaultControlPolicy` on the contract IR
(`@prisma-next/contract` and the Mongo contract foundation), its arktype
validators, the TS authoring builder option, and every reader (verifier,
planner).
- The serialized JSON key on the contract — and a regeneration of the
one committed example contract that exercises it
(`projects/supabase-integration/example/migrations/supabase/contract.{json,d.ts}`).
- Test fixtures and helpers that reference the old name.

Out (deliberately):
- The per-node `.control` field — renaming it would alter the serialized
JSON of every contract that uses control policies, regardless of the
value. The collision the rename addresses is the **default**-side
identifier; the per-node field stays `.control` for now.

## Hash impact

The feature was merged to `main` only yesterday (prisma#691 on 2026-06-02). No
downstream contract is yet using a non-default `defaultControl` value.
The omit-when-default idiom means the JSON key only appears when the
author explicitly sets a non-default policy; existing contracts in the
wild that don't set it will be byte-for-byte unchanged.

## Verification

- `@prisma-next/contract`, `@prisma-next/mongo-contract`, and
`@prisma-next/sql-contract` rebuilt — `dist/*.d.mts` exports the new
field.
- Tests green: contract (160), sql-contract (129), mongo-contract (117),
sql-contract-ts (270), family-sql (333), family-mongo (148),
target-postgres (377), target-sqlite (104), target-mongo (404) — **2042
passing**.
- Typecheck green across all touched packages.
- `pnpm lint:deps` clean.
- No stale `defaultControl` token remains in source/tests (the design
docs under `projects/control-policy/` continue to spell the pre-rename
name — they describe pre-rename state and are deleted at project
close-out, mirroring the precedent prisma#699 set for `plan.md`).

## Alternatives considered

- **Carry the rename inside the e2e demonstration slice (TML-2796)** —
no extra PR, but risks colliding with any open branch that reads the
field; landing it as substrate-first matches how prisma#699 sequenced
`effectiveControl`, removing the rebase hazard entirely.
- **Also rename the per-node `.control` field → `.controlPolicy`** —
would alter the serialized JSON of every node carrying a control policy,
churning contract hashes for every consumer regardless of value. Not
required to resolve the default-side ambiguity. Deliberately out of
scope.

Linear: TML-2800


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Standardized contract control policy property naming across MongoDB,
SQL, and related packages for improved consistency and clarity in
contract definitions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Will Madden <[email protected]>
Co-authored-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.

2 participants