Behaviour differing from OPA on cyclic references between multiple policies

Open
#743 6 comments 1 reaction 2 assignees View on GitHub

Maintainers usually reply within 1 day

@anakrish is already working on this.

Since Jun 9, 2026.

  • #745 by @copilot-swe-agent — open

Assessment

This issue has not been assessed yet.

Description

The results from OPA and regorus differ for noncyclic rules across cyclicly referencing packages/files.

I get

opa eval --data test/registry.rego --data test/package_a.rego data
Allowed by stage 1:  package_a
Allowed by stage 2:  package_a
{
  "result": [
    {
      "expressions": [
        {
          "value": {
            "registry": {
              "allow": true,
              "allow_stage1": true,
              "allow_stage2": true,
              "packages": {
                "package_a": {
                  "allow_stage1": true,
                  "allow_stage2": true
                }
              }
            }
          },
          "text": "data",
          "location": {
            "row": 1,
            "col": 1
          }
        }
      ]
    }
  ]
}

with OPA 1.17.0 while regorus v0.9.1 with python using the Engine class returns:

/home/phi1010/.local/bin/uv run /home/phi1010/PycharmProjects/htmlplayground1/.venv/bin/python /home/phi1010/PycharmProjects/htmlplayground1/documentation/evaluate_policies_with_regorus.py 
ic| engine: <builtins.Engine object at 0xb30ca00>
Traceback (most recent call last):
  File "/home/phi1010/PycharmProjects/htmlplayground1/documentation/evaluate_policies_with_regorus.py", line 22, in <module>
    run()
    ~~~^^
  File "/home/phi1010/PycharmProjects/htmlplayground1/documentation/evaluate_policies_with_regorus.py", line 18, in run
    ic(engine.eval_query("data"))
       ~~~~~~~~~~~~~~~~~^^^^^^^^
RuntimeError: 
--> package_a.rego:6:1
  |
6 | allow_stage2 if registry.allow_stage1
  | ^
error: recursion detected when evaluating rule:
--> package_a.rego:6:1
  |
6 | allow_stage2 if registry.allow_stage1
  | ^
depends on: 
--> registry.rego:5:1
  |
5 | allow if allow_stage2
  | ^
depends on: 
--> registry.rego:12:1
   |
12 | allow_stage2 if {
   | ^
depends on: 
--> package_a.rego:6:1
  |
6 | allow_stage2 if registry.allow_stage1
  | ^
depends on: cyclic evaluation

Process finished with exit code 1

The files look like this:

package_a.rego

package registry.packages.package_a

import data.registry
import rego.v1

allow_stage2 if registry.allow_stage1

allow_stage1 := true

registry.rego

package registry

import rego.v1

allow if allow_stage2

allow_stage1 if {
	data.registry.packages[name].allow_stage1
	print("Allowed by stage 1: ", name)
}

allow_stage2 if {
	data.registry.packages[name].allow_stage2
	print("Allowed by stage 2: ", name)
}

I can't try it out with v0.10.1 right now, as there are no python wheels available on pypi for that version.

Dominant language
Rust
Stars
375
Forks
81
Avg merge
1d 11h
Merged PRs (30d)
78

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/regorus

All issues in microsoft/regorus

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.