Repository navigation
feat(reconciler): evaluate records against OPA and CEL policies - #2266
Merged
muscariello merged 4 commits intoOct 2, 2026
Merged
Conversation
Contributor
|
The latest Buf updates on your PR. Results from workflow Buf CI / verify-proto (pull_request).
|
muscariello
force-pushed
the
feat/policy-evaluator-validators
branch
from
October 2, 2026 07:34
34f3533 to
a178fc4
Compare
muscariello
added a commit
that referenced
this pull request
Oct 2, 2026
dupword flags "records records" in NewValidatorEvaluator's comment. Fixes the Lint job failure on #2266. Signed-off-by: Luca Muscariello <[email protected]>
muscariello
added a commit
that referenced
this pull request
Oct 2, 2026
dupword flags "records records" in NewValidatorEvaluator's comment. The same change is on #2266, whose commit this branch still carries; it drops out when this branch is rebased onto it. Fixes the Lint job failure on #2267. Signed-off-by: Luca Muscariello <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
muscariello
added a commit
that referenced
this pull request
Oct 2, 2026
NewRegistry took a policy's version from the validator by a type assertion whose failing branch config validation makes unreachable, so its error return was never covered. validatorFor now returns the version with the validator, as the OPA and CEL constructors already know it, and the assertion goes. A provider that cannot define a policy has no version, and the policy task refuses a policy without one. Addresses the coverage report on #2266. Signed-off-by: Luca Muscariello <[email protected]>
muscariello
added a commit
that referenced
this pull request
Oct 2, 2026
dupword flags "records records" in NewValidatorEvaluator's comment. Fixes the Lint job failure on #2266. Signed-off-by: Luca Muscariello <[email protected]>
muscariello
added a commit
that referenced
this pull request
Oct 2, 2026
NewRegistry took a policy's version from the validator by a type assertion whose failing branch config validation makes unreachable, so its error return was never covered. validatorFor now returns the version with the validator, as the OPA and CEL constructors already know it, and the assertion goes. A provider that cannot define a policy has no version, and the policy task refuses a policy without one. Addresses the coverage report on #2266. Signed-off-by: Luca Muscariello <[email protected]>
muscariello
force-pushed
the
feat/policy-evaluator-validators
branch
from
October 2, 2026 12:05
0e27672 to
ebcc128
Compare
csirmazbendeguz
previously approved these changes
Oct 2, 2026
muscariello
dismissed
csirmazbendeguz’s stale review
October 2, 2026 12:33
The merge-base changed after approval.
muscariello
added a commit
that referenced
this pull request
Oct 2, 2026
dupword flags "records records" in NewValidatorEvaluator's comment. Fixes the Lint job failure on #2266. Signed-off-by: Luca Muscariello <[email protected]>
muscariello
force-pushed
the
feat/policy-evaluator-validators
branch
from
October 2, 2026 12:33
ebcc128 to
6a9c677
Compare
muscariello
added a commit
that referenced
this pull request
Oct 2, 2026
NewRegistry took a policy's version from the validator by a type assertion whose failing branch config validation makes unreachable, so its error return was never covered. validatorFor now returns the version with the validator, as the OPA and CEL constructors already know it, and the assertion goes. A provider that cannot define a policy has no version, and the policy task refuses a policy without one. Addresses the coverage report on #2266. Signed-off-by: Luca Muscariello <[email protected]>
A validator now accepts a fourth op, evaluate. It does not check records on their way in: it makes the validator a content policy, whose verdicts the reconciler stores and the server's read gate enforces. Only opa and cel accept it. An OASF schema is fetched from a remote endpoint, so the content of that policy is not known when it is loaded. A policy's ID is provider:name, such as opa:require-license: config.name, or for OPA the file's name without .rego, and required for CEL. It is limited to letters, digits, '.', '_' and '-' because it ends up in a comma-separated setting and in metric labels, and two entries cannot define the same one. Its version is a hash of its content, the .rego source or the expressions, taken from what was loaded. An edit is a new version, nothing else is, and nobody states one. Registry.Policies returns the policies with their ID, version and validator. Refs #2265, #2205 Signed-off-by: Luca Muscariello <[email protected]>
Nothing implemented policy.Evaluator, so a node could not produce a verdict and enforcing a policy would have hidden every record. ValidatorEvaluator is one: it reads the record from the store, since the index holds only the fields searches use, and has the validator decide on it. A rejection carries what the validator reported as its reason; a record that cannot be read, or a validator that cannot judge it, is an error, which the task stores as a failed evaluation that stays excluded. The service registers one evaluator for each policy in the validator registry, and the task now runs when policy_evaluation is enabled and a policy is configured. It warns when policies are configured and the task is off, and when the task is on and none is, so neither passes silently. The runbook describes how to define a policy, what its ID and version are, and what the reconciler does with a record, in place of the note that no evaluator ships. Closes #2265. Refs #2205 Signed-off-by: Luca Muscariello <[email protected]>
dupword flags "records records" in NewValidatorEvaluator's comment. Fixes the Lint job failure on #2266. Signed-off-by: Luca Muscariello <[email protected]>
NewRegistry took a policy's version from the validator by a type assertion whose failing branch config validation makes unreachable, so its error return was never covered. validatorFor now returns the version with the validator, as the OPA and CEL constructors already know it, and the assertion goes. A provider that cannot define a policy has no version, and the policy task refuses a policy without one. Addresses the coverage report on #2266. Signed-off-by: Luca Muscariello <[email protected]>
muscariello
force-pushed
the
feat/policy-evaluator-validators
branch
from
October 2, 2026 12:59
6a9c677 to
e774182
Compare
csirmazbendeguz
approved these changes
Oct 2, 2026
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 #2265. Part of #2205. Stacked on #2253:
main← #2226 ← #2229 ← #2235 ← #2237 ← #2238 ← #2241 ← #2246 ← #2248 ← #2249 ← #2253 ← this. Based onfeat/policy-audit-bypass; retargets as the PRs below it merge.What this adds
The policy task stores verdicts and the read gate enforces them, but nothing implemented
policy.Evaluator: a node could not produce a verdict, so enforcing a policy would hide every record, and nothing could be tested end to end (#2244) or dry-run (#2264). This adds the first evaluator, from the OPA and CEL validators already onmain.A validator gets a fourth op,
evaluate, which makes it a content policy instead of an admission check:provider:name:opa:require-license,cel:has-description.namedefaults to the OPA file's name without.regoand is required for CEL. Letters, digits,.,_and-only, because the ID is listed in a comma-separated setting and used as a metric label. Two entries cannot define the same ID. This is whatpolicy.enforcement.policieslists..regosource, or the expressions. An edit is a new version, anything else is not, and nobody states one. The reconciler registers it and the server follows it, as before.opaandcel. An OASF schema is fetched from a remote endpoint, so the content of that policy is not known when it is loaded; it stays an admission check.ValidatorEvaluatorreads the record from the store (the index holds only the fields searches use) and has the validator decide on it. A rejection carries what the validator reported as its reason. A record that cannot be read, or a validator that cannot judge it, is an error, which the task stores as a failed evaluation: it stays excluded and is tried again next run.Hot-reloading a policy file is out of scope: an edit takes effect when the reconciler restarts, as for every other validator.
Testing
.regosource or the expressions change, and does not depend on the file's name or the policy's name; moving the boundary between two parts changes it.compliantfor the described record, a rejection with a reason for the bare one, and registers the version the policy was loaded at.server,reconciler,cliandtestsvet clean;server,reconcilerandclitests pass.Next
#2244: the E2E test, in the daemon suite, on a node that enforces a policy defined this way.