Documentation Index
Fetch the complete documentation index at: https://docs.altheia.xyz/llms.txt
Use this file to discover all available pages before exploring further.
guard() and Altheia handles policy enforcement and auditing around it.
What it does
- Calls
/sdk/agent_checkwith the action. - If allowed: runs
fn(). If denied: throwsPolicyDeniedErrorbeforefn()runs. - After
fn()resolves, calls/sdk/agent_reportwith the outcome. Iffn()returned a string, it is passed through as the on-chaintx_signature.
Parameters
| Param | Type | Notes |
|---|---|---|
action | ActionDescriptor | What you intend to do. Used for policy check + audit. |
fn | () => Promise<T> | The function that actually executes the action. |
ActionDescriptor
Returns
Whateverfn() returns. If fn() returns a string, it is treated as a Solana tx signature and attached to the audit row.
Throws
PolicyDeniedError— policy denied the action.fn()did not run.AltheiaConnectionError— backend was unreachable ANDfailureModeis"closed".- Any error thrown by
fn()itself.
Example
When not to use guard()
If your action does not sign anything on-chain (a no-op, a read, an inference call) you usually don’t need guard(). Use check() if you want a policy decision without side effects.