Repository navigation
feat(eql-bindings): answer order queries from a field reference - #1752
Conversation
🦋 Changeset detectedLatest commit: a914822 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 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 |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
🟡 Changes recommended
The new ordering paths lack field-reference/data-path parity tests for trailing-NUL and oversized text in both TextOrdOre and TextSearchOre, leaving rejection before key requests unverified.
1 open issue
What changed in this PR
Adds ordered EQL v4 queries through Rust record field references, closing the gap described in #1668. Queries follow the existing data-plan behavior without changing SQL or stored formats.
Changes:
- Generates ordering support for numeric, date/time, ordered-text and text-search fields.
- Extends query-twin assembly to carry one or multiple index terms as required.
- Adds parity and PostgreSQL tests, updates suite registration, and documents the API.
| File | Description |
|---|---|
packages/eql/tests/encryption/tests/typed_queries.rs |
Expands operator and term parity coverage to all 39 answering types. |
packages/eql/tests/encryption/tests/typed_order_queries.rs |
Adds row-selection checks for field-reference and data-plan queries. |
packages/eql/tests/encryption/tests/common/mod.rs |
Adds a shared block ORE comparison helper. |
packages/eql/mise.toml |
Registers the new PostgreSQL test suite. |
packages/eql/crates/eql-codegen/src/targets.rs |
Generates ordering answers and multi-term twin assembly. |
packages/eql/crates/eql-bindings/src/v4/answers.rs |
Adds generated operator implementations for ordered and search types. |
packages/eql/crates/eql-bindings/src/encryption/query.rs |
Extends TwinIndex and documents supported operations. |
packages/eql/crates/eql-bindings/README.md |
Updates the operator table and adds an order-query example. |
packages/eql/crates/eql-bindings/CHANGELOG.md |
Records the new query support and API changes. |
docs/plans/2026-10-24-stack-encrypt-api-plan.md |
Updates the plan’s EQL field-query coverage. |
Review effort: Balanced
cipherstash-agent
left a comment
There was a problem hiding this comment.
Review attestation
Reviewed 4c028752 · posted from Claude Code · claude-opus-5-5 · effort medium
Sources: code-review · claude-opus-5-5; mattpocock-skills:code-review (standards and spec agents) · claude-opus-5-5; rust-security agent · claude-opus-5-5 (no new findings)
Skills: code-review, mattpocock-skills:code-review, company-skills:rust-security, company-skills:review-cross-check, company-skills:review-post
Findings (7): 3 minor, 4 nit — 5 inline, 1 below, 1 in reply.
.changeset/minor Adds to #1752 (comment): this PR adds publiceql-bindingssurface (lt/lte/gt/gtefrom field references,TwinIndex's third parameter), and the crate releases in lockstep with@cipherstash/eql. Pending changesets already bump the version, but without an'@cipherstash/eql': minorchangeset (likeeql-json-tree-open-one-child.md) the feature gets no entry inpackages/eql/packages/eql/CHANGELOG.md.
Source: code-review · claude-opus-5-5
Verified at head and dropped: 8 refuted (duplicate answers in answers_for_indexes, the two optional_terms checks, Answer::index's nameless panic, hand-edited crate CHANGELOG, TwinIndex upgrade note, duplicated impl bodies, the 6-type row tests, eq/matches scope). 1 already covered by #1752 (comment) (refusal tests).
Generated by Claude Code
|
Review round 1, addressed in 5b83b21. It was pushed as a fast-forward; the restack onto #1751's fixes comes next.
Checks at 5b83b21:
|
Mutation testing (cargo-mutants,
|
| caught | missed | unviable | timeout |
|---|---|---|---|
| 4 | 0 | 4 | 0 |
Every mutant in the changed lines was caught by a test.
c146ba5 to
3c584e6
Compare
5b83b21 to
ff7cbaf
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The added changelog paragraph contradicts the preceding entry and advertises an unsupported JsonTreeChild decryption type, so the stale duplicate should be removed.
1 open issue
1 resolved since last review
Review effort: Balanced
A field reference of an ordered EQL v4 type (IntegerOrd, DateOrdOre, TextOrd and the rest) had no op::Answers impls, so a Rust program could range-query such a field only through a data plan. eql-codegen now generates the impls for every producible type with a query twin, by the rule the data path answers a field that names the type: eq through the equality index, lt, lte, gt and gte through the type's order index (OPE or block ORE), matches through the match index. Every ordered type answers the orderings, TextOrd* answer eq too, and TextSearch and TextSearchOre answer eq, the orderings and matches. The twins differ in the terms they need, and no SQL or stored form changes. An ordered type other than text has a one-term twin (op or ob). eql_v4.query_text_ord requires hm and op together, so TwinIndex takes a third type parameter, the indexes whose terms the twin carries (defaulting to the answering index), and a TextOrd query derives the terms of (Equality, Ope) for its one value through stack-encrypt's Indexes, as the data path's run of the twin's own plan does. A text search twin's terms are optional, so QueryTwin is implemented once per term and its query carries the answering index's term alone, as the data path's projection does. No type answers between, which the data path answers on no EQL type. typed_queries.rs now holds every type's operators to the data path's with no gap, and every query's bytes to the data path's (a block ORE term, which carries a random nonce, compares equal instead). typed_order_queries.rs stores rows through a record and checks that a field reference's query and the data path's each find exactly the rows the plaintexts say, in Rust and, against an EQL v4 database, through the SQL operators; it joins the test:encryption:postgres suites. Closes #1668
…er index refuses A TextOrd* query twin carries its hm and its order term whatever the operator, so an eq query derives a block ORE (or OPE) term too. Both paths checked the equality index alone for eq: the pair Eq impl's prepare in eql-bindings, and stack-encrypt's prepare_input in check_query and query_term. So TextOrdOre eq of text that ends in NUL, or is too long for block ORE, passed a binding's boundary and was refused only while its term was derived, after the keyset's index key was loaded. An ordering of the same text was refused before any key. The typed twin now prepares every index whose term it derives: the equality index, then the order index, for eq and the orderings alike. The data path does the same for a type whose twin carries every term: TargetDescriptor gains query_carries_every_term (not on the wire, set with with_query_carrying_every_term), which eql-bindings' EqlTargets sets for every type with a twin except the text search types, whose twin carries the answering index's term alone. A text search eq of the same text is still answered by both paths, as before. typed_queries.rs now holds both paths to the same refusal, before any key request, for block ORE text ending in NUL or over the limit and for text no index normalizes, on every ordered text type and operator, and checks each type's descriptor against the terms its query carries. The 39 answering types are listed once, in one macro that writes the record, the row and the dispatch from it; typed_order_queries.rs does the same for its six columns, and ob_order picks the plaintext from the type's family. eql-codegen keys its typed-query rules on an IndexKey enum, so each rule is an exhaustive match and a new index is a compile error rather than a missed arm or a dropped import. The generated files do not change. The README and module docs are rewrapped; the API plan names the follow-up for between and the state of #1658 and #1659. A changeset records the feature for @cipherstash/eql.
The restack of the order-query change onto the child-read review fix merged the old wording of the child entry under its new wording. The old text said a child opens as DecryptSource<JsonPlaintext>, which is no longer true.
…tween plainly Searchable-encryption indexes belong to Stack Encrypt. EQL is one consumer of them, so the doc of `target_indexes` no longer calls them the indexes an EQL type answers through. The note that a field reference has no `between` now says why: a range query sends both bounds in one operand, and no SDK builds that operand yet. The eql-bindings CHANGELOG points at the issue that tracks it.
eaf369a to
a914822
Compare


Summary
A Rust record field typed with an ordered EQL type (
IntegerOrd,DateOrdOre,TextOrdand the others) can now be range-queried from its field reference:EncryptedMember::AGE.gt(30).encrypt(&keyset)returns the type's query twin (IntegerOrdQuery, …). Before this, those types answered no operator from a field reference, so a Rust program could range-query them only through a data plan. Each query is the same bytes the data plan (the Go SDK's path) derives for the same value, and finds the same rows. No EQL SQL and no stored form changes.Changes
eql-codegen (
targets.rs): the rule for which operators a type answers now covers order indexes.eqgoes through the equality index,lt/lte/gt/gtethrough the OPE or block ORE index, andmatchesthrough the match index, in the data path's operator order. The oldtyped_gapis removed.Generated
v4/answers.rs:…Ord,…OrdOpe,…OrdOre) answer the four orderings;TextOrd,TextOrdOpeandTextOrdOreanswereqand the orderings;TextSearchandTextSearchOreanswereq, the orderings andmatches.The
ANSWERStable lists them all.eql-bindings
encryption/query.rs:TwinIndex<I, Q, D = I>gains a third parameter: the indexes whose terms the twin carries (D). NewSupportsimpls cover the orderings on one-term twins, andEqplus the orderings on(Equality, O)twins.Tests:
typed_queries.rscovers all 39 answering types. Each type's operators must equal the data path's, with no gap allowed, and every query's bytes must equal the data path's. A block OREobterm carries a random nonce, so it is checked with ore-rs's comparator instead.typed_order_queries.rsstores rows through a record and checks that the field reference's query and the data path's each find exactly the expected rows, in Rust and, as an#[ignore]PostgreSQL test, through the SQL operators.packages/eql/mise.toml:typed_order_queriesis added to thetest:encryption:postgressuite list.Docs:
AGE.gt(30).query.rsmodule docs: updated, with a compile_fail doctest showing thatIntegerOrdhas noeqorbetween.Verification
Run in the
packages/eqlworkspace:cargo run -p eql-codegen -- bindingsand-- go-eql.answers.rschanged.v4/targets.rsand the Goeql_gen.goare unchanged, and regenerating again aftercargo fmtgives identical output.cargo test -p eql-bindings --all-featurespasses, and the TS and JSON Schema exports are identical to the committed ones.cargo test -p eql-codegen: the unit, parity and CLI suites pass.cargo test -p eql-encryption-tests: all pass, including the README doctests and the new tests.cargo clippywith-D warnings, on all targets and features: clean, also with--features stack-encrypt.cargo fmt --all --check: clean.cargo check --lockedfor wasm32-wasip1 passes with--features stack-encryptand with--features targets.tasks/build.shinto a throwaway PG 17. Every suite in thetest:encryption:postgreslist was run with--ignored, and all pass: text_eq, v4_types, v4_order, v4_date_time_numeric, v4_range, v4_text_search, v4_ore_block, typed_order_queries and json_tree.cargo doc -D warningsfails for eql-bindings and eql-codegen with the same pre-existing errors asnext, in files this PR doesn't touch. There is one fewer, because the staletyped_gaplink is gone.eql_gen.gois unchanged.Related
Closes #1668. Stacked on #1751.
Review notes
eql_v4.query_text_ord,_opeand_orerequire bothhmandop/ob. Every non-text ordered twin already has a single term, so those use the one-index path. This matches the data path's rule.betweenis not answered. The issue listsBetween, but the data path answersbetweenon no EQL type, and the issue asks for the data path's rule. Adding it means changing both paths, using the existingquery_*_range_*twins. It's left out on purpose, and a compile_fail doctest pins that.TextOrdeqruns only the equality index's prepare check, as the data path does.