pub struct PermissionContext {
pub mode: PermissionMode,
pub timeout: Duration,
pub session_id: String,
pub ask: Option<Arc<SessionPermissions>>,
pub events: Option<Arc<dyn PermissionEvents>>,
pub root: Option<PathBuf>,
}Expand description
The session-scoped, agent-independent half of a gate’s configuration.
Why: a gate is per AGENT (its map comes from that agent’s config), while
the session, the answering channel, and the timeout are shared by every
agent in one run, so the sub-agent runner mints a gate per delegation from
one cloned context.
What: ask is None for a headless run; an ask rule then resolves
immediately per mode. #8100: ask being Some is NOT the same as a
client being attached — the daemon mints broker state for every task.run
— so events.prompter_attached is consulted too, and a run nobody is
watching is headless however the broker was wired. #7948: root is the
run’s working root, which
subjects_for_in_root needs to decide an absolute in-root path against a
relatively-written rule; None restricts matching to the spelling the model
wrote.
Test: headless_ask_is_denied, ask_emits_requested_then_resolved,
absolute_in_root_path_meets_a_relative_deny.
Fields§
§mode: PermissionMode§timeout: Duration§session_id: String§ask: Option<Arc<SessionPermissions>>§events: Option<Arc<dyn PermissionEvents>>§root: Option<PathBuf>Implementations§
Source§impl PermissionContext
impl PermissionContext
Sourcepub fn headless(mode: PermissionMode) -> Self
pub fn headless(mode: PermissionMode) -> Self
A context that can never prompt — the tcode run-task shape.
Test: headless_ask_is_denied.
Sourcepub fn with_root(self, root: impl Into<PathBuf>) -> Self
pub fn with_root(self, root: impl Into<PathBuf>) -> Self
Attach the run’s working root.
Why (#7948): without it, a relative path rule misses the absolute
in-root spelling of the same file, which tools::fs::scoped_path
accepts.
Test: absolute_in_root_path_meets_a_relative_deny.
Sourcepub fn gate_for(
&self,
agent: Arc<AgentConfig>,
agent_id: impl Into<String>,
) -> PermissionGate
pub fn gate_for( &self, agent: Arc<AgentConfig>, agent_id: impl Into<String>, ) -> PermissionGate
Mint a gate for one agent running under this context.
Test: gate_for_agent_without_a_map_allows_everything.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PermissionContext
impl !UnwindSafe for PermissionContext
impl Freeze for PermissionContext
impl Send for PermissionContext
impl Sync for PermissionContext
impl Unpin for PermissionContext
impl UnsafeUnpin for PermissionContext
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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