Expand description
action-gate-core: a pure, deterministic decision gate over an ordered
Check registry.
Gate::evaluate runs its checks in registration order and returns the
first check’s Some(decision), or an unconditional Decision::allow if
none triggers. It is a pure function of (context, checks): no host calls,
no clock, unit-testable, and byte-stable via decision_to_canonical_json.
Determinism depends on check ordering being stable, which the builder
guarantees (insertion order).
That is the default, Mode::Open. A gate built with
GateBuilder::closed or GateBuilder::require evaluates in
Mode::Closed instead: it denies when no check decides, and every
required check must be registered and must decide. See Mode and the
closed module for the rules and reason codes.
§Config is in the checks, not a global bundle
There is no global policy-bundle type here. Each check owns its parameters (a secrets check owns its regex set, an allowlist owns its list). The consumer assembles the gate:
use action_gate_core::{Gate, checks::{AllowlistCheck, SecretsCheck}};
use action_gate_types::ActionContext;
let gate = Gate::builder()
.check(SecretsCheck::default())
.check(AllowlistCheck::new(["email.send", "email.draft"]))
.build();
let decision = gate.evaluate(&ActionContext::new("email.send"));
assert!(decision.is_allow());§Degrade is a signal, not an action
Outcome::Degrade does not perform a degraded action. The gate returns it;
the consumer decides its meaning (route to a human, require confirmation).
The gate never touches the world.
Modules§
- closed
- The stable reason codes a
Mode::Closedgate produces itself (spec 004 B-6). A check’s own decision keeps the check’s reason. - secrets
- The secret detector registry (spec 001).
Structs§
- Action
Context - Everything a
Checkneeds to make its decision about a proposed action. - Decision
- The result a
Checkreturns and theGateyields. - Deny
ByDefault - A terminal check that denies whatever reached it (spec 001 B-14).
- Evaluation
- Everything
Gate::evaluate_exhaustivefound: the decisionGate::evaluatereturns, and every deny along the way. - Gate
- A pure decision gate over an ordered list of checks.
- Gate
Builder - Builds a
Gateby registering checks in evaluation order.
Enums§
- Mode
- How a
Gatecombines its checks’ answers (spec 004). - Outcome
- The three possible outcomes of a decision.
Traits§
- Check
- A single gate check.
Functions§
- decision_
to_ canonical_ json - Serialize a decision to canonical (key-sorted) JSON, for byte-stable hashing
and comparison. Two producers serializing the same logical decision produce
the same bytes regardless of
serde_json’spreserve_orderstate. - sha256_
hex sha256:<hex>overbytes. Thesha256:prefix keeps the hash self-describing, matching the ledger primitive inattest-ledger.