pub struct Engine {
pub rules: Vec<CompiledRule>,
pub policy: Policy,
}Fields§
§rules: Vec<CompiledRule>§policy: PolicyImplementations§
Source§impl Engine
impl Engine
Sourcepub fn from_yaml(raw: &str) -> Result<Self>
pub fn from_yaml(raw: &str) -> Result<Self>
Load a Shield ruleset from a YAML string. Returns an error on malformed YAML or regex compilation failure.
Sourcepub fn extend_from_yaml(&mut self, raw: &str) -> Result<()>
pub fn extend_from_yaml(&mut self, raw: &str) -> Result<()>
Merge an additional rule pack (e.g. the optional ATR community
pack) into an already-loaded engine. The pack’s policy: block,
if any, is IGNORED – policy always comes from the primary
shieldset. Duplicate rule ids across packs are an error: silent
shadowing would make composite scoring double-count.
Sourcepub fn builtin_default() -> Self
pub fn builtin_default() -> Self
Bundled defaults – the same YAML used by the enterprise build, embedded at compile time so the binary always has some ruleset.
Sourcepub fn evaluate(
&self,
tool: &str,
params: &Value,
adj: Adjustments,
) -> Evaluation
pub fn evaluate( &self, tool: &str, params: &Value, adj: Adjustments, ) -> Evaluation
Evaluate a tool call. Returns the full evaluation (which rules
fired, points, raw vs composite vs final severity). The caller
turns this into a Decision via decide_tool_call.
Sourcepub fn evaluate_text(&self, text: &str, adj: Adjustments) -> Evaluation
pub fn evaluate_text(&self, text: &str, adj: Adjustments) -> Evaluation
Evaluate an LLM response body.
Sourcepub fn evaluate_scoped_text(
&self,
scope: Scope,
tool: Option<&str>,
text: &str,
adj: Adjustments,
) -> Evaluation
pub fn evaluate_scoped_text( &self, scope: Scope, tool: Option<&str>, text: &str, adj: Adjustments, ) -> Evaluation
Evaluate free text against the rules of one scope. tool is the
tool the text belongs to (the described tool for
Scope::ToolDescription, the called tool for Scope::ToolResult);
rules with a tool: whitelist only fire when it matches.