Skip to main content

Module policy_push

Module policy_push 

Source
Expand description

Console-pushed policy bundles.

The daemon never calls the console. pvctl console-sync --watch --pull-policies, running on the same host, pulls the org’s policy bundle (GET /api/v1/ingest/policies) and writes it atomically to the file named by policy_bundle_file. The daemon loads that file at boot and polls it for changes; each new bundle is compiled into pv_sandbox::PushedRules plus token-rate rules and swapped in whole. After every attempt the daemon writes its own answer next to the bundle (<policy_bundle_file>.status.json): the etag it applied, the policy ids it now enforces and the ones it could not enforce, with a reason. pvctl reports that file to the console, so the console’s “Enforced by N of M daemons” reflects what daemons actually run, not what was sent to them.

Pushed rules only add restrictions (see pv_sandbox::pushed). A bundle that cannot be read or parsed leaves the rules already in force unchanged — at boot that means the daemon refuses to start, because running without rules the operator expects to be there would fail open.

Kinds: budget, allowlist, schema (tool calls) and rate (per-principal token velocity on model traffic) are enforced. guardrail and transform policies document intent and attribute the daemon’s own guard hits; the daemon neither enforces nor reports them. Anything else is reported unsupported.

Structs§

BundlePolicy
One policy entry of the console bundle (contract: server/src/lib/ policy-bundle.ts).
CompiledBundle
A compiled bundle, ready to swap in.
PolicyBundle
The console bundle file.
PolicyPush
Applies bundle files to a running daemon.
PolicyStatus
The daemon’s own answer for the last bundle it processed; the body pvctl posts to POST /api/v1/ingest/policy-status.
RateLimits
Per-principal token-rate limits from the pushed bundle.
RateRefusal
A request a token-rate rule refused: which console policy, and the message the client and the audit event carry.
RateRule
One per-principal token-rate rule.
Unsupported
One policy the daemon could not enforce.

Functions§

compile
Compile a bundle. Never fails as a whole: a policy the daemon cannot enforce is listed in unsupported and the rest still apply.
read_bundle
Read and parse the bundle file. Ok(None) when it does not exist yet (nothing was ever pushed).
status_path
Path of the status file the daemon writes next to the bundle file.