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
impl PermissionGate
Sourcepub fn evaluate(agent: &AgentConfig, tool: &str, args: &Value) -> Decision
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.
Sourcepub fn evaluate_in_root(
agent: &AgentConfig,
tool: &str,
args: &Value,
root: Option<&Path>,
) -> Decision
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.
Sourcepub async fn resolve(&self, tool: &str, args: &Value) -> Outcome
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§
impl !RefUnwindSafe for PermissionGate
impl !UnwindSafe for PermissionGate
impl Freeze for PermissionGate
impl Send for PermissionGate
impl Sync for PermissionGate
impl Unpin for PermissionGate
impl UnsafeUnpin for PermissionGate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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