pub struct PermissionPolicy {
pub deny: Vec<PermissionRule>,
pub allow: Vec<PermissionRule>,
pub ask: Vec<PermissionRule>,
pub default_decision: PermissionDecision,
pub enabled: bool,
}Expand description
Permission policy configuration
Evaluation order:
- Deny rules - any match results in denial
- Allow rules - any match results in auto-approval
- Ask rules - any match requires user confirmation
- Default - falls back to default_decision
Fields§
§deny: Vec<PermissionRule>Rules that always deny (checked first)
allow: Vec<PermissionRule>Rules that auto-approve without confirmation
ask: Vec<PermissionRule>Rules that always require confirmation
default_decision: PermissionDecisionDefault decision when no rules match
enabled: boolWhether the permission system is enabled
Implementations§
Source§impl PermissionPolicy
impl PermissionPolicy
Sourcepub fn check(&self, tool_name: &str, args: &Value) -> PermissionDecision
pub fn check(&self, tool_name: &str, args: &Value) -> PermissionDecision
Check permission for a tool invocation
Returns the permission decision based on rule evaluation order:
- Deny rules (any match = Deny)
- Allow rules (any match = Allow)
- Ask rules (any match = Ask)
- Default decision
Sourcepub fn is_allowed(&self, tool_name: &str, args: &Value) -> bool
pub fn is_allowed(&self, tool_name: &str, args: &Value) -> bool
Check if a tool invocation is allowed (Allow or not Deny)
Sourcepub fn is_denied(&self, tool_name: &str, args: &Value) -> bool
pub fn is_denied(&self, tool_name: &str, args: &Value) -> bool
Check if a tool invocation is denied
Sourcepub fn requires_confirmation(&self, tool_name: &str, args: &Value) -> bool
pub fn requires_confirmation(&self, tool_name: &str, args: &Value) -> bool
Check if a tool invocation requires confirmation
Sourcepub fn get_matching_rules(&self, tool_name: &str, args: &Value) -> MatchingRules
pub fn get_matching_rules(&self, tool_name: &str, args: &Value) -> MatchingRules
Get matching rules for debugging/logging
Sourcepub fn declares_tool_access(&self, tool_name: &str) -> bool
pub fn declares_tool_access(&self, tool_name: &str) -> bool
Whether this policy explicitly declares that a tool may be considered through an Allow or Ask rule.
This ignores argument patterns and does not authorize execution. It is used when composing parent and delegated-worker visibility: an explicit worker capability can override a parent host’s ordinary model hiding, while execution-time checks from both scopes remain authoritative.
Trait Implementations§
Source§impl Clone for PermissionPolicy
impl Clone for PermissionPolicy
Source§fn clone(&self) -> PermissionPolicy
fn clone(&self) -> PermissionPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PermissionPolicy
impl Debug for PermissionPolicy
Source§impl Default for PermissionPolicy
impl Default for PermissionPolicy
Source§impl<'de> Deserialize<'de> for PermissionPolicy
impl<'de> Deserialize<'de> for PermissionPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PermissionChecker for PermissionPolicy
impl PermissionChecker for PermissionPolicy
Auto Trait Implementations§
impl Freeze for PermissionPolicy
impl RefUnwindSafe for PermissionPolicy
impl Send for PermissionPolicy
impl Sync for PermissionPolicy
impl Unpin for PermissionPolicy
impl UnsafeUnpin for PermissionPolicy
impl UnwindSafe for PermissionPolicy
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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