fix(wardens): resolve opa fmt formatting drift in guardrails.rego (LIA-542) - #1168
Merged
Conversation
…A-542)
`opa fmt --fail scripts/warden_policy/policy` (the first command in
docs/HERMES_WARDEN_OPA.md's Verification section) was exiting 2
("unexpected diff"), isolated to guardrails.rego, due to OPA version
drift between whatever opa version last formatted the file and the
currently-installed opa 1.19.0.
Ran `opa fmt --write` on guardrails.rego only. Formatting-only change,
no Rego logic/decision rules/test behavior touched:
- drops redundant parens around a multiplication that already binds
tighter than the surrounding comparison
- Rego v1 bracket-index-to-dot-notation for a static string key
- reflows two multi-line WHY-comments (trailing `att.queued_at` and
`not hermes_path_ok`) -- opa fmt inserts a blank line before the
continuation paragraph and normalizes indentation; comment text is
byte-identical pre/post, verified word-for-word by code-reviewer and
verification-gate.
The blank-line insertion in the comment reflow is opa 1.19's own
canonical/idempotent rule for a code line followed by a multi-line
own-line comment block -- confirmed unavoidable while keeping the file
opa-fmt-clean (tested manually removing it and restructuring as a
leading comment block; both re-trigger `opa fmt --list` dirtiness).
Verification (before == after, zero regressions):
- opa fmt --list guardrails.rego: clean
- opa fmt --fail scripts/warden_policy/policy: exit 0
- opa check --strict scripts/warden_policy/policy: exit 0
- opa test -v --ignore="*.schema.json": PASS 68/68 (unchanged)
- pytest scripts/warden_policy/tests: 303 passed, 1 skipped, 65
subtests passed (unchanged)
- verification-gate additionally confirmed AST-identical pre/post via
`opa parse --format json` diff (location keys stripped) -- proves
zero behavioral change at the evaluation level, not just test counts
Reversibility: single-file, whitespace-only diff -- one `git revert`
fully undoes it.
Co-Authored-By: Claude Sonnet 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.
Summary
opa fmt --fail scripts/warden_policy/policy(the first command indocs/HERMES_WARDEN_OPA.md's Verification section) was exiting 2 ("unexpected diff"), isolated toguardrails.rego, due to OPA version drift between whateveropaversion last formatted the file and the currently-installedopa 1.19.0.opa fmt --writeonguardrails.regoonly. Formatting-only change, no Rego logic/decision rules/test behavior touched.What changed (4 hunks, 1 file)
["claude"]→.claude).3 & 4. Reflows two multi-line WHY-comments (trailing
att.queued_atandnot hermes_path_ok) —opa fmtinserts a blank line before the continuation paragraph and normalizes indentation. Comment text is byte-identical pre/post — not reworded, not truncated, still directly attached to the same code line with nothing else it could document.The blank-line insertion in the comment reflow is
opa 1.19's own canonical/idempotent formatting rule for "code line followed by a multi-line own-line comment block" — confirmed unavoidable while keeping the fileopa fmt-clean. I tested two alternatives (manually stripping the blank line; restructuring as a fully-leading comment block) and both re-triggeropa fmt --listdirtiness, so this is accepted as-is rather than hand-fought.This touches
scripts/warden_policy/policy/guardrails.rego— the sole place gate/allow decisions are made for this repo's Warden policy system (a disabled-but-real git-level hard backstop,main-attestation-backstop, will eventually run this exact policy) — so it went through the full plan-review → implement → code-review → verification-gate discipline despite being mechanical.Verification evidence (before == after, zero regressions)
opa fmt --list guardrails.regoopa fmt --fail scripts/warden_policy/policyopa check --strict scripts/warden_policy/policyopa test -v --ignore="*.schema.json"python3 -m pytest scripts/warden_policy/tests -qopa parse --format jsonon pre/post withlocationkeys stripped: identical — proves zero behavioral change at the evaluation level, not just matching test countsverification-gate additionally rebuilt the pre-fix baseline independently from
git show HEAD:...and reproduced the originalexit 2failure, confirming the bug was real before confirming the fix resolves it.Review discipline
All 4 required warden gates SHIP in this worktree's bucket before commit:
plan-reviewer(Claude): SHIPplan-reviewer@gpt: SHIPcode-reviewer(Claude): SHIPcode-reviewer@gpt: SHIPcode-reviewer@glm: COULD_NOT_RUN (quota exhaustion, HTTP 429 — expected, fails open, does not block)verification-gate: SHIPReversibility
Single-file, whitespace-only diff — one
git revertfully undoes it.Follow-up (out of scope for this PR, flagged by reviewers)
No CI workflow currently runs
opa fmt --fail/opa check/opa test(confirmed via.github/workflows/*.yml— zero hits), so this exact drift can silently recur on a futureopaupgrade. Worth a follow-up ticket to add it to CI.Test plan
opa fmt --listcleanopa fmt --failexit 0opa check --strictexit 0opa testpass count unchanged (68/68)pytest scripts/warden_policy/testsunchanged (303 passed, 1 skipped, 65 subtests)🤖 Generated with Claude Code