Skip to content

fix: keep prior rule locations in concise conflict diagnostics - #820

Merged
Anand Krishnamoorthi (anakrish) merged 2 commits into
microsoft:mainfrom
maksym-mishchenko:maksym-mishchenko-regorus-conflict-diagnostics
Sep 23, 2026
Merged

Anand Krishnamoorthi (anakrish) merged 2 commits into
microsoft:mainfrom
maksym-mishchenko:maksym-mishchenko-regorus-conflict-diagnostics

Conversation

@maksym-mishchenko

@maksym-mishchenko Maksym (maksym-mishchenko) commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Proposal

I propose replacing the nested prior-rule source excerpt in
Interpreter::check_rule_path with a compact file, line, and column reference.
The current rule's source envelope stays intact.

The proposed wording, rule conflicts with rule at ..., remains provisional.

For this policy:

package test
p := 1
p := 2

The proposed diagnostic is:

--> policy.rego:3:1
  |
3 | p := 2
  | ^
error: rule conflicts with rule at policy.rego:2:1

The prior rule's location replaces its second source line/caret block and
defined here suffix. No quotes are added around the location.

Scope

Template or behavior Treatment
rule conflicts with the following rule: plus nested prior-rule diagnostic Replaced by the compact prior location. Same-file and cross-file paths are covered.
rules must not produce multiple outputs, rules should not produce multiple outputs., and function-output diagnostics Unchanged. Representative examples were executed.
recursion detected when evaluating rule: with dependency/source blocks Unchanged. Direct, mutual, and cross-module examples were executed; this proposal does not simplify recursion.
complete rules should not produce multiple outputs alternate call sites Unchanged and source-inventoried; not all sites were reached by the bounded runtime capture.
RVM inconsistent complete/function outputs Still Value::Undefined, not a new terminal conflict error.
Existing RVM RuleDataConflict Variant and PC context preserved. A data collision still fails during data setup.

Conflict detection, evaluation order, cleanup, public signatures, and status
mapping do not change. The interpreter diagnostic still crosses FFI as
RegorusStatus::Error and reaches C# as InvalidOperationException.
The known skipped RVM partial-object conflict cases remain outside this change.

Version-scoped examples

The bounded comparison exercised the exact Microsoft.Regorus NuGet 0.11.0
package and the paired managed/native binaries from this local patched tree
(assembly version 0.12.0.0). This is not a comparison against an unmodified
released 0.12.0 package or proof of the current downstream deployment version.

The package's metadata associates 0.11.0 with source commit
f98865fc980b9919d201e20969d9b28685ee72bc. Among the interpreter examples,
only the targeted separate-rule diagnostic changed. Recursive dependency
chains and the captured dynamic/function-output diagnostics were unchanged.

The corrected RVM probe compiles and loads a program and executes its named
entrypoint. Both versions return concrete values for the positive controls,
retain "<undefined>" for unequal complete/function outputs, and throw the
same C# data-setup exception:

Rule-data conflict: Conflict: rule defines path 'test.p' but data also provides this path (pc=0)

This is representative coverage, not execution of every error template.

Validation

  • cargo xtask ci-debug passed on the production change. The final two
    compiled-policy regression tests were added afterward and passed focused
    runs; no production code changed after the full run.
  • Interpreter tests cover same-file/cross-file locations, one source envelope,
    no duplicated prior source, and no added quote delimiters. Existing
    multiple-output and dependency suites passed.
  • Compiled-Rego tests verify conflicting complete/function outputs remain
    Value::Undefined in RVM while the interpreter retains its errors; equal
    outputs succeed in both. A Rust runtime test checks RuleDataConflict and
    pc: 0.
  • The FFI error/status test and neighboring panic test passed. The C# diagnostic
    test executed successfully against the paired native build.
  • No-default-feature checks, Rust formatting, and git diff --check passed.

The C# package-based test route encountered an SDK wildcard native-path packing
error; local project-reference execution succeeded. These runtime checks do
not establish package publication readiness.

Open questions

  • Is the proposed compact wording and retained current-source envelope
    the right format for this conflict family? Should recursion simplification
    remain a separate proposal?
  • Who owns the package-upgrade diagnostic-validation checklist, where should
    it live, and which downstream consumers and templates must it cover?

No AGS source changes, new terminal RVM conflict semantics, deployment, or
rollout changes are included.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@maksym-mishchenko
Maksym (maksym-mishchenko) marked this pull request as ready for review September 23, 2026 14:42
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

This PR simplifies rule-conflict diagnostics by referencing the prior rule’s file, line, and column while preserving current-source context and runtime behavior.

Changes:

  • Updated diagnostic formatting and path escaping.
  • Added interpreter, RVM, FFI, and C# regression coverage.
  • Updated fixtures and changelog documentation.
File Summary
tests/​rvm/​compiler.rs Verifies unchanged RVM conflict semantics.
tests/​interpreter/​cases/​rule/​multiple_outputs.yaml Updates conflict expectations.
src/​tests/​interpreter/​mod.rs Tests diagnostic formatting and path escaping.
src/​interpreter.rs Generates compact prior-rule locations.
CHANGELOG.md Documents the diagnostic change.
bindings/​ffi/​src/​engine.rs Verifies FFI status and message propagation.
bindings/​csharp/​Regorus.Tests/​RegorusTests.cs Verifies managed diagnostic behavior.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@anakrish
Anand Krishnamoorthi (anakrish) merged commit edbaa0b into microsoft:main Sep 23, 2026
60 checks passed
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.

3 participants