Repository navigation
Conversation
WalkthroughWarning Review details and warnings were omitted to fit the comment limit. |
🦋 Changeset detectedLatest commit: 2c26998 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Mutation testing (cargo-mutants,
|
| caught | missed | unviable | timeout |
|---|---|---|---|
| 436 | 0 | 203 | 0 |
cargo-mutants exited with no surviving mutants recorded. The run may not have completed cleanly; check the workflow run logs.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a05affaaa5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
freshtonic
left a comment
There was a problem hiding this comment.
I request changes for two release problems on the crates.io side. The code itself is in good shape, and every check I ran passes.
How I reviewed this
The diff is large because generated code is committed. I reviewed the generators and their templates, then I ran the drift checks to prove that the committed output matches them. I did not read each generated file.
- EQL codegen:
eql-codegenrenders the version-neutral SQL source two times (eql_v3andeql_v4) from theeql-domainscatalogue. It also generates the Rust payload types andeql_gen.go. - Go:
stashgengenerates the*_stash.gofiles and the goldens.
Checks run (in a worktree at a05affaaa)
- EQL:
cargo test -p eql-codegen(includes the Go parity test): pass.mise run types:check,codegen:parity,test:schemas:parity: pass.mise run build, with the installer completeness gate and the v4 isolation gate: pass.git statuswas clean after all of these.
- Rust and Go:
cargo fmt --check: pass.cargo clippy --workspace --all-features --all-targets -D warnings: pass.cargo test -p stack-guest-abi -p stack-encrypt --all-features: pass.
- Go guests and SDK:
- All five WASI guests build, and the import-surface checks pass.
go vet ./...andgo test ./...inlanguages/golang: pass.go generate ./...leaves no diff.
- I built the v3 bundle and compared it with the
@cipherstash/eql@3.0.6tarball. Onlylints()and comments changed, so the claim "v3 SQL unchanged" holds. git merge-treeagainst currentmain: no conflicts.cargo publish --dry-run -p stack-encrypt-derive -p stack-encryptagainst crates.io: fails (see below).
Blocking
- stack-encrypt 0.3.0 cannot publish. The root release-plz line publishes every stack-* version that crates.io does not have, so merging this starts a publish of stack-encrypt 0.3.0. stack-encrypt requires
stack-kms0.1.0, and that is the only stack-kms version on crates.io. Butsrc/lib.rsre-exportsstack_kms::{diagnostic, ErrorPayload}, and these were added after the 0.1.0 release with no version bump. The packaged build fails withE0432: unresolved imports stack_kms::diagnostic, stack_kms::ErrorPayload.- Fix: bump stack-kms (for example to 0.2.0, with a CHANGELOG entry), and make stack-encrypt require that version.
- Note that the publish dry run on
main(tests-crates.yml) packages all five crates together, so stack-encrypt resolves the tree's stack-kms there. That step does not catch a stack-kms that crates.io lacks under the same version number.
- The stack-encrypt CHANGELOG has no 0.3.0 section.
Cargo.tomlsays 0.3.0, but about 850 lines, including a### Breakingsection, are still under## [Unreleased]. The root release-plz line only publishes and never rewrites the changelog, so 0.3.0 would ship under "Unreleased", as 0.1.0 did. Please rename the section to## [0.3.0] - <date>in this PR.
Non-blocking (see inline)
SchemaVersionis now generic. Rust does not apply a default const parameter in an expression, soSchemaVersion::CURRENTandSchemaVersion::default()stop compiling (E0284). The changeset ships this as a minor bump and says "plainSchemaVersionstill means v3".- The stored and single-bound query domain templates accept
"v": null. The range template already guards against this. - stack-encrypt will publish with an exact pin on
cllw-ore =0.5.2-rc.1. - There are some small nits: stale vitaminc version numbers in comments, a Go wipe path, an ADR reference, and the position of a
use.
Before you merge
eql-bindings now requires stack-encrypt 0.3.0. Its crates.io publish (publish_all_features) succeeds only after release-crates has published stack-encrypt 0.3.0, so blocker 1 must be fixed first. Otherwise the EQL crate publish fails too.
Checked and fine
- SQL renderer: it refuses literal
eql_v3/eql_v4names, unknown placeholders and unmatched blocks. - Range domains and
between: correct, with STRICT/IMMUTABLE accessors and an inlinablebetween. On non-superuser installs, the ORE range domains are disabled with the same NOT VALID CHECK as the single-bound ORE domains. - v4
ore_block_v2SQL: the layout offsets and the GF(2^128) doubling are correct, and errors do not echo the input bytes. - stack-guest-abi
stepandvalue: no new raw reads of host lengths, handles are never reused,MAX_OPENis enforced, and secrets areZeroizingwithOpaqueDebug. - Go step loop: every early exit after a pause aborts the operation and wipes the buffers.
maxPausedis tied to the Rust constant by a test. - Go public surface:
QueryTerm,VerifyandTargetLimitfollow the existingSeal/Openpattern, andMatchQuerynever prints its text. - CI: actions are pinned by SHA, both copies of the path filters were updated, and no release workflow changed.
- Changesets: the EQL changesets are minor, which is correct apart from the
SchemaVersionpoint.chacha20-0-10-2.mdmatches the lockfile moves. - Skills: no skill update is needed.
stash eql installstill installs v3 only, and no skill covers the Go SDK or Stack Encrypt.
Not blocking. The points in this review are still open, but they need not stop the merge.
Deriving a data key from its key material (a recipher re-encryption and a hash) is the costly part of a batch. send_chunked now yields to the async runtime every 64 keys. On tokio that reschedules the task; in a wasm guest it hands control back to the host between chunks. Part of #1762.
A fulfilment can now do part of its work and return the rest (Fulfilled::More). settle_with yields to the runtime between the parts. In a wasm guest a column (Pending::all) stops after about 64 data keys' worth of items, and a pair passes a side's partial result on, so a batch of records yields between its rows. The guards that release recovered plaintext move into the rest, so a batch dropped part way still wipes it. Natively every fulfilment runs to its end as before: a chunk would hold recovered items across a yield, and a native fulfilment must be Send, which would ask T to be Send too. Part of #1762.
A step with an empty list of requests is a yield: the host resumes it at once with no responses, releasing the client lock in between, so the Go garbage collector and other callers get their turn. Every operation now takes a paused slot, since any can pause to yield. A step with no requests field is still malformed. Decrypting 1,410 values against ZeroKMS, the longest guest step falls from 42 ms to 11 ms; most steps take 1 to 2 ms. CPU is unchanged. Closes #1762.
The test-only KeysetCipher::equality_term, match_terms, ore_term, and ope_term were copies of the target path. Each repeated the derivation that the term type's Term::encrypt_from already makes. So the lone_terms tests compared each copy with its original. The four methods and the lone_terms tests are removed. The dynamic tests that compared a dynamic term with a typed one now derive the typed term through its target, with encrypt_into_with_context. That keeps two separate paths in each comparison. The test file `tests/credential.rs` already checks that a term built before the keyset loads is the term built after it. The helpers equality_term_normalized and match_terms_under now compile only with the dynamic feature, because only that path calls them. The docs no longer say that the compiler enforces one context for a term and its ciphertext. A bare term target still takes any context. The term shares its ciphertext's context only as a field of a derived record, or beside its ciphertext in Encrypted<(…)>. The wording changes in ADR-0004's amendment, the CHANGELOG, and the sem module and impl docs. Each also says that a bare MatchTerms with short words on is a stored filter, not a query. The CHANGELOG upgrade note now covers jiff's civil::Date and Timestamp, and rust_decimal's Decimal. OreTerm<T> and OpeTerm<T> need T: Zeroize, so those types take value::Date, value::Timestamp, or value::Decimal, or the borrowed operation target::ope::<_, _, Borrowed>(). A scratch test checked that both routes compile and give the same bytes. The sem module docs say that a target and a field query's encrypt return a Pending, since a field reference's operator returns a FieldQuery. ADR-0009's match_terms bullet points to ADR-0004's amendment. Two paragraphs are rewrapped.
KeysetCipher::ore_block_term built a block order-revealing encryption (ORE) term outside a target, as the four term methods removed earlier on this branch did. Nothing tied that term to the context of the ciphertext stored beside it. The method is removed. The term type OreBlockTerm<T>, the operation target::ore_block, and the index OreBlock stay public. No helper becomes dead. order_pending, ore_block, and ore_block_error still serve the OreBlockTerm target through the order_term macro. The tests that called the method now build each term through its target, with encrypt_into_with_context. The borrowed-value test runs target::ore_block with a Borrowed source through KeysetCipher::run. The credential test still checks that a term built before the keyset loads equals one built after it. A block ORE term contains a random nonce, so the test compares by the scheme's comparison. The pinned left halves pass with the same bytes. A scratch test, since deleted, checked the upgrade route for the three types that are not Zeroize: jiff's civil::Date and Timestamp, and rust_decimal's Decimal. KeysetCipher::run with target::ore_block::<_, _, Borrowed>() compiles for each. The term it builds has the same left half as the term of value::Date, value::Timestamp, or value::Decimal built with encrypt_into_with_context. The CHANGELOG Breaking entry and the Orderable rustdoc in lib.rs now name that route. The amendment to architecture decision record 0004 now says that the method is removed.
The earlier text said the methods were removed because nothing tied a term to its ciphertext's context, and that most indexes send a query term unlike the term they store. Neither is the reason. A term does not have to share its ciphertext's context; a type that needs that ties the two together, as an EQL type does with its one context field. And of the indexes behind these methods, only match sends a different query term. The reason is that a query must be built in the same domain as the stored term it searches. A field reference does this from the field's own context and options, and the removed methods copied their target's code without that tie. The CHANGELOG entry, the ADR-0004 amendment and the sem docs now say so.
…simulator refactor(stack-encrypt): move the JsonDocument EQL simulators into eql_simulator
…a wedged Close Review follow-ups for the stuck-call backstop. - The stuck branch of Client.step now wipes a paused step's requests (bearer token, key-material contexts) as well as its output, as drive does on every other path that drops a step. - Close on a wedged client releases the credentials at once: the stuck step reads only the token it was handed. They are released once (sync.OnceValue), whichever of Close and the step gets there first. - Close reads `released` (now atomic, set last) instead of racing TryLock, so it returns nil once the stuck step has released the instance, never a spurious ErrState. - One error, errStuck, for every call that fails on a wedged client. It matches ErrState and wraps guest.ErrStuck. Acquire is AcquireUnless with a nil channel. - The test queues a caller before the backstop fires, and covers abort and the credential release on a wedged client. - Docs: the stuck call's own caller now waits for it; comments that still said the runtime closes the module under a stuck step are fixed. - Numbers: the option cost the guest 3.5 to 5 times its CPU, as #1761 says. The EQL guest grows by 1.9 MB (4.9 MB at "s", 6.8 MB at 3, measured from this tree).
A wedged client failed only the callers waiting for its lock. A call waiting for one of the 64 paused slots, or for its token, waited on, and a new call fetched a token before it failed. drive now returns ErrState at once on a wedged client, its wait for a slot ends with the wedge, and the token fetch runs under a context the wedge cancels. wedged is a context so the fetch can be tied to it. A cancelled fetch also lets go of the auth strategy's lock, so Close on a wedged client waits only for a refresh already sent. The docs now say Close returns ErrState without waiting for the stuck call, not at once.
…nto feat/golang-guest-yield # Conflicts: # languages/golang/encrypt/client.go
…nking from mutants The chunking of a column and a pair (fulfil_column_from, fulfil_column_item, fulfil_pair_right, and the wasm32 fulfil_column and fulfil_pair) is compiled only for wasm32, so the native mutants build never runs it and every mutant there survived. Exclude them, as the wasm32 into_future impls already are; the native functions of the same names have no viable mutant of these shapes. The behaviour is pinned from Go instead. TestABigBatchYieldsAndRoundTrips checked only that a 200-row batch yielded at all, which a broken weight count or yield condition would still pass; it now asserts nine yields each way: a User takes three keys, so a column yields every 22 rows. Also say that every operation takes a paused slot, in drive's doc and in the CHANGELOG, as it has since the guest could yield.
The first figures were measured while the laptop's performance cores clocked down between ZeroKMS round trips, which made the fixed build look about 2.5 times slower than it is. Measured again with the clock held steady (cipherstash/benches#31): 100 rows of 14 columns take about 39 ms of CPU, not 105, against about 400 before.
A call that never reaches ZeroKMS (a plan check, the catalog, a verify, a limit) asks the guest for no keys, so it cannot pause: it neither waits on ZeroKMS nor yields, since a yield needs at least 64 keys' worth of items. Taking a slot only made it wait behind 64 calls in flight.
…or alone A yield asks for no requests, so a caller that gives up at one has sent none and was about to send none. Its call now fails with the context's error, as it did before the guest yielded, rather than matching ErrTransport too. A pause that asked for requests still matches both.
…st memory The guest drops a batch between two chunks only in wasm, so no Rust test reaches that drop. The new test encrypts 200 rows, cancels at the first yield, and checks that the call fails with context.Canceled and not ErrTransport, that none of the rows' plaintext remains in guest memory (it is there at the yield, so the scan would see it), and that the client still round-trips afterwards. A test hook on the client, run at each yield, replaces the yield counter: the yield-count tests count through it, and this test cancels through it.
The rest of a column's work holds the items recovered so far, which can be plaintext, in its guard, which releases and wipes them if the operation is dropped at the yield.
…ant and future YIELD_EVERY and YieldNow are defined in both crates. Sharing them would make them public API of a published crate, so each copy now names the other and says the two are meant to stay equal.
No native fulfilment stops part way, so nothing polled stack-encrypt's yield future in a native test, and its mutants were unviable only by the way the file names Poll. Each crate now tests its copy: pending once, with one wake, then ready.
…est in flight The loop yields every YIELD_EVERY keys, but buffered passes a yield on only once two requests have yielded or it has polled them all. With one request in flight, as the Go SDK's guest has, that is every YIELD_EVERY keys. With more it is about twice as many, or more.
feat(golang): bound GC pauses by having the guest yield every 64 keys
…ate-term-methods refactor(stack-encrypt)!: remove the lone term methods from the public API
Nothing explained how to build a binding on Stack Encrypt. The knowledge was spread over the dynamic module's docs, the Go guest's module docs, stack-guest-abi, ADR-0007 and ADR-0008, and an author had to reconstruct it from the Go SDK. A Python integration has started without it. The guide ships in the crate docs as `dynamic::guide`, included from `docs/language-integration.md`, so it renders on docs.rs beside the API it describes. It is ordered contract before API: the binding versus the language SDK; native versus WebAssembly; the three operations and the Go guest's exports; the plan grammar; control messages versus plaintext, both frames, neither a tree; the plaintext hygiene rules and the heap tests that prove them; the step loop, the token import and the cancellation contract; the status table and se_last_error; versioning and the frozen stored-rows fixtures; one int32 stored as EQL v4 IntegerEq, traced through encrypt, query and decrypt with the bytes from the committed fixtures; and a checklist for a new binding. The frame format stays in vitaminc-aead-frame's documentation and is linked, not restated. The frame bytes in the worked example are asserted by doctests, so the guide fails the build if the engine's bytes move. The stored row and the query term are quoted from fixtures the Go SDK and Rust both read, named by file and key. Linked from the crate docs, the SDK design principles and the Go SDK's README. Closes #1254.
…with next The guide was written against a next that has since moved a long way. Every claim was checked against the code again, and the guide now describes what is there: - The API as it is: plans read from a `ProtectedRef`, operators named by `Op`, decrypt through `&cipher` or `&keyset` (`CipherRef`), and `.audit(..)` and `.with_credential(..)` on every pending call. - What a binding now has to know about: scopes and bindings, the plan's `null` and `bind` keys, the `json` type and the document operators, `json_open`, and the guest's new `se_json_open` and `se_contexts` exports and `audit` option. - Credentials for a native binding: a strategy that takes a credential with each call needs `.with_credential(..)` on every call. - The status table: code 5 is the only status a token refresh fixes, not the only retryable one (a transient KMS_TRANSPORT failure may be retried under the transport's policy), and a wrong context against ZeroKMS is KMS_FORBIDDEN, not AUTH. - The checklist is built on `conformance/stack-encrypt`: run every profile in the binding's language, exchange fresh artifacts with Rust, and test the value conversion. A native binding that links the crate has no codec of its own; it tests its conversion to and from a frame, and the version it pins is its statement of the frame format. - ADR-0008's location is corrected, the newer ADRs are linked, the frame-format link points at 0.10.0, and the fuzz targets are the ones that exist. The worked example's bytes are unchanged and still asserted by the doctests.
`OpSpec` was renamed to `Op` in this release and kept as a deprecated type alias. Nothing in the repository uses the old name, and the rename has not shipped yet, so there is no reason to carry it. Code written against 0.3.0 renames `OpSpec` to `Op`; the variants and their wire names are unchanged. The CHANGELOG entry for the rename, the two ADRs that named the alias and a Go comment now say `Op`.
…ve bindings - Section 2 now says to link the engine natively through the language's own Rust binding tool (PyO3, Rustler, napi-rs). A WebAssembly guest is for a language that cannot link a native library cleanly, which is Go today and perhaps C or C++, never for one with a good binding story. - Section 3 runs the operations through `dynamic::Planned`: a plan read once and paired with each value, through `encrypt_into` and `decrypt_from`, with queries planned ahead through `Plan::query` or `Plan::field`. The plan-and-value functions appear only as what the Go guest calls, and for the one check `Planned` does not take (a context-field plan's expected context). - Sections 5 to 8 put the native extension first and mark the buffer registry, the step loop, the token import and the status table as the guest path. A native extension gets the engine's error as a Rust value. - The worked example's doctest runs through `Planned`.
… not a guest An edge runtime or a browser runs JavaScript, which cannot load a native library. The answer there is the same extension crate compiled for `wasm32-unknown-unknown` with `wasm-bindgen`, as the `@cipherstash/stack/wasm-inline` entry is built, with ZeroKMS requests going out through the runtime's `fetch`. It is not the WASI guest.
The guide is included in the crate's rustdoc, and doc_hygiene refuses a rustdoc line that names a design record or a path into docs/adr: a reader on docs.rs cannot follow it. Each reference now states the rule it pointed at, and the closing list points at the SDK design principles alone.
next now yields every 64 data keys on wasm32: the guest pauses a step with no requests, and the host resumes it at once with no responses. A guest host has to treat an empty request list as a yield rather than a malformed step, so the step loop section says so. The native section says the same batch yields to the async runtime when built for wasm32, and the Go client's paused-slot bound now names which operations take a slot.
…uide docs(stack-encrypt): a guide to building a language integration
Summary
This is the integration branch for a release candidate of EQL v4 and of Stack Encrypt's Rust and Go support. EQL is the SQL that lets PostgreSQL store and search encrypted values; EQL v4 is a second copy of it for values written by Stack Encrypt, the Rust encryption engine behind the Go SDK. The open pull requests for both are merged here first, so they can be tested together before any of them reaches
main.The release version is not decided yet.
Why a branch, not main
Some of this work depends on vitaminc and ore.rs code that is not yet on crates.io, so it pins those crates to a git commit.
stack-encryptandeql-bindingsare published crates, andcargo publishdrops those git pins, so nothing on this branch can be released until vitaminc 0.6 is published (cipherstash/vitaminc#389, which waits on cipherstash/vitaminc#463). Once it is, the git pins become crates.io versions and this branch merges tomainas a normal release.What lands here, in order
feat/aead-remove-legacy-traitsto one commit on vitamincmain, and takes vitaminc's breaking changes since then.Rules for this branch
rev, neverbranch. A branch is deleted when its stack merges.packages/eqlandpackages/stack-encrypt/fuzz. Two commits mean two copies of vitaminc's traits, and the code stops compiling.Changes
Verification
nextwas created frommainat 2a70a47. Nothing has been built yet, because nothing has changed.Related