pub struct CapabilityChecker { /* private fields */ }Expand description
Capability checker that enforces per-agent access control.
The checker reads capabilities from the process table and validates tool access, IPC routing, service access, and resource limits. It is designed to be called from tool execution hooks without requiring a direct dependency on the kernel crate (via trait objects in the core).
Implementations§
Source§impl CapabilityChecker
impl CapabilityChecker
Sourcepub fn new(process_table: Arc<ProcessTable>) -> Self
pub fn new(process_table: Arc<ProcessTable>) -> Self
Create a new capability checker backed by the given process table.
Sourcepub fn check_tool_access(
&self,
pid: Pid,
tool_name: &str,
tool_permissions: Option<&ToolPermissions>,
sandbox: Option<&SandboxPolicy>,
) -> Result<(), KernelError>
pub fn check_tool_access( &self, pid: Pid, tool_name: &str, tool_permissions: Option<&ToolPermissions>, sandbox: Option<&SandboxPolicy>, ) -> Result<(), KernelError>
Check whether a process is allowed to call a tool.
Evaluation order:
- Agent must have
can_exec_toolsenabled. - If
tool_permissions.denyis non-empty, the tool must not be in the deny list (deny overrides allow). - If
tool_permissions.allowis non-empty, the tool must be in the allow list. - Shell tools require
sandbox.allow_shell.
§Errors
Returns KernelError::CapabilityDenied with a description
of why access was denied.
Sourcepub fn check_ipc_target(
&self,
from_pid: Pid,
to_pid: Pid,
) -> Result<(), KernelError>
pub fn check_ipc_target( &self, from_pid: Pid, to_pid: Pid, ) -> Result<(), KernelError>
Check whether a process may send a message to another process.
Uses the sender’s IPC scope to determine if communication with the target PID is allowed.
§Errors
Returns KernelError::CapabilityDenied if IPC is disabled
or the target is outside the sender’s IPC scope.
Sourcepub fn check_ipc_topic(&self, pid: Pid, topic: &str) -> Result<(), KernelError>
pub fn check_ipc_topic(&self, pid: Pid, topic: &str) -> Result<(), KernelError>
Check whether a process may publish or subscribe to a topic.
§Errors
Returns KernelError::CapabilityDenied if the agent’s IPC
scope does not permit the given topic.
Sourcepub fn check_service_access(
&self,
pid: Pid,
service_name: &str,
tool_permissions: Option<&ToolPermissions>,
) -> Result<(), KernelError>
pub fn check_service_access( &self, pid: Pid, service_name: &str, tool_permissions: Option<&ToolPermissions>, ) -> Result<(), KernelError>
Check whether a process may access a named service.
If tool_permissions has a non-empty service_access list,
the service name must appear in it.
§Errors
Returns KernelError::CapabilityDenied if the service is not
in the agent’s service access list.
Sourcepub fn check_resource_limit(
&self,
pid: Pid,
resource: &ResourceType,
) -> Result<(), KernelError>
pub fn check_resource_limit( &self, pid: Pid, resource: &ResourceType, ) -> Result<(), KernelError>
Check whether a resource usage is within the agent’s limits.
§Errors
Returns KernelError::ResourceLimitExceeded if the resource
usage exceeds the agent’s configured limits.
Sourcepub fn process_table(&self) -> &Arc<ProcessTable>
pub fn process_table(&self) -> &Arc<ProcessTable>
Get a reference to the underlying process table.
Auto Trait Implementations§
impl Freeze for CapabilityChecker
impl !RefUnwindSafe for CapabilityChecker
impl Send for CapabilityChecker
impl Sync for CapabilityChecker
impl Unpin for CapabilityChecker
impl UnsafeUnpin for CapabilityChecker
impl !UnwindSafe for CapabilityChecker
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