fix(rego): schedule comprehensions in rule outputs - #825
Open
Maksym (maksym-mishchenko) wants to merge 3 commits into
Open
Maksym (maksym-mishchenko) wants to merge 3 commits into
Maksym (maksym-mishchenko) wants to merge 3 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Anand Krishnamoorthi (anakrish)
September 25, 2026 11:53
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The scheduler logic aligns with interpreter branch semantics and is comprehensively covered by focused regression tests.
Review effort: Balanced
Findings: None
What changed in this PR
Schedules inline comprehensions in Rego rule outputs so interpreter evaluation matches RVM behavior.
Changes:
- Schedules comprehensions using body-local scope.
- Handles nested, function, partial-rule, and
elseoutputs. - Adds interpreter/RVM parity and fresh-engine regression tests.
| File | Description |
|---|---|
src/scheduler.rs |
Adds output-expression scheduling and nested-scope propagation. |
tests/engine/mod.rs |
Tests fresh-engine evaluation and variable safety. |
tests/rvm/rego/cases/comprehensions.yaml |
Covers comprehension output variants and parity. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Problem
An inline comprehension in a guarded rule output loads and compiles, but interpreter evaluation fails with
statements not scheduled in query {query:?}when the guard succeeds. Moving the comprehension into a separate rule works; RVM already handles the inline form.The reported empty-input failure did not reproduce: empty or missing collections correctly leave the guarded rule undefined, not false.
Fix
I schedule comprehensions in output expressions with the body's local variables visible, including nested outputs, function results, and bodyless partial-set keys. Branch analysis follows the output actually evaluated, preserving
elseand independent partial-rule body semantics.Regression tests cover interpreter/RVM parity and fresh-engine
eval_rule/eval_query, including empty and missing inputs and duplicate/false array elements.Verification
cargo xtask ci-debugpassed.