Repository navigation
core: prefix internal helpers with an underscore so the public rules are clear - #98
Merged
Merged
Conversation
…are clear Only report, report_with_params, violations, operators, op_passed, value_at, arg and leaf_passed keep their names. Every other rule now starts with _, so a policy that calls one of them directly, like ergo.row_cause, breaks and should use the report instead. Closes #27 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jbpros
force-pushed
the
core/private-helpers
branch
from
October 2, 2026 21:20
b587e6c to
6769820
Compare
jbpros
marked this pull request as ready for review
October 2, 2026 21:22
jbpros
added a commit
that referenced
this pull request
Oct 2, 2026
Follows #98. CI now runs [Regal](https://www.openpolicyagent.org/projects/regal)'s `bugs` rules, so it fails when a file outside `package ergo` calls a rule whose name starts with `_` (`leaked-internal-reference`). Test files are exempt. Only the `bugs` rules are on. All of Regal's rules together report about 400 findings, mostly line length and references it can't resolve across the test and custom operator packages, and each would need its own decision. `redundant-existence-check` is off. Its one finding is `_verdict_cause(passed) := "satisfied" if passed`, and that condition is needed: removing it makes 46 tests error, because a failed check then matches both `_verdict_cause` rules. The flags are on the command line, not in `.regal/config.yaml`, because OPA loads every YAML file it finds as data. AGENTS.md lists the command with the other checks. Regal is pinned to 0.43.0 through `open-policy-agent/setup-regal@v2.0.0`. That action has no `v2` tag, so Dependabot will bump it. ## Checks - `regal lint --disable-all --enable-category bugs --disable redundant-existence-check --ignore-files '.github/**' .` says `8 files linted. No violations found.` - On a scratch package where another package calls `ergo._x`, the same rules exit 3 and flag the call. - This PR's own CI run is the first time the workflow step runs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
jbpros
added a commit
that referenced
this pull request
Oct 2, 2026
…rest (#103) Follows #98. REFERENCE.md's "Policies" section now says a policy should call only `ergo.report`, `ergo.report_with_params` and `ergo.violations`, that `_` rules can change in any release, and that Regal's `leaked-internal-reference` flags a call to one. Our CI can't see users' repos, so this is how they find out. I checked the Regal claim with Regal 0.43.0 on a scratch folder holding `ergo.rego` and a `package policy` file that calls `ergo._row_cause` and `ergo.report`. It flagged only the `_row_cause` call. Custom operators are covered by the existing list in "Custom operators", and #101 is about linting them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #27.
Eight rules keep their names, because the docs tell people to call or define them:
report,report_with_params,violations,operators,op_passed,value_at,argandleaf_passed. The other 227 now start with_.This breaks any policy that calls a helper directly, like
ergo.row_cause.How the rename was done
OPA lets a local variable or parameter share a rule's name, so a plain find-and-replace wasn't safe. A script renamed identifiers outside strings and field reads (
.x), and would have skipped any rule body that declared a local with the same name. It found none. Calls from other packages were renamed only where written asergo.x.Other changes
ergo_test.regocall_is_violation,_definition_fieldand_rfc3339_shapeddirectly. Two pin thatviolationsreads only the requirements, and two test the RFC 3339 gate on its own (compare_timeaccepts numbers through another branch), so neither can be checked through the report. They stay where they are: Regal'sleaked-internal-referencedoesn't apply to_test.regofiles, and moving them intopackage ergowould put test rules intodata.ergo.check_passedfrom the list of rules that cause a loop, since it's private now, and fixes "Two rules:" over a list of three.Checks
opa check --strict . --ignore .github,opa fmt --list .(prints nothing),opa test . --ignore .github(642/642, the same count as main), and the--strict-builtin-errorsrun printstrue.ergo_test.regocalls a_rule from outsidepackage ergo.regal lint --disable-all --enable leaked-internal-reference --ignore-files '.github/**' .finds nothing.#34 is the only open PR touching
ergo.rego, so it will need its helper calls renamed when rebased.🤖 Generated with Claude Code