Skip to main content

PermissionGate

Struct PermissionGate 

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

The permission gate: a session’s standing authority plus the classifier and the durable approval ledger. Pure and synchronous so it can be embedded anywhere; the engine wraps it for its async pipeline.

Implementations§

Source§

impl PermissionGate

Source

pub fn new(granted: PermissionTier) -> PermissionGate

A gate with the given standing tier, default classifier, mandatory approval at FullAccess, and an in-memory ledger.

Source

pub fn with_classifier(self, classifier: RiskClassifier) -> PermissionGate

Source

pub fn with_ledger(self, ledger: ApprovalLedger) -> PermissionGate

Source

pub fn with_mandatory_approval_at(self, tier: PermissionTier) -> PermissionGate

Override the tier at and above which approval is mandatory.

Source

pub fn granted_tier(&self) -> PermissionTier

Source

pub fn set_granted_tier(&mut self, tier: PermissionTier)

Source

pub fn classifier(&self) -> &RiskClassifier

Source

pub fn ledger(&self) -> &ApprovalLedger

Source

pub fn evaluate(&self, action: &Action) -> GateDecision

Evaluate an action. Precedence:

  1. A prior rejection denies (a human said no).
  2. A prior approval allows (a human elevated this operation).
  3. Actions at/above the mandatory-approval tier need approval.
  4. Otherwise the granted tier must cover the required tier.
  5. Exceeding standing authority escalates to a human, not a hard deny — autonomy is suspended, not the task abandoned.
Source

pub fn evaluate_against( &self, action: &Action, ledger: &ApprovalLedger, ) -> GateDecision

Self::evaluate, but consulting an external ledger instead of the gate’s own. For deployments that share ONE approval ledger across many per-session gates (per-session tier, shared approvals): the daemon keeps a single journal-backed ledger on its server state so an approval recorded on one connection is visible to every other and survives restart — a per-connection in-memory ledger would strand the approver’s decision where the runner never reads it.

Source

pub fn evaluate_with_ceiling( &self, action: &Action, ceiling: Option<PermissionTier>, ) -> GateDecision

Evaluate an action as if the session’s standing authority were capped at ceiling — the join between skill-trust governance (arXiv 2602.12430) and the action-level gate. The effective authority is min(granted, ceiling), so an action driven by a skill whose deployment ceiling is read_only cannot perform a sandbox_edit operation even in a full_access session; it escalates to a human instead. A None ceiling is identical to Self::evaluate.

The caller supplies the ceiling — it is the persisted SkillMeta::deployment_tier of the skill that drove the action, which the caller already knows (it retrieved the skill). The gate does not invent action→skill provenance; it honours the ceiling it is handed.

Source

pub fn evaluate_with_ceiling_against( &self, action: &Action, ceiling: Option<PermissionTier>, ledger: &ApprovalLedger, ) -> GateDecision

Self::evaluate_with_ceiling against an external ledger — see Self::evaluate_against for when a shared ledger is the substrate.

Source

pub fn evaluate_axes( &self, action: &Action, ceiling: Option<PermissionTier>, ledger: Option<&ApprovalLedger>, ) -> ActionAxes

Both authorization axes for one action, flattening its parameters once.

Every caller that records a PermissionDecision needs both: the gate’s verdict (may this run?) and the rollback contract (could it be taken back?). Computed separately they each call action_text, which walks every nested string in Action::parameters into a String and then allocates a lowercase copy — twice, per action, on the execution path, for payloads that can be a whole document or diff. Parslee-ai/car#856.

ceiling caps standing authority the way Self::evaluate_with_ceiling does; ledger selects an external approval ledger the way Self::evaluate_against does, or None to use the gate’s own.

The two fields answer independent questions and neither is derived from the other — see classify_reversibility. They travel together here only because they read the same text.

Source

pub fn approve( &mut self, action: &Action, reviewer: &str, reason: &str, evidence: Option<String>, ) -> Result<ApprovalRecord, Error>

Record a human approval for the operation action represents. Errs when the ledger journal write fails (the decision is then NOT recorded — see ApprovalLedger::record).

Source

pub fn reject( &mut self, action: &Action, reviewer: &str, reason: &str, evidence: Option<String>, ) -> Result<ApprovalRecord, Error>

Record a human rejection for the operation action represents. Errs when the ledger journal write fails (the decision is then NOT recorded — see ApprovalLedger::record).

Source

pub fn record_for_fingerprint( &mut self, fingerprint: &str, required_tier: PermissionTier, decision: ApprovalDecision, reviewer: &str, reason: &str, evidence: Option<String>, ) -> Result<ApprovalRecord, Error>

Record a decision against an explicit fingerprint (when the caller holds the fingerprint from a prior NeedsApproval, not the action). Errs when the ledger journal write fails (the decision is then NOT recorded — see ApprovalLedger::record).

Source

pub fn decision_record( &self, action: &Action, decision: ApprovalDecision, reviewer: &str, reason: &str, evidence: Option<String>, ) -> ApprovalRecord

Build (but do NOT store) the ApprovalRecord for a decision on action — the gate classifies the action and derives its fingerprint; the caller records the result on whichever ledger is the substrate (its own via ApprovalLedger::record, or a shared daemon ledger). This is what lets a per-session gate keep its tier/classifier while the approval store is shared.

Trait Implementations§

Source§

impl Debug for PermissionGate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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