Bugfix/partially cyclic evaluation#762
Draft
phi1010 wants to merge 4 commits into
Draft
Conversation
Author
|
@microsoft-github-policy-service agree |
Author
|
This is still incomplete, it does not reject all recursions in doubt: import textwrap
import regorus
from icecream import ic
def run():
eng = regorus.Engine()
eng.add_policy(
"recursion.rego",
textwrap.dedent(
"""
package foo
import rego.v1
a := [input.x,i] if {
i:=a with input as { "x": input.x+1 }
}
"""),
)
ic(eng.eval_query("data"))
if __name__ == "__main__":
run()$ ./rego-recursion.py
ic| eng.eval_query("data"): {'result': [{'bindings': {},
'expressions': [{'location': {'col': 1, 'row': 1},
'text': 'data',
'value': {'foo': {}}}]}]}
$ opa eval --data test.rego "data"
{
"errors": [
{
"message": "rule data.foo.a is recursive: data.foo.a -\u003e data.foo.a",
"code": "rego_recursion_error",
"location": {
"file": "test.rego",
"row": 3,
"col": 13
}
}
]
} |
Collaborator
|
@phi1010 Can you also address the RVM flow in this PR? Currently the fix only targets the interpreter. I will free up next week and should be able to devote more time to this. |
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.
Bugfix written with Fable5 alone, and unit tests for the edgecases it fixes.
Code not yet verified by a Rust developer, might cause unintended side effects the tests don't cover.
Please review thouroughly as discussed in #743