Skip to main content

RiskProfileConfig

Struct RiskProfileConfig 

pub struct RiskProfileConfig {
Show 17 fields pub level: AutonomyLevel, pub workspace_only: bool, pub allowed_commands: Vec<String>, pub forbidden_paths: Vec<String>, pub require_approval_for_medium_risk: bool, pub block_high_risk_commands: bool, pub shell_env_passthrough: Vec<String>, pub auto_approve: Vec<String>, pub always_ask: Vec<String>, pub allowed_roots: Vec<String>, pub delegation_policy: DelegationPolicy, pub approval_route: Option<ApprovalRoute>, pub allowed_tools: Vec<String>, pub excluded_tools: Vec<String>, pub sandbox_enabled: Option<bool>, pub sandbox_backend: Option<String>, pub firejail_args: Vec<String>,
}
Expand description

Named risk/autonomy profile ([risk_profiles.<alias>]).

Unified policy surface. Agents reference a profile by alias and the runtime resolves through it for shell command allowlists, approval gates, sandbox/resource limits, and delegation guardrails. The conventional risk_profiles["default"] is the resolution target for non-agent contexts (orchestrator init, cron worker startup); the Default impl below mirrors the legacy safety-first defaults so a fresh install behaves the same as a config from before the per-profile split.

Fields§

§level: AutonomyLevel

Autonomy level applied to this profile. Default: supervised.

§workspace_only: bool

Restrict filesystem access to workspace-relative paths. Default: false.

§allowed_commands: Vec<String>

Allowlist of executable names for shell execution.

§forbidden_paths: Vec<String>

Explicit path denylist.

§require_approval_for_medium_risk: bool

Require approval for medium-risk operations.

§block_high_risk_commands: bool

Block high-risk commands even when allowlisted.

§shell_env_passthrough: Vec<String>

Environment variable names passed through to shell subprocesses.

§auto_approve: Vec<String>

Tools that never require approval in this profile.

§always_ask: Vec<String>

Tools that always require approval in this profile.

§allowed_roots: Vec<String>

Extra directory roots the agent may access.

§delegation_policy: DelegationPolicy

Whether agents using this profile may initiate delegation. Defaults to Forbidden. Reachable delegate targets and bounded/independent mode are resolved from each caller agent’s config.

§approval_route: Option<ApprovalRoute>

Route this profile’s tool approvals to a DISTINCT approver channel instead of the channel that triggered the run (closes the cross-channel-HITL gap). Absent ⇒ the originating channel approves (today’s behavior). See crate::autonomy::ApprovalRoute.

Honored on both the interactive channel-driven path and the non-interactive turn path (gateway chat/webhook dispatch and agent-to-agent peer messages). On the non-interactive path the approver is resolved from the live daemon channel registry; if no registry is available or the approver is not live, the gate keeps the non-interactive default (fail-closed deny under the default on_no_approver).

§allowed_tools: Vec<String>

Tools the agent may call in agentic mode. Empty = inherit / no authorization constraint. Authorization decision: which tools is the agent permitted to invoke at all. See excluded_tools for the inverse denylist scoped to non-CLI channels.

The TOML config does not distinguish an omitted field from allowed_tools = []; both deserialize to Vec::new() and SecurityPolicy::from_profiles maps that to “no authorization constraint” at this layer. If you need an explicit deny-all gate, apply it on the caller-supplied per-run allowed_tools (cron jobs and other narrowers pass that list in directly to ToolAccessPolicy, which honors Some(vec![]) as deny-all) or via excluded_tools covering the specific tools you want blocked.

MCP exception: when the list is non-empty, runtime-discovered MCP tools (any name containing __, which is the <server>__<tool> convention used by the MCP wrapper) are auto-admitted into the effective allow-list without needing to be listed here individually. This keeps the post-change eager-MCP default usable for agents with an explicit allow-list. Block individual MCP tools via excluded_tools.

Scope of the exception: the __ auto-admit applies only to this risk-profile allow-list, not to caller-supplied per-run allowed_tools (cron job allowed_tools, narrowed delegate invocations, etc.). Per-run lists are still strict explicit-list intersections, so a job that narrows allowed_tools = ["cron_add"] will not see runtime-discovered MCP tools unless it names them.

§excluded_tools: Vec<String>

Tools excluded from non-CLI channels under this profile.

Also subtracts from the agentic-delegate allow-list resolved at runtime, which is the only way to block individual <server>__<tool> MCP names that would otherwise be auto-admitted by the allowed_tools MCP exception described above.

§sandbox_enabled: Option<bool>

Whether the sandbox is enabled for this profile. None inherits global.

§sandbox_backend: Option<String>

Sandbox backend identifier (e.g. "firejail", "landlock"). None inherits.

§firejail_args: Vec<String>

Extra arguments forwarded to firejail when sandbox_backend = “firejail”.

Implementations§

Source§

impl RiskProfileConfig

Source

pub fn ensure_default_auto_approve(&mut self)

Merge the built-in default auto_approve entries into the current list, preserving any user-supplied additions.

Source

pub fn sandbox_config(&self) -> SandboxConfig

Synthesize a SandboxConfig from this profile’s flattened sandbox fields. Sandbox config is stored flat on the profile; callsites that still want a SandboxConfig instance (sandbox detection in zeroclaw-runtime::security::detect) can call this helper.

Source§

impl RiskProfileConfig

Source

pub fn configurable_prefix() -> &'static str

Returns the #[prefix] value for this Configurable struct.

Source

pub fn secret_fields(&self) -> Vec<SecretFieldInfo>

Returns metadata about all #[secret] fields on this struct and nested children.

Source

pub fn secret_field_terminals() -> Vec<&'static str>

Source

pub fn encrypt_secrets(&mut self, store: &SecretStore) -> Result<(), Error>

Encrypt all secret fields in place using the provided store.

Source

pub fn decrypt_secrets(&mut self, store: &SecretStore) -> Result<(), Error>

Decrypt all secret fields in place using the provided store.

Source

pub fn set_secret(&mut self, name: &str, value: String) -> Result<(), Error>

Set a secret field by its full dotted name, dispatching to nested children.

Source

pub fn prop_fields(&self) -> Vec<PropFieldInfo>

Returns metadata about all property fields on this struct and nested children.

Source

pub fn get_prop(&self, name: &str) -> Result<String, Error>

Get a property value by its full dotted name, returning it as a display string.

Source

pub fn set_prop(&mut self, name: &str, value_str: &str) -> Result<(), Error>

Set a property value by its full dotted name, parsing from string.

Source

pub fn prop_is_secret(name: &str) -> bool

Check if a property name refers to a secret field (static, no instance needed).

Source

pub fn init_defaults(&mut self, prefix: Option<&str>) -> Vec<&'static str>

Instantiate None nested sections whose prefix matches. Returns the prefixes that were initialized.

Source

pub fn map_key_sections() -> Vec<MapKeySection>

Enumerate every map-keyed (HashMap<String, T>) and list-shaped (Vec<T>) section discoverable from this Configurable’s tree. The dashboard / CLI consume this to surface “+ Add” affordances without hardcoding the section list.

Source

pub fn nested_section_help(name: &str) -> Option<&'static str>

Help blurb for a #[nested] field on this struct, sourced from the field-level /// docstring. Returns None for unknown names so callers can fall through to a different lookup.

Source

pub fn nested_section_group(name: &str) -> Option<&'static str>

Source

pub fn get_map_keys(&self, section_path: &str) -> Option<Vec<String>>

Return the current alias keys at section_path, or None if the path doesn’t resolve to a map-keyed section in this tree.

Source

pub fn nested_option_entries(&self) -> Vec<NestedOptionEntry>

Source

pub fn create_map_key( &mut self, section_path: &str, map_key: &str, ) -> Result<bool, String>

Source

pub fn delete_map_key( &mut self, section_path: &str, map_key: &str, ) -> Result<bool, String>

Source

pub fn rename_map_key( &mut self, section_path: &str, map_key: &str, new_key: &str, ) -> Result<bool, String>

Trait Implementations§

Source§

impl Clone for RiskProfileConfig

Source§

fn clone(&self) -> RiskProfileConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · §

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RiskProfileConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for RiskProfileConfig

Source§

fn default() -> RiskProfileConfig

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for RiskProfileConfig

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<RiskProfileConfig, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for RiskProfileConfig

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl MaskSecrets for RiskProfileConfig

Source§

impl Serialize for RiskProfileConfig

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,