Skip to content

refactor(server): split policy config into evaluations and operations - #2354

Merged
muscariello merged 1 commit into
mainfrom
feat/policy-config-split
Oct 14, 2026
Merged

muscariello merged 1 commit into
mainfrom
feat/policy-config-split

Conversation

@tkircsi

@tkircsi tkircsi commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Content policies lived in one list distinguished only by op, whose four values were three points in a record's lifecycle and "evaluate", which is not one. That conflation made an evaluation policy look like an operation, and it is upstream of most of what makes the model hard to explain: an evaluation policy has no op and no mode because it never acts, while an operation policy has both and no scheduling.

They are now two blocks, each carrying only the fields that apply to it. config: is gone with them, since splitting by kind leaves each block's settings mostly common; a setting belonging to another provider is now rejected rather than silently ignored.

No semantics change: the same policies run at the same points with the same results.

policy.enforcement stays as a third block, which is one more than the two kinds this change describes. It survives because it is still the only thing driving the read gate: the search mode injects SQL into the index query, and the fetch mode runs a separate count for a record read by CID. Neither read is expressed as an operation policy yet, so dropping the block now would remove the gate with nothing in its place. It is retired once pull and search are operation policies, at which point the IDs it lists become a condition inside such a policy and its two modes become that policy's mode.

Mode moves to the validators config package, with policyconfig.Mode an alias for it, so the read gate and an operation policy cannot drift into meaning different things by the same word. All three values parse; only enforce is acted on until the operation write path lands.

OPA's name still defaults to the file name without .rego, and oasf can no longer appear as an evaluation, because a verdict is stored against hashed policy content and a schema behind an HTTP endpoint has none.

Refs #2340

@tkircsi
tkircsi requested a review from a team as a code owner October 13, 2026 14:33
@tkircsi tkircsi self-assigned this Oct 13, 2026
@tkircsi tkircsi linked an issue Oct 13, 2026 that may be closed by this pull request
2 tasks done
@github-actions github-actions Bot added the size/L Denotes a PR that changes 1000-1999 lines label Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

The latest Buf updates on your PR. Results from workflow Buf CI / verify-proto (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped⏩ skipped✅ passedOct 14, 2026, 1:26 PM

@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.79592% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
server/policy/config/config.go 22.2% 7 Missing ⚠️
server/validators/registry.go 78.3% 5 Missing ⚠️
reconciler/dryrun/candidate.go 75.0% 1 Missing ⚠️
reconciler/main.go 0.0% 1 Missing ⚠️
server/validators/config/config.go 99.1% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tkircsi
tkircsi force-pushed the feat/policy-config-split branch from 542d1e7 to 4ee0c9e Compare October 13, 2026 14:58
@github-actions github-actions Bot added size/XL Denotes a PR that changes 2000+ lines and removed size/L Denotes a PR that changes 1000-1999 lines labels Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR exceeds the recommended size of 2000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note that this PR might take longer to review due to large size.

@tkircsi
tkircsi changed the base branch from main to feat/typed-cel-env October 13, 2026 14:58
@github-actions github-actions Bot added size/L Denotes a PR that changes 1000-1999 lines and removed size/XL Denotes a PR that changes 2000+ lines labels Oct 13, 2026
@tkircsi
tkircsi force-pushed the feat/policy-config-split branch from 4ee0c9e to 485def6 Compare October 13, 2026 15:01
ramizpolic
ramizpolic previously approved these changes Oct 13, 2026
expressions []string
}

func validateProviderFields(where, provider string, f providerFields) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thought, since this is the config people will start using: each provider's settings are top-level fields, and this switch only knows oasf/opa/cel. Adding a provider later means changing this struct and this function. Would a block per provider work (cel: {expressions: ...}, opa: {file: ...}), or letting each provider check its own settings? You'd still get the "doesn't apply to this provider" error. Not a blocker, it's just easier to change now than after a release.

muscariello
muscariello previously approved these changes Oct 14, 2026

@muscariello muscariello left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved as part of the stack, with one request before this reaches a release.

mode on an operation policy is read from the config but never used. Setting mode: off or mode: shadow is accepted, and the policy still rejects records exactly as in enforce. I checked with a push policy that rejects everything: it refused the record in all four cases (no mode, enforce, shadow, off). Someone who sets off to switch a policy off would get it enforced. Please make the config reject off and shadow for operation policies until they are implemented. Nothing is released yet, so this costs nothing.

Also, operation policies now need a name. Before, only evaluation policies did. The description says there is no behaviour change, so it's worth mentioning there.

@muscariello
muscariello force-pushed the feat/policy-config-split branch 2 times, most recently from 19f018c to 9149c61 Compare October 14, 2026 11:04
Base automatically changed from feat/typed-cel-env to main October 14, 2026 12:52
@github-actions github-actions Bot added size/XL Denotes a PR that changes 2000+ lines and removed size/L Denotes a PR that changes 1000-1999 lines labels Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR exceeds the recommended size of 2000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note that this PR might take longer to review due to large size.

@github-actions github-actions Bot added size/L Denotes a PR that changes 1000-1999 lines and removed size/XL Denotes a PR that changes 2000+ lines labels Oct 14, 2026
@lgecse
lgecse force-pushed the feat/policy-config-split branch from f983bd6 to bbb3e78 Compare October 14, 2026 13:25

@muscariello muscariello left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@muscariello
muscariello added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit e87b873 Oct 14, 2026
36 of 38 checks passed
@muscariello
muscariello deleted the feat/policy-config-split branch October 14, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 1000-1999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Split policy config into evaluations and operations

5 participants