pub struct CapabilityPolicy {
pub tools: Vec<String>,
pub capabilities: BTreeMap<String, Vec<String>>,
pub workspace_roots: Vec<String>,
pub read_only_roots: Vec<String>,
pub side_effect_level: Option<String>,
pub recursion_limit: Option<usize>,
pub tool_arg_constraints: Vec<ToolArgConstraint>,
pub tool_annotations: BTreeMap<String, ToolAnnotations>,
pub sandbox_profile: SandboxProfile,
pub process_sandbox: ProcessSandboxPolicy,
}Fields§
§tools: Vec<String>§capabilities: BTreeMap<String, Vec<String>>§workspace_roots: Vec<String>§read_only_roots: Vec<String>Roots the workload may read but never write. A path resolving
under one of these passes read scope checks yet is rejected for
write_text/delete, and the generated OS sandbox profile
grants it read-only. Intended to be disjoint from
workspace_roots (which are read-write); cloud mounts lower
their FilesystemAccess::ReadOnly entries here so a “read-only”
mount is actually unwritable inside the sandbox.
side_effect_level: Option<String>§recursion_limit: Option<usize>Remaining Harn-side nested-execution depth. The
enter_nested_execution_policy helper validates this at every
agent_loop, sub_agent_run, spawn_agent worker, workflow
stage, and nested-workflow surface: Some(0) rejects the
launch with a categorized BudgetExceeded error; Some(n>0)
allows the descent and gives the child Some(n - 1). None
disables the budget gate entirely.
tool_arg_constraints: Vec<ToolArgConstraint>Argument-level constraints for specific tools.
tool_annotations: BTreeMap<String, ToolAnnotations>Per-tool annotations (kind, arg schema, capabilities, side-effect level). Pipelines own the registry; the VM reads it.
sandbox_profile: SandboxProfileConfinement strength applied to subprocesses spawned under this
policy. Defaults to SandboxProfile::Worktree; pipelines opt
into SandboxProfile::OsHardened when the workload should
refuse to run if the platform sandbox is unavailable.
process_sandbox: ProcessSandboxPolicyProcess-only filesystem allowances layered into OS subprocess sandboxes without widening Harn file builtins.
Implementations§
Source§impl CapabilityPolicy
impl CapabilityPolicy
Sourcepub fn neutral() -> Self
pub fn neutral() -> Self
The identity element under CapabilityPolicy::intersect: a policy
that expresses no opinion on any axis.
Use this — not Default::default — to build an overlay: a policy
that constrains some axes (tools, capabilities, side-effect level) and
deliberately says nothing about the rest. Default is the confinement
decision for a run that has none of its own, so it carries
SandboxProfile::Worktree. An overlay built on Default inherits
that profile and asserts filesystem confinement its author never
intended. Merged into a parent the mistake is invisible, because
intersect keeps the strictest profile and the parent’s is already at
least as strict; with no parent the overlay is pushed verbatim and a
deliberately unsandboxed run silently becomes sandboxed.
Unrestricted is the identity for the profile axis specifically:
strictest_sandbox_profile ranks it lowest, so intersecting an overlay
against any real parent yields the parent’s profile unchanged.
pub fn is_unbounded(&self) -> bool
pub fn tools_are_restricted(&self) -> bool
pub fn tools_deny_all(&self) -> bool
pub fn allowed_tool_patterns(&self) -> impl Iterator<Item = &str>
pub fn restrict_tools(&mut self, tools: Vec<String>)
pub fn tool_pattern_allows(&self, tool: &str) -> bool
pub fn capabilities_are_restricted(&self) -> bool
pub fn capabilities_deny_all(&self) -> bool
pub fn allowed_capabilities(&self) -> impl Iterator<Item = (&str, &[String])>
pub fn capability_operations(&self, capability: &str) -> Option<&[String]>
pub fn restrict_capabilities( &mut self, capabilities: BTreeMap<String, Vec<String>>, )
pub fn intersect( &self, requested: &CapabilityPolicy, ) -> Result<CapabilityPolicy, String>
Sourcepub fn assert_within_ceiling(
&self,
requested: &CapabilityPolicy,
) -> Result<(), String>
pub fn assert_within_ceiling( &self, requested: &CapabilityPolicy, ) -> Result<(), String>
Enforce the ceiling invariant on a requested policy: every
capability / budget / permission dimension must stay within (or
narrower than) self, the workflow-level grant. Used where a
Harn-computed flattened stage policy re-enters Rust: the flattener may
narrow a ceiling but must never widen one. Returns a categorized
error naming the widened dimension.
“Empty means unbounded” matches intersect: an
empty tools / workspace_roots / read_only_roots / capabilities
ceiling imposes no bound on that dimension, so anything passes.
Trait Implementations§
Source§impl Clone for CapabilityPolicy
impl Clone for CapabilityPolicy
Source§fn clone(&self) -> CapabilityPolicy
fn clone(&self) -> CapabilityPolicy
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 CapabilityPolicy
impl Debug for CapabilityPolicy
Source§impl Default for CapabilityPolicy
impl Default for CapabilityPolicy
Source§fn default() -> CapabilityPolicy
fn default() -> CapabilityPolicy
Source§impl<'de> Deserialize<'de> for CapabilityPolicy
impl<'de> Deserialize<'de> for CapabilityPolicy
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>,
impl Eq for CapabilityPolicy
Source§impl PartialEq for CapabilityPolicy
impl PartialEq for CapabilityPolicy
Source§impl Serialize for CapabilityPolicy
impl Serialize for CapabilityPolicy
impl StructuralPartialEq for CapabilityPolicy
Auto Trait Implementations§
impl Freeze for CapabilityPolicy
impl RefUnwindSafe for CapabilityPolicy
impl Send for CapabilityPolicy
impl Sync for CapabilityPolicy
impl Unpin for CapabilityPolicy
impl UnsafeUnpin for CapabilityPolicy
impl UnwindSafe for CapabilityPolicy
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);