keelgate.policy¶
Stability of each symbol (stable or provisional) is listed in the API contract. Narrative and semantics are in the integration contract.
Policy-as-code decision point. Deterministic gate in front of every WRITE.
Decision
¶
Bases: StrEnum
What a policy engine decides: ALLOW, DENY or REQUIRE_APPROVAL.
OpaHttpEngine
¶
Policy engine that asks an OPA server over HTTP (the production default).
Fails closed: any error, timeout or malformed answer is a DENY.
PolicyAction
¶
Bases: BaseModel
The proposed action a policy judges: the tool, its side effect and capability, and its arguments.
PolicyActor
¶
Bases: BaseModel
Who is acting, as verified from the grant: the agent, the tenant and the grant id.
PolicyContext
¶
Bases: BaseModel
Trusted facts about the world at as_of.
PolicyDecision
¶
Bases: BaseModel
What the policy decided, and exactly which policy decided it.
PolicyEngine
¶
Bases: Protocol
Decides ALLOW / DENY / REQUIRE_APPROVAL for one proposed action.
Implementations must be deterministic functions of policy_input and the
loaded policy. They must not consult the wall clock, the network (other than
their own decision point) or any model.
PolicyInput
¶
Bases: BaseModel
Everything a policy engine is given: the action, the actor, the resource facts derived from validated arguments, and the trusted context.
Built by Keelgate, never by the model.
to_document
¶
The JSON document handed to the engine.
as_of is rendered as UTC with an explicit +00:00 offset, the one
form both OPA and the in-process evaluator parse. NaN and infinity are
refused outright (allow_nan=False): they compare false against every
limit, which is exactly how a limit check gets bypassed.
RegoEngine
¶
Policy engine that evaluates the same Rego packs in-process.
For tests, the quickstart and single-process use; production should use OPA. Fails closed.
decide_document
async
¶
Evaluate a raw input document. Used by conformance tests and adapters.
decision_from_result
¶
Turn an engine's raw result into a decision, failing closed.
Anything that is not a well-formed {effect, reasons, approval_tier}
object with a known effect becomes a DENY. An approval requirement without a
usable tier is treated as the strictest tier rather than the loosest.
deny
¶
A fail-closed denial.
hash_sources
¶
A stable version hash over named policy sources.
Names are bare file names so the same pack hashes identically whether it is read from disk or fetched back out of a running OPA.
load_pack_sources
¶
Read a pack's .rego sources, excluding *_test.rego.
pack_path
¶
Locate a shipped policy pack.
Installed wheels carry packs under keelgate/policy/packs; a source
checkout keeps them in policies/ at the repository root.