1---2name: opa-policy3description: Use when editing tracked Rego, OPA, Gatekeeper templates, or policy constraints.4---56<!-- Generated from harness/github-copilot/plugins/open-horizons-platform/instructions/opa-policy.instructions.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# OPA and Gatekeeper Policies910## Conventions1112- Keep policy evaluation pure and deterministic: no time-, network-, random-, or environment-dependent authorization decisions.13- Use explicit package names, rule names, input shapes, and defaults so undefined data cannot become an accidental allow.14- Return stable, actionable denial or violation messages without secrets or full sensitive objects.15- Normalize sets and object traversal deliberately; do not depend on iteration order.16- Keep allow and deny precedence explicit and fail closed for malformed or unsupported inputs.17- Align each Gatekeeper `ConstraintTemplate` name, generated constraint kind, parameters schema, targets, and Rego package.18- Scope constraints with deliberate match and exclusion rules; avoid exemptions broader than the documented compatibility need.19- Keep generated security-baseline policy under `scripts/golden-paths/` portable and deterministic.20- Add fixtures for allowed, denied, missing, malformed, boundary, and exemption cases.2122## Verification2324- Rego formatting, parsing, and policy tests pass with the repository-supported OPA tooling.25- Gatekeeper templates and constraints agree on API versions, kinds, names, and parameters.26- Repeated evaluation of identical input produces identical structured results.2728## Do / Do Not2930| Do | Do not |31| --- | --- |32| Keep policy decisions stable, structured, and covered by allow and deny fixtures. | Hide exceptions, depend on evaluation order, or mutate external state. |33| Keep Gatekeeper templates and constraints schema-aligned. | Change parameters on one side without updating the other. |3435## Checklist Before Opening a PR3637- [ ] The change matches this instruction's `applyTo` scope.38- [ ] Formatting, parsing, and policy tests pass.39- [ ] Allow, deny, missing, malformed, boundary, and exemption fixtures are covered.40- [ ] Templates and constraints agree on API, kind, name, and parameters.41- [ ] No unrelated edits or unresolved placeholders remain.