AgentTrust
AgentTrust
ProgramsPolicyVault
ProgramsPolicyVault

PolicyVault

The policy composer that returns Allow, Deny, or RequireValidation.

PolicyVault is the decision engine for AgentTrust. It reads payer, payee, policy, velocity, kill-switch, and optional attestation data, then returns a GateDecision.

Composer order

The order is fixed and fail-fast:

OrderPolicyWhy it runs there
1KillSwitchcheapest global stop
2Spendingpure amount and calendar bounds
3Velocitysliding-window spend bound keyed by payer tier
4CounterpartyTierreads payee AtomStats trust data
5RequireValidationreads the attestation PDA last
pub fn compose_decision(input: ComposerInput) -> ComposerResult {
    // KillSwitch -> Spending -> Velocity -> CounterpartyTier -> RequireValidation
    // On Allow, deltas are returned for the Anchor wrapper to apply.
    // On Deny or RequireValidation, deltas are None.
}

Decision shape

pub enum GateDecision {
    Allow,
    Deny(DenyReason),
    RequireValidation([u8; 32]),
}

DenyReason::code() is stable for clients even though the Borsh enum order is internal to Anchor.

Policy kinds

PolicyInputsState mutation on Allow
Spendingamount, UTC day, ISO weekdaily and weekly counters
Velocityamount, slot window, payer tierVelocityLedger.cumulative_amount
CounterpartyTierpayee tier, risk, confidencenone
RequireValidationsubject, capability hash, attestor, expirynone
KillSwitchper-agent paused flagnone

Safety rule

The Anchor handler snapshots all accounts before composing, then applies returned deltas only when the decision is Allow.

match result.decision {
    GateDecision::Allow => {
        spending::apply_deltas(&mut ctx.accounts.policy_account, d);
        velocity::apply_deltas(&mut ctx.accounts.velocity_ledger, d);
    }
    GateDecision::Deny(_) | GateDecision::RequireValidation(_) => {}
}

Formal checks

5 / 5 invariants formally verified

PolicyVault safety properties are checked by Kani in CI.

  • paused_implies_no_allow
  • velocity_counter_le_limit
  • counterparty_tier_monotone
  • validation_expiry_correct
  • multisig_threshold_enforced

Source: programs/policy-vault/src/policies/composer.rs.

repo github.com/mohit-1710/agenttrustnpm @agenttrust-sdk/trustgateMIT

On this page

⌘I