Prisma Next 0.16, payload-identifier routing, and digest-verified baked EQL migration artefacts#763
Prisma Next 0.16, payload-identifier routing, and digest-verified baked EQL migration artefacts#763coderdan wants to merge 6 commits into
Conversation
All @prisma-next/* deps move 0.14.0 -> 0.16.0 in lockstep. prismaContract now requires the target's createNamespace factory (0.15 stopped materialising a placeholder namespace) — added to both configs and the bundled skill. The PSL interpreter test moves to the CST symbol-table input. Contracts re-emitted: postgres-schema namespace kind, StorageColumnTypes maps, scalarList capability; storage hashes unchanged.
…ifier
Every EQL v3 payload carries its required i: {t, c} identifier, and
ZeroKMS commits the cell key to it — the authoritative routing source.
decode now reads it first (ctx.column kept as fallback for non-v3
documents), and decodeJson builds fully-routed envelopes from it instead
of throwing, unblocking relation include() and aggregate projections.
…est-verified Replaces runtime injection: the framework applies extension migrations from on-disk vendored copies without the descriptor, and the seed phase never refreshes an existing package dir, so injection's environment- dependent hashes orphaned every consumer copy on each EQL bump (PN-MIG-5002) and the recomputed hash laundered tampering. Each migration self-emit now embeds readVerifiedInstallSql() — refused unless sha256 matches @cipherstash/eql's releaseManifest.installSqlSha256. One content-addressed identity flows from git through npm to vendored copies and the DB ledger. CI guards: provenance pin (committed SQL digest == installed manifest), frozen published-migration hashes, and byte-parity between the example's vendored space and the shipped artefacts. The example's stale vendored space is regenerated (stale v2 dir removed). Also fixes the upgrade migration's stale describe() space hashes. Follow-ups tracked in #762.
🦋 Changeset detectedLatest commit: e02c2b9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughThis PR upgrades Prisma Next dependencies and contracts, embeds digest-verified EQL v3 SQL in published migrations, adds migration parity and integrity checks, and changes EQL v3 decoding to derive routing from payload identifiers. ChangesPrisma Next 0.16 contract and configuration
Digest-verified EQL v3 migrations
EQL v3 payload routing
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
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/prisma-next/src/v3/codec-runtime-v3.ts`:
- Around line 291-312: Update decodeJson in
packages/prisma-next/src/v3/codec-runtime-v3.ts to return null immediately when
the JSON value is null, matching decode’s nullable-column behavior before
routingKeyFromPayload runs. Add coverage in
packages/prisma-next/test/v3/codec-runtime-v3.test.ts at lines 351-361 verifying
decodeJson(null) round-trips as null; no other sites require changes.
In `@packages/prisma-next/test/psl-interpretation.test.ts`:
- Around line 17-20: Move packages/prisma-next/test/psl-interpretation.test.ts
into the appropriate __tests__/ directory and update its relative imports and
test configuration. Move
packages/prisma-next/test/v3/vendored-space-parity.test.ts under __tests__/ as
well, adjusting all relative paths for the new location while preserving both
suites’ behavior.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7078b56a-8625-4946-8ae2-a8a50627609d
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (33)
.changeset/eql-baked-digest-verified.md.changeset/prisma-next-0-16.md.changeset/v3-payload-routing.mdexamples/prisma/migrations/cipherstash/20260601T0000_install_eql_bundle/migration.jsonexamples/prisma/migrations/cipherstash/20260601T0000_install_eql_bundle/ops.jsonexamples/prisma/migrations/cipherstash/20260601T0100_install_eql_v3_bundle/migration.jsonexamples/prisma/migrations/cipherstash/20260601T0100_install_eql_v3_bundle/ops.jsonexamples/prisma/migrations/cipherstash/20260720T0000_upgrade_eql_v3_3_0_2/migration.jsonexamples/prisma/migrations/cipherstash/contract.jsonexamples/prisma/migrations/cipherstash/refs/head.jsonexamples/prisma/package.jsonexamples/prisma/prisma-next.config.tsexamples/prisma/src/prisma/contract.d.tsexamples/prisma/src/prisma/contract.jsonpackages/prisma-next/migrations/20260601T0100_install_eql_v3_bundle/migration.jsonpackages/prisma-next/migrations/20260601T0100_install_eql_v3_bundle/migration.tspackages/prisma-next/migrations/20260601T0100_install_eql_v3_bundle/ops.jsonpackages/prisma-next/migrations/20260720T0000_upgrade_eql_v3_3_0_2/migration.jsonpackages/prisma-next/migrations/20260720T0000_upgrade_eql_v3_3_0_2/migration.tspackages/prisma-next/migrations/20260720T0000_upgrade_eql_v3_3_0_2/ops.jsonpackages/prisma-next/package.jsonpackages/prisma-next/prisma-next.config.tspackages/prisma-next/src/contract.d.tspackages/prisma-next/src/contract.jsonpackages/prisma-next/src/exports/control.tspackages/prisma-next/src/migration/eql-bundle-v3.tspackages/prisma-next/src/v3/codec-runtime-v3.tspackages/prisma-next/test/bundling-isolation.test.tspackages/prisma-next/test/psl-interpretation.test.tspackages/prisma-next/test/v3/codec-runtime-v3.test.tspackages/prisma-next/test/v3/migration-v3.test.tspackages/prisma-next/test/v3/vendored-space-parity.test.tsskills/stash-prisma-next/SKILL.md
💤 Files with no reviewable changes (1)
- examples/prisma/migrations/cipherstash/20260601T0000_install_eql_bundle/migration.json
Addresses code-review findings on the baked-EQL work: - migration-v3.test.ts: the provenance pin compared each migration's baked SQL digest against the LIVE @cipherstash/eql manifest, so it self- destructed on the next EQL bump (frozen 3.0.2 bytes can't match a 3.0.3 manifest) — pushing a maintainer toward re-emitting the published baseline. Reworked to a PUBLISHED_MIGRATIONS table with per-migration FROZEN digests (identity + baked-SQL, tied to each migration's own release) plus one bump-safe lockstep check (the installed release must be baked by SOME published migration) and an on-disk completeness check (no unpinned or stale migration dirs). - descriptor.test.ts: the 'injects the runtime EQL install SQL' test still named and described the deleted sentinel-injection design and compared against a live readInstallSql() (also bump-unsafe). Rewritten to assert the op carries the baked bundle verbatim, without the live comparison; dropped the now-unused import. - DEVELOPING.md: refreshed the sections that still documented the sentinel/ runtime-injection design and instructed re-emitting published migrations (the exact action the new doctrine and frozen-hash guard forbid); added the second (upgrade) migration to the layout and invariants. Reviewed in this branch; follow-ups (#4/#6/#8 payload-routing edges, efficiency items) tracked separately.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/prisma-next/test/descriptor.test.ts`:
- Around line 120-129: The descriptor test’s loose substring and size checks do
not verify the exact migration bundle. Update the assertions around installOp
and its execute SQL to reuse the frozen SHA-256/digest verification established
by migration-v3.test.ts, comparing the embedded SQL against the expected release
provenance without calling readInstallSql() or reading the installed package at
runtime.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: e96a0ffb-1adb-43ed-afdc-ae47ebe331c1
📒 Files selected for processing (3)
packages/prisma-next/DEVELOPING.mdpackages/prisma-next/test/descriptor.test.tspackages/prisma-next/test/v3/migration-v3.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/prisma-next/test/v3/migration-v3.test.ts
CodeRabbit flagged decodeJson(null) as throwing. It is unreachable: the SQL runtime null-guards before both codec methods — decodeField before decode, and sql-orm-client's include-decode loop (plus its many-typed element path) before decodeJson — so a NULL cell never reaches the codec. Null-handling is the runtime's contract; returning null here would also break the framework's decodeJson(json): TInput envelope signature. Comment only, no behavior change.
…t migrate'
Prisma Next has no 'migration apply' subcommand — the apply verb is the
top-level 'prisma-next migrate' ('migration' only groups plan/new/show/
status/log/list/graph/check). Running the prescribed 'migration apply'
errors: 'Unknown command: apply. Use prisma-next migrate --to <contract>'.
Fixes the stale name in the stash-prisma-next and stash-cli skills, the
@cipherstash/prisma-next README, and — user-visibly — stash init
--prisma-next's printed next-steps, the init flag help, and the stash eql
install Prisma-Next refusal message. Updated the CLI unit + e2e assertions
that pinned the old string. Historical CHANGELOG entries left as-is.
Surfaced by the rc.4 skilltester run (found at PN 0.14.0, confirmed 0.16.0);
tracked with the other skilltester findings in a follow-up issue.
Three related pieces of work on the Prisma Next integration, in review order per commit:
1. Upgrade to Prisma Next 0.16 (from 0.14)
All 31
@prisma-next/*pins move to 0.16.0 in lockstep. The CipherStash encryption surface is unchanged. Notable:createNamespaceis now required inprismaContract(...)(0.15 stopped materialising a placeholder namespace) — added to both configs and documented in the bundledstash-prisma-nextskill.parse+buildSymbolTable).postgres-schemanamespace kind,StorageColumnTypesmaps,scalarListcapability, discrete FK/index entities. Storage hashes unchanged.Verified: unit + live-PG (27) + integration (595) suites green with a
~/.cipherstashdevice profile and the local compose Postgres.2. Route v3 decoding from the EQL payload's own identifier
Every EQL v3 payload carries its required
i: {"t", "c"}identifier, and ZeroKMS commits the cell key to it — making it the authoritative routing source, not the query AST.decodenow reads it first (projected-column context kept as fallback for non-v3 documents), anddecodeJsonbuilds fully-routed envelopes from it instead of throwing.This unblocks relation
include()(the SQL ORM decodes included cells throughdecodeJsonwith no column ref available) and aggregate/computed projections. A two-modelinclude()e2e test remains a follow-up (needs thedb-ref planning workflow — see #762).3. Bake the EQL install SQL into migration artefacts, digest-verified
Replaces the runtime-injection design. The framework applies extension migrations from on-disk vendored copies without the descriptor, and the CLI seed phase never refreshes an existing package directory — so injection's environment-dependent hashes orphaned every consumer's vendored copy on each EQL bump (
PN-MIG-5002), and recomputing the hash from installed content meant tampering could never be detected.Now each migration's self-emit embeds
readVerifiedInstallSql()— refused unless its sha256 matches@cipherstash/eql'sreleaseManifest.installSqlSha256. One content-addressed identity flows from this repo's git history through the npm tarball into consumers' vendored copies and the DB ledger. EQL upgrades ship as new append-only migration directories (the existing invariant-edge pattern).CI guards added:
migrations/cipherstash/must be byte-identical to the shipped artefacts (catches the exact staleness class that wedged it).Proven end-to-end: seed phase materialises byte-identical copies; fresh-DB
migrateinstalls EQL 3.0.2 and records both invariants; a tampered vendoredops.json(injectedDROP TABLE) is rejected by hash verification before execution; example e2e (40), live-PG (27), and unit (341) suites green.dist/control.jsgrows to ~5 MB (inlined artefacts, control-plane entry only — runtime entries unchanged, pinned by the bundling-isolation test).Also fixes the upgrade migration's stale
describe()space hashes and theeql-3.0.0→3.0.2label drift.rc consumers (none external today): delete
migrations/cipherstash/and re-runprisma-next migration planonce — the seed phase regenerates it byte-identical.Follow-ups tracked in #762.
Summary by CodeRabbit
scalarListand expanded generated storage type mappings.createNamespacesetup and post-upgrade regeneration expectations; clarifies changes when upgrading EQL v3 and migration publication behavior.Closes #765.