feat(lint): expose XPath/expression AST to Starlark rules#688
feat(lint): expose XPath/expression AST to Starlark rules#688Andries-Smit wants to merge 5 commits into
Conversation
AI Code ReviewReview SummaryCritical Issues: None
Minor Issues:
What Looks Good:
Recommendation: Approve after adding Starlark builtin integration test to Detailed FindingsOverlap & Duplication✅ No duplication:
MDL Syntax Design✅ Not applicable:
Full-Stack Consistency✅ Not applicable:
Test Coverage
Security & Robustness✅ Strong:
Scope & Atomicity✅ Focused:
Code Quality✅ High:
Key Observations
Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
…arse_xpath builtins Addresses the missing integration test flagged in the PR mendixlabs#688 review. Exercises the full pipeline: catalog seed → LoadStarlarkRule → rule.Check → violation assertions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AI Code Review##Review Summary This PR adds two new Starlark builtins ( Critical Issues
Moderate Issues
Minor Issues
What Looks Good
RecommendationApprove the PR. The changes are well-implemented, follow existing code patterns, include comprehensive tests, and provide valuable functionality for writing sophisticated lint rules. The minor concerns about the missing Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
AI Code ReviewWhat Looks Good
RecommendationApprove - This PR is ready to merge. It adds valuable functionality for lint rule writers without violating any applicable review checklist items (it doesn't add MDL syntax, so those specific checks don't apply). The implementation is robust, well-tested, and follows established patterns in the codebase. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
|
Strong PR — verified end-to-end on the branch. What's solid:
🟠 Main gap — no skill documentation (should block): all 5 changed files are under Minor:
Recommendation: approve once the skill docs are added for the two builtins, the |
Add two new builtins available to all `.star` lint rules: - `xpath_expressions()` — iterates XPathExpressionEntry records from the catalog, covering RETRIEVE, SECURITY, and DATASOURCE usage types across microflows, access rules, and pages. - `parse_xpath(expr)` — parses a raw XPath string into a structured Starlark tree using the existing exprcheck parser. Returns a recursive struct tree with a `kind` discriminator field and type-specific child fields (left/right for bin, operand for unary, args for call, etc.). Internal additions: - `starlark_xpath.go` — robustExprToStarlark() converter and xpathExpressionEntryToStarlark() mapper - `starlark_xpath_test.go` — unit tests for the converter - `LintContext.XPathExpressions()` iterator (context.go) - `"PERF001": "Performance"` mapping in report.go These builtins make it possible to write performance and security lint rules that inspect the parsed expression tree rather than raw strings — for example, flagging negative enumeration XPath conditions that prevent database index usage (PERF001). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BGEk1wbb3i1kMc6HBAodHQ
…arse_xpath builtins Addresses the missing integration test flagged in the PR mendixlabs#688 review. Exercises the full pipeline: catalog seed → LoadStarlarkRule → rule.Check → violation assertions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The function returns a struct with kind="null", not starlark.None. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
[a = 1][b = 2] was incorrectly stripped to a = 1][b = 2 because the check only looked at the first and last characters. The fix walks bracket depth to confirm the opening [ at position 0 is matched by the final ] before stripping. Added two test cases for chained predicates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R1yYeYn9rosf8UdAimdatt
…n skill Adds to write-lint-rules.md: - xpath_expressions() in the query functions table - parse_xpath(s) in the helper functions table - xpath_expression object (13 fields) - expr AST node schema (14 kind variants + type-specific fields) - Leaf-kind list and tree-walking example Closes the skill-docs gap flagged in PR mendixlabs#688 review. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R1yYeYn9rosf8UdAimdatt
AI Code ReviewWhat Looks Good
RecommendationApprove. The PR successfully adds the requested XPath expression analysis capabilities to Starlark lint rules without violating any project guidelines. Since it doesn't introduce or modify MDL syntax, the MDL-specific checklist items (grammar, AST, visitor, executor, etc.) correctly do not apply. The implementation is robust, well-tested, and integrates cleanly with the existing linter framework. The documentation clearly explains the new builtins and their usage. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
Add two new builtins available to all
.starlint rules:xpath_expressions()— iterates XPathExpressionEntry records from the catalog, covering RETRIEVE, SECURITY, and DATASOURCE usage types across microflows, access rules, and pages.parse_xpath(expr)— parses a raw XPath string into a structured Starlark tree using the existing exprcheck parser. Returns a recursive struct tree with akinddiscriminator field and type-specific child fields (left/right for bin, operand for unary, args for call, etc.).Internal additions:
starlark_xpath.go— robustExprToStarlark() converter and xpathExpressionEntryToStarlark() mapperstarlark_xpath_test.go— unit tests for the converterLintContext.XPathExpressions()iterator (context.go)These builtins make it possible to write performance and security lint rules that inspect the parsed expression tree rather than raw strings — for example, flagging negative enumeration XPath conditions that prevent database index usage.
Example Rule