Repository navigation
feat(stack-encrypt): JSON operators Contains, ContainedBy and AtPath - #1209
Conversation
|
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. |
Mutation testing (cargo-mutants,
|
| caught | missed | unviable | timeout |
|---|---|---|---|
| 134 | 0 | 45 | 0 |
Every mutant in the changed lines was caught by a test.
freshtonic
left a comment
There was a problem hiding this comment.
Review of this PR's diff against #1208.
AtPath<Op> gets its TermFor bound from Op, and that is correct. The compile-fail test pins AtPath<Matches> to a probabilistic term. No index answers the JSON operators yet, so this PR has no runtime effect today. No mutants (the changes are types only).
Blocking
ContainsandContainedByare declared exact. The only JSON index in this repository cannot answer them exactly. See the inline comment atsrc/op/mod.rs:515.
Suggested follow-up PR
- Ordering at a path under an array. ADR-0009 shows
AtPath<Gte>ascol -> selector >= term. Under an array, the selector is a wildcard (ArrayWildcardItem), so several entries share it. Say which entry->returns. If it returns one entry, an ordering at that path can miss a matching element, which is a false negative. Settle this before the JSON index PR. null,[]and{}. Say whether SteVec emits a selector for anullleaf, an empty array and an empty object. If it does not, the needle{"a": []}or{"a": null}has no selector and matches every row under@>. Also, a stored{"a": null}is then contained by every needle under<@. Add these cases to the JSON index tests.- CI. The Test EQL PG17 shard failures come from the base. This PR does not cause them.
69ef7b3 to
9895211
Compare
701fc22 to
ca0af99
Compare
9895211 to
909eb50
Compare
ca0af99 to
e9e6336
Compare
909eb50 to
20513db
Compare
This comment has been minimized.
This comment has been minimized.
20513db to
63331c7
Compare
e9e6336 to
a63d2e7
Compare
Generated by Claude Code |
… and AtPath ADR-0009 decision 1 names three JSON operators. `op::Contains` and `op::ContainedBy` are the containments (`@>` and `<@`), exact, and take one value, the document. `op::AtPath<Op>`, written `op::AtPath(op::Eq)`, applies another operator at a JSON path and inherits that operator's fidelity through `TermFor`: an exact term answers `AtPath<Eq>` and `AtPath<Lt>`, and only a probabilistic one answers `AtPath<Matches>`. No index answers them. This crate has no JSON index, and EQL v4 has no JSON type Stack Encrypt produces, so a containment query or a query at a path does not compile on any plan, which the compile-fail tests pin. `AtPath`'s arity is a new `op::Pathed`, a path and the leaf's input, and no `op::Input` of it exists until the JSON index arrives, since the path becomes a selector only that index can derive. The value-selector and selector-plus-leaf term shapes the issue lists wait for the same index. Closes #1187 Claude-Session: https://claude.ai/code/session_01VYKAWbd361xDLmqBdLoUcB
- `op::Pathed` carries the leaf operator's arity, `Pathed<A>`, so `AtPath<Eq>` takes `Pathed<One>` (a path and a value) and `AtPath<Between>` takes `Pathed<Pair>` (a path and a pair of bounds). A JSON index's `Input` impls can then derive one term or two as the leaf needs. A unit test pins the three arities. - `AtPath<Op>` takes only a leaf operator, the new `op::Leaf`: `Eq`, `Lt`, `Lte`, `Gt`, `Gte`, `Between` and `Matches`. `AtPath<Contains>`, `AtPath<ContainedBy>` and `AtPath<AtPath<_>>` are no longer operators, since none of them is one selector and value; `op::LeafArity` (sealed: `One` and `Pair`) keeps an accessor from nesting. `tests/ui/op_at_path_not_a_leaf.rs` pins the diagnostic. - The `DefaultIndex` diagnostic says no index answers the JSON operators yet, instead of only pointing at `.via(index)`, which led to a second error. `op::Input` gains a diagnostic naming what each arity takes. - The module intro lists the JSON operators and the `Pathed` arity, and `Operator::Arity`'s doc names all three arities.
63331c7 to
8daa5ae
Compare
a63d2e7 to
6eff76a
Compare
|
Fixes for the second review are in 6eff76a. tobyhede
freshtonic's suggested follow-ups
|
Summary
Stacked on #1208. This PR declares the JSON operators of ADR-0009 decision 1 and pins what they require of a term. It is the part of #1187 that does not need a JSON index, and it says plainly what does.
op::Containsandop::ContainedBy, the containments (@>and<@). Exact: any query term answers them. They take one value, the document.op::AtPath<Op>, writtenop::AtPath(op::Eq), applies another operator at a JSON path and inherits its fidelity throughTermFor: an exact term answersAtPath<Eq>andAtPath<Lt>, and only a probabilistic one answersAtPath<Matches>. That is decision 4's "AtPath<Op>inherits the fidelity ofOp" as a type rule, including through nested accessors.Answersimpl, andAtPathhas a new arity,op::Pathed, a path and the leaf's input, with noop::Inputuntil the JSON index exists, since the path becomes a selector only that index can derive. So a query with any of them does not compile on any plan, and the error says why.What waits for the JSON index
The issue's second and third items,
AtPath<Eq>as a value-selector term and the orderings at a path as a selector plus a leaf term, are the shapes of terms that only a JSON index can derive, so they land with it. The third item'sverifyat a path is moot under the revised ADR-0009:Probabilisticis Bloom-only and no probabilistic leaf exists, soAtPath<Op>over this crate's operators is exact.Tests
AtPath<Eq>,AtPath<Lt>,AtPath<Between>and a nestedAtPath<AtPath<Eq>>; aMatchQueryanswersAtPath<Matches>; the containments take any term.EqualityTermcannot answerAtPath<Matches>;op::Containsandop::AtPath(op::Eq)do not compile on a plan.Test plan
cargo nextest run -p stack-encrypt --all-features: 584 passed.-D warningswith and without--all-features, rustdoc with warnings as errors,cargo fmt --check.Closes #1187
https://claude.ai/code/session_01VYKAWbd361xDLmqBdLoUcB
Summary by CodeRabbit