Skip to main content

PermissionGate

Struct PermissionGate 

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

One agent’s permission gate — the object the agent loop holds.

What: consulted in every harness mode. #7948: HarnessMode::Parity is not exempt — a deny the operator wrote holds there too; the tool SCHEMAS a parity run advertises are unchanged by the gate. Test: deny_never_dispatches.

Implementations§

Source§

impl PermissionGate

Source

pub fn evaluate(agent: &AgentConfig, tool: &str, args: &Value) -> Decision

Evaluate one tool call against agent’s configuration — the pure half.

Why: an associated function so precedence is testable with a config and a JSON value alone. What: the LEGACY tcode_tools allowlist runs FIRST — a tool absent from it is denied before the map is consulted, so a map cannot widen an allowlist. #7948: a tool in HARNESS_REGISTERED_TOOLS skips that branch, because the harness — not the agent’s author — put it in the registry. Then the map decides over every subject of the call; an unmatched call is Allow. Test: legacy_allowlist_denial_precedes_the_map, legacy_allowlist_absent_means_every_tool, unmatched_tool_is_allowed, deny_rule_produces_deny, ask_rule_produces_ask, harness_registered_tool_bypasses_the_legacy_allowlist, stock_pm_agent_may_call_delegate_to_agent, explicit_deny_beats_the_harness_registered_exemption.

Source

pub fn evaluate_in_root( agent: &AgentConfig, tool: &str, args: &Value, root: Option<&Path>, ) -> Decision

PermissionGate::evaluate with the run’s working root supplied.

Why (#7948): a path rule an operator wrote relative must also decide the absolute in-root spelling of the same file — see subjects_for_in_root. What: identical to PermissionGate::evaluate but for the extra root-relative subject, which evaluate_call’s safest-wins fold can only use to restrict. Test: absolute_in_root_path_meets_a_relative_deny, path_deny_holds_for_the_absolute_in_root_spelling.

Source

pub async fn resolve(&self, tool: &str, args: &Value) -> Outcome

Decide one tool call, prompting and waiting when the map says ask.

Why: the single call the agent loop makes; the caller must not dispatch on Outcome::Denied. What: evaluate runs; Allow/Deny return at once. Ask checks this session’s remembered grants, then AllowAsks — both auto-allow paths record the approval — then, only with an answering channel AND a client watching the session (#8100), emits PermissionRequested, awaits an answer for ctx.timeout, and emits PermissionResolved. Missing either is Denied { source: Headless }, returned at once rather than after DEFAULT_ASK_TIMEOUT_SECS.

Test: headless_ask_is_denied, allow_asks_mode_permits_an_ask, ask_without_an_attached_prompter_denies_immediately, an_ask_on_an_unwatched_session_is_headless_while_a_sibling_is_watched, an_ask_with_no_event_sink_is_headless, allow_asks_mode_emits_an_audit_event, timed_out_ask_is_denied, client_deny_is_denied, ask_emits_requested_then_resolved, allow_for_session_is_remembered_for_a_later_matching_call, remembered_grant_emits_a_resolution_event.

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<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<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
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> 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<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