feat(querier): RFC 0002 green — L4 validation error contract (.14) - #535
Conversation
Discharge scenario RFC0002.14: param(n)/bucket(w) misuse errors are a pinned contract, not incidental behaviour. - (i)–(iii) compile-time (no pin / disjunction / not-buried pin / resolves_to alias set): already enforced by the execution slice's pinning check; now pinned end-to-end as InvalidQuery citing the single-template pinning rule, leak-free per RFC0002.8. - (iv) parse-time: group_term use outside a by-list previously fell through to the generic unknown-field error; the parser now rejects param(...)/bucket(...) in predicate paths, call/aggregate paths, and project field lists with a specific error citing the §7 v1.1 group_term by-list confinement. Pinned across all four contexts. No query reaches execution in any case. Test-file header updated: RFC0002.12–.16 are all green, no stubs remain. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y
📝 WalkthroughWalkthroughThe DSL parser now rejects ChangesGroup-term validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Implements the RFC 0002 amendment “green slice” for L4 validation/grammar error contracts (RFC0002.14), ensuring param(n)/bucket(w) misuse produces specific, leak-free errors and that semantic vs grammatical failures are distinguished.
Changes:
- Replaces the RFC0002.14 ignored stub with an end-to-end integration test asserting correct error class/message and token leak-freedom.
- Updates the DSL parser to reject
param(…)/bucket(…)when used outsideby-lists with a grammar-citing error message.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/ourios-querier/tests/it/rfc0002_dsl.rs | Turns RFC0002.14 into a real async test covering compile-time vs parse-time misuse cases and leak-free error messages. |
| crates/ourios-querier/src/dsl/parse.rs | Adds targeted parse-time rejection for param(…)/bucket(…) outside by-lists with a specific grammar-based error. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/ourios-querier/src/dsl/parse.rs (1)
1133-1143: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a colocated unit test asserting the diagnostic's message content.
The existing
rejects_malformed_group_termstest only checksis_err()for the by-list-outside cases; nothing in this file asserts that the message actually cites the grammar rule (that's currently only verified by the integration test inrfc0002_dsl.rs). A local assertion onerr.message()/.to_string()containing e.g."group_term"would guard the wording contract closer to the source.As per coding guidelines: "Unit tests must be next to the code and are mandatory for anything non-trivial."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/ourios-querier/src/dsl/parse.rs` around lines 1133 - 1143, Add a colocated unit test near group_term_outside_by and rejects_malformed_group_terms that exercises a malformed group term outside a by-list, asserts parsing returns an error, and verifies err.message() or to_string() contains “group_term”. Keep the assertion focused on the diagnostic wording contract.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/ourios-querier/src/dsl/parse.rs`:
- Around line 1133-1143: Add a colocated unit test near group_term_outside_by
and rejects_malformed_group_terms that exercises a malformed group term outside
a by-list, asserts parsing returns an error, and verifies err.message() or
to_string() contains “group_term”. Keep the assertion focused on the diagnostic
wording contract.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 04d4f0c9-ead2-477d-bd4e-723d5203858e
📒 Files selected for processing (2)
crates/ourios-querier/src/dsl/parse.rscrates/ourios-querier/tests/it/rfc0002_dsl.rs
What
The grammar/compile-validation green slice for RFC 0002's L4 amendment — discharges RFC0002.14, the last open scenario in the amendment (execution landed in #533).
param(n), a pin buried underor/not,resolves_toas a non-pin) were already enforced byvalidate_group_terms/pinned_template_id— now pinned end-to-end viarun_query: error classQueryError::InvalidQuery, message namesparam(0)/"pin"/"template", asserted leak-free against the RFC0002.8 engine-token set. Each case is also asserted to parse successfully first, proving the rejection is semantic, not grammatical.param(n)/bucket(w)outside aby-list) needed real enforcement — it previously fell through to a generic "unknown field" error that didn't cite the grammar, which the scenario's Then requires. Fixed in the parser: group terms are now rejected with a message citing "grammar §7 v1.1" across six contexts (predicate paths,projectfields, insidematches(...), as asum(...)path).Checks run
cargo fmt --all --check; workspacecargo clippy --all-targets --all-features -- -D warnings;cargo nextest run(full workspace) — 1116 passed, 36 skipped, rebased onto the merged #533.🤖 Generated with Claude Code
https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y
Summary by CodeRabbit
Bug Fixes
param(...)andbucket(...)expressions used outside permittedbylists.Tests
param(...)andbucket(...)usage, including compile-time and parse-time validation scenarios.