openagent-skills-policy · engine
Declared module signatures, types, configuration, and source documentation.
Source: openagent-sdk/crates/openagent-skills-policy/rust/src/engine.rs. SHA-256: 9e55ac1b6524d85519315932929f89032d22db8f361634fcd7adc6b13a394abe.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
engine::InvocationContext
Context passed into can_invoke / record_invocation describing who is
attempting to use a skill, when, and with what arguments.
#[derive(Debug, Clone)]
pub struct InvocationContext {
/// DID of the invoking agent.
pub agent_did: Did,
/// Session ID (opaque string — matches `arsenal-core::SessionId` shape).
pub session_id: String,
/// Arguments that will be passed to the skill.
pub arguments: serde_json::Value,
/// Wall-clock time of the attempted invocation (UTC).
pub invoked_at: OffsetDateTime,
/// Whether the caller has already collected human-in-the-loop consent.
pub consent_granted: bool
}Source line: 31.
engine::InvocationContext::new
Convenience constructor. consent_granted defaults to false.
pub fn new(
agent_did: Did,
session_id: impl Into<String>,
arguments: serde_json::Value,
) -> Self;Source line: 46.
engine::InvocationContext::with_consent
Mark consent as granted (e.g. after a HITL approval flow).
#[must_use]
pub fn with_consent(mut self) -> Self;Source line: 62.
engine::InvocationContext::with_invoked_at
Override the invocation timestamp (primarily for testing).
#[must_use]
pub fn with_invoked_at(mut self, t: OffsetDateTime) -> Self;Source line: 69.
engine::SkillsPolicy
Governance engine for agent skill invocations.
pub struct SkillsPolicy {
}Source line: 76.
engine::SkillsPolicy::from_yaml
Parse a policy YAML document.
Errors
Returns [SkillsPolicyError::InvalidPolicy] if the YAML is malformed
or fails structural validation.
pub fn from_yaml(yaml: &str) -> Result<Self>;Source line: 101.
engine::SkillsPolicy::from_file
Load a policy YAML document from a file path.
Errors
Returns [SkillsPolicyError::Io] on read failure, or any error from
[SkillsPolicy::from_yaml] on parse/validation failure.
pub fn from_file(path: &Path) -> Result<Self>;Source line: 119.
engine::SkillsPolicy::agent
The DID of the agent this policy applies to.
#[must_use]
pub fn agent(&self) -> &Did;Source line: 129.
engine::SkillsPolicy::has_rule
Whether the policy has a per-skill rule for skill.
#[must_use]
pub fn has_rule(&self, skill: &str) -> bool;Source line: 135.
engine::SkillsPolicy::can_invoke
Read-only check: can ctx invoke skill right now?
This runs every policy dimension except the rate-limit advance. A
successful return does not consume any rate-limit tokens — use
record_invocation for that.
Errors
Returns a specific [SkillsPolicyError] variant per failed dimension.
pub fn can_invoke(&self, skill: &str, ctx: &InvocationContext) -> Result<()>;Source line: 147.
engine::SkillsPolicy::record_invocation
Authorize and record an invocation.
This runs can_invoke, then checks and advances the rate limiter,
then appends a [Receipt] to the hash-chained audit log. On any
failure no state changes.
Errors
Returns the first dimension that failed. On rate-limit failure the
caller gets used and max values to surface a friendly error.
pub fn record_invocation(
&mut self,
skill: &str,
ctx: &InvocationContext,
) -> Result<Receipt>;Source line: 213.
engine::SkillsPolicy::audit_chain
Borrow the audit chain for inspection (verification, export).
#[must_use]
pub fn audit_chain(&self) -> &AuditChain;Source line: 281.
engine::SkillsPolicy::reset_rate_limit
Reset the rate-limit state for a single skill.
pub fn reset_rate_limit(&mut self, skill: &str);Source line: 286.
engine::arsenal_error_from
Used by integration with Arsenal: convert a SkillsPolicyError into an
arsenal_core::ArsenalError. Kept behind the engine module so that
downstream crates can depend on this without pulling the whole module
graph.
pub fn arsenal_error_from(err: &SkillsPolicyError) -> arsenal_core::ArsenalError;Source line: 370.