How request-scoped facts and EvaluationSession work
mainGatehouse uses EvaluationSession to manage the lifecycle of facts during an authorization pass. When a policy requires external data (facts), the FactSource::load_many method is called to fetch them.
Key behaviors of EvaluationSession:
- Caching: Results are cached for the duration of a single request/session to prevent redundant loads.
- Deduplication & Ordering: It expands duplicate caller inputs and preserves the original caller order.
- Batching: It chunks loads according to the
FactSource::max_batch_sizeto optimize backend calls. - Concurrency: It joins concurrent in-flight loads for the same key.
FactSource Contract:
FactSource::load_many must receive unique keys and return exactly one result per key in the same order as requested.
Policy Behavior:
RebacPolicy is the built-in fact-backed policy. Decisions follow these rules:
Found(false)andMissingresult in an abstention.- Missing sources, backend errors, or contract violations produce indeterminate decisions.