Repository navigation
Conversation
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.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
coderdan
left a comment
There was a problem hiding this comment.
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.
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.
cipherstash-agent
left a comment
There was a problem hiding this comment.
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) andsealed_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-31says applications may have persisted{t, v}. That is out of date, but it is not part of this plan.
Generated by Claude Code
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.
|
Replies to the four points in the review body that asked for a decision. I checked each against the code.
All 14 inline findings were correct. The fixes are in 0c4766a. Each thread has a reply. |
…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.
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.
…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.
|
#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
So the plan's references to An open question moved here from #2003. |
…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.
|
Checked against #2003 at 5aa6552, and fixed in 132a2a3. The package path. #2003 now adds The reader's package. The plan no longer proposes
Open question 8 still asks whether a package of its own is wanted. That choice is not mine to make. The six
The plan does not choose. Principle 7 rules out a public signature that takes a plan. So the choice is between a move behind |
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 last commit dated both a day late.
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.
Open question 2 is answered. Every language can then skip a passthrough node without reading its frame.
Open question 3 is answered by the rule for decrypt: a term opens nothing. A term at the root or in a sequence is refused as malformed.
On decrypt, a type that stores its context opens under the stored one, as typed Rust does today. A renamed column then does not stop old rows from opening. The Go SDK refuses a stored i that differs from the plan, so step 1.6 changes that. Open question 4 is answered.
The last commit recorded the opposite of the decision. Today's rule stays: on decrypt, the stored i of an EQL value has to match the plan's label. The label comes from the declaration and is independent of the name of a database column, so a renamed column does not stop old rows from opening.
Open question 5 is answered. eql-codegen reads the catalog, so the generated Go and TypeScript types and eql-bindings share one source.
An EQL value is written with the prefix rc:1: in place of stack-encrypt:1:. A reader accepts both, so every stored value still opens. It is groundwork item G9. Open question 41 asks whether the change is rolled out in one release or two.
The first release accepts both prefixes and still writes the old one. The second writes rc:1:. Open question 41 is answered.
Open question 7 is answered for selectors and tokens. The host type writes the base64 and decides how the value binds. The two operands that are whole EQL objects wait for the JSON check.
…e default Open question 8 is answered. The interface has one unexported method that only the default has, so a new kind of node breaks no type.
Open question 10 is answered. Issue 2029 stays open until step 1.5 lands.
Open question 12 is answered: an SDK reads no list of types. The EQL package has each concrete type with its visitor. Step 1.6 had three stale sentences. After G8 no rule about empty match text moves to the host type. The host type checks the stored i. The prefix on c comes from the catalog, and a reader accepts both.
…tashgen Open question 13 is answered: no release has the two eql-bindings modules, and the next EQL release waits until this plan is done, so they are deleted. Open question 42 asks whether the Go SDK keeps its code generator once the stored types are built in Go.
The Go SDK reads the fields of a struct while the program runs, as encoding/json does. The call is cipher.Encrypt(ctx, users, &rows). A stored struct can also have a method that says how it is sealed, and the compiler then checks each field. It is step 1.8. The Go principle that asks for a generator is dropped, and so is the rule that no call takes a context. An SDK mirrors the Rust API as closely as is idiomatic in its language. PR 1716 is a second generator for a program that uses sqlc, because stashgen has no struct to tag there.
Open question 14 is answered. Step 1.5 builds TypeScript records on the tree from the start. Issues 1813 and 1803 stay open until then.
…e unexported Open questions 15 and 16 are answered by step 1.8: with no generated code, Go needs no deprecated QueryTerm, and the cipher methods that take a plan have no caller outside the module.
Open questions 18 and 19 are answered. DecryptSource<P> keeps the compile-time check that a stored type opens to a plaintext type, and returns the decrypt half of the declaration.
Open question 21 is answered. Step 1.4 keeps the order of next.
Open questions 22 and 23 are answered. Both are on next, and the spike left both out. Step 1.4 keeps them, and its done-when list says so.
Open question 24 is answered. Each index says whether it has an index for each operator, written out with no macro, and zip reads that from its two sides. A prototype compiled.
Open question 25 is answered. A closure reads each field and gives its type, so a hand-written declaration cannot check one field and seal another. A plan still reads fields by name. A prototype compiled. The closure that builds the plaintext takes the fields by position, as next does, so two fields of one type can still be exchanged there.
…me for it Open questions 26 and 28 are answered. A typed JsonPlaintext is handed to the JSON tree directly, as on next. Its walk gives JSON text, which is the opaque form. For a struct or a record from a binding, a sink is the aim, and the JSON check decides. The plan says JSON tree where it said JSON index, and the terms section defines JSON tree and opaque JSON.
Open question 27 is answered.
Open questions 29 and 30 are answered. The stored layout of a leaf is in sealed/. The EQL test for opaque JSON and the test crate of the recipher-js value bridge both go through Stack Encrypt, with the test key source of the test-support feature.
The groundwork table says which pull requests exist. Step 1.3 no longer waits for open question 3, which is answered.
The CRAP (Change Risk Anti-Patterns) gate scores every function under the crate's source folder and fails on a complex function with no coverage. The gate skipped test code in two ways: a `tests/` directory by an exclude, and an inline test module because the tool does not score one. A test module in a file of its own is neither. So the gate scored 346 test functions as production code and failed on seven of them. The task now excludes `tests.rs` and `*_tests.rs`, as the stack-auth task already does for `tests.rs`. With the excludes, the tool scores the same 1,779 functions as it does on the base branch. Refs #2040
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:
The plan also says how the one walk is built. A field is described once, by a declaration. That one declaration encrypts the field, decrypts it, and gives its query terms. The design follows the iterator adapters of the Rust standard library. A spike of it is in #2043.
Three more parts came from the review:
cipher.Encrypt(ctx, users, &rows), and the SDK reads the struct's fields while the program runs, asencoding/jsondoes. That is step 1.8.cbecomesrc:1:. A reader accepts the old prefix too, so every stored value still opens. Nothing else that is stored changes.stack-encryptandvitaminc-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.The plan has these parts:
Verification
Citations. The plan cites code as it stands on
nextatb939de404. Each cited line was read there. The answers of 5 and 6 December citenextatbf69526db, and were read there. Lines cited from the spike say so, and name spike: one walk for records and values (not for merging) #2043.Reviews. Two automated reviews checked the first version against the code. Dan Draper then reviewed the plan and left 17 comments. Every finding and comment has an answer on this pull request.
Open questions. Each one was gone through with Dan Draper on 5 and 6 December 2026. Each answer is written under its question in the plan.
The spike. spike: one walk for records and values (not for merging) #2043 tried the declaration design for encrypt, decrypt, and query.
Prototypes. Six small programs were compiled and run to check claims in the plan. Three are Rust, on 1.94.1:
zipleaves a term out of what decrypt takes;Three are Go, on 1.26.10. They show the shape of a call with no generated code, and which mistakes the compiler finds. None of the six encrypts, and none is in this pull request.
Plain language. The checker reports 0 items that must be fixed.
No test was run for this pull request, because it changes no code.
Related
@cipherstash/recipherhas no records — declare a record once and encrypt and decrypt whole rows and single fields #1813, andrecipher-jsreview cleanups: remove theLabelboundary check, deriveOpaqueDebugonRecordPlan, and rewrite the doc comments in plain language #1803. These issues stay open until step 1.5 lands.stashgencannot tag. Step 1.8 answers both.eql, so a generic mechanism is named after one product #2033. Step 1.7 removes the output that issue is about.cargo denyandcargo vethave to coverstack-encryptbefore the AES cipher moves there.Review notes
stashgen, where a struct declares its context, and how a query names a column. They also cover which other Go principles change. Question 47 is about a record of a Rust struct. Questions 43 to 46 wait for the trial in step 1.8.docs/sdk-design-principles.mdand its decision record change in a pull request of their own.plaintext_from, and the Go and TypeScript names in step 1.5, are proposals.docs/plans/.