pub struct Permissions;Expand description
The K9 unified evaluator. Rules + Mode + Hooks compose into a
single Decision; deny-first; ask falls through to mode.
Stateless type — every input is a parameter. The active rules
list is held in the process-wide active_permission_rules
registry so callsites in mcp.rs / handlers.rs don’t need to
thread a config handle through every function.
Implementations§
Source§impl Permissions
impl Permissions
Sourcepub fn evaluate(
ctx: &PermissionContext,
hook_decisions: &[HookDecision],
) -> Decision
pub fn evaluate( ctx: &PermissionContext, hook_decisions: &[HookDecision], ) -> Decision
Evaluate the full pipeline.
hook_decisions is the (possibly empty) sequence of
decisions returned by hook chains for this op. Callers that
have not yet wired a hook chain into a particular op pass
&[]; the pipeline still works (rules + mode resolve the
decision).
Sourcepub fn evaluate_with(
ctx: &PermissionContext,
hook_decisions: &[HookDecision],
rules: &[PermissionRule],
mode: PermissionsMode,
) -> Decision
pub fn evaluate_with( ctx: &PermissionContext, hook_decisions: &[HookDecision], rules: &[PermissionRule], mode: PermissionsMode, ) -> Decision
Same as Permissions::evaluate but takes the rule list and
mode as explicit parameters. Used by the K9 test matrix so
scenarios can exercise specific rule-set / mode combinations
without poking the process-wide registry.
§H8 invariant — namespace cannot be elevated by Modify
The pinned namespace for rule evaluation is taken from
ctx.namespace BEFORE any rule pass. If a hook returns
Modify { namespace: <other_ns> } the pipeline RE-EVALUATES
the entire rule set against the new namespace; if that
re-evaluation returns Decision::Deny, the modification is
rejected (the original Deny reason is surfaced — annotated
with the rejected escalation). This closes the v0.7.0 review
blocker H8 / #628 where a Modify-rewrite of namespace
could bypass a rule that targeted the destination namespace.
Auto Trait Implementations§
impl Freeze for Permissions
impl RefUnwindSafe for Permissions
impl Send for Permissions
impl Sync for Permissions
impl Unpin for Permissions
impl UnsafeUnpin for Permissions
impl UnwindSafe for Permissions
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<T> ErasedDestructor for Twhere
T: 'static,
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