OpenAgentID documentation
Source referencesRust module referenceopenagent-aegis-policy

openagent-aegis-policy · spending

Declared module signatures, types, configuration, and source documentation.

Source: aegis/openagent-aegis-policy/src/spending.rs. SHA-256: d738d77fb45bbce2138bd6339f2609b54478bbf9c2bea677092eeac3f0e3f302.

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.

spending::TransactionInfo

A transaction to evaluate against spending policies.

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct TransactionInfo {
/// The asset being transferred (e.g. "ETH", "USDC").

pub asset: String,
/// Decimal string representing the amount (e.g. "1.5").

pub amount: String,
/// Recipient address.

pub recipient: String,
/// Blockchain chain identifier.

pub chain: String
}

Source line: 19.

spending::SpendingPolicyEvaluator

Evaluates spending policy constraints against a transaction.

pub struct SpendingPolicyEvaluator;

Source line: 31.

spending::SpendingPolicyEvaluator::evaluate

Evaluate a transaction against spending limits.

Checks the following dimensions in order:

  1. Asset allowlist -- the transaction asset must be in the allowed set.
  2. Recipient allowlist -- the recipient must be in the allowed set.
  3. Max amount per transaction.
  4. Daily volume (daily_spent + amount must not exceed daily_volume).
  5. Approval threshold -- if amount exceeds threshold, an Approve obligation is added.

Empty allowlists are permissive (all values accepted). Returns a deny PolicyDecision with reason on the first violation found. Returns an allow PolicyDecision on success, possibly with obligations.

pub fn evaluate(
        limits: &SpendingLimits,
        tx: &TransactionInfo,
        daily_spent: &str,
    ) -> Result<PolicyDecision, PolicyError>;

Source line: 46.

spending::parse_amount

Parse a decimal string into an f64.

Returns a PolicyError::EvaluationFailed if the string is not a valid number, is negative, or is non-finite (NaN / infinity).

pub fn parse_amount(s: &str) -> Result<f64, PolicyError>;

Source line: 177.

On this page