Skip to content

test(dir): check that a node serves a record only once its policy passes it - #2267

Merged
muscariello merged 1 commit into
feat/policy-evaluator-validatorsfrom
feat/policy-e2e
Oct 2, 2026
Merged

muscariello merged 1 commit into
feat/policy-evaluator-validatorsfrom
feat/policy-e2e

Conversation

@muscariello

Copy link
Copy Markdown
Member

Closes #2244. Part of #2205. Stacked on #2266: main ← #2226 ← #2229 ← #2235 ← #2237 ← #2238 ← #2241 ← #2246 ← #2248 ← #2249 ← #2253 ← #2266 ← this. Based on feat/policy-evaluator-validators; retargets as the PRs below it merge.

What this adds

The last piece of #2205: an end-to-end test of the whole path. A node that enforces a content policy must withhold a record until the reconciler has evaluated it, serve it once the policy passes it, and keep it from callers when the policy rejects it. Until #2266 no node could produce a verdict, so none of this could run.

A new suite, tests/e2e/policy, with a daemon environment of its own (no cluster). It is not a second environment of the daemon suite: a node that enforces withholds every record until it is evaluated, so the daemon suite's specs, which push a record and read it straight back, could not run on it.

The environment defines a CEL policy, cel:has-description (a record needs a description), enforces it on search and fetch, and runs the indexer and the policy task every 5s with the server following the policy registry every 2s.

Specs, in order:

  1. A record is withheld until it has been evaluated. Just pushed, a record the policy would pass is refused by pull and lookup with PermissionDenied.
  2. It is served once the policy passes it. Pull, lookup and search return it after the reconciler's verdict.
  3. A record the policy rejects stays out of reach. Pull and lookup refuse it and search leaves it out, through another round of the reconciler.
  4. A CID that was never pushed gets the same refusal. An enforcing node checks its policy before it looks in the store, so the refusal does not reveal which CIDs it holds.

Every refusal is checked to say the record is not available under the node's content policy, and not to name the policy. The first spec waits for the policy to be enforced by pushing a record it rejects and waiting for it to be refused: a policy is enforced once the reconciler has registered it and its verdicts cover the records, and until then the node serves as it did.

The suite is registered in tests/Taskfile.yml (task e2e:test:policy:default) and in the E2E CI matrix, and described in the E2E README.

Scope

#2244 asked for the scenario with records received from a peer. The indexer adds a pushed record and a record copied in by registry sync the same way, with no verdict, so this covers what a synced record goes through after the copy; the copy itself (regsync) is not touched by the gate. A two-node version would exercise regsync, not enforcement, and needs Helm/kind changes to enforce a policy on the receiving node.

Testing

  • Run locally against a daemon built from this branch: all four specs pass, in about 17 seconds.
  • The suite fails when it should, against two daemons with a real regression each: with the policy inverted (a record it must reject is served), BeforeAll times out reporting that a rejected record was never refused; with the policy gate removed from Lookup only, the first spec fails at the Lookup assertion while pull is still gated.
  • Task parses the suite and resolves its environment (task e2e:list, a dry run of e2e:testenv:policy:default:up). tests vets clean.

@muscariello
muscariello requested a review from a team as a code owner October 2, 2026 07:23
@github-actions

github-actions Bot commented Oct 2, 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 2, 2026, 12:59 PM

@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Oct 2, 2026
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

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ses it

A node that enforces a content policy must withhold a record until the
reconciler has evaluated it, serve it once the policy passes it, and keep
it from callers when the policy rejects it. Nothing tested that across
the indexer, the policy task and the read gate together.

This adds a suite, policy, with a daemon environment of its own. A node
that enforces withholds every record until it is evaluated, so the daemon
suite's specs, which read back what they push, could not run on it. The
environment defines a CEL policy, cel:has-description, enforces it on
search and fetch, and runs the indexer and the policy task every 5s.

The specs: a record just pushed is refused with PermissionDenied, though
the policy would pass it; once evaluated it is served by pull, lookup and
search; a record the policy rejects stays refused, and out of search,
through another round of the reconciler; a refusal names no policy; and a
CID that was never pushed is refused the same way, so an enforcing node
does not say which CIDs it holds. The first spec waits for the policy to
be enforced by pushing a record it rejects and waiting for it to be
refused.

The indexer adds a pushed record and a record copied in by registry sync
the same way, with no verdict, so this covers what a synced record goes
through after the copy. The copy itself is not touched by the gate.

Closes #2244. Refs #2205

Signed-off-by: Luca Muscariello <[email protected]>
@muscariello
muscariello added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit 63bcb7d Oct 2, 2026
58 of 64 checks passed
@muscariello
muscariello deleted the feat/policy-e2e branch October 2, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test that records received through sync stay hidden until evaluated

2 participants