pub struct GovernanceRule {
pub id: String,
pub description: String,
pub branch: GovernanceBranch,
pub severity: RuleSeverity,
pub active: bool,
pub reference_url: Option<String>,
pub sop_category: Option<String>,
pub rule_type: GovernanceRuleType,
pub action_selector: Option<String>,
pub tool_selector: Option<String>,
pub force_on_match: bool,
}Expand description
A governance rule that restricts agent behavior.
Fields§
§id: StringUnique rule identifier.
description: StringHuman-readable rule description.
branch: GovernanceBranchWhich branch defined this rule.
severity: RuleSeverityRule severity (how critical the violation is).
active: boolWhether this rule is currently active.
reference_url: Option<String>SOP reference URL for agents to consult for full procedure.
sop_category: Option<String>SOP category tag for filtering rules by domain.
rule_type: GovernanceRuleTypeRule type discriminator. Defaults to GovernanceRuleType::General.
Serde defaults missing fields so older chain-anchored rules remain valid.
action_selector: Option<String>Optional action selector (WEFT-634).
When set, the rule only applies when the request’s action matches.
Matching is exact, or prefix when the selector ends with *
(e.g. "tool.agent_*" matches "tool.agent_spawn").
None / empty means “match any action” (magnitude-only rules).
tool_selector: Option<String>Optional tool selector (WEFT-634).
When set, the rule only applies when the request context key
"tool" (or fallback "gate_action") matches. Same exact/prefix
semantics as Self::action_selector. None means “any tool”.
force_on_match: boolWhen true, a selector-matching General rule applies its severity
without requiring effect magnitude to exceed the threshold
(WEFT-634 / WEFT-633 spawn-approval foundation).
Magnitude-only rules leave this false (default) so behaviour is
backward-compatible. BrowserPolicy / BindingThread paths already
ignore magnitude and do not consult this flag.
Implementations§
Source§impl GovernanceRule
impl GovernanceRule
Sourcepub fn filter_by_category<'a>(
rules: &'a [GovernanceRule],
category: &str,
) -> Vec<&'a GovernanceRule>
pub fn filter_by_category<'a>( rules: &'a [GovernanceRule], category: &str, ) -> Vec<&'a GovernanceRule>
Get rules by SOP category from a slice of rules.
Sourcepub fn filter_by_type<'a>(
rules: &'a [GovernanceRule],
rule_type: &GovernanceRuleType,
) -> Vec<&'a GovernanceRule>
pub fn filter_by_type<'a>( rules: &'a [GovernanceRule], rule_type: &GovernanceRuleType, ) -> Vec<&'a GovernanceRule>
Get rules of a given type from a slice of rules.
Sourcepub fn selectors_match(&self, request: &GovernanceRequest) -> bool
pub fn selectors_match(&self, request: &GovernanceRequest) -> bool
Whether this rule’s action/tool selectors match request (WEFT-634).
- No selectors set → always matches (magnitude-only rule).
- Action selector: matches
request.action. - Tool selector: matches
context["tool"], elsecontext["gate_action"]. - Both set → both must match (AND).
Sourcepub fn browser_policy(
id: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn browser_policy( id: impl Into<String>, description: impl Into<String>, ) -> Self
Build a blocking browser_policy rule (S7 / WEFT-108).
Sourcepub fn binding_thread(description: impl Into<String>) -> Self
pub fn binding_thread(description: impl Into<String>) -> Self
Build the binding-thread integrity rule (WEFT-342).
Rule id is the governance action name
BINDING_THREAD_RULE_ID (soul.binding_thread_intact).
Sourcepub fn spawn_requires_approval() -> Self
pub fn spawn_requires_approval() -> Self
Build the spawn-approval rule (WEFT-633 foundation).
Matches tool.agent_spawn / tool context agent_spawn and forces
a blocking decision independent of effect magnitude so the gate
maps to GovernanceDecision::EscalateToHuman →
crate::gate::GateDecision::Defer when the engine has
human_approval_required. Without human approval, the decision
is a hard deny (operator must grant via exemption or lower severity).
Trait Implementations§
Source§impl Clone for GovernanceRule
impl Clone for GovernanceRule
Source§impl Debug for GovernanceRule
impl Debug for GovernanceRule
Source§impl<'de> Deserialize<'de> for GovernanceRule
impl<'de> Deserialize<'de> for GovernanceRule
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>,
Auto Trait Implementations§
impl Freeze for GovernanceRule
impl RefUnwindSafe for GovernanceRule
impl Send for GovernanceRule
impl Sync for GovernanceRule
impl Unpin for GovernanceRule
impl UnsafeUnpin for GovernanceRule
impl UnwindSafe for GovernanceRule
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> 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> 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