> ## Documentation Index
> Fetch the complete documentation index at: https://tavryn.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Deterministic Spending Policy Engine — Zero LLM Approval

> How Tavryn enforces spending rules with pure TypeScript math — no LLM approval power — plus 1-tap HMAC-SHA256 supervisor escalation for large transactions.

Every financial decision Tavryn makes must pass through a gatekeeper that has nothing to do with artificial intelligence. The Policy Engine is pure TypeScript arithmetic — deterministic functions that evaluate a proposed transaction against your organisation's configured rules and return a binary pass/escalate/reject verdict. The LLM that negotiates on your behalf has no ability to influence, bypass, or reinterpret this check. It runs after the negotiation, after the Reviewer Agent, and its result is final.

## Why deterministic-only?

AI language models are probabilistic. A well-crafted vendor prompt or an unusual negotiation context could, in principle, nudge an LLM-based approver toward a favourable decision it shouldn't make. Tavryn eliminates this entire attack surface by placing an inviolable math layer between the negotiation and the wallet. No matter what the negotiation agent concludes, a $10,000 transaction against a $2,000 autonomous ceiling returns `needs_human` — every time, without exception.

> [!NOTE]
>
> **The LLM cannot approve transactions.** Policy evaluation is performed exclusively by deterministic TypeScript code. The negotiation agent's output feeds into the policy check as input data only — it has no mechanism to influence the outcome of the policy evaluation itself.

## Policy parameters

You configure the following parameters per organisation. All values are fetched fresh on every evaluation — there is no in-memory caching that could serve stale limits.

### `max_auto_transaction`

The **autonomous spending ceiling** in USDC. Any proposed transaction at or below this value can be executed without human involvement, provided all other checks pass.

* **Default:** `2000`
* Transactions above this value return `needs_human` and trigger a supervisor approval link.

### `min_savings`

The **minimum projected annual savings** required to justify initiating a renegotiation. If the agent calculates that renegotiation would yield less than this amount, the deal is rejected outright — it's not worth the operational overhead.

* **Default:** `200`
* Deals below this threshold return `rejected` unless a human override is explicitly configured for the evaluation context.

### `human_approval_required_above`

A **separate escalation threshold** that triggers supervisor notification regardless of the autonomous ceiling. Useful when you want a human in the loop for any transaction above a certain size even if your `max_auto_transaction` is higher.

* **Default:** `2000`
* When the transaction amount exceeds this value, the engine adds a `needs_human` flag alongside any other checks.

### `allowed_categories`

The **whitelist of spend categories** the agent is permitted to negotiate within. Any transaction in a category not on this list is hard-rejected (`rejected`) immediately — it does not escalate to a human, it stops.

Supported category values:

> [card] software

> [card] cloud

> [card] contractors

> [card] infrastructure

> [card] legal

> [card] marketing

### `category_budgets`

An optional **per-category monthly budget** expressed as a USDC amount. The engine tracks cumulative spend for the current calendar month and adds the proposed transaction amount before comparing against the limit.

* If `prior_spend + proposed_amount > category_budget` but `proposed_amount <= category_budget`, the engine returns `needs_human` — you may still want to approve it.
* If `proposed_amount > category_budget` on its own, the engine returns `rejected`.
* If no budget is configured for a category, the check is skipped automatically.

## How a policy check works

The policy engine runs seven sequential checks. All checks run regardless of earlier failures so you receive a complete diagnostic, not just the first error.

| Check | Pass condition | Failure outcome |
| - | - | - |
| `valid_numbers` | Amount and savings are non-negative numbers | `rejected` |
| `category_allowed` | Category is in `allowed_categories` | `rejected` |
| `savings_threshold` | Savings ≥ `min_savings` | `rejected` (or `needs_human` if override flag set) |
| `category_budget` | Cumulative spend within budget | `needs_human` or `rejected` |
| `treasury_balance` | Amount ≤ available treasury balance | `rejected` |
| `human_approval_threshold` | Amount ≤ `human_approval_required_above` | `needs_human` |
| `amount_within_auto_ceiling` | Amount ≤ `max_auto_transaction` | `needs_human` |

The final verdict is determined by strict priority: `rejected` beats `needs_human` beats `approved`. A single hard rejection prevents human escalation — those cases require a policy change, not a supervisor override.

## 1-tap HMAC-SHA256 approval links

When a transaction returns `needs_human`, Tavryn generates a cryptographically signed approval link delivered out-of-band to your designated supervisor. The token is an HMAC-SHA256 signature over the transaction parameters, scoped to a single negotiation ID.

**Token properties:**

* Expires **48 hours** after generation
* **Single-use only** — the first redemption atomically marks the token as consumed, preventing concurrent double-approvals
* Scoped to a specific negotiation — a token generated for one deal cannot authorise a different deal
* Every approval requires the negotiation context to be present; open-ended business-wide approvals are explicitly prohibited

> [!WARNING]
>
> **GET requests to approval links are read-only previews.** They show you the deal terms and policy evaluation details, but they do not approve anything. Approval requires an **authenticated POST** request. This prevents approval-by-email-prefetch, link scanners, or browser pre-fetching from accidentally triggering an irreversible financial action.

## Server-side enforcement

In addition to the policy engine itself, Tavryn enforces policy a second time server-side immediately before any escrow creation or payment execution. This server-side guard:

1. Fetches your organisation's policy directly from the database (never from a request parameter)
2. Queries live treasury balance from the Arc network via JSON-RPC, with a database fallback
3. Calculates real cumulative category spend for the current calendar month
4. Re-runs the full policy check with all live values
5. Verifies a valid, unused human approval record for the exact negotiation, when required

This double-enforcement architecture means the LLM agent cannot short-circuit policy by constructing a crafted execution path. Policy is enforced at the gateway, not trusted from the agent's own output.

> [!TIP]
>
> You can test your policy configuration without running a live negotiation. Use the **Policy Simulator** in the dashboard to submit a hypothetical transaction amount, category, and savings figure and see exactly which checks pass, which fail, and what the escalation path would be.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.