Repository navigation
Description
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 codeno_eql_nodeand the messageno "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/srcmention EQL.dynamic/record.rshas 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
eqlkey 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
- Rename the output key from
eqltotarget, andEQL_KEYto match. - Rename
NoEqlNodeand its codeno_eql_nodeto say "target". Check first whether any SDK or user matches on that code. - Rename the query output form that is named
"eql", the same way. - In docs, comments and error messages, say "target" for the mechanism. Say "EQL" only for an example of a target.
- In the same change, update everything that reads the key: the Go guest, the Go host, and the conformance fixtures.
- Leave
stack_encrypt::eql_simulatoras it is. That module is a test copy of EQL's read functions, so its name is accurate. Leavepackages/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
- stack-encrypt: the encrypted tree of a record has no serde, so each binding writes its own conversion #2029 and its pull request feat(stack-encrypt): typed encrypted records that cross to a language binding through serde #2031 add a typed encrypted record for bindings. That new type names the output
targetfrom the start, so it does not add to this problem. The existing tree form keepseqluntil this issue is done. - The Go adapter and the TypeScript binding both read the record form, so this is best done before the TypeScript SDK is released.
Activity
docs(plans): split the resolver's removal into its own step