docs(#1802): add direct unit testing requirement for helper functions - #1803
docs(#1802): add direct unit testing requirement for helper functions#1803fullsend-ai-coder[bot] wants to merge 1 commit into
Conversation
Add guidance to AGENTS.md and .claude/rules/policy-rules.md requiring new public helper functions in policy/lib/ to have direct unit tests in their corresponding _test.rego files, not just indirect coverage through consuming rules. This addresses a gap identified during PR #1781 review where the lacks_effective_anchor helper had 4 logical branches but was only tested indirectly through anchoring_errors callers. Direct tests should exercise each logical branch, edge cases, and the function contract independently. Closes #1802
|
🤖 Finished Review · ✅ Success · Started 10:35 AM UTC · Completed 10:46 AM UTC Commit: |
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
Labels: PR is a documentation-only change modifying AGENTS.md and .claude/rules/policy-rules.md |
|
|
||
| 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: |
There was a problem hiding this comment.
[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'.
What:
Add documentation requiring direct unit tests for new public helper functions in
policy/lib/.Changes:
AGENTS.md: New "Testing New Helper Functions" section after the review checklist, specifying that new helpers must have direct tests covering each logical branch, edge cases, and the function contract independently of callers..claude/rules/policy-rules.md: New bullet reinforcing that indirect coverage alone is not sufficient for helper functions.Why:
During PR #1781, human reviewer st3penta identified that the
lacks_effective_anchorhelper had 4 logical branches tested only indirectly throughanchoring_errors. While CI's 100% coverage gate was met, the indirect tests did not guarantee all edge-case combinations were exercised. This convention exists in practice (most helpers inpolicy/lib/already have direct test suites) but was not documented, so automated reviewers had no basis to flag the gap.Tickets:
#1802
Closes #1802
Post-script verification
agent/1802-add-helper-testing-guidance)c09eff2a05a0b5ce23515a96b907b8a6f361cdfb..HEAD)