Skip to main content

Crate action_gate_core

Crate action_gate_core 

Source
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).

§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.

Structs§

ActionContext
Everything a Check needs to make its decision about a proposed action.
Decision
The result a Check returns and the Gate yields.
Gate
A pure decision gate over an ordered list of checks.
GateBuilder
Builds a Gate by registering checks in evaluation order.

Enums§

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’s preserve_order state.
sha256_hex
sha256:<hex> over bytes. The sha256: prefix keeps the hash self-describing, matching the ledger primitive in attest-ledger.