Repository navigation
Conversation
… names A type can implement `Encrypt` and `Decrypt` by hand instead of deriving them. Such an impl names the sink traits, the `depth` constants, the types of a scalar, and the `Scalar` and `FromScalar` traits. `stack-encrypt` re-exported none of these, so a crate that wrote such an impl had to depend on `vitaminc-aead` too. The new `stack_encrypt::plaintext` module re-exports the sink traits and the scalar types. It also has a `depth` module of its own. That module adds `MAX_DEPTH` to the depth constants. `Scalar` and `FromScalar` are re-exported at the crate root, next to `Encrypt`, and `Decrypt`. The module docs show a complete hand-written `Encrypt` and `FromScalar` impl, run against the in-memory key source. The `OpaqueEncode` docs and doctests now import from `stack_encrypt`. The compile error for a `Scalar` type with the wrong `DEPTH` names `stack_encrypt::plaintext::depth::SCALAR`. A refused `FromScalar` bound now prints as `FromScalar`, through the root re-export, so one UI snapshot changes in that line only.
…pt's derives `stack_encrypt::Encrypt` and `stack_encrypt::Decrypt` re-exported the derives of vitaminc-aead-derive. Their code named every item through `::vitaminc_aead`. Rust resolves that path only in a crate that lists `vitaminc-aead` as a dependency of its own. So a crate that depended on `stack-encrypt` alone could not derive either trait. The error did not say why. The two derives now live in `stack-encrypt-derive`, in `src/value/`, and `stack-encrypt` re-exports them. The generated code names every item through `<crate>::__derive`. `<crate>` is `::stack_encrypt` unless `#[aead(crate = "...")]` names another path. `vitaminc_aead::__derive` is a hidden module that lists exactly the items the expansion names, and `stack_encrypt::__derive` re-exports it. No other part of vitaminc-aead is re-exported for the derives. vitaminc-aead-derive is removed rather than kept as a second public derive. So a derive bug has one place to fix, and one set of expansion tests. Its source, unit tests, and attribute docs move with their history. The moved files keep their MIT licence, in `LICENSE-MIT` beside them. vitaminc-aead loses its derive dependency and its re-export of the macros. Its own tests and doctests use Stack Encrypt's derive, with `#[aead(crate = "::vitaminc_aead")]`, since stack-encrypt depends on it. The attributes keep the name `aead`. That name does not name vitaminc. It also keeps them apart from the `#[stash(...)]` attributes of the record derives. So neither family of derives refuses the other's keys. The wire shape does not change. The UI snapshots change only in line numbers and in the depth error. That error now names `stack_encrypt::plaintext::depth::MAX_DEPTH`. These move with the crate: - the root workspace member and patch; - the mise task include, with a rustdoc task for stack-encrypt-derive in place of the old crate's; - the release-plz entry; - the mutation-testing config, now for the value derives only; - the workflow path filters and CODEOWNERS; - the vitaminc-aead supply-chain config. cargo deny now leaves stack-encrypt-derive out of vitaminc-aead's graph, as cargo vet's filter already did. The derive's own tests reach the whole workspace. BREAKING CHANGE: `vitaminc_aead::Encrypt` and `vitaminc_aead::Decrypt` are traits only. Import the derives from `stack_encrypt`. `#[aead(crate = "...")]` now names the path to `stack_encrypt`. A path to `vitaminc_aead` still works.
…paces Every Cargo workspace that resolves vitaminc-aead 0.10 patched both vitaminc-aead and vitaminc-aead-derive to the copies in this repository. The derive crate is gone, and vitaminc-aead no longer depends on it, so nothing in these workspaces resolves vitaminc-aead-derive 0.10 any more. A patch that names a missing path fails every cargo command in the workspace. These workspaces now patch vitaminc-aead alone: - the two Go guests; - recipher-js, and its test addon; - EQL, and its timing generator; - the three fuzz crates. Each `Cargo.lock` loses the vitaminc-aead-derive 0.10 entry. The 0.5.1 copy that cts-common reaches through vitaminc 0.5.1 still comes from crates.io. No code in these workspaces used the derives.
…ncrypt alone Every crate in this repository that derived `Encrypt` or `Decrypt` already depended on vitaminc-aead. So nothing noticed that the derives did not compile without it. The new crate is a member of the root workspace. Its only dependency is `stack-encrypt`, as an application's would be. `tests-crates.yml` builds and tests it with the rest. The crate derives both traits for these types: - a newtype; - a struct with named fields and a passthrough field; - a fieldless enum; - a generic newtype; - a generic struct. It also writes `Encrypt`, `Scalar`, and `FromScalar` by hand for one more type. Its tests send each type through `keyset.encrypt` or `keyset.encrypt_tree` and back, under the in-memory key source. `tests/manifest.rs` fails if the manifest names a dependency other than `stack-encrypt`. It also fails if any table names a vitaminc crate. Two trybuild cases pin what a user reads when a derive is refused. The trait bounds print as `stack_encrypt` paths. The depth error names `stack_encrypt::plaintext::depth::MAX_DEPTH`. The crate implements `Zeroize` by hand, through `stack_encrypt`'s re-export of the trait, so that it needs no zeroize dependency either. It is `publish = false`, with `release = false` in release-plz.toml. The live jobs of tests.yml skip a change that touches only this crate.
The stack-encrypt CHANGELOG has two new entries: - Under Fixed: the derives now compile in a crate that depends only on stack-encrypt. The entry says what stays the same, what `crate = "..."` now names, and how to migrate. - Under Added: the `plaintext` module, and the `Scalar` and `FromScalar` re-exports, for a hand-written impl. Two entries of the same release named `vitaminc_aead::plaintext::depth` and "Vitamin C's `Scalar`". They now name the stack-encrypt paths. The vitaminc-aead CHANGELOG lists two changes under Breaking. The crate has no derives of its own, and the entry says how to import them instead. The hidden `plaintext::__private` module is replaced by `__derive`. AGENTS.md's repository layout and SECURITY.md's package list name the two AEAD crates that remain. They say where the value derives went, and describe stack-encrypt-downstream.
…derives Brings in the latest review fixes of the base branch. Conflicts, and how they are resolved: - The derive's `encrypt.rs` moved to `packages/stack-encrypt-derive/src/value/encrypt.rs` here. The base branch decides once whether a type has a fixed depth. Its logic is kept as it is, with the generated paths renamed to `#aead::...` as in the rest of the moved file. - `vitaminc-aead-derive/src/lib.rs` is deleted here. Its new paragraph, that `#[derive(Zeroize)]` does not wipe a fieldless enum, moves to `stack-encrypt-derive/docs/value-derives.md`, with its doctest importing `stack_encrypt::Encrypt`. - `scalar.rs` keeps the base branch's new text and its wording of the `DEPTH` error, with the `stack_encrypt::plaintext::depth::SCALAR` path. - The stack-encrypt CHANGELOG keeps the base branch's entry, names `stack_encrypt::plaintext::depth`, and no longer says that a crate needs vitaminc-aead to use the derive. - The vitaminc-aead CHANGELOG has one Breaking section with the entries of both branches.
|
|
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
|
Mutation testing (cargo-mutants,
|
| caught | missed | unviable | timeout |
|---|---|---|---|
| 16 | 0 | 3 | 0 |
Every mutant in the changed lines was caught by a test.
coderdan
left a comment
There was a problem hiding this comment.
Code review at medium effort. Five findings: one pre-existing problem that this PR widens, and four nits. I checked each one against the branch. For the first, I also compared the registry copy of vitaminc-aead 0.10.0 with the copy in this repository.
The code that writes every derived `Encrypt` and `Decrypt` impl moved from vitaminc-aead-derive to stack-encrypt-derive. The supply-chain checks left the new crate out, so a change to it, or a bump of its syn, was no longer vetted. The workflow also did not start when the derive changed. The derive's dev-dependencies include stack-encrypt, and stack-encrypt reaches the rest of the workspace. So each tool now leaves out those dev-dependencies alone, and keeps the derive's normal dependencies: - cargo deny checks the derive as the root of its own graph, with `--exclude-dev`. The other two crates' checks leave the derive out with `--exclude`. A `[graph] exclude` entry cannot do this, because cargo deny cannot use an excluded crate as a root. - cargo vet keeps the derive and stack-encrypt-jsonpath in the filter. The derive's policy is `safe-to-deploy`, with `dev-criteria = []`. - stack-encrypt-jsonpath's policy asks nothing of miette. miette comes only with the `diagnostics` feature. The derive does not turn it on. The derive's graph brings in thiserror 1.0.69 and thiserror-impl 1.0.69, through stack-encrypt-jsonpath. No imported registry audits them, so they are exemptions at `safe-to-deploy`, as thiserror 2.0.18 is. The reviewer decides whether an audit should replace them. The licence check allows the PolyForm Small Business licence for the two first-party crates only.
The too-deep compile error named `stack_encrypt::plaintext::depth::MAX_DEPTH` as fixed text. Every other path in the expansion follows `#[aead(crate = "...")]`. A type derived with `crate = "::vitaminc_aead"`, as vitaminc-aead's tests and docs do, was told about a path that does not resolve there. The message now builds the path from the crate path. vitaminc-aead re-exports `MAX_DEPTH` from `plaintext::depth`, as stack-encrypt does, so the path resolves under both crates. An expansion test checks the message for the default path and for `::vitaminc_aead`. vitaminc-aead's `sink_too_deep` snapshot now names `vitaminc_aead::plaintext::depth::MAX_DEPTH`.
The manifest guard compared only the table named `[dependencies]`. A dependency written as `[dependencies.serde]`, or listed under `[target.'cfg(unix)'.dependencies]` or `[build-dependencies]`, was never read. The guard still passed, and the crate no longer showed what its docs say. The guard now parses the manifest with the `toml` crate, as a new dev-dependency. trybuild already brings `toml` 1.1.8 into the lockfile. Parsing reads every form Cargo accepts, including dotted keys under a target. A table other than a dev-dependency table can list only stack-encrypt, at the top level or under a target. No table names a vitaminc crate, under its own name or through `package`. Unit tests feed the checks a manifest for each form.
…ture set rustc lists a trait's other implementors in the errors that `field_type_not_encryptable.stderr` records. A stack-encrypt feature such as `dynamic` adds implementors. So the recording looked as if it could match only one feature set, and as if the re-record command picked the wrong one. It matches every feature set. trybuild builds the ui cases as a separate project, from this crate's dev-dependencies and features. This crate has no features, so CI's `--workspace --all-features` run records the same errors as a plain `cargo test`. Both pass with the committed recording. Limiting the test with `required-features`, as stack-encrypt's own ui test does, would need a feature here that turns on `stack-encrypt/dynamic`. That feature would add `&Frame<'_>` and `&Lent<'_, T>` to the lists, and so make the recording depend on features after all. The ui test's docs now say why the recording matches every feature set. A manifest test fails if a `[features]` table is added to this crate.
The comment above the two licence exceptions said the crates are under a PolyForm Small Business licence. Their LICENSE file is the PolyForm Internal Use License. cargo-deny reads that text as PolyForm-Small-Business-1.0.0, so the exception has to name that identifier. The comment now says so.
cipherstash-agent
left a comment
There was a problem hiding this comment.
Review attestation
Reviewed 6e5cda5 · posted from Claude Code · claude-opus-5-5 · effort medium
Sources: code-review · claude-opus-5-5; mattpocock-skills:code-review agent · claude-opus-5-5; rust-security agent · claude-opus-5-5
Skills: code-review, mattpocock-skills:code-review, company-skills:rust-security, company-skills:review-cross-check
Findings (5): 2 major, 3 minor — 3 inline, 1 below, 1 in reply.
-
AGENTS.md:817(outside diff) minor Two sentences still say there are three AEAD crates:AGENTS.md:817-818("for the three AEAD crateskani.yml, …") andAGENTS.md:878("All three#[deny(unsafe_code)]"), and so does the rootCargo.toml:5comment. Onlyvitaminc-aeadandrecipher-frameremain, so change "three" to "two" at all three sites.Source: mattpocock-skills:code-review agent · claude-opus-5-5
Generated by Claude Code
stack-encrypt-downstream is a member of the root Cargo workspace, so the counts in AGENTS.md were one short. The Repository Layout bullet now lists the crate in its opening paths and says two crates were added here. The workspace note now says eight stack-* crates. SECURITY.md lists the unpublished test harness `eql-encryption-tests` and says that it adds no published package. stack-encrypt-downstream is also an unpublished test crate, so SECURITY.md now says the same of it.
The AEAD crates moved from vitaminc are now vitaminc-aead and recipher-frame. The derive crate that came with them is gone. Its code is in stack-encrypt-derive. Two sentences in AGENTS.md and the comment above the root workspace members still counted three. The AGENTS.md sentence about `#![deny(unsafe_code)]` is still true of both crates.
cargo udeps runs over the whole root workspace, and stack-encrypt-downstream is a member. But neither path list named the crate. A change that stops using one of its dev-dependencies, such as `toml`, did not start the job. Both lists now name it, as tests-crates.yml does. The other workflows that list stack-encrypt-derive do so because their builds depend on stack-encrypt, or because they check named crates. Nothing depends on stack-encrypt-downstream, so they do not list it.
The other stack-* crates warn on `dbg!`, `mem::forget`, printing, `unwrap`, `expect`, and `panic!`. Those crates also deny unsafe code. CI's clippy turns each warning into an error. The downstream crate had none of these lints. Clippy does not run most of them by default, because they are restriction lints. So a `dbg!(&self.cents)` in the hand-written `Encrypt` for `Price` passed CI. The crate now carries the same block as stack-encrypt, with the same allowances for unit tests. Nothing in the crate breaks the lints.
The CHANGELOG said that `#[aead(crate = "...")]` still works with a path to `vitaminc_aead`. The derives' code names `<crate>::__derive`. Only the `vitaminc-aead` source in this repository has that module. crates.io's 0.10.0 does not. So the line was true only inside this repository, and the CHANGELOG now says so. The entry for the too-deep error also says that its path starts at the `crate` path, when a type names one.
|
The finding outside the diff is fixed in afdfcff. |
Brings in #2014 and, through it, next with #2011. Conflicts: - stack-encrypt's lib.rs: this branch re-exports `FromScalar` and `Scalar`, and #2011 re-exports `ScalarTarget`. The merge re-exports all three. - stack-encrypt's CHANGELOG: both sides added an entry at the top of Added. The merge keeps both entries. - owned_collection_elements.stderr: the merge takes the snapshot of #2014. Recording it again with TRYBUILD=overwrite gave the same file. #2011 added tests and a doc example to vitaminc-aead that use the derives from vitaminc_aead. On this branch vitaminc-aead has no derives. So these now use stack_encrypt_derive with `#[aead(crate = "::vitaminc_aead")]`, as the other vitaminc-aead tests do: - tests/scalar_target.rs - four compile-fail tests in tests/ui/scalar_target/ - the example on `ScalarTarget` in typed.rs The four snapshots of those compile-fail tests change only in their line numbers. Two doc comments in typed.rs now say "Stack Encrypt's `#[derive(Decrypt)]`", as the rest of the file does.
The merge of #2014 added packages/mn-meta.err and packages/eql/tests/timing/mn-meta.err. Both are empty logs from a local lockfile check, and are not part of the change.
Summary
#[derive(Encrypt)]and#[derive(Decrypt)]are now Stack Encrypt's own derives. A crate whose only dependency isstack-encryptcan derive both traits, or write them by hand. Before this PR, the user'sCargo.tomlalso neededvitaminc-aead, and the compile error did not say so.The
vitaminc-aead-derivecrate is deleted.vitaminc-aeadkeeps the traits and has no derives of its own.Closes #2013. This PR is stacked on #2014. Both change the same derive code.
What a user writes
Before:
After,
stack-encryptalone. The derive code is the same:A hand-written impl imports from
stack_encrypt:Changes
The derive code moved into
stack-encrypt-derive. Its source, unit tests, and attribute docs moved withgit mv, so they keep their history. There is one place to fix a derive bug, and one set of expansion tests.Generated code names
stack_encrypt. It writes::stack_encrypt::__derive::X.__deriveis a hidden module that lists only the 23 items the generated code uses.#[aead(crate = "...")]still overrides the path, for crates in this repository that cannot namestack_encrypt.New public paths for a hand-written impl:
ScalarandFromScalar, besideEncrypt,EncryptRef,Decrypt, andDecodeError;stack_encrypt::plaintextmodule:Sink,SeqSink,MapSink, and the type descriptions such asFixedType;stack_encrypt::plaintext::depth:SCALAR,MAX_DEPTH, and the other depth helpers.The whole
vitaminc_aeadcrate is not re-exported.Compile errors name Stack Encrypt paths, such as
stack_encrypt::plaintext::depth::MAX_DEPTH.A crate that proves it:
packages/stack-encrypt-downstream. It is a workspace member that CI builds, withpublish = false. Its only dependency isstack-encrypt.Encrypt,Scalar, andFromScalarby hand for one more type.keyset.encryptandencrypt_tree.tests/manifest.rsfails if the crate lists any dependency butstack-encrypt, or names a vitaminc crate.vitaminc-aead's own derive tests stay where they are. They usestack-encrypt-deriveas a dev-dependency, with#[aead(crate = "::vitaminc_aead")]. So mutation testing ofvitaminc-aeadstill runs them.Every other Cargo workspace drops its patch entry for the deleted crate. None of them used the derives. They are:
Docs and config: CHANGELOGs,
AGENTS.md,SECURITY.md,CODEOWNERS,release-plz.toml, the mutation-testing config, and the path filters of ten workflows.Breaking changes
#[derive(vitaminc_aead::Encrypt)], or importing the derive macros fromvitaminc_aead, no longer compiles. Import them fromstack_encrypt.#[aead(crate = "...")]now names the path tostack_encrypt. A path tovitaminc_aeadstill works, because that crate has the same hidden module.Verification
Run locally on Rust 1.94.1.
Root workspace:
-D warningsfor all features and forstack-encryptwith no default featuresstack-encrypt-derive,vitaminc-aead(all features),stack-encrypt(all features, with the compile tests),stack-encrypt-downstreamandrecipher-framevitaminc-aeadtests with no features, and with each ofjiff,rust_decimal,uuid, andhlistRustdoc: public and private items, with
-D warnings, for the changed crates.Mutation testing (
--in-diff): 17 mutants, 14 caught, 3 that do not compile, 0 missed.Supply chain:
cargo vet --locked, andcargo denyforvitaminc-aeadandrecipher-frame.Lockfiles:
cargo metadata --lockedpasses in all 10 workspaces whose lockfile changed.Other workspaces:
eql-bindingswith all features, and the encryption testsThese ran before the merge of fix(stack-encrypt): encrypt a derived newtype with keyset.encrypt #2014's latest commits. Those commits changed only messages and docs.
Test counts: no test was removed. The 93 derive unit tests are the old crate's 61 plus 32. The derive doctests went from 43 to 29, because the old crate included its attribute docs three times; the 8 distinct examples each run once.
Not run: the nightly fuzz builds, the release-only jiff test, and the script tests, because the worktree has no
node_modules.Related
stack-encrypt/CHANGELOG.md,stack-encrypt/src/lib.rs, and the snapshotowned_collection_elements.stderr). Six files in feat(stack-encrypt)!: encrypt and decrypt one value known only at run time, and bound the typed decrypt to a scalar #2011 also import the derives fromvitaminc_aeadand need the same change as this PR.TakesScalarthen goes instack_encrypt::plaintext.Review notes
Open questions:
stack-encryptdepends onvitaminc-aeadfrom crates.io, sovitaminc-aeadmust be published from this repository first. Removing its derive macros is a breaking change. 0.11.0 is the semver-correct version, but the vitaminc crates that depend on it would need new releases too.src/value/LICENSE-MIT. The crate itself is licensed PolyForm Internal Use. In git, the only authors of these files are CipherStash staff and release bots, so they could be relicensed.#[aead(...)]. It does not name vitaminc. It also keeps these attributes apart from the record derives'#[stash(...)]: both have apassthroughkey with a different meaning.vitaminc_aeadin the dependency graph". It comes fromvitaminc-aead0.5.1. That version is a dependency ofcts-common. This PR does not cause it.