# Autonomy and approvals

Index: https://backenly.com/llms.txt

## The loop

A Monitor → Analyze → Plan → Execute loop watches every project. It applies on its own only additive, snapshotted changes in the reversible safe band (missing indexes, broken triggers). Anything it will not apply lands on the project's **Autonomy** page as a finding with a receipt, for a human to approve or reject. Auth, external credentials, destructive and irreversible changes always wait for a human. Its fixes are rule-based, and it never draws AI credits.

## Actions

<!-- generated:actions:autonomy by scripts/generate-agent-docs.ts from lib/mcp/domains.ts; do not edit -->
Call as `autonomy { action: "<action>", … }`.

| Action | What it does | Needs | Read-only key | Approval |
| --- | --- | --- | --- | --- |
| `status` | mode, recent repairs and what is waiting | nothing | yes | no |
| `findings` | open health findings with evidence | nothing | yes | no |
| `maintenance` | the schema-maintenance ladder and its consent state | nothing | yes | no |
| `evolution` | architecture changes, what waits for approval, recommendations; detail: true for evidence and exact plans | nothing | yes | no |
| `set_level` | OFF, CONSERVATIVE, BALANCED or AGGRESSIVE | `level` | no | no |
<!-- end generated -->

`set_level { level }` takes `OFF`, `CONSERVATIVE`, `BALANCED` or `AGGRESSIVE`. Approving what the loop queued is for a human only; there is no agent action for it.

## Architecture changes

Self-healing keeps a backend working; architecture changes keep it well shaped. When a group of columns in a table behaves as a job of its own (the refund columns on `orders`) and keeping it there has a measured cost, Backenly proposes moving it into a table of its own, rehearsed on a copy first. An organization admin approves the exact plan on the **Autonomy** page; there is no agent action for it. The new table is kept in step with the old one in both directions while the data is copied, so code that uses the old table keeps working, and who can read or change the data stays the same. Undo leaves the original table exactly as it was, and dropping the old columns is shown in the plan but never run by Backenly. Most of the time the answer is that no change is recommended.

`autonomy { action: "evolution" }` reads what is proposed, waiting or done; `autonomy { action: "evolution", detail: true }` adds the evidence and the exact plans. When your human asks why a table changed shape, or whether a change helped, read it there.

## Approvals

Some actions never run from the call that asks for them: every one marked "waits for a human" in a topic's action table, and dropping or truncating a table or discarding a branch through `backend_chat`. For those:

1. The exact call, with its arguments, is parked. The response carries an `approval` object with its `id`, and nothing has changed.
2. A human approves or rejects it on the project's **Autonomy** page.
3. Once approved, the parked call runs verbatim: no model reads it again, and nothing is re-derived from a description.
4. Poll `check_approval { id }` every 15–30 seconds until the status is terminal:
   - `executed`: done.
   - `rejected`: do not retry; ask your human what they want instead.
   - `expired`: nobody decided within 24 hours.
   - `failed`: the call did not complete. Read `resultSummary` and check the current state before raising it again: a call that stops part-way, such as a deploy or a data migration, can leave some of its work applied.
   - `partial`: only on requests from before approvals ran one exact call. Some changes landed before the run stopped; read `resultSummary` and verify state instead of replaying the call.

A read-only key is never parked: its write calls are refused with `READ_ONLY_KEY` before anything else happens. Calling a destructive tool directly by an older name (for example `delete_bucket`) is refused with `DESTRUCTIVE_NEEDS_APPROVAL`; use the section tool's action, which parks it.
