Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/rules/policy-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ paths:
# Policy Rule Conventions

- Every `.rego` file must have a corresponding `_test.rego` — 100% coverage enforced
- New public helper functions in `policy/lib/` require direct unit tests, not just indirect coverage through callers
- All rules require METADATA annotations (title, description, short_name, failure_msg)
- Release policy rules declare collection membership via `collections:` in their METADATA annotations
- Run `make fmt` before committing; `make generate-docs` after changing rule metadata (titles, descriptions, collections, or adding new rules)
12 changes: 12 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ Rego is a declarative policy language (Datalog-inspired), not imperative code:
- **Test coverage:** Every new rule needs tests in a corresponding `_test.rego` file. CI enforces
100% coverage.

## Testing New Helper Functions

When a PR introduces a new public helper function in `policy/lib/`, it must have
direct unit tests in the corresponding `_test.rego` file — not just indirect
coverage through consuming rules. Direct tests should exercise:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] documentation formatting consistency

The new 'Testing New Helper Functions' section uses bare dash bullets whereas the checklist-style sections in AGENTS.md (Key Conventions, Common Change Patterns, Review Checklist for New Policy Rules) use the '- Bold label: description' pattern. The Rego Evaluation Model section also uses bare dashes, so this is not universally inconsistent, but the new section is closer in nature to the checklist sections.

Suggested fix: Consider reformatting bullets to match the checklist pattern, e.g., '- Branch coverage: Exercise each logical branch of the function'.

- Each logical branch of the function
- Edge cases (empty strings, non-string values, boundary conditions)
- The function's contract independent of any specific caller

100% coverage through indirect tests alone is not sufficient for functions with
multiple logical branches.

## PR Conventions

Conventional commits are encouraged. Run `make ci` before pushing. CI runs on every PR via
Expand Down
Loading