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

# Five Levels of Agency

> How read, propose, and write privileges are gated monotonically across L1–L5 without relying on LLM self-restraint.

Truly Agentic gates every tool call across explicit **`AgencyLevel` (`1 | 2 | 3 | 4 | 5`)** and **`ActionTier` (`'read' | 'propose' | 'write'`)** rules inside `PolicyEngine` (`src/policy-engine.ts`).

Language models never evaluate their own permission boundaries. Even if an upstream prompt attempts to persuade the model into issuing a wire or bypassing review, `PolicyEngine.evaluate()` denies or holds the tool call deterministically in TypeScript.

## Tier-to-Level Mapping

In `src/policy-engine.ts`:

```ts theme={null}
const TIER_REQUIRED_AGENCY: Record<ActionTier, number> = {
  read: 1,
  propose: 2,
  write: 3,
};
```

Each `ToolPolicy` specifies both a `tier` and a `minAgencyLevel`, while `PolicyEngine` takes `Math.max(policy.minAgencyLevel, TIER_REQUIRED_AGENCY[policy.tier])`.

| Level | Operational Posture | Typical Tools | Human Gate & Enforcement |
| - | - | - | - |
| **L1 — Read-Only** | Passive inspection & data synthesis | `erp.get_invoice`, ticket lookup, log summaries | Scoped read-only credential lease; cannot draft or mutate state |
| **L2 — Propose / Draft** | Generates candidate payloads without side effects | Reconciliation diffs, email drafts, staged journal entries | Output persists strictly in staging/shadow mode for human comparison |
| **L3 — Supervised Write** | Single-record state mutations inside strict parameter bounds | `erp.post_payment_batch` (bounded by ceiling & allowlists) | **Mandatory** Control 3 `ApprovalGate` sign-off by named `usr_*` approver + `idempotencyKey` |
| **L4 — Guardrailed Workflow** | Multi-step approved operational sequences under hard spend caps | Batch settlement runs within pre-approved vendor/IBAN rules | Pre-reserved budget (`budgetUsdCap`), named-approver sign-off on sensitive steps, WORM logging |
| **L5 — Bounded Autonomy** | High-maturity bounded automation after shadow validation | Pre-cleared internal low-blast-radius reconciliations | Deterministic value/domain/rate caps + instant `activateKillSwitch` lease suspension |

## Deterministic Parameter Validation

Beyond agency levels, `PolicyEngine` enforces hard code-level checks (`validateDeterministicConstraints`) on every candidate `ToolCallRequest`:

* `maxAmountUsd`: Rejects non-positive, non-finite, or over-ceiling monetary amounts
* `allowedCurrencies`: Enforces uppercase currency allowlists (e.g. `['USD', 'AED', 'EUR']`)
* `allowedIbanPrefixes`: Validates structural IBAN regex and restricts permitted country prefixes (e.g. `['AE', 'GB', 'DE']`)
* `allowedRecipientDomains`: Restricts destination vendor/recipient email domains against approved allowlists

Any mismatch returns `outcome: 'deny'` tagged with `['ASI02', 'ASI05']` and appends a `blocked` audit record before returning.


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