Repository navigation
Conversation
WalkthroughWarning Review details and warnings were omitted to fit the comment limit. |
🦋 Changeset detectedLatest commit: b2510b3 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.
…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
zerokms-keyset is the recipher crate renamed (recipher up to 0.3.3). 0.3.4 adds a wasm32 SIMD path for proxy re-encryption, which stack-kms exposes as an opt-in `wasm-simd` feature: a wasm runtime without SIMD refuses a module that contains a SIMD instruction, so it stays off. Breaking: `InvalidKeyMaterialError` now wraps `zerokms_keyset::Error`, and the re-exported `GenRandom` and `Iv` come from `zerokms_keyset::key`. The Go encrypt guest's test fixture passes a keyset into stack-kms, so its dev-dependency moves too. The Dependabot ignores and the lockfiles that resolve stack-kms by path (guest, EQL, both fuzz crates) follow.
…uest Enables stack-kms's `wasm-simd` feature in all four encrypt guest builds. Proxy re-encryption is the costly part of deriving a data key. wazero's default runtime config enables the WebAssembly 2.0 core features, SIMD among them, and encrypt/guest.go does not narrow them, so the module still loads. Measured under wazero 1.12.0 (the module's pin) on the shared index-key fixture: 20,000 data-key derivations took 65 ms with SIMD and 315 ms without, and both produced the same keys as the native scalar path, with the index key matching the known answer.
…n answers The encrypt guest turns on stack-kms's `wasm-simd`, so on wasm32 it re-encrypts key material on a SIMD path that no native test reaches. The Go tests do not reach it either: their deterministic key source builds keys without re-encrypting anything. A SIMD-only regression would give the Go SDK different keys from the native and TS SDKs while every test passed. tests/key_derivation.rs pins the index key to the fixture shared with cipherstash-client, and three data keys computed natively. nextest runs it natively (the scalar path), and `wasm:guest:test` now runs it again on wasm32-wasip1 under wazero, the Go module's runtime, at the version go.mod pins. On wasm a panic aborts before libtest prints captured output, so the run passes --nocapture to keep a failure's message.
…ames The stack-kms CHANGELOG told callers to replace `recipher::` with `zerokms_keyset::`, which turns `recipher::errors::RecipherError` into a path that does not exist; the type is `zerokms_keyset::Error`. It now gives the mapping, and says a match on the error needs a `_` arm, since the type is `#[non_exhaustive]`. stack-encrypt re-exports stack-kms as `kms`, so the same types change for its callers; its CHANGELOG now says so. docs/wasm-analysis.md and a mise.toml comment still named `recipher`, and the doc's `cargo check -p recipher` no longer resolved.
feat(stack-kms)!: depend on zerokms-keyset 0.3.4, with wasm SIMD in the Go guest
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