Skip to content

docs(prisma-next): EQL v3 concrete per-domain design (design A)#603

Draft
tobyhede wants to merge 2 commits into
mainfrom
docs/eql-v3-prisma-next-design
Draft

docs(prisma-next): EQL v3 concrete per-domain design (design A)#603
tobyhede wants to merge 2 commits into
mainfrom
docs/eql-v3-prisma-next-design

Conversation

@tobyhede

@tobyhede tobyhede commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Design spec for authoring EQL v3 columns in @cipherstash/prisma-next via concrete per-domain constructors that map 1:1 to the public.* Postgres domains — capabilities encoded in the type system, no boolean-option surface, no runtime resolver.

Grounded against feat/eql-v3-supabase-adapter (protect-ffi 0.28):

  • public.* domains (native types) + eql_v3.* operator functions — the two schemas are distinct and must not be conflated.
  • BigInt is a first-class v3 family (EncryptedBigInt/Eq/Ord); only searchable JSON stays V2-only; public.boolean is storage-only.
  • Catalog derived from the stack DOMAIN_REGISTRY (no hand-maintained table).
  • Concrete per-domain types are the spine — literal codecId/nativeType/capabilities, threaded end-to-end, with mandatory *.test-d.ts.
  • Separate v2/v3 entry points — distinct extension ids, same operator method names, no mixed-in-one-client (the flat OperationRegistry disallows override).
  • Encrypted ORDER BY (asc/desceql_v3.ord_term); between parenthesisation + bigintSafeReplacer as correctness invariants; framework-neutral primitives (codec, gate index-sets, fn-schema/op-map) lifted to eql/v3/.

Status

  • Design spec (docs/superpowers/specs/2026-07-08-eql-v3-prisma-next-design.md)
  • Implementation plan — being finalized against this spec; will be pushed to this branch. Draft until then.

Note: docs/superpowers/plans/ is locally git-excluded on this repo; the plan will be force-added when committed.

Design for authoring EQL v3 columns in @cipherstash/prisma-next via concrete
per-domain constructors that map 1:1 to the public.* Postgres domains, with
capabilities encoded in the type system (no boolean-option surface, no
resolver). Reflects protect-ffi 0.28: public.* domains + eql_v3.* operator
functions, first-class BigInt family, DOMAIN_REGISTRY as source of truth,
separate v2/v3 entry points, and concrete per-domain types threaded end-to-end.
@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0d7f021

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8b0cb1d6-ad73-4a5e-94fa-5fada10f0144

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/eql-v3-prisma-next-design

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.

Add the design-A implementation plan and remediate the review findings.

Real bugs fixed:
- cipherstashBetween is now a self-parenthesised conjunction '(gte AND lte)'
  so any generic NOT/OR composition is safe (Postgres binds NOT tighter than
  AND; the 9c82f50 bug class). Operator-lowering tests pin the full
  parenthesised skeleton for all operators and assert NOT (gte AND lte).
- v3ToDriver restores bigintSafeReplacer; a stray bigint in a malformed
  envelope serialises instead of throwing. Pinned by a test.
- codec-runtime encode test now exercises the real envelope/.expose() contract
  (the old test fed a plain object with no .expose(), so it never passed).
- constants-v3 drift test replaced the masking cast with a pinned literal tuple
  (as const satisfies) + bidirectional Exclude guard + runtime equality check.

Type spine (the core of v3):
- Authoring factories are typed per-domain via v3Authored(types.X): distinct
  return type per domain, literal codecId/nativeType/capabilities (never
  string/unknown). Mandatory column-types.test-d.ts pins non-assignability +
  literal field types. Derivation preserves the concrete column type.

Separate v2/v3 entry points (decision 1b):
- v3 registers its own extension descriptor with a distinct
  CIPHERSTASH_V3_SPACE_ID/VERSION, keeping the same cipherstash* method names,
  and is never co-registered with v2 (the flat OperationRegistry rejects the
  duplicate method). Task 7 replaces the two-client dispatch with a v3-only
  cipherstashFromStackV3; a v2 codec id in a v3 contract is a hard error.

Plan under docs/superpowers/plans/ (locally git-excluded; force-added).

Remaining (follow-up): encrypted ORDER BY (asc/desc -> eql_v3.ord_term),
shared-primitive lift to eql/v3/, bulk-middleware edge-case tests, live
plaintext-oracle suite, genuine property tests, minor type cleanups.
@tobyhede tobyhede force-pushed the docs/eql-v3-prisma-next-design branch from 94eb842 to 0d7f021 Compare July 9, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant