Skip to content

Bugfix/partially cyclic evaluation#762

Draft
phi1010 wants to merge 4 commits into
microsoft:mainfrom
phi1010:bugfix/partially-cyclic-evaluation
Draft

Bugfix/partially cyclic evaluation#762
phi1010 wants to merge 4 commits into
microsoft:mainfrom
phi1010:bugfix/partially-cyclic-evaluation

Conversation

@phi1010

@phi1010 phi1010 commented Jul 13, 2026

Copy link
Copy Markdown

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

@phi1010

phi1010 commented Jul 13, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@phi1010

phi1010 commented Jul 13, 2026

Copy link
Copy Markdown
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
      }
    }
  ]
}

@anakrish

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants