feat(query): accept issue #33 literal examples — diff head + inline kwargs + PA-id auto-route#88
Open
hyperpolymath wants to merge 3 commits into
Open
feat(query): accept issue #33 literal examples — diff head + inline kwargs + PA-id auto-route#88hyperpolymath wants to merge 3 commits into
hyperpolymath wants to merge 3 commits into
Conversation
just isn't packaged for ubuntu-22.04 stock apt. Inline the commands the recipes wrapped so CI no longer needs apt-get install just. Local contributors keep the Justfile shortcuts unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Chapel 2.8.0 .deb apt-installs but fails with "Depends: libunwind-dev" on stock ubuntu-22.04 runners — dpkg bails before unpacking. Install libunwind-dev first across all 4 Chapel install sites. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… kwargs + PA-id auto-route Issue #33's body advertises three example query expressions. Two of them parsed-then-errored or parsed-then-matched-nothing under the existing grammar: (category PA001 :severity Critical :pr-state nil) → parse error: "expected ')', got Atom(":severity")" (diff :since 2026-04-12 :category PA022) → parse error: "unknown query head: diff" (category PA001) → parsed, but matched zero findings — `category` expects the `WeakPointCategory` Debug name (e.g. "UnsafeCode"), not a rule ID This patch makes all three literal expressions in the issue work as documented: * New `diff` head — keyword-only sugar for `(and (kw VALUE) ...)`, unwrapped to the single clause when only one kwarg is supplied. * Inline `:keyword VALUE` kwargs accepted on every unary head (`category`, `rule-id`, `severity`, `repo`, `file`, `pr-state`, `since`) via a shared `parse_trailing_kwargs` helper. Desugars to `(and head-positional kw-clauses…)`. Existing single-arg forms keep parsing to the same atomic `Query` variants. * `(category PAxxx)` auto-routes to `Query::RuleId` so the issue's literal expression actually selects findings. Shared `query_for_keyword` dispatch keeps inline-kwargs and `diff` in lock-step — adding a new unary head requires a single row. Docs updated in the `src/query/mod.rs` module header with the new supported forms and a worked desugaring example. 12 new unit tests (300 total, was 288): parse_category_pa_id_auto_routes_to_rule_id parse_category_word_does_not_auto_route parse_issue_example_category_with_inline_kwargs parse_issue_example_diff_form parse_diff_with_single_kwarg_unwraps parse_diff_empty_errors parse_diff_rejects_unknown_keyword parse_diff_rejects_positional_arg parse_inline_kwargs_on_severity_head parse_inline_kwargs_on_since_head run_issue_example_category_with_kwargs_matches run_diff_form_matches_recent_findings End-to-end smoke against the three issue examples: all parse, all run, all return "No matches" against an empty store (correct). `cargo test --lib`: 300 passed. `cargo clippy --all-targets --no-default-features -- -D warnings`: clean. Refs #33. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 30, 2026
Owner
Author
|
FYI: panic-attack Base ruleset now requires |
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
Closes the residual gap on #33: the issue body advertises three example query expressions, but two of the three failed to parse and one parsed-then-matched-nothing under the existing grammar. After this patch, all three expressions in the issue work verbatim.
The S1/S2/S3 architectural work is already in main (see #57, #58, #60, #61, #62, #63). This is the user-facing-syntax polish that lets the issue itself close cleanly against its own documented examples.
What changed
(crosslang :from FFI :to ProofDrift)(category PA001 :severity Critical :pr-state nil)(and (rule-id PA001) (severity Critical) (pr-state nil))(diff :since 2026-04-12 :category PA022)(and (since 2026-04-12) (rule-id PA022))(category PA001)(rule-id PA001), matches findingsThree additions to
src/query/mod.rs:diffhead — keyword-only sugar for(and (kw VALUE) ...)over its:keyword VALUEpairs. Unwraps to the single clause when only one kwarg is supplied so the AST stays minimal.:keyword VALUEkwargs on every unary head —category,rule-id,severity,repo,file,pr-state,since. Implemented via a sharedparse_trailing_kwargshelper so adding a new unary head adds a single dispatch row.(category PAxxx)auto-routes toQuery::RuleIdso the issue's literal example actually selects findings instead of silently matching zero.(category UnsafeCode)continues to match byWeakPointCategoryDebug name.Shared
query_for_keyworddispatch keeps the inline-kwargs path and thediffpath in lock-step.Module-header docs updated
src/query/mod.rsnow documents the new forms and shows the desugaring:```text
(category PA001 :severity Critical :pr-state nil)
≡ (and (rule-id PA001) (severity Critical) (pr-state nil))
(diff :since 2026-04-12 :category PA022)
≡ (and (since 2026-04-12) (rule-id PA022))
```
Test plan
cargo test --lib --no-default-features— 300 passed (288 before; 12 new).cargo clippy --all-targets --no-default-features -- -D warnings— clean.(crosslang :from UnsafeFFI :to ProofDrift)(category PA001 :severity Critical :pr-state nil)(diff :since 2026-04-12 :category PA022)Backwards compatibility
QueryAST. Verified by running the full existing test suite (288 tests) unchanged.diffform unwraps to the underlying clause, so AST consumers never see a needlessQuery::Andwrapper.Out of scope
cargo fmtdrift insrc/assail/analyzer.rs,src/bridge/{classify,lockfile,reachability}.rs, andsrc/main.rsdiscovered while running checks. Filing separately to keep the diff scoped.Refs #33.
🤖 Generated with Claude Code