Skip to content

docs(plans): one walk for a record, and host-built stored types - #2040

Open
coderdan wants to merge 15 commits into
nextfrom
docs/one-walk-record-plan
Open

coderdan wants to merge 15 commits into
nextfrom
docs/one-walk-record-plan

Conversation

@coderdan

@coderdan coderdan commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This adds a draft plan. It changes no code.

Stack Encrypt is the Rust library that encrypts values and derives search terms. Today it encrypts a record one field at a time. EQL is the SQL library that stores and queries encrypted values in PostgreSQL. Today the EQL form of a stored value is built in Rust for every language, by a piece of code called a resolver.

The plan changes both, in two phases:

  1. A record is encrypted in one walk. The encrypted tree has a node for a search term. Go and TypeScript read the tree themselves and build the stored value, so the resolver can be removed.
  2. A query comes back as the same kind of tree.

No stored format changes.

The plan also says how the one walk is built. A field is described once, by a declaration, and that one declaration encrypts the field, decrypts it, and gives its query terms. The design follows the Rust standard library's iterator adapters. A spike of it is in #2043.

The plan also has a new layout for stack-encrypt and vitaminc-aead. With it, a reader can follow one encrypt call from the first file.

Changes

  • docs/plans/2026-12-01-one-walk-records-and-host-built-types.md: the plan.

Verification

  • Each line the plan cites was read on next at 54e647124, the commit this branch is cut from. The numbers in the layout section are from the spike's branch, and the section says so.
  • Two reviews checked the first version of the plan against the code. Their 21 findings are answered on this PR. The fixes are in the second and third commits.
  • The declaration design was tried in spike: one walk for records and values (not for merging) #2043, for encrypt, decrypt, and query. The plan's section "What was checked" lists each case, what the spike did not cover, and the four ways it differs from today's code.
  • The plain-language checker reports 0 items that must be fixed.
  • No test was run for this PR, because it changes no code.

Related

Review notes

  • The decisions at the top of the plan are Dan Draper's. The steps are a proposal.
  • The plan marks one change as proposed and not yet agreed: a length on a passthrough node, in step 1.3.
  • The plan ends with 28 open questions. Questions 1, 6, 9, 11, and 17 have answers. Questions 3, 5, 10, and 12 change the order of work. Questions 18 to 28 came from the spike.
  • The plan's citations stay on 54e647124 until refactor(stack-encrypt)!: clearer names and modules for the dynamic record path #2042 merges. That pull request moves several of the cited lines.
  • No changeset: the PR changes one file under docs/plans/.

A draft plan in two phases. Phase 1 encrypts a record in one walk, adds a
term node to the ciphertext tree, and moves the building of a stored type
into Go and TypeScript, so the resolver can be removed. Phase 2 returns a
query as a tree of terms.
@changeset-bot

changeset-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3b704db

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI; Enforced overrides: Organization
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1245ac6e-f316-44c4-8bdf-581021471ce2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

@coderdan coderdan left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review at medium effort. It reported seven findings. I checked each one against next at 54e647124, and all seven are correct, two of them in part. The inline comments give each finding and what I found when I checked it.

Three findings change the plan's order of work. Four are corrections to citations and figures.

| 2.2 | Query types read it with a visitor, in each language |
| 2.3 | `QueryTerm` and each binding's second reader are removed |

Phase 2 needs steps 1.3 and 1.5. Phase 2 does not need step 1.4.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phase 2 depends on step 1.6, and the plan says it does not.

Step 2.1 drops the SQL domain and the eql encoding from a query's answer. The plan says they exist because a resolver returns finished EQL JSON. Step 2.2 has eql-codegen write query types beside the stored types. Those stored types arrive in step 1.6.

Checked: correct. Suppose phase 2 is built after steps 1.3 and 1.5 only. A query on a field that names an EQL type then fails until step 1.6.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 76cb8ef. Phase 2 now needs steps 1.3, 1.5, and 1.6. Step 1.6 removes the resolver whole, with its query form, the SQL domain, and the eql encoding. In step 1.6 a generated query type is a function of a term's bytes, as in the Go experiment. Phase 2 then makes it a visitor.

- `recipher-frame`: the new kind and the length, in both directions. The
encoder still refuses what the decoder would refuse.
- `stack-encrypt`: `shape_record` writes a term node in place of
`bytes_node`. The Rust `Visitor`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan does not say how the new term method relates to the typed term methods.

The Rust Visitor already has equality, matching, ore, ope, and ore_block (transcode.rs:96 to :130). Each takes a typed term. The plan adds "a new method that the tree calls for a term" and does not say whether it replaces them.

Checked: correct. The typed methods are called by the typed term readers (impl Reader for EqualityTerm and the others, transcode.rs:194 to :215). Nothing in the tree calls them. The plan has to say that the new method is separate from those five, and which code converts bytes to a typed term.

@coderdan coderdan Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 76cb8ef. Step 1.3 has a new paragraph on the Rust Visitor.

  • The five typed methods stay, and the typed term readers still call them.
  • The new method takes a term's bytes, and only the tree's reader calls it.
  • The plan adds no conversion from bytes to a typed term. It says why: the types that read a term from a tree are in Go and TypeScript.

| 1.1 | Go's plan carries match options | Nothing |
| 1.2 | The tree codec takes any leaf | Nothing |
| 1.3 | A term node, and a length on a passthrough node | #2003, 1.2 |
| 1.4 | One walk of a record | Nothing. The walk writes term nodes once 1.3 is in |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 1.4 is listed as depending on nothing, but one seal with a key descriptor for each field is untested.

Today one descriptor covers every key in a tree (core.rs:105). The plan lists the single seal under what neither experiment checked. "Checks to make first" covers step 1.6 only.

Checked: correct in part. The experiment sealed each field through its own pending and merged them. That is one key request already, so step 1.4 has a fallback. The plan does not say so. The plan also does not ask for the descriptor change to be checked first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 76cb8ef. Step 1.4 now starts by trying the descriptor change. The step says that the experiment merged one pending for each field, and that the merge already makes one key request. If the single seal does not work, the step keeps the merge. The step table names the check.

|---|---|---|
| `conformance/stack-encrypt/v1/record-raw-frames-v1.cases.json` | 1.3 | Its cases are transport bytes, so they are regenerated |
| The `ciphertext_malformed` section of `conformance/vitaminc-aead/value-conformance.json` | 1.3 | Has new cases for the new kind and the length |
| Go's `FuzzUnmarshalCipherText` and its seeds | 1.3, 1.5 | Covers the new reader |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FuzzUnmarshalCipherText is not in this repository at the cited commit.

The same is true of the exported UnmarshalCipherText that step 1.5 cites at records.go:93.

Checked: correct. On next, records.go:93 calls the unexported wrapper unmarshalCipherText. The wrapper calls vitaminc's vcffi.UnmarshalCipherText (ciphertext.go:95). The fuzz target and the function in internal/frame arrive with #2003. The plan has to say that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 76cb8ef. Step 1.5 now says the call at records.go:93 goes through a wrapper, and that UnmarshalCipherText in internal/frame is the function it reaches after #2003. The checks table says #2003 adds the fuzz target.


Rust's plan accepts the options in an object form
(`packages/stack-encrypt/src/dynamic/record.rs:1206`). Go's plan cannot send
them. `encrypt.Match` takes options and drops them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 1.1 misdescribes Go's match options.

The plan says encrypt.Match "takes options and drops them". No MatchOption exists to drop: the type is an interface with no implementation. The comment the step corrects is on MatchOption (term.go:53), not on encrypt.Match.

Checked: correct. The step has to define the options in Go's public API as well as send them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 76cb8ef. Step 1.1 now says Go has no option to give: MatchOption has no implementation, and encrypt.Match ignores its arguments. The step defines the options in Go's public API, sends them, and corrects the comment on MatchOption.


The pieces for one walk exist in `vitaminc-aead`: `Sink`, `Tee`
(`packages/vitaminc-aead/src/plaintext/tee.rs`), `EncryptSink::root`
(`packages/vitaminc-aead/src/encrypt_sink.rs:131`), and `Either`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two citations point at the wrong symbol.

  • encrypt_sink.rs:131 is pub fn plan. EncryptSink::root is at :273.
  • query.rs:290 is enum Operand. QueryTerm is at :281.

Checked: both correct. For the second, the four shapes are Operand's, so the sentence should cite both lines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 76cb8ef. EncryptSink::root is cited at :273. The query sentence cites QueryTerm at :281 and the four shapes of its operand at :290.


- the second form of every dynamic entry point, and `Verb::Target`;
- about 730 lines of `packages/stack-encrypt/src/dynamic/target.rs`;
- the three resolver files of `eql-bindings`, about 3,000 lines;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two size figures are wrong.

  • The three resolver files are resolver.rs, targets.rs, and query.rs under eql-bindings/src/encryption/. They total about 2,300 lines, not about 3,000.
  • More than ten source files name QueryTerm, and the list leaves out eql-codegen and the Go SDK.

Checked: both correct. The files are 425, 1,225, and 650 lines. Outside tests, 12 Rust source files name QueryTerm: seven in stack-encrypt, two in eql-bindings, and three in the Go guest. eql-codegen/src/targets.rs and six files of the Go SDK name it too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 76cb8ef. Step 1.6 names the three files and says about 2,300 lines. Step 2.3 gives the count I checked: 12 Rust source files outside tests, with eql-codegen/src/targets.rs and six files of the Go SDK.

Phase 2 depends on step 1.6, because the resolver's query form goes there.
Step 1.4 checks the single seal first and can keep today's merge of
pendings. Step 1.3 says how the new term method relates to the typed term
methods. Step 1.1 defines Go's match options as well as sending them. Two
citations and two size figures are corrected, and names that arrive with
#2003 say so.
@coderdan
coderdan marked this pull request as ready for review December 1, 2026 13:09
@coderdan
coderdan requested a review from a team as a code owner December 1, 2026 13:09

@cipherstash-agent cipherstash-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review attestation

Reviewed 76cb8efe · posted from Claude Code · claude-opus-5-5 · effort medium
Sources: code-review · claude-opus-5-5; rust-security · claude-opus-5-5; mattpocock-skills:code-review (standards and spec) · claude-opus-5-5
Skills: code-review, company-skills:rust-security, mattpocock-skills:code-review, company-skills:review-cross-check

Findings (14): 5 major, 9 minor. All 14 are inline.

Every finding was checked against the code at 76cb8efe. None repeats the seven threads already on this PR. Three findings were refuted and are not posted: the TypeScript {t, v} form (no shipped addon produces it), the count of 26 frame tags (correct: 0xF4 is refused on read), and skills drift (no skill documents this surface).

Four further points need a decision by the author and were not verified as defects:

  • A term node would count as a sealed leaf in check_shape (vitaminc-aead/src/seal.rs:293) and sealed_any (walk.rs:146), because both test !matches!(n, Passthrough). Then a map or sequence that holds only terms passes the rule that refuses a container with no sealed leaf. Step 1.3 should say that a term is not sealed.
  • After step 1.6, the dynamic path refuses a JSON index on a plain field (JsonIndexPending, kind.rs:111-118). Its JSON operators also run only through a target (query.rs:833-838). So the JSON check needs more than the host building the stored value.
  • Step 1.6 removes eql_bindings::encryption::{query, targets}. These are public modules of a crate published in lockstep with @cipherstash/eql, so that is a major release of all five EQL artefacts. The section "What this changes elsewhere" does not say so.
  • value-napi/src/ciphertext.rs:23-31 says applications may have persisted {t, v}. That is out of date, but it is not part of this plan.

Generated by Claude Code

Comment on lines +309 to +318
Changes:

- `vitaminc-aead`: the variant, and what each sink and reader does with it.
- `recipher-frame`: the new kind and the length, in both directions. The
encoder still refuses what the decoder would refuse.
- `stack-encrypt`: `shape_record` writes a term node in place of
`bytes_node`. The Rust `Visitor` has a new method for a term's bytes,
described below.
- `languages/golang/internal/frame/ciphertext.go`: the same two changes. The
SDK's hand-written mapping reads the new node until step 1.5 replaces

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major Step 1.3 leaves out TypeScript. node_to_js in recipher-js/value-napi/src/ciphertext.rs:192-225 is an exhaustive match on CipherText, so the new variant breaks the build, and tests-recipher-js.yml runs on vitaminc-aead/**. The shipped addon exposes one opaque Ciphertext (recipher-js/crate/src/ciphertext.rs:34), so no step gives TypeScript the tree's transport bytes that step 1.5's reader reads: add value-napi here and a step, before 1.5, that hands TypeScript a record tree.

Source: code-review · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0c4766a. I checked both claims, and both are correct.

  • Step 1.3 lists value-napi/src/ciphertext.rs and its match on every variant.
  • The TypeScript half of step 1.5 now starts with two native calls. One returns a record's tree as transport bytes. The other takes a tree back, for decrypt.

PR #1776 adds records to the package in another form. Open question 14 asks how the two relate.

Comment on lines +193 to +195
Each check is done when the host type builds the bytes Rust builds. If the
JSON check fails, it must report what else has to cross. Step 1.6 then keeps
the resolver for the JSON types until that is settled.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major This fallback contradicts step 1.6's done criteria (L492-497): if the JSON check fails, 1.6 keeps the resolver, so stack-encrypt never builds without one, not every EQL v4 type gets a host type, and the Go tests do not pass on one guest. Phase 2 needs 1.6 (L507), so it is blocked with no way out. Split JSON's resolver removal into its own step with its own done criteria.

Source: code-review · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0c4766a. The resolver's removal is its own step, 1.7, with its own done list. Step 1.6 is done one type at a time.

If the JSON check fails, step 1.6 still covers every other type. Step 1.7 and phase 2 then wait for a revised plan. The plan does not design that revision, because nobody knows yet how the check would fail.

because a resolver returns finished EQL JSON;
- the Go guest built with the EQL types, and its test build. A Go release
then carries three guests, not five;
- every mention of EQL in `stack-encrypt`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major "Every mention of EQL in stack-encrypt" cannot be removed while the plan keeps what uses it. json/query.rs:403 and :434 serialize the eql_v4.query_json_* operands that the kept eql-bindings JSON types use (L471), and pub mod eql_simulator (lib.rs:739) is public; #2033 says to leave both alone. Limit the removal to the resolver path: TargetResolver, EQL_KEY (record.rs:177), NoEqlNode, the "eql" query form (query.rs:392), and the query domain fields.

Source: code-review · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0c4766a. I checked json/query.rs:403 and :434, and lib.rs:739. The finding is correct.

Step 1.7 lists what it removes: TargetResolver, EQL_KEY, NoEqlNode, the "eql" query form, and the SQL domain. The step names the two mentions that stay. The summary no longer says that Stack Encrypt does not name EQL.

Comment on lines +524 to +526
The operator, the fidelity, and the index leave the answer. They describe
the plan, not one query. Go's checker already reads them from the catalog
(`languages/golang/encrypt/checker.go:295`). The SQL domain and the `eql`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major Removing the resolver in step 1.6 removes the catalog this relies on. Go's Checker.Targets (checker.go:73-84, used by stashgen/engine.go:102) reads se_targets, which comes from TargetResolver::targets() (target.rs:563), and field_operators, verify, target_limit, and check_query take resolver in their only form (query.rs:534, :1196, :1248, :815), with target_limit's EQL twin branch backed by the MatchTwin that 1.6 deletes. Say in 1.6 where the type catalog comes from, and drop the resolver parameter and the twin branch. checker.go:295 is inside parseOperators' switch, not a catalog.

Source: mattpocock-skills:code-review (spec) · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0c4766a. I checked every line cited, and the finding is correct.

  • Step 1.6 says where the catalog comes from today. It proposes that eql-codegen writes the catalog into each language. Open question 12 asks for a decision.
  • Step 1.7 removes the resolver parameter from the five query calls, and the EQL branch of target_limit.
  • The sentence that cited checker.go:295 was wrong. It now says that Go parses the result of field_operators there.

Comment on lines +112 to +113
four fixed shapes (`:290`). The answer crosses through serde. Each binding
has a second reader for the answer, such as Go's `parseQueryTerm`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor AGENTS.md says "Do not call the user-facing library a binding". parseQueryTerm is in the Go SDK's encrypt package, at query.go:184, not :177. The same mistake is at L292, L505, and L565: write "language SDK" or "each SDK" there.

Source: mattpocock-skills:code-review (standards) · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0c4766a. The citation is query.go:184. The four places now say "language SDK", "SDK", or "reader".


| Check | Why it is first |
|---|---|
| A JSON search type built in Go or TypeScript | The hard case: 1,050 hand-written lines in `packages/eql/crates/eql-bindings/src/v4/json_tree.rs`. Nobody has looked at what the tree contains for a JSON index today, or whether that is enough to build the stored value |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor json_tree.rs has 1,050 lines in all, and #[cfg(test)] starts at line 882, so about 880 lines are code outside tests.

Source: mattpocock-skills:code-review (standards) · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0c4766a. The plan says 1,050 lines, about 880 of them outside tests.

Comment on lines +611 to +615
- **Decision records.** This plan needs a record of its own. That record
changes what three others describe:
- the target model (0003);
- how a binding enters (0007, with its amendment for the EQL guest);
- the query term (0009).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor There are three ADR-0003 files: docs/adr, packages/stack-encrypt/docs/adr, and packages/vitaminc-aead/docs/adr. Give the paths, or write "stack-encrypt ADR-0003, 0007, and 0009".

Source: mattpocock-skills:code-review (standards) · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0c4766a. The plan names packages/stack-encrypt/docs/adr.

Comment on lines +480 to +481
Then the resolver is removed:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor The PR body says step 1.6 removes the output #2033 is about, but the plan does not name #2033, EQL_KEY, or the record's eql key. #2033 asks for the change before the TypeScript SDK ships, and step 1.5 comes before 1.6, so a TypeScript reader could ship that reads eql. Name #2033 here, or do its rename before step 1.5.

Source: mattpocock-skills:code-review (spec) · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0c4766a. Step 1.7 names #2033, EQL_KEY, NoEqlNode, and the query form.

Under this plan the TypeScript SDK never reads the eql key, because its types ask for plain outputs. Go reads the key until step 1.7. I did not move the rename ahead of step 1.5. If it is wanted sooner, #2033 can be done on its own.


| Check | Result |
|---|---|
| Go's and TypeScript's stored values against Rust's | The same bytes, once `c` is set aside. `c` is sealed under a new key each time |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor Go cannot send EQL's match options today (term.go:53-65, record.go:544, step 1.1), so Go's TextMatch matched Rust's bytes only through a test-only route. Say so in this row.

Source: mattpocock-skills:code-review (spec) · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0c4766a. The row now says that Go sent EQL's match options through a test-only call.

A second review found that the plan could not finish if the JSON check
failed, because one step both built the stored types and removed the
resolver. Step 1.6 now builds the types one by one, and step 1.7 removes
the resolver when every type is done.

The plan also says what the JSON check has to change first, where the type
catalog comes from once no resolver answers, which mentions of EQL stay in
stack-encrypt, and that TypeScript needs a call that returns a record's
tree. Step 1.4 has two refusal tests. Refs #2033.
@coderdan

coderdan commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Replies to the four points in the review body that asked for a decision. I checked each against the code.

  1. A term counted as a sealed leaf. Correct (seal.rs:293, walk.rs:146). Step 1.3 now says that a term is not a sealed leaf, and names both rules.
  2. The JSON index on a plain field. Correct (refusal.rs:923, query.rs:833). "Checks to make first" now says the JSON check has to change Stack Encrypt first. It has to admit the index on a plain field and return the document in the tree.
  3. The public modules of eql-bindings. Correct. query and targets are public. targets is public on main too. The plan lists this under what changes elsewhere. Open question 13 asks whether it is a major release.
  4. The comment in value-napi. Not part of this plan, so nothing changed.

All 14 inline findings were correct. The fixes are in 0c4766a. Each thread has a reply.

|---|---|
| A JSON search type built in Go or TypeScript | The hard case. `packages/eql/crates/eql-bindings/src/v4/json_tree.rs` is 1,050 lines, about 880 of them outside tests. Today's tree has nothing to build the type from. See below |
| The order types: `ob`, `op`, and `between` with its two terms | A second kind of term, and a query of two terms. The check needs only today's tree and the experiment's deserializer |
| `TextSearch` | Its filter differs from the filter of `TextMatch`. The check needs only today's tree and the experiment's deserializer |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do they differ? I suspect they shouldn't.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right for almost every text. The plan's sentence was wrong.

The two types build a filter the same way. Both use EQL's match options, EqlMatch. See packages/eql/crates/eql-bindings/src/encryption.rs:472 for TextMatch, and :517 for TextSearch. Both write the positions as the same list (:443). The two filters have one JSON schema (packages/eql/crates/eql-bindings/src/v4/mod.rs:126).

The types differ in one case: text that cuts no token, such as empty text or one letter.

Type Text that cuts no token
TextMatch Refused with EmptyTermText (encryption.rs:434)
TextSearch and TextSearchOre Stored with an empty filter (encryption.rs:498)

The rustdoc gives a reason at v4/mod.rs:104. = and < still find a search value through hm and its order term. A TextMatch value with an empty filter is a row that no operator can find.

Fixed in 4b7ba10. The plan has a new section, "The TextSearch check", that says this. Under this plan the difference is one rule in the host types: TextMatch refuses a match term with no positions, and TextSearch accepts it.

A single rule for both types would change what EQL stores or refuses. This plan does not make that change. Do you want it listed as an open question?

…SON check

The plan said the filter of TextSearch differs from the filter of
TextMatch. The two are built the same way, under the same match options.
They differ only for text that cuts no token: TextMatch refuses it, and
TextSearch stores an empty filter. The plan now says so, with the lines
that do it, and names the one rule the two host types differ by.

The JSON check gave two facts and no reason. It now says why a JSON
document has no route through the tree today: a plan cannot list the
JSON index as an output, the target builds the stored value in Rust from
the index's document, and a JSON operator reads its options from the
target.

| | Go | TypeScript |
|---|---|---|
| Where | `languages/golang/internal/frame`, on that package's reader | `languages/typescript/packages/recipher-js/src`, in TypeScript |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is used by encrypt/eql and likely by others later, I'd suggest that its not in "internal".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and changed in cbec346. The plan now puts Go's reader and visitor in a public package.

What I checked:

  • internal. Go lets only code inside languages/golang import a package under languages/golang/internal. encrypt/eql has no go.mod of its own, so it is inside. That package could import the reader from internal. A type in another module could not.
  • gensupport. The plan assumed that gensupport would make the visitor public. That package is for code that stashgen writes. The package's documentation says that a program never imports it (languages/golang/encrypt/gensupport/gensupport.go:3). So gensupport is the wrong place too.
  • The experiment. The experiment's package was public already: languages/golang/encrypt/transcode. That package imported the standard library alone, so no exported name used an internal type.

The plan has a new paragraph in step 1.5, "Go's reader and visitor are public", that says this. The frame codec from #2003 stays in internal/frame. Step 1.3 still changes it there.

Two parts are open, and open question 8 now asks them:

  1. The name. The plan proposes encrypt/transcode, after the Rust module. Do you want another name?
  2. The default. The visitor becomes public API. A new kind of node adds a method to the interface, and that change breaks a type that does not embed the default. Should the interface make every type embed the default?

A stored type implements the visitor, so a type outside the Go module has
to be able to import it. A package under internal cannot be imported from
another module, and gensupport is for generated code alone. The open
question on the package now asks for its name, and whether a type must
embed the default.
| Where | `languages/golang/internal/frame`, on that package's reader | `languages/typescript/packages/recipher-js/src`, in TypeScript |
| Who can use it | The SDK and `encrypt/eql`. Generated code reaches it through `gensupport` | The package and the EQL extension |
| Failures | Two errors: malformed bytes, and a shape the type does not store | The same two, as a result value. Nothing throws |
| The way back | `MarshalCipherText` exists | A small encoder, for the tree a decrypt sends |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjust the names of these so they are consistent across languages (within the conventions of the language).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 242f795. Step 1.5 has a new table, "Names", with one name for each part. Each language writes the name in its own style.

Rust has every part today but the method for a term node, so the table uses Rust's words:

Part Rust Go TypeScript
The interface Visitor Visitor Visitor
The method for a term node term Term term
The elements of a sequence SequenceReader SequenceReader SequenceReader
The entries of a map MapReader MapReader MapReader
From bytes to a visitor decode_ciphertext DecodeCipherText decodeCipherText
From a tree to bytes encode_ciphertext EncodeCipherText encodeCipherText

The six methods for today's kinds of node have the same words too: sealed, sequence, map, empty_sequence, empty_map, and passthrough.

The Go names, the TypeScript names, and term are proposed. They differ from the code in three places:

I left the names of the two errors out of the table. You parked the naming of errors earlier.

- the generated code that takes only a term's bytes
(`languages/golang/encrypt/gensupport/field.go:121`).

This is not a small change. `QueryTerm` and its operand are public. Outside

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the go bindings are in use anywhere. We may want to consider a deprecated shim for QueryTerm that is implemented in terms of the new structure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 242f795, as an option in step 2.3 and as open question 15. The plan does not choose yet.

Three facts decide how much a shim helps in Go:

  • Cipher.QueryTerm. A program cannot call this method. The method takes a plan type from an internal package (languages/golang/encrypt/query.go:140).
  • Generated files. A generated file calls Term, Range, and NullTerm in gensupport (languages/golang/encrypt/gensupport/field.go:121, :131, and :143). Each returns a term's bytes.
  • The layout version. A generated file names the version of its layout (languages/golang/encrypt/gensupport/gensupport.go:35). A file from another layout does not compile.

So the shim matters most for a generated file that was written before the change. With the shim, that file still compiles. Without the shim, the program has to run stashgen again.

I have not checked whether steps 1.6 and 1.7 already change that layout. If they do, a program runs stashgen again in phase 1, and the shim helps less.

The Rust QueryTerm in stack-encrypt is public too (packages/stack-encrypt/src/dynamic/query.rs:281). I read your comment as about Go alone. Is that right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

…im to consider

The reader and the visitor had different names in Rust, in the experiment
and in the Go codec. The plan now proposes one name for each part, written
in each language's style. Step 2.3 records the option of a deprecated
QueryTerm in Go, with the facts that decide how much it helps.
@coderdan

coderdan commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

#2003 is updated, and this plan's Go steps name a package it no longer adds.

#2003 no longer merges vitaminc's Go packages into internal/frame. It moves them as they are, and both are public:

  • vcffi → languages/golang/encrypt/frame: the codec, including MarshalCipherText and UnmarshalCipherText, and the storage profile.
  • vcvalue → languages/golang/encrypt/value: the value types. It imports only the standard library.

encrypt.Date, Decimal, Int128, Uint128 and UUID are aliases of value's types, and encrypt.Encryptable and Encoder are aliases of frame's.

So the plan's references to internal/frame (lines 274, 371, 393 and 574) need to become encrypt/frame. That also bears on open question 8. Step 1.5 proposes a new public package, encrypt/transcode, beside the codec, partly because the codec was internal. Now that encrypt/frame is public, the reader and visitor could live there, next to UnmarshalCipherText, which step 1.5 already says becomes a visitor on the public reader. Is a separate package still wanted?

An open question moved here from #2003. encrypt.Cipher's QueryTerm, Verify, TargetLimit, Contexts, Seal, Open and JSONOpen all take a *record.Plan, from internal/record. A program outside the module can't import that type, so it can't call these methods; only generated code can. Step 2.3 removes QueryTerm. The plan doesn't say what happens to the other six. Step 1.4, where a record is encrypted in one walk, rewrites the path behind Seal and Open. Should that step also give these methods signatures that use no internal type, by the rule the plan sets for the visitor ("No internal type in an exported name")? Or should they stay as they are, for generated code only?

…oes there

The frame-codec pull request now moves vitaminc's Go packages as two public
packages, encrypt/frame and encrypt/value, and adds no internal/frame. The
plan's Go steps name the new path. With the codec public, the reader and
the visitor go beside it, so the plan no longer proposes a package of its
own. A new open question asks what happens to the Cipher methods that take
an internal plan type.
@coderdan

coderdan commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Checked against #2003 at 5aa6552, and fixed in 132a2a3.

The package path. #2003 now adds languages/golang/encrypt/frame and languages/golang/encrypt/value, and no internal/frame. The plan's Go steps name encrypt/frame in every place.

The reader's package. The plan no longer proposes encrypt/transcode. Step 1.5 now puts the reader and the visitor in encrypt/frame, beside the codec. The reasons:

  • The codec was internal, and that was the main reason for a second package. It is public now.
  • With the reader beside the codec, one package reads the tree. Step 1.5 has a rule that each language has one parser.
  • encrypt/frame imports the standard library and encrypt/value alone, so no exported name uses an internal type.

Open question 8 still asks whether a package of its own is wanted. That choice is not mine to make.

The six Cipher methods. Added as open question 16. The facts in the plan:

  • Verify, TargetLimit, Contexts, Seal, Open, and JSONOpen take a *record.Plan (languages/golang/encrypt/query.go:292, languages/golang/encrypt/records.go:47).
  • Step 1.4 rewrites the path behind Seal and Open.
  • The Go SDK's principle 7 says that no method that a user touches is called a plan or returns one (docs/sdk-design-principles.md:160).

The plan does not choose. Principle 7 rules out a public signature that takes a plan. So the choice is between a move behind gensupport and no change.

The spike in #2043 walks a record with one sink built from the plan and
seals it in one pass, with no adapter sink in the caller. The plan now
records the decisions from the spike, what it checked, the order of the
pull requests for step 1.4 and the rules each one follows. Questions 1,
9 and 11 have answers, and question 17 asks whether the plan still
implements EncryptTarget.
The spike in #2043 showed that a target can be declared once, as a sink
for one walk of the value and a finishing step, and that the one
declaration encrypts the target, decrypts it and gives its query terms.
The combinators become adapters over that trait, as the standard
library's iterator adapters are. This is how the plan's third decision
is built, so the question of whether it still stands is answered.

The plan now has:
- the decisions made during the spike;
- the declaration design, and what the compiler checks;
- what the spike checked for encrypt, decrypt and query, what it did not
  cover, and the four ways it differs from today's code;
- the layout of stack-encrypt and vitaminc-aead: the three calls as
  top-level modules, one place for each index, the order of the
  modules, and the crate root's 29 names;
- the groundwork that can start now: #2042, the AES cipher in #2044,
  vitaminc-normalize and the layout moves;
- step 1.4 as eight pull requests;
- twelve new open questions, and answers to questions 1, 6 and 17.

It replaces the record-sink design of the last commit, which the
declaration design superseded.
The plan said the move was an unchanged copy of the published crate,
followed by the crate's changes. The move in #2052 follows the
vitaminc-aead move: the crate comes with its git history, at the code of
its 0.10.0 release. The crate's own changes follow from the vitaminc-aead
changes in step 1.4, so they go there. The supply-chain store does not
cover the crate yet, and the plan now says what that needs.
The plan's file:line citations now point at next at b939de4, the merge
of #2042. They were read at 54e6471.

#2042 moved the dynamic record code. The match options' object form and
EQL_KEY are now in dynamic/record/plan.rs, and bytes_node and the record
decrypt doc are further up dynamic/record.rs. #2003 shifted lines in the
Go SDK's query.go and records.go, and the EQL guest builds in
tests-golang.yml.

Every citation was updated. None could not be.
#2044 moved the AES-256-GCM cipher into vitaminc-aead. Its only caller
outside tests is stack-encrypt, which builds a one-key Aes256Cipher for
each leaf inside its own key-per-leaf cipher, and seeds a random number
generator for each leaf while doing so.

Step 1.4's first pull request now moves the cipher into stack-encrypt as
crate-private functions, with the stored layout of a leaf. vitaminc-aead
then has no encryption primitive and no key. Before that, cargo deny and
cargo vet cover stack-encrypt (#1842), so that aws-lc-rs, aws-lc-sys and
aes-gcm stay checked.

Two open questions are new: where the leaf layout sits in stack-encrypt,
and what the two tests outside stack-encrypt that build an Aes256Cipher
seal with afterwards.
The plan opened with about 25 decision bullets before its summary, and
used terms such as spike, sink, declaration, resolver, and visitor before
saying what they mean.

The summary now comes straight after the contents. A terms section
defines the words a reader needs, and the decisions follow in a section
of their own. The groundwork labels say that G stands for groundwork.
Fifteen sentences that began with a pronoun that could point at more than
one thing now name what they mean. No decision, step, or question
changed.
| Adapter | `a.accepting::<C>()` | Take a context that converts to the one `a` needs |
| Adapter | `a.under(own)` | Run under a context of its own |
| Adapter | `a.entry("email")` | Read the entry of that name from a record |
| Adapter | `a.under_field("email")`, `fields.context_from("tenant")` | For a record whose context is the value of one of its fields |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there two versions of this? Are they different or used in different places?

A record of two fields is one expression. The derive writes it:

```rust
indexed_equality().under(label("users/email")).entry("email")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is indexed_equality() in this example?

Comment on lines +278 to +281
.convert(
|(email, age)| EncryptedUser { email, age },
|stored: EncryptedUser| (stored.email, stored.age),
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow what Convert is doing here.
Might be helpful to include a full example.

Comment on lines +286 to +291
```rust
plan.fields().iter()
.map(|field| planned(field)?.under(own).entry(name))
.collect::<Result<Fields<_>, _>>()?
.record()
```

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this example the dynamic equivalent of the combinator above?
Where do the own and name values come from?

Comment on lines +307 to +308
`map` and `try_map` are the two adapters that do not open, because a
function has no inverse. A target that has to open ends with `convert`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow what this means.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants