Skip to content

feat(server): apply operation policy modes, pass the peer, log decisions - #2425

Merged
tkircsi merged 3 commits into
mainfrom
feat/operation-decisions
Oct 28, 2026
Merged

tkircsi merged 3 commits into
mainfrom
feat/operation-decisions

Conversation

@tkircsi

@tkircsi tkircsi commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Second of the two-layer content-policy PRs, on top of #2419. Closes #2344, refs #2128.

#2419 gave operation policies an input to read. This makes the three things that input was for actually work.

Modes are applied per policy. Operation.Mode shipped in v1.8.0 as configuration nothing read. It is now resolved at load time and applied in Decide: off does not run the policy, shadow runs it and logs the decision without refusing the record, enforce refuses it. An unset mode enforces — no shipped configuration sets mode:, so the alternative would have silently disabled OASF schema validation in the Helm values, daemon config and e2e suite. Per policy, so one can be introduced in shadow while the rest keep enforcing.

The peer reaches the policy. Decide takes ...DecideOption, and autosync passes policy.FromPeer(peerID.String()) to populate context.source_peer_id. An option rather than a parameter because one of four callers has one. This is not an authorization input: the allow-set is matched against the authenticated peer.ID in MaybeEnqueue long before a validator runs, so this only buys per-peer rules.

Decisions are logged. Each policy that runs writes one line under the policy component, carrying operation, cid, policy_id, mode, decision, reason, and peer or caller. Emitted inside Decide rather than by its callers, because a shadow policy's decision is dropped there and never returned — the log is the whole of what shadow mode produces. decision is what the policy decided and mode is what was done about it, so decision=refuse mode=shadow reads as a record that was accepted. Refusals at INFO, accepted records at DEBUG. Only the CID is logged, never the record. The dir_policy_gate_* counters are untouched; they aggregate over the evaluation layer.

Not included: the issue asks the log to carry the verdict keys read. verdicts is declared in neither the CEL environment nor the Rego document, since reaching one needs a database read this path does not have, so the field would be empty on every line. It belongs in the PR that makes the read gate a pull/search policy.

@tkircsi
tkircsi requested a review from a team as a code owner October 28, 2026 07:10
@tkircsi tkircsi self-assigned this Oct 28, 2026
@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Oct 28, 2026
@tkircsi tkircsi added kind/feature Categorizes issue or PR as related to a new feature. area/dir/server and removed size/M Denotes a PR that changes 200-999 lines labels Oct 28, 2026
@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Oct 28, 2026
Signed-off-by: Tibor Kircsi <[email protected]>

# Conflicts:
#	server/policy/policies_test.go
@tkircsi
tkircsi added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit e0fdc7b Oct 28, 2026
37 checks passed
@tkircsi
tkircsi deleted the feat/operation-decisions branch October 28, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dir/server kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Operation policies at push, autosync and index, with decision logging

2 participants