pub struct Gate { /* private fields */ }Expand description
A pure decision gate over an ordered list of checks.
Implementations§
Source§impl Gate
impl Gate
Sourcepub fn builder() -> GateBuilder
pub fn builder() -> GateBuilder
Start building a gate.
Sourcepub fn evaluate(&self, ctx: &ActionContext) -> Decision
pub fn evaluate(&self, ctx: &ActionContext) -> Decision
Evaluate ctx against the checks in order, under the gate’s Mode.
In Mode::Open (the default) the first check to return Some wins;
if none does, the gate allows. Mode::Closed is documented on the
variant.
Sourcepub fn evaluate_exhaustive(&self, ctx: &ActionContext) -> Evaluation
pub fn evaluate_exhaustive(&self, ctx: &ActionContext) -> Evaluation
Evaluate ctx and also collect every deny (spec 004 B-8).
Every check runs exactly once, including those after the deciding one, so a
consumer that reports all of its reasons can read them in registration
order. The decision is the one Gate::evaluate returns.
Sourcepub fn required_ids(&self) -> Vec<&str>
pub fn required_ids(&self) -> Vec<&str>
The required check ids, sorted. Empty for an open gate.
Sourcepub fn unregistered_required(&self) -> Vec<&str>
pub fn unregistered_required(&self) -> Vec<&str>
The required ids that name no registered check, sorted. A closed gate
with any denies every action (closed::REQUIRED_UNREGISTERED); a
consumer can call this at startup to refuse the configuration early.
Sourcepub fn config_hash(&self) -> String
pub fn config_hash(&self) -> String
A stable sha256:<hex> hash of the gate’s configuration.
In Mode::Open it is taken over the canonical JSON array of each
check’s config_fingerprint, in order,
exactly as in 0.1.0 and 0.2.0, so a recorded hash does not move. In
Mode::Closed it is taken over the canonical JSON object
{"checks": [...], "mode": "closed", "required": [...]} with the
required ids sorted. An object never serializes like an array, so a
closed gate never hashes the same as an open one.
Record this in a ledger alongside a decision to prove the decision came from exactly this gate configuration. Because it is order-sensitive and folds in each check’s parameters, a reordered or reconfigured gate hashes differently.