docs(#1757): add Rego evaluation model guidance to AGENTS.md#1759
docs(#1757): add Rego evaluation model guidance to AGENTS.md#1759fullsend-ai-coder[bot] wants to merge 1 commit into
Conversation
Add a "Rego Evaluation Model (for AI reviewers)" section to AGENTS.md covering Rego's declarative semantics, idiomatic testing patterns, and common anti-patterns that AI reviewers should avoid suggesting. Key additions: - Evaluation semantics: rules are OR/AND propositions, not functions with return values or control flow - Testing idioms: testing conjunction terms independently is sufficient; do not request integration tests when clause coverage exists - Idiomatic patterns table: some x in collection, object.get, set membership, negation - Anti-patterns: no early returns, try/catch, null guards for parser-guaranteed keys, or integration test requests when coverage is 100% This addresses repeated false-positive findings from PR #1745 where the review agent applied imperative-language heuristics to Rego code across 5 review cycles. Closes #1757
|
🤖 Finished Review · ✅ Success · Started 4:15 PM UTC · Completed 4:27 PM UTC |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
ReviewFindingsMedium
Low
|
| within a body are **conjunctions** (AND). | ||
| - Rules evaluate to `true` or `undefined` — there are no "return values" or | ||
| control flow. Do not describe Rego rules as "returning" values or having a | ||
| "public API" in the imperative sense. |
There was a problem hiding this comment.
[medium] technical accuracy
The claim that rules evaluate to true or undefined is incomplete and misleading. Rego rules can evaluate to arbitrary values. Complete rules (defined with :=) evaluate to their assigned value, set rules produce sets, and object rules produce objects. This codebase uses value-producing rules extensively. Only boolean rules evaluate to true/undefined.
Suggested fix: Revise to: Boolean rules (no :=) evaluate to true or undefined. Rules defined with := evaluate to their assigned value, or undefined if no body matches. Functions accept arguments and produce values.
| control flow. Do not describe Rego rules as "returning" values or having a | ||
| "public API" in the imperative sense. | ||
| - There is no call/return mechanism, no early returns, and no try/catch. | ||
|
|
There was a problem hiding this comment.
[medium] technical accuracy
The claim there is no call/return mechanism is factually incorrect. Rego has user-defined functions that are called with arguments and produce values. This codebase uses them pervasively. While Rego functions are not imperative, stating there is no call/return mechanism is wrong.
Suggested fix: Revise to: Rego has functions but no imperative control flow — no early returns, no exceptions, no side effects. A function evaluates to the value of whichever body conditions are satisfied.
| ### Evaluation Semantics | ||
|
|
||
| - Multiple rule bodies with the same name are **disjunctions** (OR). Conditions | ||
| within a body are **conjunctions** (AND). |
There was a problem hiding this comment.
[low] internal consistency
The statement Do not describe Rego rules as returning values contradicts actual Rego semantics. Rego functions and complete rules DO produce values. The guidance is overly prescriptive.
Suggested fix: Soften to: Avoid imperative framing like early return or fallthrough. It is acceptable to say a rule or function evaluates to or produces a value.
Add a "Rego Evaluation Model (for AI reviewers)" section to AGENTS.md covering Rego's declarative semantics, idiomatic testing patterns, and common anti-patterns that AI reviewers should avoid suggesting.
Key additions:
with return values or control flow
do not request integration tests when clause coverage exists
set membership, negation
parser-guaranteed keys, or integration test requests when coverage
is 100%
This addresses repeated false-positive findings from PR #1745 where the review agent applied imperative-language heuristics to Rego code across 5 review cycles.
Closes #1757
Post-script verification
agent/1757-add-rego-paradigm-guidance)7e57219e2d4844569bc4933063c0c2d2f1bed147..HEAD)