Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
7fa4539
refactor(stack-encrypt): one definition of the JSON operators' inputs…
coderdan Nov 15, 2026
61f5f76
feat(stack-encrypt,eql-bindings): typed JSON queries from a field ref…
coderdan Nov 15, 2026
132291d
fix(stack-encrypt): address the review of typed JSON queries
coderdan Nov 16, 2026
24220bd
feat(stack-encrypt)!: Error::Input for a refusal of the caller's input
coderdan Nov 16, 2026
f4c7d07
test(stack-encrypt): pin the JSON field reference lines the mutation …
coderdan Nov 16, 2026
235660e
test(stack-encrypt): name every JSON input's operator, and exclude an…
coderdan Nov 16, 2026
768bd82
fix(stack-encrypt): address the second review of typed JSON queries
coderdan Nov 21, 2026
7b86835
fix(stack-encrypt,eql-bindings): seal a value without copying it
coderdan Nov 21, 2026
e9ca44b
refactor(stack-encrypt): move the JSON path grammar into stack-encryp…
coderdan Nov 21, 2026
debe04d
feat(stack-encrypt,stack-encrypt-derive): typed JSON paths from the f…
coderdan Nov 21, 2026
3a919ec
feat(stack-encrypt): give a JSON predicate its variables one at a time
coderdan Nov 21, 2026
f58d65e
docs: record the typed JSON paths in the plan, the changelogs and the…
coderdan Nov 21, 2026
c143c4e
test(stack-encrypt-jsonpath): pin the decoder, the wipe and the paylo…
coderdan Nov 21, 2026
382c907
docs(stack-encrypt): hide the fake key source in the JSON field refer…
coderdan Nov 21, 2026
ec70517
fix(stack-encrypt-jsonpath): consume a byte on every turn of the stri…
coderdan Nov 21, 2026
77d6050
feat(stack-encrypt,stack-encrypt-derive): declare a path's type for e…
coderdan Nov 21, 2026
fa2a158
fix(stack-encrypt,stack-encrypt-jsonpath): address the third review o…
coderdan Nov 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .cargo/mutants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ exclude_re = [
# `Ok(())`, so the replacement is the body. Text overrides it with
# `query::order_text`, pinned by `an_ordering_refuses_only_text_it_cannot_encode`.
'stack-encrypt/src/sem/mod\.rs:\d+:\d+: replace sealed::Sealed::check_query -> Result<\(\), super::TermError> with Ok\(\(\)\)$',
# A JSON document type's default options are the defaults: the trait's
# body is `JsonOptions::default()`. A type that overrides them is pinned
# by `a_field_that_names_no_options_queries_under_its_types_own`, and
# `Option<T>` forwarding by `a_nullable_field_queries_under_its_types_own_options`.
'stack-encrypt/src/json/target\.rs:\d+:\d+: replace JsonQueries::default_options -> JsonOptions with Default::default\(\)$',
# Both unit-context conversions explicitly return Self::default().
'stack-encrypt/src/target/context\.rs:\d+:\d+: replace <impl From<\(\)> for (DeclaredContext|ExpectedContext<T>)>::from -> Self with Default::default\(\)$',
# A caller shape with no placeholder IS `CallerShape::default()`:
Expand Down Expand Up @@ -145,7 +150,7 @@ exclude_re = [
# bits with a low nibble below 16: the bits never overlap, so `^` is `|`.
'stack-encrypt/src/json/mod\.rs:\d+:\d+: replace \| with \^ in unhex$',
# `JsonPath::root` is `Self::default()`.
'stack-encrypt/src/json/path\.rs:\d+:\d+: replace JsonPath::root -> Self with Default::default\(\)$',
'stack-encrypt-jsonpath/src/path\.rs:\d+:\d+: replace JsonPath::root -> Self with Default::default\(\)$',
# A document always has a root, so its terms are never empty: `false` is
# the value `is_empty` returns. The `true` replacement is still caught.
'stack-encrypt/src/json/derive\.rs:\d+:\d+: replace JsonTerms::is_empty -> bool with false$',
Expand Down
17 changes: 17 additions & 0 deletions .changeset/eql-json-field-reference-queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@cipherstash/eql': minor
---

`eql-bindings`, the Rust crate released with this package: a `JsonTreeDocument` field of a derived Stack Encrypt record is queried from its field reference, and each query returns the EQL query type a parameter binds as.

- `EncryptedCustomer::PROFILE.contains(doc)` gives a `JsonTreeQuery` for `@>`, and `contained_by(doc)` one for `<@`.
- `#[stash(json(ordered = { "$.age": u32, "$.visits[*].place": String }))]` on the field names the paths the documents order and the type of the values at each. The field is sealed under those options and queried under them. `paths = { "$.name": String }` beside it declares a path compared with equality alone, which adds no ordering term. Stack Encrypt's derive checks every path when it compiles the record.
- Each declared path has a typed method: `at().age().gt(v)` and the other comparisons give a `JsonTreeLeafQuery`, `at().age().between(lo, hi)` two of them, and `at().age().selector()` the `JsonTreeSelector` that `->` takes. A path, a member or a value type the field does not declare does not compile, and neither does an ordering of a `paths` path.
- `elements().visits().place().eq(v).and()..` gives a `JsonTreeElementsQuery`, `predicate(text).var(name, v)` a `JsonTreePredicateQuery`, and `children(path)` a `JsonTreeToken`.
- A path built at run time is text: `at_text_path(path)` and `elements_text_path(path)` check it when the query is encrypted.

Each query is the operand a data plan naming `JsonSearch` derives for the same column and options, which is what the Go SDK sends.

A value passed by value is now sealed without a copy when its type seals it and derives no search term: a `JsonTreeDocument`, a data plan field that names `JsonSearch`, and the storage-only v4 types (`Integer`, `Text`, `Json` and the rest). The copy was wiped before, so nothing leaked; it was not needed.

The stored format, the SQL bundle and the TypeScript types do not change.
2 changes: 1 addition & 1 deletion .changeset/eql-remove-structural-traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- Every type keeps `EncryptTarget` and `DecryptSource`. Write with `value.encrypt_into_with_context(&keyset, column)` and read with `P::decrypt_from_with_context(stored, &keyset, column)`.
- A typed query is a field reference of a derived record, such as `EncryptedMember::EMAIL.eq("bob").encrypt(&keyset)`.
- A JSON document is a `JsonPlaintext`, not a `serde_json::Value`. A typed JSON query has no replacement yet: derive the operand through a data plan that names `JsonSearch`.
- A JSON document is a `JsonPlaintext`, not a `serde_json::Value`. A typed JSON query is a document field's reference query, such as `EncryptedCustomer::PROFILE.at().age().gt(30).encrypt(&keyset)`.
- `JsonTree` no longer implements `stack_encrypt::target::Layout`. `encryption()`, `index()` and `specs()` are its own methods.

The stored format, the SQL bundle, and the TypeScript types do not change.
1 change: 1 addition & 0 deletions .github/workflows/bench-eql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ on:
- "conformance/stack-encrypt/**"
- "packages/stack-encrypt/**"
- "packages/stack-encrypt-derive/**"
- "packages/stack-encrypt-jsonpath/**"
- "packages/stack-kms/**"
- "packages/stack-auth/**"
- "packages/stack-profile/**"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/crap-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- packages/stack-auth/**
- packages/stack-encrypt/**
- packages/stack-encrypt-derive/**
- packages/stack-encrypt-jsonpath/**
- Cargo.toml
- Cargo.lock
- mise.toml
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/mutants.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Mutants

# Gates pull requests on mutation testing of the lines they change in
# stack-auth and stack-encrypt. Ported from cipherstash-suite's `mutants.yml`.
# stack-auth, stack-encrypt and stack-encrypt-jsonpath (the path grammar,
# moved out of stack-encrypt). Ported from cipherstash-suite's `mutants.yml`.
#
# cargo-mutants rewrites small pieces of logic (flip `<` to `<=`, replace a
# body with `Default::default()`) and reruns the tests; a mutant that survives
Expand All @@ -11,7 +12,7 @@ name: Mutants
# filter (which drops the trybuild `ui` binary), excludes and timeouts live in
# .cargo/mutants.toml, so the gate and the local tasks agree.
#
# Scoped to the two crates with `-p`: the baseline runs the unmutated tests of
# Scoped to those crates with `-p`: the baseline runs the unmutated tests of
# those packages only. A diff touching only other crates yields no mutants and
# passes.
#
Expand All @@ -27,6 +28,7 @@ on:
paths:
- packages/stack-auth/**
- packages/stack-encrypt/**
- packages/stack-encrypt-jsonpath/**
- Cargo.toml
- Cargo.lock
- mise.toml
Expand Down Expand Up @@ -140,7 +142,7 @@ jobs:
EVENT_NAME: ${{ github.event_name }}
run: |
set +e
crates=(-p stack-auth -p stack-encrypt)
crates=(-p stack-auth -p stack-encrypt -p stack-encrypt-jsonpath)
if [ "$EVENT_NAME" = "pull_request" ]; then
cargo mutants --no-shuffle -vV "${crates[@]}" --in-diff pr.diff
else
Expand All @@ -161,7 +163,7 @@ jobs:
timeout=$(count timeout.txt)
{
echo '<!-- cargo-mutants-report -->'
echo "## Mutation testing (cargo-mutants, \`--in-diff\`, stack-auth + stack-encrypt)"
echo "## Mutation testing (cargo-mutants, \`--in-diff\`, stack-auth + stack-encrypt + stack-encrypt-jsonpath)"
echo
if [ ! -d "$out" ]; then
# No output dir: either nothing to mutate (exit 0) or the run
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ jobs:
run: |
set -euo pipefail
publish_needed=false
for crate in stack-auth stack-profile stack-kms stack-encrypt stack-encrypt-derive; do
for crate in stack-auth stack-profile stack-kms stack-encrypt stack-encrypt-derive stack-encrypt-jsonpath; do
version="$(grep -m1 '^version = ' "packages/${crate}/Cargo.toml" | cut -d'"' -f2)"
# crates.io 403s curl's default User-Agent.
published="$(curl -fsSL --retry 3 -H "User-Agent: cipherstash-stack-release (https://github.com/cipherstash/stack)" "https://crates.io/api/v1/crates/${crate}/versions" | jq -r '.versions[].num' | grep -Fx "$version" || true)"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-eql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ on:
- "conformance/stack-encrypt/**"
- "packages/stack-encrypt/**"
- "packages/stack-encrypt-derive/**"
- "packages/stack-encrypt-jsonpath/**"
- "packages/stack-kms/**"
- "packages/stack-auth/**"
- "packages/stack-profile/**"
Expand Down Expand Up @@ -213,6 +214,7 @@ jobs:
- "conformance/stack-encrypt/**"
- "packages/stack-encrypt/**"
- "packages/stack-encrypt-derive/**"
- "packages/stack-encrypt-jsonpath/**"
- "packages/stack-kms/**"
- "packages/stack-auth/**"
- "packages/stack-profile/**"
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/tests-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ on:
- packages/stack-encrypt/**
- conformance/stack-encrypt/**
- packages/stack-encrypt-derive/**
- packages/stack-encrypt-jsonpath/**
- packages/stack-guest-abi/**
- languages/typescript/packages/auth/**
- languages/typescript/packages/profile/**
Expand All @@ -47,6 +48,7 @@ on:
- packages/stack-encrypt/**
- conformance/stack-encrypt/**
- packages/stack-encrypt-derive/**
- packages/stack-encrypt-jsonpath/**
- packages/stack-guest-abi/**
- languages/typescript/packages/auth/**
- languages/typescript/packages/profile/**
Expand Down Expand Up @@ -144,7 +146,7 @@ jobs:
run: cargo build --locked -p stack-encrypt --examples

# The crates release-plz publishes. `--dry-run` packages and compiles
# each the way crates.io would (all five together, so each resolves the
# each the way crates.io would (all six together, so each resolves the
# others from cargo's temporary local registry rather than from
# crates.io), catching a publish-blocker on the PR instead of in
# release-crates on main: missing metadata, a runtime path dependency
Expand All @@ -156,7 +158,7 @@ jobs:
# version is on crates.io, cargo warns rather than fails on a dry run of
# it.
- name: Verify the stack-* crates package cleanly for crates.io
run: cargo publish --locked --dry-run --allow-dirty -p stack-profile -p stack-auth -p stack-kms -p stack-encrypt-derive -p stack-encrypt
run: cargo publish --locked --dry-run --allow-dirty -p stack-profile -p stack-auth -p stack-kms -p stack-encrypt-jsonpath -p stack-encrypt-derive -p stack-encrypt

node-bindings:
name: node bindings, napi typings, stack-auth-wasm
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ on:
- packages/stack-encrypt/**
- conformance/stack-encrypt/**
- packages/stack-encrypt-derive/**
- packages/stack-encrypt-jsonpath/**
- packages/stack-guest-abi/**
# The eql guest build links eql-bindings.
- packages/eql/crates/eql-bindings/**
Expand Down Expand Up @@ -84,6 +85,7 @@ on:
- packages/stack-encrypt/**
- conformance/stack-encrypt/**
- packages/stack-encrypt-derive/**
- packages/stack-encrypt-jsonpath/**
- packages/stack-guest-abi/**
# The eql guest build links eql-bindings.
- packages/eql/crates/eql-bindings/**
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ jobs:
- '!languages/golang/**'
- '!packages/stack-encrypt/**'
- '!packages/stack-encrypt-derive/**'
- '!packages/stack-encrypt-jsonpath/**'
- '!packages/stack-kms/**'
- '!packages/stack-guest-abi/**'
- '!packages/stack-auth/fuzz/**'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/udeps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
- packages/stack-kms/**
- packages/stack-encrypt/**
- packages/stack-encrypt-derive/**
- packages/stack-encrypt-jsonpath/**
- packages/stack-guest-abi/**
- languages/typescript/packages/auth/**
- languages/typescript/packages/profile/**
Expand All @@ -35,6 +36,7 @@ on:
- packages/stack-kms/**
- packages/stack-encrypt/**
- packages/stack-encrypt-derive/**
- packages/stack-encrypt-jsonpath/**
- packages/stack-guest-abi/**
- languages/typescript/packages/auth/**
- languages/typescript/packages/profile/**
Expand Down
Loading
Loading