You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
policy: FallbackEvaluate disagrees with the OPA engine on enabled defaults, AND/OR semantics, and rootDirectory #115
Three related semantic-drift issues between the primary Rego/OPA evaluator and the pure-Go FallbackEvaluate path in packages/policy:
rego.go:42 — enabledForRego and enabledForFallback disagree on which features/rules are considered enabled by default, so the same configuration can be interpreted differently depending on which evaluator handles it.
policy.go:375 — FallbackEvaluate combines multiple constraints with OR logic where the Rego policy combines the equivalent constraints with AND, so a rule that should require all conditions to hold can be satisfied by just one of them under the fallback evaluator.
policy.go:360 — rootDirectory constraint checking is entirely unimplemented in FallbackEvaluate (a no-op / always-true), while the Rego engine enforces it.
Impact
Whenever the fallback evaluator is used instead of OPA (e.g. OPA unavailable, or a deployment configured to run fallback-only), policies can be enforced with meaningfully looser semantics than intended: features assumed disabled by default may be enabled, AND-combined constraints degrade to OR, and rootDirectory confinement does nothing at all. This is a silent policy-weakening bug whose effect is invisible to anyone validating policy behavior solely against the Rego engine.
Repro
Compare enabledForRego and enabledForFallback's default-enabled sets directly; find at least one rule/feature where they differ.
Write a policy rule with two constraints that must both hold (AND semantics in Rego); evaluate the same policy via FallbackEvaluate with only one constraint satisfied and observe it is allowed, where the Rego path would deny it.
Set a rootDirectory constraint and evaluate a path outside it via FallbackEvaluate; observe it is allowed, where the Rego engine would deny it.
Suggested fix
Audit enabledForRego vs enabledForFallback and make them share a single source of truth for default-enabled rules rather than two independently maintained lists. Change FallbackEvaluate's constraint combination at :375 from OR to AND to match the Rego semantics (or, better, extract the combination logic into a shared helper exercised by both evaluators). Implement rootDirectory checking in FallbackEvaluate using the same path-containment logic as the Rego engine (see the related rootDirectory issue for the Rego side's own boundary bug, which the fallback implementation should not blindly copy).
The fallback evaluator should produce identical results to the OPA engine for every input. I'll add a conformance test suite that runs the same policy through both evaluators and asserts identical decisions, then fix every divergence.
Activity
sharmis-tp commentedon Nov 18, 2026
The fallback evaluator should produce identical results to the OPA engine for every input. I'll add a conformance test suite that runs the same policy through both evaluators and asserts identical decisions, then fix every divergence.