Skip to content

stack-encrypt: name the operator, not the index, in a query (Eq and Matches) #1182

Open

Description

@coderdan

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 (MatchTerms for 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::op module with the operator unit types Eq and Matches<C = Insensitive>, the case markers Insensitive and Sensitive, and the traits Operator, QueryTerm, Supports<Op, S> and Answers<Op, S> (ADR-0009 decisions 1 to 4).
  • Supports<Eq, S> for Equality, whose query term is the EqualityTerm. Supports<Matches<C>, S> for Match<O> when O's case is C, whose query term is a new MatchQuery<O>, distinct from the stored MatchTerms<O>.
  • A case-sensitive Matches against 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 through Answers<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 Eq query is byte-equal to the stored equality term, a Matches query 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

Activity

  1. added
    enhancementNew feature or request
    rustPull requests that update Rust code
    on Oct 13, 2026
  2. self-assigned this
    on Oct 13, 2026
  3. added a commit that references this issue on Oct 14, 2026
    5601068
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

SDKenhancementNew feature or requestrustPull requests that update Rust code

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions