Repository navigation
stack-encrypt: name the operator, not the index, in a query (Eq and Matches) #1182
Copy link
Copy link
Open
Labels
SDKenhancementNew feature or requestNew feature or requestrustPull requests that update Rust codePull requests that update Rust code
Description
Background
ADR-0009 (#1177) has the caller name an operator rather than an index. Today a query is cipher.query(value).using(&plan).index(Match(..)) or .equality(): the caller picks the index, and nothing in the types says which operators an index answers.
Problem
- A caller has to know which index answers which operator.
- An operator an index cannot answer is not a compile error.
- The query term is typed as the stored term (
MatchTermsfor both), so the API has nowhere to say that a query differs from what is stored.
Proposal
Add an operator-typed query to packages/stack-encrypt for the two operators that stack-encrypt's indexes answer today.
- A
stack_encrypt::opmodule with the operator unit typesEqandMatches<C = Insensitive>, the case markersInsensitiveandSensitive, and the traitsOperator,QueryTerm,Supports<Op, S>andAnswers<Op, S>(ADR-0009 decisions 1 to 4). -
Supports<Eq, S>forEquality, whose query term is theEqualityTerm.Supports<Matches<C>, S>forMatch<O>whenO's case isC, whose query term is a newMatchQuery<O>, distinct from the storedMatchTerms<O>. - A case-sensitive
Matchesagainst a case-folding match index is a compile error. -
.op(op)on all three plan shapes: a field of a fields plan, a one-value plan with indexes, and a one-value plan with a target. A target answers throughAnswers<Op, S>, chosen by hand per type. A plan that declares indexes answers through the operator's default index..op_via(op, index)names a different index, such as a match index with its own configuration. - Remove
QueryUsing::equality(); callers use.op(op::Eq). - Keep
QueryUsing::index(..). It is still the only way to query ORE and OPE, and stack-encrypt: ordering operators Lt, Lte, Gt, Gte and Between, and remove QueryUsing::index #1186 removes it once the ordering operators exist. - Update ADR-0009's code to the spelling this ships.
- Tests: the
Eqquery is byte-equal to the stored equality term, aMatchesquery is contained in the stored filter, and an undeclared index, a wrong plaintext type, an unsupported operator and a case mismatch are each refused, the last two at compile time (tests/ui).
Out of scope
The EQL types implementing Answers and serialising a query term to an eql_v4.query_* domain (decision 8). On this base the v4 types are not Stack Encrypt targets yet; that waits for #1179. verify (#1183) and target_limit (#1184).
Related
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
SDKenhancementNew feature or requestNew feature or requestrustPull requests that update Rust codePull requests that update Rust code
Activity
feat(stack-encrypt)!: a query names an operator, not an index