pub struct TaintGate { /* private fields */ }Expand description
Taint gate - checks whether a tool invocation is allowed given the current taint state of the context window. Attached per-agent (as an ECS component) when the agent’s blueprint opts into taint tracking.
Implementations§
Source§impl TaintGate
impl TaintGate
Sourcepub fn new(config: SecurityConfig) -> Self
pub fn new(config: SecurityConfig) -> Self
Create a new taint gate with the given security config.
Sourcepub fn config(&self) -> &SecurityConfig
pub fn config(&self) -> &SecurityConfig
Get the security config.
Sourcepub fn set_tool_classification(
&mut self,
tool_name: String,
classification: ToolClassification,
)
pub fn set_tool_classification( &mut self, tool_name: String, classification: ToolClassification, )
Register a tool classification override.
Sourcepub fn tool_classification(&self, tool_name: &str) -> ToolClassification
pub fn tool_classification(&self, tool_name: &str) -> ToolClassification
Get the classification for a tool (override first, then built-in default).
Sourcepub fn apply_mcp_overrides(
&mut self,
overrides: &HashMap<String, McpToolOverride>,
)
pub fn apply_mcp_overrides( &mut self, overrides: &HashMap<String, McpToolOverride>, )
Apply the [mcp_overrides] section of policy.toml to this gate.
Each override starts from the tool’s current classification and
replaces only the fields it sets, keyed the same server.tool way MCP
tools are named at dispatch. An unrecognized direction string keeps
the existing direction and warns, rather than silently reclassifying
a security property.
Called at gate construction. A later session-scoped “always allow”
writes the same map through Self::set_tool_classification, so the
user’s runtime decision still wins over the config file.
Sourcepub fn check_traditional(
&mut self,
agent_id: &str,
tool_name: &str,
window: &ContextWindow,
) -> GateDecision
pub fn check_traditional( &mut self, agent_id: &str, tool_name: &str, window: &ContextWindow, ) -> GateDecision
Check the gate for a traditional-mode tool invocation.
In traditional mode, the overall taint (max across all regions) is compared against the tool’s clearance.
Sourcepub fn check_with_policy(
&mut self,
agent_id: &str,
tool_name: &str,
window: &ContextWindow,
target: Option<&str>,
policy: &PolicyConfig,
script_checker: Option<&ScriptRuleChecker>,
) -> GateDecision
pub fn check_with_policy( &mut self, agent_id: &str, tool_name: &str, window: &ContextWindow, target: Option<&str>, policy: &PolicyConfig, script_checker: Option<&ScriptRuleChecker>, ) -> GateDecision
Check the gate with allowlist and scripted rule support.
This is the full gate check that runs:
- Basic taint vs clearance check
- If blocked, check static allowlist rules
- If still blocked, check scripted rules (if checker provided)
- Return final decision
Sourcepub fn record_allow(
&mut self,
agent_id: &str,
tool_name: &str,
taint: TaintLevel,
clearance: TaintLevel,
source: GateDecisionSource,
)
pub fn record_allow( &mut self, agent_id: &str, tool_name: &str, taint: TaintLevel, clearance: TaintLevel, source: GateDecisionSource, )
Record an allow decision from the user or allowlist.
Sourcepub fn record_deny(
&mut self,
agent_id: &str,
tool_name: &str,
taint: TaintLevel,
clearance: TaintLevel,
source: GateDecisionSource,
)
pub fn record_deny( &mut self, agent_id: &str, tool_name: &str, taint: TaintLevel, clearance: TaintLevel, source: GateDecisionSource, )
Record a deny decision (the user or a default policy denied the call).
Sourcepub fn apply_resolution(
&mut self,
agent_id: &str,
tool_name: &str,
tool_id: &str,
taint: TaintLevel,
clearance: TaintLevel,
resolution: GateResolution,
) -> Option<(String, String)>
pub fn apply_resolution( &mut self, agent_id: &str, tool_name: &str, tool_id: &str, taint: TaintLevel, clearance: TaintLevel, resolution: GateResolution, ) -> Option<(String, String)>
Apply the user’s resolution of a blocked outbound call: record the
audit event and, for AlwaysAllow, raise the tool’s clearance for the
rest of the run. Returns Some((tool_id, message)) when the call is
denied (and must be skipped), or None when it should execute.
Synchronous so it can be unit-tested directly, keeping the async run-loop path that awaits the prompt as thin as possible.
Trait Implementations§
Source§impl Component for TaintGate
impl Component for TaintGate
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreAuto Trait Implementations§
impl Freeze for TaintGate
impl RefUnwindSafe for TaintGate
impl Send for TaintGate
impl Sync for TaintGate
impl Unpin for TaintGate
impl UnsafeUnpin for TaintGate
impl UnwindSafe for TaintGate
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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
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> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.