test(sexpr): audit predicate matrix + fuzz + doc examples + linked-from source-arg fix#194
Merged
test(sexpr): audit predicate matrix + fuzz + doc examples + linked-from source-arg fix#194
Conversation
Comprehensive s-expression audit: close the coverage gaps in the
predicate inventory and add four campaigns on top of the existing
proptest_sexpr properties.
New coverage:
* rivet-core/tests/sexpr_predicate_matrix.rs (92 tests)
Three-shape coverage — positive, negative, malformed — for every
predicate the lowerer recognises. Fills gaps for !=, >, <, >=, <=,
linked-from (arity), count, reachable-from, reachable-to, plus
arity/operator-shape errors for every head form.
* rivet-core/tests/sexpr_fuzz.rs (4 proptest campaigns, 256 cases each)
- parse_never_panics: random ASCII + paren/quote soup must not panic
sexpr::parse
- lower_never_panics: full parse_filter on arbitrary input
- evaluate_never_panics: lowered Expr evaluated on a synthetic store
- roundtrip_equivalence: generated Expr → pretty-print → re-parse
must preserve truth value on every fixture artifact
* rivet-core/tests/sexpr_doc_examples.rs (9 tests)
Every s-expression example in docs/getting-started.md runs
end-to-end with an asserted match count, catching any future drift
between the docs and the evaluator.
* rivet-cli/tests/sexpr_filter_integration.rs (6 tests)
CLI-level smoke for list/stats/coverage --filter, including a
baseline vs. filtered comparison to catch silently-ignored filters
and a bad-s-expr exit-code assertion.
Verifies: REQ-048
Refs: REQ-028
`(linked-from "satisfies" "REQ-A")` silently ignored its second argument — the evaluator's `Expr::LinkedFrom` arm bound the source parameter as `_source` and only checked the link type. A filter naming a specific source ID got the same result set as the wildcard form, which hid real differences at the source level. This is the same class of bug as the `links-count` operator drop fixed in v0.4.2 — lowerer accepts the argument, evaluator throws it away — so the fix follows the same pattern as `Expr::LinkedBy`: treat `Value::Wildcard` as "any source" and otherwise require an exact match against the backlink source. Adds a regression test (`linked_from_source_filter_is_honoured`) in the predicate-matrix audit suite that exercises both the specific-id and wildcard forms on a store with two distinct source artifacts. Fixes: REQ-004 Verifies: REQ-004
📐 Rivet artifact deltaNo artifact changes in this PR. Code-only changes (renderer, CLI wiring, tests) don't touch the artifact graph. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Comprehensive audit of the s-expression filter/query language used by
rivet list --filter,rivet matrix --filter,rivet export --filter,rivet coverage --filter,{{query:(...)}}embeds, and schema conditional/traceability rules.Scope
rivet-core/src/sexpr_eval.rs::lower_listparse,lower,evaluate, and pretty-print roundtrip from panicslist --filter,stats --filter,coverage --filterBug found + fixed
(linked-from <type> <source>)silently ignored its second argument. Same silent-accept shape as v0.4.2'slinks-countoperator drop. Regression testlinked_from_source_filter_is_honouredpins the fix.Stats
getting-started.md)Recommendations the audit surfaced but did not act on
(count <scope>)is equivalent to(exists <scope> true)— lowering for(> (count …) N)doesn't exist; either add it or clarify docsmatchessilently returns false on invalid regex — consistent with filter semantics but a parse-time warning would save debugging timeAccessor::Fieldis the only variant; dotted accessorslinks.satisfies.*parse as symbols and resolve to empty strings — worth documentingThese three go into a follow-up PR as part of v0.4.3.
Test plan
cargo test --workspace— all 40 test binaries greenrivet docs check— PASS (41 files, 0 violations)Refs: REQ-004, REQ-010
🤖 Generated with Claude Code