# Troubleshooting

> First-problem fixes for Osevel: a held API call, a server that will not start, a missing secret, an agent that is cut off, undo conflicts.

Source: https://osevel.com/docs/troubleshooting/

The situations people meet first, by product, and what to run. Each section is taken from the
guides, which have the full detail.

- [OsBase (databases)](#osbase-databases)
- [OsVault](#osvault)
- [OsApi](#osapi)
- [OsBox](#osbox)
- [OsMemory](#osmemory)
- [OsBrain](#osbrain)
- [With the Osevel service installed](#with-the-osevel-service-installed)

## OsBase (databases)

### The agent is cut off

If something gives the agent role a capability you have not accepted (an extension such as
`pg_net` enabled after install, a new or changed SECURITY DEFINER function it can call, a foreign
table, an accepted SECURITY DEFINER item re-opened by an approved schema change, ...), two things
happen:

- the MCP server refuses **every** statement, reads included, and tells the agent
  `DATABASE ACCESS DISABLED`;
- the database itself cuts the agent role off in the same transaction as the change that caused
  it: the role is set `NOLOGIN`, its open sessions are terminated, and all its privileges on
  managed tables are revoked.

`status`, `verify` and `doctor` show `THE AGENT IS CUT OFF` (or `THE AGENT IS BLOCKED`) with the
reason and the unaccepted items. An unaccepted SECURITY DEFINER **trigger** is narrower: only the
tables it is on (and managed tables whose cascades reach it) lose agent and undo writes.

There are two ways back:

1. **Remove what gives the capability** (for example `REVOKE ... FROM PUBLIC` and from the agent
   role, grant it only to the roles that need it; or `ALTER FUNCTION ... SECURITY INVOKER` for a
   trigger function), then run `osevel sync` as the admin. `sync` re-checks, lets the agent
   log in again and restores its grants.
2. **Accept it:** `osevel risks accept` (admin connection, typed code). It lists every
   unaccepted item (for the list risks every item that will be accepted, with its owner, and why
   accepted SECURITY DEFINER items were re-opened), asks you to type each risk's name, then
   re-applies the installation with the accepted risks (same role prefix, schemas and RLS mode,
   **no password changes**, so the running MCP server keeps working) and runs `sync`. For
   `foreign_tables` and the SECURITY DEFINER risks this accepts exactly the items shown.
   `osevel risks list` shows the current state without changing anything.

No osevel login role can lift a cut-off; only the admin can, through `sync` or
`risks accept`.

### Undo reports conflicts

A conflict means that undoing the step would overwrite or destroy something that is no longer the
agent's. The step is skipped and reported.

| Reason             | Meaning                                                                     |
| ------------------ | --------------------------------------------------------------------------- |
| `row_missing`      | The row no longer exists.                                                   |
| `row_modified`     | The row was changed after the agent inserted it, so it is not deleted.      |
| `columns_modified` | Someone changed these columns after the agent; they are not restored.       |
| `key_taken`        | A row with this key exists again, so the deleted row cannot be re-inserted. |
| `ambiguous_match`  | Table without a primary key: no unique row matches the agent's image.       |
| `schema_drift`     | The table or column changed since (renamed, dropped, recreated).            |
| `irreversible`     | The original action is irreversible.                                        |
| `apply_failed`     | The database rejected the reversing statement.                              |

Some conflicts carry a detail:

| Detail                        | Meaning                                                                                                                                                                          |
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `rewritten_later`             | Another captured writer (an agent session, an approved schema change or an earlier undo) wrote this row afterwards, so it is no longer the agent's value even if it looks equal. |
| `dependency_skipped`          | An earlier step on the same row was skipped, so this one is too.                                                                                                                 |
| `still_referenced`            | Deleting the row would cascade into rows this undo does not remove.                                                                                                              |
| `data_present`                | The table or column to remove holds data someone else wrote; undo will not delete it.                                                                                            |
| `constraint`                  | It would violate a unique, foreign-key or check constraint.                                                                                                                      |
| `lock_timeout`                | Another transaction held a lock too long; try again.                                                                                                                             |
| `privilege`                   | The undo role lacks a privilege on the table (run `sync` as the admin).                                                                                                          |
| `no_migrator` / `no_approver` | A schema step needs that connection, which could not be opened.                                                                                                                  |
| `database_error`              | The database refused the statement (for example a trigger of yours did something the undo role may not do).                                                                      |
| `journal_tampering`           | See below.                                                                                                                                                                       |

**The ABA limit.** Writes by your application are not journaled. If the application changed a value
and later set it back to exactly what the agent wrote, undo cannot tell and restores the old value
over it. Every plan states this.

### "JOURNAL TAMPERING STOPPED"

Code attached to one of the tables (a trigger, default, constraint or policy) tried to change
osevel's own records (`changes` or `ddl_log`) while the undo was running. The undo
transaction was rolled back, so nothing of it was applied. Inspect the triggers and functions on
the named tables, and who created them (`log` shows approved schema changes), before you retry.
Reading the journal cannot be detected this way; only changes to it can.

### Checking the install: doctor

```sh
osevel doctor
osevel doctor --admin
```

Without `--admin` (journal role): the verification report; tables needing attention (no primary
key, row-level security, cascades into other schemas, rewrite rules, SECURITY DEFINER functions the
agent can call); and crash recovery: changes left `pending` by a crashed server are resolved from
the database's transaction status, and stale approvals are expired or settled. If schema changes
ran at the approval gate without osevel recording them, `doctor` raises an **ALERT** and
records them as irreversible changes. Unless the server crashed at exactly that moment, someone
used the migrator password directly: treat it as leaked and rotate the passwords by re-running
`init`.

With `--admin`: the full pre-install check as the admin.

### New tables are not journaled: sync

```sh
osevel sync
```

Runs as the admin, in one transaction: attaches capture triggers and grants to tables in the
managed schemas that are not managed yet, repairs disabled or altered capture triggers, re-applies
RLS policies, refreshes the cascade closure, and lifts a cut-off when nothing unaccepted remains.
It prints each table's result and the verification report (exit code 4 if violations remain). You
need it after creating tables when event triggers are not installed, after dropping a rewrite rule
from a managed table, and to come back from a cut-off.

## OsVault

### `vault run` does not give the production secrets

Without `--env`, a run uses `development` only, never "the only environment", which might be
production. Name it: `osevel vault run --env production -- <command>`. The computer must have
been given that environment in the panel. Without `--vault`, the computer must be linked to
exactly one vault.

### A variable is missing in the command

Names that programs rely on (`PATH`, `NODE_OPTIONS` and the like) and names already set in your
environment are never given by a vault. Rename the secret, or unset the local variable.

### A short value shows unmasked

Values under 8 characters cannot be masked; the run names them. A value split between stdout and
stderr is not masked either: each stream is masked on its own.

### A locked key does not work in a request

A locked key reaches the program as a stand-in (`osv_ph_…`). The proxy puts the real key in only
on requests to the address it is locked to, and only where a credential goes: a credential
header, a credential parameter or a whole path segment. A stand-in inside a request body, in a
free-text field or sent twice is not replaced, and the request is refused. An API that wants the
key inside a JSON body cannot use a locked key.

### `npm` does not start through `vault_run` on Windows

`vault_run` runs one command without a shell. On Windows, `.cmd` files such as `npm` must be run
through `cmd.exe /c`.

### `--software-keys` is refused

With the Osevel service installed, the service holds the computer's Vault keys, and keys in a
file are refused. To drop the service's link, an administrator runs
`sudo /opt/osevel/bin/osevel vault forget --service`.

### The panel does not sign in on `http://localhost` in Safari

Safari drops `Secure` cookies on plain http. Use Chrome or Firefox for a local stack, or serve it
over https.

## OsApi

### An everyday command is held

OsApi holds calls that reveal secrets, run SQL outside OsBase, or can overwrite or delete
values. Some everyday commands do that: reading Railway variables (`railway run`,
`railway variables`), `vercel env pull`, reading Supabase API keys, Neon connection strings
through MCP. See what waits and decide:

```bash
osevel api holds
osevel api approve <hold-id>
```

The agent then sends exactly the same call again within 15 minutes. To stop being asked for one
operation, `osevel api policy allow <operation>` (a typed code; refused for operations whose loss
cannot be undone).

### A dangerous call went through without being held

OsApi sees a call only when the agent uses a key that a vault holds **locked**, inside
`osevel vault run`. Check:

- `osevel api scan` lists provider keys in `.env` files, shell profiles and CLI sign-in files.
  An agent can use those without OsApi seeing anything. Move them into a vault.
- A Railway token is a plain UUID and is not locked by itself: lock it to
  `backboard.railway.com` when you save it.
- `OSEVEL_API=watch` lets every call through and only records what would have been held.
- Deploys, jobs and code pushes are everyday changes and go through. To hold them in production:
  `osevel api policy preset production-deploys`.

### "OsApi refused this call"

The call could not be read in one plain way (for example a method override, an odd path
spelling, or a write too large to read whole). A refused call cannot be approved. Send it in a
plain form.

### `osevel api verify` exits 4

The chain of call records is broken: a line was changed or removed. Without the Osevel service,
the records are in your own folder, which a program running as you can rewrite.

## OsBox

### A server does not start

A server runs only after you accept it on this computer. `osevel box status` shows what is
accepted and what waits.

```bash
osevel box accept <name>
```

A repository's servers (`osevel.yaml`) are accepted per repository with
`osevel box repo accept <name>`. Any edit of that section asks again.

### A tool answers "held"

The server's tool list changed since you accepted it (a new description, a new tool). Look at
the change in `osevel box status`, then `osevel box accept <name> --lists`. If one of your
OsBrain rules holds the call instead, the answer says so; tool calls are not approved one by one.

### "needs sign-in"

A remote server needs one sign-in: `osevel box login <name>` (OAuth in your browser).

### "no sandbox here" on Linux

OsBox uses bubblewrap at `/usr/bin/bwrap`. Install it, or accept the server as unsandboxed
(`osevel box add … --no-sandbox`). On Linux a sandboxed server cannot have network yet: remove
its `--allow-host` hosts, or accept it as unsandboxed.

### "no sandbox on this system yet" on Windows

There is no sandbox on Windows yet. A server runs there only when added with `--no-sandbox` and
accepted that way.

### A server fails inside the sandbox

A sandboxed server reads only its own install and what you declared, and reaches only declared
hosts. Add what it needs with `--allow-read`, `--allow-write` and `--allow-host`, install it
again and accept it again. A server that starts other programs, or uses a runtime the sandbox
profile does not know, needs `--no-sandbox` for now.

### After `box install`, the server is not accepted any more

A reinstall makes a new pin. Accept it again.

## OsMemory

### A note does not appear for agents

Notes about you, imported notes, and notes that read like instructions, hold hidden characters
or point at secret paths wait for you. `osevel memory list --held` lists them; keep or drop each
in the panel (OsMemory → Waiting for you).

### A note is refused

Text with a recognisable secret is refused, and so is a masked database value. With the Osevel
service, a note that matches one of your OsVault values is refused too; after 5 such matches in
a day the service takes no notes on that computer until the next day.

### A project's memory is empty in a new folder

A project is bound to the real path of the folder with `.git` or `osevel.yaml`. A copy or a new
clone starts with an empty memory of its own. To use an existing project's memory there:
`osevel memory project link <scope>`. A window shows a code that you type back, so an agent
cannot do it for you.

### The memory tools are missing in an AI tool

OsMemory is served by the OsBox gateway. Run `osevel box connect` for that tool.

## OsBrain

### A rule for one agent does not hold its API or tool calls

Rules with `--agent` match database moves only. OsApi and OsBox moves are recorded under the
name `agent`, because the run proxy and the gateway do not know which agent runs them.

### A rule I added does not apply

With the Osevel service installed, `osevel brain rules add` without `sudo` changes only runs in
your own process, and says so. For the service: `sudo /opt/osevel/bin/osevel brain rules add …`.

### `osevel brain verify` exits 4

The decision ledger's chain is broken: a line was changed or removed.

### A key or database is missing from the list of held moves

OsBrain decides only on what passes through Osevel. `osevel brain coverage` lists the keys,
services and databases agents here can reach without it, with the step that covers each.

## With the Osevel service installed

Commands that decide a held move or change what is asked are run as root through the launcher:

```bash
sudo /opt/osevel/bin/osevel api approve <hold-id>
sudo /opt/osevel/bin/osevel brain rules remove <id>
```

Project commands run as root without the launcher are refused. If the launcher is missing, run
`sudo osevel daemon install` again; `osevel daemon doctor` checks that the service really keeps
its credentials away from your user.

## Still stuck

Check [Limitations](https://osevel.com/docs/reference/limitations/) for what each product does not do, and the
[security model](https://osevel.com/docs/security/model/#what-osevel-does-not-protect-against) for what it does not
protect against.
