feat(stack-drizzle): EQL v3 JSON selector-with-constraint querying#651
feat(stack-drizzle): EQL v3 JSON selector-with-constraint querying#651coderdan wants to merge 1 commit into
Conversation
Add ops.selector(col, '$.path') to the v3 Drizzle integration (#623): comparison methods (eq/ne/gt/gte/lt/lte) bound to a JSONPath into a types.Json column, emitting `eql_v3.<op>(eql_v3."->"(col,'<sel>'), eql_v3."->"('<needle>'::eql_v3_json,'<sel>'))`. Its unique power over `contains` is ORDERING at a path (col->'$.age' > 21). - Selector hash from encryptQuery(path, searchableJson) (string needle → ste_vec_selector). - Comparison entry from a STORAGE encrypt of {path: value} — its ciphertext `c` is required by the eql_v3_jsonb_entry domain (a query term can't carry it). - One new dialect fn (selectorEntry); reuses equality/comparison for the compare. - v1: dot-notation object paths; array/wildcard rejected with a clear error. Core needs no change. Supabase is a follow-up (#650) — blocked by PostgREST's inability to cast a filter value. Refs #623 Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
🦋 Changeset detectedLatest commit: 59b994e The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
Adds JSONPath selector-with-constraint querying for EQL v3 encrypted JSON to the Drizzle integration. Refs #623. Draft — pending CI (integration is live-DB only).
What it adds
ops.selector(col, '$.path')returns comparison methods bound to a JSONPath into atypes.Jsoncolumn:Methods:
eq,ne,gt,gte,lt,lte. It complements the existingcontains(@>) operator; its unique power is ordering at a path (gt/gte/lt/lte), which containment cannot express. (Equality-at-a-path is also expressible viacontains(col, {path: value}), butselector(...).eqis more direct.)How it works (verified against the v3 bundle)
Emits
eql_v3.<op>(eql_v3."->"(col, '<sel>'), eql_v3."->"('<needle>'::public.eql_v3_json, '<sel>')):<sel>):encryptQuery(path, searchableJson)— a string needle infers aste_vec_selectorterm → the bare HMAC selector hash, bound as thetextarg ofeql_v3."->".encryptof the reconstructed{path: value}document. Theeql_v3_jsonb_entrydomain CHECK requires ciphertextc, so a ciphertext-free query term can't be the RHS — hence a storage encryption, from which the same selector extracts the entry.Scope decisions
@cipherstash/stack: no change. The selector term + comparison entry come from the existingencryptQuery/encryptontypes.Json.encrypt(storage) alongsideencryptQuery— needed only for the selector RHS.$.a,$.a.b); array-index/wildcard paths are rejected with a clear error (a follow-up).Verification
integration/json-selector.integration.test.ts(equality, orderinggt/lt/gte, empty result, array-path rejection). These run in CI only (need a live EQL-v3 Postgres).Verified in CI, not locally — watch these
encryptQuery(path)hash must equal the storage doc's ste_vec entry selector for the same path.gt/lttests assume stored ste_vec entries carry theop(CLLW-OPE) ordering term extractable via->; if entries carry onlyhm, ordering needs a bundle-side adjustment.Remaining before ready
skills/stash-drizzle+skills/stash-encryptiondocs for the selector pattern (holding until CI confirms the API shape).Refs #623 · follow-up #650
https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w