Repository navigation
feat(server): supersede only the verdicts the changed metadata affects - #2432
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
csirmazbendeguz
previously approved these changes
Oct 29, 2026
Signed-off-by: Tibor Kircsi <[email protected]>
tkircsi
dismissed
csirmazbendeguz’s stale review
October 29, 2026 13:24
The merge-base changed after approval.
tkircsi
force-pushed
the
feat/verdict-invalidation-scope
branch
from
October 29, 2026 13:24
160d6eb to
e6fe877
Compare
csirmazbendeguz
approved these changes
Oct 29, 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.
Description
Part of #2343. The first PR made a metadata write supersede a record's verdicts; this one narrows that to the policies whose answer the write can have changed.
A policy's fact dependencies are read off its own source when it compiles — the CEL AST for
meta.<group>selects, the Rego module forinput.meta.<group>references — and registered with the policy version by the reconciler, in the same call that records the version. Each of the six metadata writers then names the group it changed, and the supersede keeps only the verdicts of versions recorded as reading that group.This matters for availability, not CPU. A superseded verdict withholds the record until the policy task next runs, and that task is only woken by the indexer on a five-minute default interval. Before this, a rescan that changed nothing a policy reads could hide a record for that long.
Two cases decide correctness, and both are load-bearing in the
dependsOnFactGrouppredicate. A version with no dependency rows is superseded by anything, because nothing here can say it is unaffected — that is any policy evaluated before an upgrade across this change. A version that reads nothing is recorded explicitly, carrying anonesentinel, which is the only way "reads nothing" is distinguishable from "nothing recorded": both are otherwise an empty query result.Dependencies are keyed by version, so a verdict from an edited policy is judged by what the version behind it read, not by what the current one reads.
Changes
server/policy/factgroups.go: reads the metadata groups a CEL or Rego policy depends on, falling back to all groups when a reference cannot be resolved.server/policy:EvaluatorreportsFactGroups(), collected at compile time and carried through the registry.RegisterPolicyVersiontakes the groups and writes them with the version in one transaction, into a newpolicy_fact_dependenciestable.SupersedePolicyEvaluationstakes the fact group that changed and scopes the update to the policies reading it.scan; signature verifications and the signed flagsignature; identity claimsidentity.Testing
Unit tests cover dependency extraction for both engines, the conservative fallbacks, registration, and the scoping — including that each writer reaches its own group, that a policy reading nothing or another group keeps its verdict, that an unrecorded policy is always superseded, and that dependencies follow the version the verdict came from.
Mutation-checked: removing either arm of the predicate, or making a writer name the wrong group, fails tests.