Skip to content

stack-encrypt: the record names its target output eql, so a generic mechanism is named after one product #2033

Backlog

Description

@coderdan

Background

Stack Encrypt (packages/stack-encrypt) is the Rust crate that encrypts values and derives search terms. A language binding, such as the Go guest or the Node binding, gives it a plan and a row. Stack Encrypt returns an encrypted record. Each field has a set of outputs under short keys, such as c (the sealed value) and eq (an equality term).

A plan field can name a target. A target is a type from outside Stack Encrypt that stores a field's encrypted value in its own format. Stack Encrypt does not know any target. The caller supplies a TargetResolver, and Stack Encrypt asks it to run the type.

EQL (Encrypt Query Language) is the SQL library that stores and queries encrypted values in PostgreSQL. The EQL types are the only targets today. The crate eql-bindings defines them. That crate also supplies the resolver (packages/eql/crates/eql-bindings/src/encryption/resolver.rs:52).

Problem

The target mechanism is generic, but its names say EQL. So Stack Encrypt's record form describes one caller's product.

Verified on next at 4a6a3bee5:

  • The output key of a target field is the text eql: pub const EQL_KEY: &str = "eql" (packages/stack-encrypt/src/dynamic/record.rs:177). The constant's docs call it "the map key a target field's EQL value rides under".
  • A refusal reason is named after it: NoEqlNode, with the code no_eql_node and the message no "eql" node (packages/stack-encrypt/src/refusal.rs:981).
  • A query's output form is named "eql" (packages/stack-encrypt/src/dynamic/query.rs:392).
  • The resolver's docs and errors say "EQL type" where they mean "target" (packages/stack-encrypt/src/dynamic/target.rs:327–329, :561, :666). One error reads "this build holds no EQL types; a plan cannot name {name} as a target".
  • 31 source files in packages/stack-encrypt/src mention EQL. dynamic/record.rs has 178 mentions.
  • Stack Encrypt has no Cargo dependency on eql-bindings. Only the names refer to it.

Why this matters:

  • The abstraction leaks. An encrypted record has a key that names a product Stack Encrypt does not own, and every binding reads that key. A second kind of target would have to store its value under eql.
  • Each new binding copies the name. The Go host reads the eql key today. The TypeScript binding is about to read the same record form.

Nothing catches this, because the names are consistent with each other and every test uses them.

Plausible, not verified: renaming the key changes no stored data. The Go SDK stores the target's value in its column, not the key. The key crosses only between the guest and the Go host.

Proposal

  1. Rename the output key from eql to target, and EQL_KEY to match.
  2. Rename NoEqlNode and its code no_eql_node to say "target". Check first whether any SDK or user matches on that code.
  3. Rename the query output form that is named "eql", the same way.
  4. In docs, comments and error messages, say "target" for the mechanism. Say "EQL" only for an example of a target.
  5. In the same change, update everything that reads the key: the Go guest, the Go host, and the conformance fixtures.
  6. Leave stack_encrypt::eql_simulator as it is. That module is a test copy of EQL's read functions, so its name is accurate. Leave packages/stack-encrypt/src/json/ for a separate look: it names EQL's JSON storage on purpose, and may need its own decision.

Before step 1, confirm that no stored value contains the key. If one does, the change needs a reader for the old key. Record that in this issue.

Relationship to other work

Activity

  1. added
    Rust
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RefactorRustSDK

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions