Skip to main content

Gate

Struct Gate 

Source
pub struct Gate { /* private fields */ }
Expand description

The leash enforcer. One gate backs a session (or a sub-delegation); it tracks the remaining call budget and the generation it is valid for.

The gate is interior-mutable on its budget (an AtomicU64) so authorize takes &self — a registry can hold one shared gate behind an Arc.

Implementations§

Source§

impl Gate

Source

pub fn new(generation: u64) -> Gate

A gate at generation, with no independent budget cap of its own (the grant’s max_calls still applies on the first authorize) and the honest P0 sandbox kind (SandboxKind::None).

Source

pub fn with_budget(generation: u64, max_calls: CountBound) -> Gate

A gate whose call budget is seeded from a CountBound — typically the max_calls of the session grant — so the budget persists across multiple authorize calls on this gate. Unlimited ⇒ no cap.

Source

pub fn with_sandbox(self, sandbox: &dyn Sandbox) -> Gate

Record the OS-level sandbox this gate’s contexts run under. A tool reads it back via ToolContext::sandbox_kind. (P3 wires a real Sandbox.)

Source

pub fn with_strength_floor(self, floor: AxisEnforcement) -> Gate

Set the required fence-strength floor for every context this gate mints (ADR 0012 D3) — the weakest per-axis enforcement the principal accepts before a confinement site refuses to spawn. A strong principal raises it to AxisEnforcement::Kernel (fail closed on any restricted axis the real backend cannot kernel-confine); the default is the permissive AxisEnforcement::Advisory. The floor only ever raises on delegation (it cannot be lowered from inside a running tool — it has no setter on the minted ToolContext).

Source

pub fn generation(&self) -> u64

The generation this gate embodies.

Source

pub fn authorize( &self, tool: &dyn Tool, granted: &Caveats, ) -> Result<ToolContext, ToolError>

The only path to a ToolContext.

See the module docs for the four enforcement steps. Order matters: we deny on authority/generation before charging the budget, so a denied request does not consume a call.

Source§

impl Gate

Step-up admission (human-presence capabilities) — see [crate::step_up].

Gate::evaluate is the pure entry point; when a step-up is owed it returns Decision::NeedsDischarge without minting or charging. The caller obtains a proof and re-presents it to Gate::authorize_with_discharge. The gate only ever verifies a proof — it never performs the gesture (that is a host capability, a sibling of Sandbox).

Source

pub fn evaluate( &self, tool: &dyn Tool, granted: &Caveats, request: &CallRequest, policy: &StepUpPolicy, ) -> Decision

Evaluate a call under a StepUpPolicy without performing any gesture.

Decision::Allow (minted and charged) when no step-up is owed, Decision::NeedsDischarge (nothing minted or charged) when one is, and Decision::Deny on a generation or budget failure.

Source

pub fn authorize_with_discharge( &self, tool: &dyn Tool, granted: &Caveats, request: &CallRequest, policy: &StepUpPolicy, attempt: &DischargeAttempt<'_>, ) -> Result<(ToolContext, Option<Attestation>), ToolError>

Admit a call that owes a step-up by verifying a [Discharge].

Recomputes the bound Challenge from request, the gate’s generation, and nonce, then asks verifier to check the proof. On success mints the context (least authority, exactly as Gate::authorize) and — when the policy demanded a record — returns a content-addressed Attestation. Ordering matches authorize: deny on generation or verification before charging, so a rejected discharge consumes no call. With no step-up owed this degenerates to an ordinary authorize.

Source

pub fn authorize_step_up( &self, tool: &dyn Tool, granted: &Caveats, request: &CallRequest, policy: &StepUpPolicy, provider: &dyn DischargeProvider, verifier: &dyn DischargeVerifier, nonce: [u8; 32], ) -> Result<(ToolContext, Option<Attestation>), ToolError>

Orchestrate the whole step-up sequence — evaluate, run the host ceremony, and authorize — so a host needs one call for the gated path.

Computes the requirement for request; if no gesture is owed this degenerates to an ordinary Gate::authorize (with None for the attestation). Otherwise it runs the host’s provider ceremony, supplying the gate’s generation and the caller’s single-use nonce, then forwards the produced proof to Gate::authorize_with_discharge — reusing that single verified mint path (this adds no second mint site).

Fail-closed: a provider error (the human declined, no authenticator, a transport failure) returns ToolError::denied and mints/charges nothing. The gate still verifies the proof itself via verifier (the presence floor and the challenge binding); the provider is never trusted to self-attest (ADR 0007 D5), so a verifier that rejects a too-weak or mismatched proof still denies even when the provider returned Ok.

Auto Trait Implementations§

§

impl !Freeze for Gate

§

impl RefUnwindSafe for Gate

§

impl Send for Gate

§

impl Sync for Gate

§

impl Unpin for Gate

§

impl UnsafeUnpin for Gate

§

impl UnwindSafe for Gate

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<F, T> ConvertInto<T> for F
where T: ConvertFrom<F>,

Source§

fn convert_into(self) -> T

Infallibly converts a value of type Self to a value of type T.
Source§

impl<F, T> ConvertTryFrom<F> for T
where F: ConvertInto<T>,

Source§

type Error = !

The type of an error that can occur during a conversion. Read more
Source§

fn convert_try_from(value: F) -> Result<T, !>

Fallibly converts a value of type F to a value of type Self.
Source§

impl<F, T> ConvertTryInto<T> for F
where T: ConvertTryFrom<F>,

Source§

type Error = <T as ConvertTryFrom<F>>::Error

The type of an error that can occur during a conversion. Read more
Source§

fn convert_try_into(self) -> Result<T, <T as ConvertTryFrom<F>>::Error>

Fallibly converts a value of type Self to a value of type T.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more