Authority and Safety
This page explains how Neusym limits what an agent may do, and what happens when something goes wrong: a write times out, a document carries hidden instructions, an answer contains a secret. Read it before…
This page explains how Neusym limits what an agent may do, and what happens when something goes wrong: a write times out, a document carries hidden instructions, an answer contains a secret. Read it before you move an environment above review. The kits each level needs are listed in Build an Environment.
The model only proposes tool calls; the kernel and your kits decide. Every tool declares an effect: read, draft, execute or commit. Each call goes through tool-gateway: its arguments are checked against the tool's schema, the kernel checks the level, then the guards that kits add to action.authorize vote. One deny refuses the call; a vote for approval sends it to a person. (Architecture explains guards.) The examples use a small connector with one tool, refund_payment; every output comes from a real run.
#Levels
The level line in workspace.yaml sets the most an agent may do. Each level keeps everything below it.
level | Tool effects allowed | What must be in place (checked by neusym plan) |
|---|---|---|
empty | none | No kits load. Used to test the kernel and drivers. |
review | read | Spend caps on model steps and tool calls; a block on writes after untrusted text; tenant walls on context, calls and answers; secret redaction in context and a secret check on answers; an identity check on incoming triggers |
draft | up to draft | Goals and saved artifacts; a kit that must explicitly allow each task completion; validators on completions and calls |
execute | up to execute | Grants, the operation journal and the audit ledger; a kit that must explicitly allow each tool call |
commit | up to commit | Human approvals, and a notifier to reach the approver |
The level names ports and guard phases, never kits (contracts/levels/contract.json, rules Z5 to Z8), and plan fails when no loaded kit fills one. At run time the kernel adds two checks of its own. A call above the level is refused before any kit sees it, as here in a review environment:
├─ ✗ tool.call refund_payment denied LEVEL_CEILING_DENIED by kernel 3msAnd where a kit is the authority for a point (completion-gate for task.complete, action-gate for action.authorize), staying silent is not enough: the kernel refuses unless that kit votes allow (AUTHORITY_DID_NOT_ALLOW).
#Grants and standing seals
From execute up, action-gate decides each tool call. read and draft calls pass. An execute call needs an active grant that matches its tool and effect, plus anything else the grant names: the actor, the goal and its revision, the task, the operation key, the exact arguments, a use limit, an expiry. Without one:
├─ ✗ tool.call refund_payment denied GRANT_REQUIRED by action-gate:level-and-grant 7msGive grants in workspace.yaml, or at run time with neusym grants issue ./my-env --tool refund_payment --effect execute --max-uses 10 --as ops-1 (and neusym grants revoke):
domain:
seeds:
grants:
- id: refunds
tools: [refund_payment]
effects: [execute]Revoking a grant stops the next call that relied on it, even mid-run (GRANT_REVOKED). When a goal is revised, grants bound to an older revision are revoked. Other refusals: GRANT_EXPIRED (used up or past its time), GRANT_GOAL_STALE, GRANT_GOAL_INACTIVE.
A standing seal (neusym grants seal ./my-env --work-kind nightly-sync --tool sync_rows) covers a recurring kind of work without a grant per call. Seals count only when action-gate runs with standingSealMode: enforce; the default, off, ignores them. In enforce mode, starting a sub-agent also needs an active seal. A seal can never cover commit (STANDING_SEAL_COMMIT_FORBIDDEN), nor can a grant in workspace.yaml: a commit always needs a person's approval.
#Human approval
At commit level, approvals puts every commit call in front of a person. The call does not fail; the task waits:
└─ tool.call refund_payment require_approval APPROVAL_REQUIRED by approvals:commit-approval 16msneusym waiting ./my-env lists open requests. neusym approve ./my-env apr_… --as ops-1 (or neusym reject) decides one and prints grant grant_… (single use, for exactly the approved call). The task is queued again; neusym work (with worker-pool) or neusym run ./my-env --resume <taskId> continues it. The grant works once, so the same call again needs a new approval. The approval is bound to:
- the tool, its effect and a digest of the exact arguments (the stored copy is redacted);
- the goal and its revision: if the goal is revised or closed, the approval goes stale (
APPROVAL_STALE); - the current state of the target, when the tool can read it (
readTargetState). The approver passes the hash of the state they checked (--target-state); if the target changes before the call runs, a new request opens; - the operation key, the task and the person who asked.
approvals setting | Default | Effect |
|---|---|---|
allowSelfApprove | false | The approver must be named (--as) and must not be the one who asked (SELF_APPROVAL_FORBIDDEN). |
defaultRequiredApprovers | 1 | 1 to 5 different people must approve (DUPLICATE_APPROVER). One rejection rejects. |
defaultAllowedApproverRoles, approverRolesByActor | none | Only people with one of these roles may approve (APPROVER_ROLE_FORBIDDEN). Roles also come from role:<name> scopes. |
expireAfterMs | 72 hours | An undecided request expires (APPROVAL_EXPIRED); 0 means never. With scheduler loaded, a timer expires it on time and wakes the task. |
escalationSteps | none | After afterMs, the step's escalateToRoles join the approver roles and the notifier is told. Needs scheduler. |
#When the outcome of a write is unknown
A timeout is the dangerous case: the refund may or may not have happened, and a blind retry could refund twice. From execute up, operation-journal saves each execute or commit call as PREPARED before it runs, then records how it ended:
| State | When | What it blocks |
|---|---|---|
PREPARED | The call is running. | A retry with the same key (OPERATION_IN_FLIGHT). If the process dies, a sweep marks it UNKNOWN after preparedStaleMs (15 minutes). |
CONFIRMED | The call returned. | Nothing. The same call again returns the saved result without calling the tool. |
REJECTED | The tool said no for certain (error code OPERATION_REJECTED). | The same call again gets the same error. |
UNKNOWN | The call threw any other error, such as a timeout or an MCP isError. | A retry with the same key (OPERATION_OUTCOME_UNKNOWN), and the task's completion: the task moves to reconciling. |
The key comes from the task, run, tool and arguments, unless the caller passes its own (opKey, for example refund:pay_42, which also holds across runs). The same key with other arguments is refused (OPERATION_PARAMS_MISMATCH). Here the payment API times out:
task task_… · run run_… · reconciling (OPERATION_OUTCOME_UNKNOWN)
reason: Task "task_…" has operation "auto:0596ed0cc3f60e" in status "UNKNOWN" and must reconcile before completing.neusym waiting lists the operation. Someone checks the payment system and records what happened:
neusym reconcile ./my-env auto:0596ed0cc3f60e rejected --as ops-1 --note "No refund in the payment dashboard"operation auto:0596ed0cc3f60e: REJECTED by ops-1 · tool=refund_payment · task=task_…
note: No refund in the payment dashboardThe task goes back to queued. Use confirmed if the refund did happen; a result a person records is stored as untrusted, so it never counts as trusted evidence.
A tool can also check its own outcome (probeOperation). A sweep of UNKNOWN operations then probes it with backoff, settles it, and tells a person after maxProbeAttempts (default 5) tries. The HTTP server runs this sweep in its work loop (Deployment). After a backup restore, host code can put the store in restore mode; while it is on, every non-read call is refused (RESTORE_MODE_BLOCKED).
#Undo tiers
reversibility-gate (from execute up) sorts each non-read call by how hard it is to undo, using policies you write. With no active policy it does nothing.
one_click: cheap to undo; the call goes on. The default forread,draftandexecute.cleanup: undoing takes work. The policy can require successful runs of named check tools in this task (requiredTraceToolsForCleanup,UNDO_TIER_TRACE_REQUIRED). Whenindependent-reviewis loaded, the call also needs an approved review of this exact call (UNDO_TIER_REVIEW_REQUIRED).no_undo: the call waits for a person to approve it (UNDO_TIER_NO_UNDO), even anexecutecall. Without theapprovalskit nobody can, so the call does not run. The default forcommit.
At any tier a policy can also require a trusted evidence artifact with "passed": true (requireTrustedEvidenceTiers). Rules match on tool name, effect, an argument value (argEquals), a minimum number (argNumericMin) or a changed path (mutatedPathPrefixes), and only ever raise the tier. Policies live in workspace.yaml, a pack, the kit's staticPolicies setting, or neusym reversibility upsert ./my-env --file policy.yaml. With this one, a refund of 250,000 cents waits for a person (UNDO_TIER_NO_UNDO), while a refund of 1,500 cents still goes through on its grant:
domain:
seeds:
reversibilityPolicies:
- name: payments
rules:
- id: large-refunds
tier: no_undo
toolNames: [refund_payment]
argNumericMin: { amountCents: 100000 }#Independent review
independent-review (from draft up) has other agents check work before it counts. A review starts 1 to 5 reviewer tasks (default 2) that see only the subject: artifact digests, trusted evidence, a digest of the call's arguments and the instructions, never the conversation that produced it. Verdicts settle by quorumMode: unanimous (default), majority or threshold. If reviewers disagree or time out, a person decides with neusym reviews resolve <dir> <reviewId> --decision approved|rejected --as <actorId>; when the review names an arbiter, only that person may.
requireReviewForTools holds the listed tools until an approved review is bound to the exact call (INDEPENDENT_REVIEW_REQUIRED); enforceOnTaskComplete holds a task's completion until its artifacts are reviewed. Agents ask for reviews with the review.request tool.
#Untrusted text
Text from outside, such as a web page, an email or a tool result, may carry instructions written for the model. Neusym does not try to spot them; it tracks where text came from. A tool result is untrusted unless the connector sets untrusted: false. External documents, and context from any source other than system, user and policy, are marked tainted. Once a run has seen tainted content it stays tainted, and injection-guard refuses its draft, execute and commit calls. A run that read an email, then tried a refund it holds a grant for:
│ ├─ ✗ tool.call refund_payment denied TAINTED_WRITE_BLOCKED by injection-guard:taint-write-guard 3msThe guard reads the run's saved state, so leaving the flag off a call does not get around it. taintedDraftAllowlist lets named draft tools run in a tainted run, never execute or commit ones; blockTaintedWrites: false turns the guard off.
To use facts from untrusted documents, declassify them. A read tool declares declassifies.outputSchema, and tool-gateway's declassificationAllowlist names the tool. Its output stays trusted only if it fits: a closed object, every string limited by enum, const or a maxLength of at most 256, arrays with maxItems, no newlines or control characters, 8 KB in total by default. Anything else is quarantined (DECLASSIFICATION_SCHEMA_FAILED). This keeps a clean run clean; it never cleans a run that is already tainted.
#Secrets, tenants and the kill switch
secrets leases a credential from the vault for the one call that needs it; only the tool sees the value. Leased values, common key formats (private keys, cloud and API tokens) and your own redactPatterns are replaced in model context, scrubbed from tool results, errors, journal and approval records, and blocked in answers (SECRET_LEAK_BLOCKED). When tenants share a vault, set allowedVaultKeys so each tenant can name only its own keys.
tenancy drops other tenants' context before the model sees it and refuses a call whose tenantId argument names another tenant (CROSS_TENANT_ACTION). For data that must never cross, host code registers markers per tenant through dlp@1: context holding another tenant's marker is dropped, and an answer holding one is blocked (CROSS_TENANT_DLP_BLOCKED) without saying whose marker it was.
budget caps cost, tokens, steps, actions and time per scope (neusym budget set). Its kill switch stops a tenant at once: after neusym kill-switch on ./my-env --as ops-1 --reason "incident 12", every model step and every non-read call is refused (KILL_SWITCH_ACTIVE) and pending tasks are halted, until neusym kill-switch off.
#The audit ledger
From execute up, audit-ledger appends every event (refusals, grants, approvals, journal changes and the rest) to a hash chain per tenant. Entries keep ids, codes, tool names, hashes and costs, not prompts or tool data. With chainKeyTarget set, the chain is keyed (HMAC-SHA256) with a secret, so someone who can write the store cannot recompute it. Keep an anchor (neusym audit anchor ./my-env) outside the store, and check the chain against it later with neusym audit verify ./my-env --anchor <seq>:<hash>:
audit chain ok: 17 entries, holds 1 anchor(s)neusym audit witness --out <file> writes the anchor with a timestamp to a file; witnessEveryNEntries stores one in blob storage every N entries.
How much observation data is kept is a separate setting, observe.capture (content, metadata or none), which a tenant (observe.tenantCapture) or a command (--capture) can lower but never raise. Guards, the event log and the audit ledger work the same at every setting.
The scenario catalog has runnable cases for these rules, for example v5-05 (timeout reconciled before retry), v5-15 (same key, changed arguments), v5-23 (untrusted document cannot trigger writes) and v5-24 (cross-tenant data blocked).