TML-2727: delete storage namespace construction shims (S1.D-1)#630
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds Mongo and SQL namespace builders; requires pre-built Namespace maps for storage inputs; updates validators, serializers, authoring, runtime wiring, test utilities, and many tests to use the builders and to pass materialized namespaces (including unbound slot handling). ChangesNamespace builders and storage input tightening
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
@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/extension-cipherstash
@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: |
size-limit report 📦
|
Records the five review findings (identity-named concretion + static factory, drop instanceof discrimination, justify/remove the __unbound__ cast, use ifDefined, clarify raw-vs-hydrated) as round-2 actions with a refusal trigger guarding the public structural-type/.d.ts assignability. Signed-off-by: Will Madden <madden@prisma.io>
Rename bound namespace concretions to SqlBoundNamespace / MongoBoundNamespace with static factories, discriminate map entries by family kind instead of instanceof, brand __unbound__ on SqlStorageInput, and use ifDefined at hydration boundaries. Signed-off-by: wmadden-electric <286902546+wmadden-electric@users.noreply.github.com>
The granular S1.D ticket (TML-2625) was canceled and archived in the 2026-05-20 ticket cleanup; recreated as TML-2727 (the single live S1.D ticket). Also: the subsumed cleanup tickets (TML-2579/2580/2582/2545/ 2563) are already Canceled, so PDoD10 needs no close-out dispatch \u2014 mark it satisfied in the coverage map. Signed-off-by: Will Madden <madden@prisma.io>
…efer structural items A 2026-05-29 inventory falsified S1.D as one deletions-only slice: three of the eight subsumed surfaces carry structural prerequisites (a contract.json- shape coordinate change, a hash-computation change, a query-builder type rewrite). Per the narrow-and-defer decision, S1.D ships the three clean deletes now as independent parallel slices (construction-discipline shims, canonicalizer family hook, migration -> elementCoordinates) and defers the three structural items to follow-ups recorded in deferred.md. Amends PDoD5/PDoD10 to scope the deferred items out; restructures the plan composition into parallel groups (no stack); adds the three lean slice specs. Signed-off-by: Will Madden <madden@prisma.io>
Remove SqlNamespacePayload, MongoNamespacePayload, normaliseNamespaceEntry, and DEFAULT_NAMESPACES. SqlStorage and MongoStorage now require built Namespace instances; call sites use buildSqlNamespace / buildMongoNamespace. Signed-off-by: Will Madden <madden@prisma.io>
…ndCast Signed-off-by: Will Madden <madden@prisma.io>
Records the five review findings (identity-named concretion + static factory, drop instanceof discrimination, justify/remove the __unbound__ cast, use ifDefined, clarify raw-vs-hydrated) as round-2 actions with a refusal trigger guarding the public structural-type/.d.ts assignability. Signed-off-by: Will Madden <madden@prisma.io>
Rename bound namespace concretions to SqlBoundNamespace / MongoBoundNamespace with static factories, discriminate map entries by family kind instead of instanceof, brand __unbound__ on SqlStorageInput, and use ifDefined at hydration boundaries. Signed-off-by: wmadden-electric <286902546+wmadden-electric@users.noreply.github.com>
d961ba0 to
7aa9b78
Compare
Signed-off-by: wmadden-electric <286902546+wmadden-electric@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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-mongo-family/1-foundation/mongo-contract/src/ir/mongo-storage.ts`:
- Around line 15-18: The namespaces field on MongoStorageInput is too loose and
the constructor uses an unsafe cast; change MongoStorageInput.namespaces from
Readonly<Record<string, Namespace>> to Readonly<Record<string, MongoNamespace>>
so types align with MongoStorage.namespaces, and remove the bare cast in the
constructor (replace Object.freeze(input.namespaces) as Readonly<Record<string,
MongoNamespace>> with Object.freeze(input.namespaces) directly). If runtime
validation is required, explicitly map/validate each entry from input.namespaces
to a MongoNamespace before freezing instead of using an "as" cast; update
references to MongoStorageInput.namespaces, MongoStorage.namespaces and the
constructor initialization accordingly.
In
`@packages/2-mongo-family/1-foundation/mongo-contract/test/mongo-storage.test.ts`:
- Around line 76-83: The test currently only verifies that constructing
MongoStorage with a namespaces map succeeds; update it to assert the "requires
namespaces" contract by adding a negative-path assertion that constructing new
MongoStorage without the namespaces field throws (e.g., call new MongoStorage({
storageHash: hash }) and expect it to throw or throw a specific error), while
keeping the existing happy-path that uses UNBOUND_NAMESPACE_ID and
MongoUnboundNamespace.instance to ensure valid input still does not throw;
reference the MongoStorage constructor and the
UNBOUND_NAMESPACE_ID/MongoUnboundNamespace.instance symbols to locate the code
to change.
In `@packages/2-sql/1-core/contract/src/validators.ts`:
- Around line 448-450: Replace the bare TypeScript cast on the local variable
"validated" (currently using "result as SqlStorageInput & { readonly
namespaces?: SqlStorageInput['namespaces']; }") with the project's blindCast
utility; import blindCast from "`@prisma-next/utils/casts`" and call
blindCast<SqlStorageInput & { readonly namespaces?:
SqlStorageInput['namespaces']; }, "Describe reason here">(result) so the type
assertion uses blindCast and includes a short reason string, keeping the
variable name "validated" and the same target type.
- Around line 451-458: The validateStorage path currently blindCast()s the
namespace map produced by buildSqlNamespaceMap(validated.namespaces ?? {}) but
buildSqlNamespaceMap only creates SqlUnboundNamespace.instance when an entry
with id === UNBOUND_NAMESPACE_ID is present; fix validateStorage by detecting
when validated.namespaces is missing or does not contain UNBOUND_NAMESPACE_ID
and then injecting SqlUnboundNamespace.instance into the map before calling
blindCast()/returning the new SqlStorage, referencing validateStorage,
buildSqlNamespaceMap, SqlUnboundNamespace.instance, UNBOUND_NAMESPACE_ID and
blindCast; alternatively you may enforce the __unbound__ entry in
createSqlStorageSchema, but pick one approach and update validateStorage (or the
schema) consistently so the structural cast never relies on a non-existent
__unbound__ slot.
🪄 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: 27120888-f32b-412a-9faa-4ee7578832f5
⛔ Files ignored due to path filters (7)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlprojects/contract-ir-planes/deferred.mdis excluded by!projects/**projects/contract-ir-planes/plan.mdis excluded by!projects/**projects/contract-ir-planes/slices/canonicalizer-family-hook/spec.mdis excluded by!projects/**projects/contract-ir-planes/slices/construction-discipline-shims/spec.mdis excluded by!projects/**projects/contract-ir-planes/slices/migration-element-coordinates/spec.mdis excluded by!projects/**projects/contract-ir-planes/spec.mdis excluded by!projects/**
📒 Files selected for processing (78)
packages/1-framework/1-core/framework-components/src/ir/namespace.tspackages/2-mongo-family/1-foundation/mongo-contract/src/contract-schema.tspackages/2-mongo-family/1-foundation/mongo-contract/src/exports/index.tspackages/2-mongo-family/1-foundation/mongo-contract/src/ir/build-mongo-namespace.tspackages/2-mongo-family/1-foundation/mongo-contract/src/ir/mongo-storage.tspackages/2-mongo-family/1-foundation/mongo-contract/test/element-coordinates.test.tspackages/2-mongo-family/1-foundation/mongo-contract/test/mongo-storage.test.tspackages/2-mongo-family/1-foundation/mongo-contract/test/validate-storage.test.tspackages/2-mongo-family/2-authoring/contract-psl/src/interpreter.tspackages/2-mongo-family/2-authoring/contract-psl/test/interpreter.test.tspackages/2-mongo-family/2-authoring/contract-ts/src/contract-builder.tspackages/2-sql/1-core/contract/package.jsonpackages/2-sql/1-core/contract/src/exports/types.tspackages/2-sql/1-core/contract/src/ir/build-sql-namespace.tspackages/2-sql/1-core/contract/src/ir/sql-storage.tspackages/2-sql/1-core/contract/src/types.tspackages/2-sql/1-core/contract/src/validators.tspackages/2-sql/1-core/contract/test/build-sql-namespace-map.test.tspackages/2-sql/1-core/contract/test/element-coordinates.test.tspackages/2-sql/1-core/contract/test/sql-storage.test.tspackages/2-sql/2-authoring/contract-ts/src/build-contract.tspackages/2-sql/4-lanes/relational-core/test/codec-descriptor-registry.test.tspackages/2-sql/4-lanes/sql-builder/test/runtime/field-proxy.test.tspackages/2-sql/5-runtime/test/async-iterable-result.test.tspackages/2-sql/5-runtime/test/codec-integrity.test.tspackages/2-sql/5-runtime/test/contract-codec-registry.test.tspackages/2-sql/5-runtime/test/intercept-decoding.test.tspackages/2-sql/5-runtime/test/marker-verification.test.tspackages/2-sql/5-runtime/test/marker-vs-intercept-ordering.test.tspackages/2-sql/5-runtime/test/mutation-default-generators.test.tspackages/2-sql/5-runtime/test/parameterized-types.test.tspackages/2-sql/5-runtime/test/runtime-ctx-passthrough.test.tspackages/2-sql/5-runtime/test/scope-plumbing.test.tspackages/2-sql/5-runtime/test/sql-context.codec-context.test.tspackages/2-sql/5-runtime/test/sql-context.test.tspackages/2-sql/5-runtime/test/sql-family-adapter.test.tspackages/2-sql/5-runtime/test/sql-runtime-abort.test.tspackages/2-sql/5-runtime/test/sql-runtime.test.tspackages/2-sql/5-runtime/test/utils.tspackages/2-sql/9-family/src/core/ir/sql-contract-serializer-base.tspackages/2-sql/9-family/test/contract-to-schema-ir.test.tspackages/2-sql/9-family/test/control-instance.descriptor-self-consistency.test.tspackages/2-sql/9-family/test/field-event-planner.test.tspackages/2-sql/9-family/test/schema-verify.helpers.tspackages/3-extensions/cipherstash/test/cipherstash-codec.test.tspackages/3-extensions/pgvector/test/migrations/planner.behavior.test.tspackages/3-extensions/pgvector/test/migrations/planner.contract-to-schema-ir.test.tspackages/3-extensions/pgvector/test/migrations/planner.storage-types.test.tspackages/3-targets/3-targets/postgres/src/core/postgres-contract-serializer.tspackages/3-targets/3-targets/postgres/test/element-coordinates.test.tspackages/3-targets/3-targets/postgres/test/migrations/issue-planner.test.tspackages/3-targets/3-targets/postgres/test/migrations/verify-postgres-namespaces.test.tspackages/3-targets/3-targets/sqlite/test/migrations/issue-planner.test.tspackages/3-targets/3-targets/sqlite/test/migrations/nullability-backfill.test.tspackages/3-targets/3-targets/sqlite/test/migrations/planner-strategies.test.tspackages/3-targets/3-targets/sqlite/test/migrations/planner.authoring-surface.test.tspackages/3-targets/6-adapters/postgres/test/migrations/cross-namespace-fk.integration.test.tspackages/3-targets/6-adapters/postgres/test/migrations/db-init-update.cli.integration.test.tspackages/3-targets/6-adapters/postgres/test/migrations/fixtures/runner-fixtures.tspackages/3-targets/6-adapters/postgres/test/migrations/planner.authoring-surface.test.tspackages/3-targets/6-adapters/postgres/test/migrations/planner.codec-field-event.test.tspackages/3-targets/6-adapters/postgres/test/migrations/planner.fk-config.test.tspackages/3-targets/6-adapters/postgres/test/migrations/planner.reconciliation.integration.test.tspackages/3-targets/6-adapters/postgres/test/migrations/planner.reconciliation.test.tspackages/3-targets/6-adapters/postgres/test/migrations/planner.referential-actions.test.tspackages/3-targets/6-adapters/postgres/test/migrations/planner.semantic-satisfaction.test.tspackages/3-targets/6-adapters/postgres/test/migrations/planner.storage-types.integration.test.tspackages/3-targets/6-adapters/postgres/test/migrations/runner.multi-space.integration.test.tspackages/3-targets/6-adapters/postgres/test/migrations/runner.unbound-namespace.integration.test.tspackages/3-targets/6-adapters/postgres/test/migrations/schema-verify.after-runner.integration.test.tspackages/3-targets/6-adapters/postgres/test/test-utils.tspackages/3-targets/6-adapters/sqlite/test/migrations/db-init-update.cli.test.tspackages/3-targets/6-adapters/sqlite/test/migrations/fixtures/runner-fixtures.tspackages/3-targets/6-adapters/sqlite/test/migrations/planner-introspection.integration.test.tspackages/3-targets/6-adapters/sqlite/test/migrations/planner.codec-field-event.test.tspackages/3-targets/6-adapters/sqlite/test/migrations/planner.test.tspackages/3-targets/6-adapters/sqlite/test/migrations/runner.multi-space.test.tstest/integration/test/contract-space-fixture/contract.ts
- Mirror the SQL R3 fix on Mongo: type MongoStorageInput.namespaces as Readonly<Record<string, MongoNamespace>> so the constructor assignment needs no cast; drop the bare `as`. - Make the SQL `__unbound__` brand sound rather than asserted: inject the SqlUnboundNamespace singleton when the validated/hydrated namespaces omit the late-bound slot (cross-namespace contracts legitimately do), then reconstruct the branded map. Removes the unsound blindCast in validateStorage and the bare `as` bridge cast; keeps an honest, runtime-guaranteed cast in the hydrate path. - Make the Mongo construction test honest: it exercises the unbound-only happy path (namespaces is a required field, not a runtime throw). Signed-off-by: wmadden-electric <286902546+wmadden-electric@users.noreply.github.com>
Records the five review findings (identity-named concretion + static factory, drop instanceof discrimination, justify/remove the __unbound__ cast, use ifDefined, clarify raw-vs-hydrated) as round-2 actions with a refusal trigger guarding the public structural-type/.d.ts assignability. Signed-off-by: Will Madden <madden@prisma.io>
Rename bound namespace concretions to SqlBoundNamespace / MongoBoundNamespace with static factories, discriminate map entries by family kind instead of instanceof, brand __unbound__ on SqlStorageInput, and use ifDefined at hydration boundaries. Signed-off-by: wmadden-electric <286902546+wmadden-electric@users.noreply.github.com>
Reconcile S1.D-1 (#630, now on main) with S1.D-2 (#631) hook work: - sql-contract-serializer-base.ts / build-contract.ts: keep #630's materialised-namespace naming + unbound injection, layer #631's canonicalization hook threading (shouldPreserveEmpty/sortStorage) on top. - descriptor-self-consistency test + contract-space fixture: compose the shared hooks over #630's namespace bodies. - pnpm install relinked @prisma-next/utils into sql-contract (dep added by #630). Generated fixtures regenerated via scripts; fixtures:check zero-diff. Signed-off-by: wmadden-electric <286902546+wmadden-electric@users.noreply.github.com>
…istory Replace the three synthetic normal-shape golden cases with cases drawn from real merged PRs, so the corpus measures Drive runs against work the team actually shipped rather than synthesised tasks: - direct-change-example-emit-outputpath (TML-2722 / #618) - slice-dedupe-generated-imports (TML-2714 / #614) - project-reap-subsumed-ir-surfaces (TML-2727 / #630, #631, #629) — a three-slice parallel fan-out that exercises planner parallelisation and scope discipline. Each real case carries the task as posed (Linear ticket, solution-scrubbed so the run still does the design/planning), a base_sha to run against, and a reference.md describing the known-good output by commit SHA (the output itself is fetchable via git diff <base_sha> <merge_sha>). case.json gains source + base_sha; the loader ignores the extra fields until the experiment-engine slice wires base_sha into a checkout. The two pathological cases (i12-halt, spike-first) stay synthetic: no clean merged PR exhibits a halted or spiked run. Update harness tests, SKILL.md examples, and the corpus README for the renamed slugs. validate-parser fixtures are left as-is — they are synthetic parser fixtures with tuned event counts, not corpus members. Signed-off-by: wmadden-electric <286902546+wmadden-electric@users.noreply.github.com>
Linked issue
Refs TML-2727
Slice spec:
projects/contract-ir-planes/slices/construction-discipline-shims/spec.mdParallel to S1.D-2 / S1.D-3 and S1.E — disjoint files; no ordering dependency.
Motivation
Pre-namespace construction shims (
normaliseNamespaceEntry,DEFAULT_NAMESPACES, and the loose POJO payload types) letSqlStorage/MongoStorageaccept partially-built namespace data and silently inject an__unbound__default. S1.A already routes authoring through built namespaces; this slice deletes the shims and makes the constructors require fully-constructedNamespaceinstances.Grep gate
At a glance
Constructors no longer coerce POJOs or inject defaults when
namespacesis empty.Verification
pnpm typecheck(137/137 tasks)pnpm test:packages— 24 failures / 14 uncaught exceptions, predominantlyECONNRESET/Connection terminated unexpectedlyin Postgres wire/integration tests; core contract packages pass (@prisma-next/sql-contract112/112,@prisma-next/mongo-contract105/105)pnpm test:integration— 59 failures, same Postgres connection teardown patternpnpm fixtures:check—emit:authoringhits 100ms timeout inside-by-side-contracts.test.tswhen run without--testTimeout; manual emit +git diffoncontract.json/expected.contract.jsonshows no semantic fixture driftpnpm lint:depsNo emitted
contract.jsonchanges (expected per spec).Refusal trigger: not fired — no construction path depended on
DEFAULT_NAMESPACESinjecting__unbound__; call sites were updated to pass built namespaces.Checklist
packages/Summary by CodeRabbit
New Features
Refactor
Tests