pub struct PolicyEngine { /* private fields */ }Expand description
策略引擎
Implementations§
Source§impl PolicyEngine
impl PolicyEngine
pub fn new(config: PolicyConfig) -> Self
Sourcepub fn evaluate_batch(&self, batch: &IntentBatch) -> Vec<PolicyDecision>
pub fn evaluate_batch(&self, batch: &IntentBatch) -> Vec<PolicyDecision>
校验整个 IntentBatch, 返回每个意图的决策。
不检查后端能力等级,也不进行 target-not-in-context 检查—— 用于未指定后端 / 未携带窗口上下文的场景或向后兼容。
Sourcepub fn evaluate_batch_with_capability(
&self,
batch: &IntentBatch,
capability: &CapabilityLevel,
) -> Vec<PolicyDecision>
pub fn evaluate_batch_with_capability( &self, batch: &IntentBatch, capability: &CapabilityLevel, ) -> Vec<PolicyDecision>
校验整个 IntentBatch,同时执行后端能力等级检查。
Sourcepub fn evaluate_batch_with_context(
&self,
batch: &IntentBatch,
capability: &CapabilityLevel,
ctx: &StructuredContext,
) -> Vec<PolicyDecision>
pub fn evaluate_batch_with_context( &self, batch: &IntentBatch, capability: &CapabilityLevel, ctx: &StructuredContext, ) -> Vec<PolicyDecision>
完整的校验入口:风险 + 能力 + 上下文。
当上下文 (ctx) 提供时,引擎会拒绝任何 target 指向未在本窗口
出现过的 package/path 的动作。这是封堵 LLM 凭空指定目标的关键门。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PolicyEngine
impl RefUnwindSafe for PolicyEngine
impl Send for PolicyEngine
impl Sync for PolicyEngine
impl Unpin for PolicyEngine
impl UnsafeUnpin for PolicyEngine
impl UnwindSafe for PolicyEngine
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
Mutably borrows from an owned value. Read more