Expand description
Ordinary Rust gates and resource policies with inspectable decision evidence.
Start with a named boolean check; use () for a permit/deny outcome.
use gatekeep::{Fact, StaticFactId, KnownFacts, condition, policy, evaluate};
struct Owner;
impl Fact for Owner { const ID: StaticFactId = StaticFactId::new("record.owner"); }
let policy = policy::grant_clause((), condition::has::<Owner>()).into_policy();
let facts = KnownFacts::new().with_bool::<Owner>(true);
assert!(evaluate(&policy, &facts).is_permit());PreparedPolicy and Authorizer add checked resolution and required
audit persistence. ResourcePolicy groups typed application operations.
Graded outcomes, partial evaluation and explicit SQL mappings are optional
next steps. Applications own authentication, transactions and disclosure.
Guides and the record service show these boundaries in use.
Modules§
Structs§
- Application
Verified Tenant Binding - An application-verified tenant binding with an explicit validity window.
- Audit
Entry - Durable audit payload for a decision.
- Authorization
Attempt - Separate durable event for an authorization attempt that produced no decision.
- Authorization
Decision - A completed authorization decision and its audit occurrence.
- Authorizer
- Framework-independent resolution, evaluation and required audit boundary.
- Batch
Decisions - Ordered results retaining decisions and per-item failures, including denials.
- Binding
Provenance - Bounded application-supplied provenance for a tenant or resolver binding.
- Clause
Label - Owned gatekeep identifier.
- Context
- Request-scoped data passed to adapter boundaries.
- Decision
- Structured policy decision with obligations and a typed trace.
- Decision
Audit Id - Owned gatekeep identifier.
- Decision
Audit Occurrence - The stable identity and authoritative occurrence time for one decision.
- Decision
Summary - Monomorphic observer payload for a decision.
- Decision
Trace - Typed trace produced by pure evaluation.
- Denial
Reason - Stable denial reason emitted by the core.
- Evidence
Digest - Fixed-size digest carried as evidence without retaining raw claims or tokens.
- FactId
- Owned gatekeep identifier.
- Fact
Observation - A selected boolean observation and bounded source metadata, never a domain object.
- Fact
Resolution - One atomic result from a fact resolver.
- Fact
Resolution Evidence - Bounded evidence for the complete resolved fact set used by one decision.
- Fact
Resolution Metadata - Resolver metadata supplied by an application for one fact-set observation.
- Identity
Reason Catalog - Reason catalog that renders the stable reason code.
- Known
Facts - Fact bundle accepted by full evaluation.
- Legacy
Audit Entry - Historical audit shape used only by an explicit migration decoder.
- Legacy
Policy Anchor - Policy anchor shape retained for explicit migration of pre-4.0 audit data.
- Locale
- Language or locale tag used by human-facing reason text.
- Lowered
- Backend filter and grade projection produced by query lowering.
- Noop
Audit Sink - Audit sink that discards entries.
- Noop
Policy Observer - Observer that discards decision summaries.
- Obligation
Id - Owned gatekeep identifier.
- Param
Key - Owned gatekeep identifier.
- Partial
Facts - Fact bundle accepted by partial evaluation.
- Pending
Decision - An evaluated decision awaiting required persistence, not an authorization token.
- Policy
Anchor - Stable policy identity recorded with summaries and audit entries.
- Policy
Hash - Owned gatekeep identifier.
- Policy
Id - Owned gatekeep identifier.
- Policy
Inspection - Borrowed metadata inventory for tooling and reason-catalog checks.
- Prepared
Policy - Immutable policy with its versioned identity and required facts computed once.
- Reason
Code - Owned gatekeep identifier.
- Request
Id - Owned gatekeep identifier.
- Static
Clause Label - Static gatekeep identifier.
- Static
Fact Id - Static gatekeep identifier.
- Static
Obligation Id - Static gatekeep identifier.
- Static
Param Key - Static gatekeep identifier.
- Static
Reason Code - Static gatekeep identifier.
- Static
Request Id - Static gatekeep identifier.
- Static
Subject Slot - Static gatekeep identifier.
- Static
Tenant Id - Static gatekeep identifier.
- Subject
Ref - Application-owned subject reference.
- Subject
Slot - Owned gatekeep identifier.
- System
Clock - Clock implementation that reads the system UTC wall clock.
- Tenant
Binding Evidence - Bounded evidence for an application-verified tenant binding.
- Tenant
Id - Tenant routing identity shared with Dovecote’s 255-byte
CloudEventsvalue. - Trace
- Durable, non-generic decision trace.
- Trusted
Service Binding - A separately named binding for an explicitly trusted internal service.
Enums§
- Attempt
Authorization Error - Complete failure result when recording failed authorization attempts.
- Attempt
Failure - Failure category recorded without backend messages or untrusted request bodies.
- Attempt
Validation Error - Failure establishing a trusted attempt record.
- Audit
Construction Error - Failure while deriving a durable entry from a typed decision.
- Audit
Entry Error - Validation failure for a current durable audit entry.
- Authorization
Error - Error produced while resolving, evaluating, tracing, or auditing a decision.
- Batch
Error - Whole-batch failure before any decisions are evaluated or persisted.
- Binding
Authority - Authority metadata supplied by the application that verified a binding.
- Condition
- Boolean predicate over known or deferred facts.
- Context
Error - Error returned when a request context cannot establish a safe tenant boundary.
- Decision
Audit Occurrence Error - Validation failure for a decision occurrence crossing the SQL audit boundary.
- Decisive
Clause - Typed decisive clause.
- Deny
Shape - Disclosure shape for a denied grant.
- Effect
- Permit or deny effect produced by evaluation.
- Effect
Kind - Permit/deny effect without the generic outcome value.
- Explanation
Audience - Who may receive an explanation. Audit output contains internal fact names.
- Fact
Resolution Error - Invalid or stale freshness information in a resolver envelope.
- Fact
Resolution Evidence Error - Failure while creating bounded fact-set evidence.
- Gatekeep
Error - Validation errors returned by typed gatekeep records.
- Lower
Error - Error returned by query-lowering adapters.
- Observation
Error - Invalid selected evidence. Error messages never include source content.
- Policy
- Reified authorization policy.
- Policy
Advice - Advisory authoring issue; it does not change evaluation or invalidate a policy.
- Presence
- Presence state of a named fact.
- Reason
Value - Structured denial-reason parameter value.
- Replay
Error - Historical evidence cannot reconstruct the supplied policy’s inputs.
- Residual
- Result of partial evaluation with possibly unknown facts.
- Residual
Policy - Residual policy produced by partial evaluation.
- Residual
Policy Branch - Child branch considered by
ResidualPolicy::try_fold_pruned. - Residual
Policy Node - Fold node exposed by
ResidualPolicy::try_fold. - Resolve
Error - Error returned by fact resolution orchestration.
- Tenant
Binding - The binding authority carried by a
crate::Context. - Tenant
Binding Error - Errors returned when constructing or validating a tenant binding.
- Trace
Clause - Serialized decisive clause.
- Trace
Error - Error produced while serializing trace or reason values.
Constants§
- AUDIT_
ENTRY_ SCHEMA_ VERSION - Current durable representation version for decision audit entries.
- MAX_
FACT_ OBSERVATIONS - Maximum selected observations retained by one decision.
- MAX_
TENANT_ ID_ BYTES - Maximum UTF-8 byte length shared with Dovecote tenant routing values.
- POLICY_
HASH_ FORMAT_ VERSION - Durable encoding version used by
Policy::hash.
Traits§
- Attempt
Audit Sink - Required persistence boundary for failed attempts, separate from decisions.
- Audit
Sink - Append-only audit boundary.
- Batch
Fact Resolver - Provider-owned bulk loading. No default loop pretends to eliminate N+1 reads.
- Clock
- Application-owned source of UTC instants used at adapter boundaries.
- Fact
- Marker trait for compile-time known facts.
- Fact
Resolver - Async boundary that resolves policy facts from application-owned storage.
- Lattice
- Outcome ordering used when policies combine permissions.
- Obligation
Spec - Marker trait for compile-time known obligations.
- Observation
Facts - Explicit observations available for validating selected resolution evidence.
- Policy
Observer - Side-channel observer for decision summaries.
- Query
Fact Resolver - Optional query resolution for applications that lower policies into list filters.
- Query
Lowering - Lowers a residual policy into a backend filter and grade projection.
- Reason
Catalog - Presentation adapter for localized denial reasons.
- Resource
Policy - Application-owned operations and named checks for one resource type.
Functions§
- complete_
residual - Completes a partial-evaluation result against known facts.
- evaluate
- Evaluates a policy against known facts.
- evaluate_
residual - Evaluates a residual policy against known facts.
- partial_
evaluate - Partially evaluates a policy against present, absent, and unknown facts.
- required_
facts - Returns every fact that may be consulted by a policy.
- required_
residual_ facts - Returns every fact that may be consulted by a residual policy.
Type Aliases§
- Gatekeep
Result - Result type used by gatekeep constructors and validators.
- Trace
Value - Opaque serialized value used only for trace and audit output.