
# Checks overview

Checks are the `[[check.invariant]]` and `[[check.smoke]]` entries in `agentcloud.toml`: the only tests Agent Cloud runs on a release, not your own test suite. Run them with `agc check` on your mirror. `agc ship` runs them again on a branch of production, and a failure stops the release (exit 11).

```bash runnable
agc up --detach
agc migrate
agc check
```

## Execution contract

- **Before starting:** Declare checks in `agentcloud.toml`; start the mirror.
- **Do:** Run `agc check`; read `data.results`, skipped checks included.
- **Success:** The checks passed. Empty results or skipped checks do not prove the feature.
- **If blocked:** Exit 11 means a check failed. Fix the change and rerun; edit a check only when this ship makes it obsolete.
- **Human handoff:** Changing a held check needs a person.

## Ask your agent

```text
Add Agent Cloud checks: no double bookings, one confirmation email per booking. Run them on the mirror.
```

## How it works

```mermaid
flowchart LR
  A[agc check on mirror] -->|masked data, full evidence| B{pass?}
  B -->|yes| C[agc ship]
  C --> D[rehearsal on a fresh branch of production]
  D --> E[migrations + no row lost]
  E --> F[smoke flows on new build]
  F --> G[invariants]
  G -->|pass| H[decide, then go live]
  G -->|fail| I[exit 11, production unchanged]
```

The same checks run twice: on your mirror with full evidence, then in the rehearsal (pass or fail only).

| Kind | What it is | Page |
|---|---|---|
| Invariant | SQL that returns violating rows; must return none | [Invariants](/docs/checks/invariants.md) |
| Smoke flow | HTTP steps against the running app | [Smoke flows](/docs/checks/smoke-flows.md) |
| `no existing row was deleted` | Platform check around every migration | [Safe schema changes](/docs/data/safe-schema-changes.md) |
| `sign-in checks state` | Platform check for apps on Agent Cloud sign-in | [Smoke flows](/docs/checks/smoke-flows.md) |
| Background work | Platform rehearsal run with the worker killed mid-job | [Background work](/docs/build/background-work-and-workers.md) |
| `[[verify]]` | An AI browser agent tries a feature; advisory, never blocks | [AI browser verification](/docs/checks/ai-browser-verification.md) |

**On the mirror (`agc check`).** With the mirror running, agc first applies pending migrations as `agc migrate` does (no seed), listed in `data.migrated`. A migration it can't apply or prove fails with `agc migrate`'s code. Then come the smoke flows on `127.0.0.1`, the sign-in state check, and each invariant, read-only, 30 seconds each. `unchanged` and `equal:` invariants and the row check report what that migrate proved. An app that exits mid-run fails `the app didn't restart`. Failed invariants show up to three rows, text blanked.

**In the rehearsal (`agc ship`).** Agent Cloud forks production, applies the ship's migrations proving no row was lost, starts the new build and runs the smoke flows and invariants on the unmasked branch. Only each check's name, pass or fail, and a fixed sentence reach you.
**A failing check is held.** A check that stops a release is held from then on: a later ship that removes or changes its definition goes to a person ([Held checks](/docs/checks/invariants.md#held-checks-and-fixes)).

## Reference

Exit 0 means every check passed.

| Exit | Meaning here |
|---|---|
| 11 | A check failed (`check.failed` from `agc check`, `ship.check_failed` from a ship); also `migrate.not_preserved`, `verify.failed` |
| 1 | The checks couldn't run (`mirror.not_running`, `mirror.restart_required`), or the app wasn't answering (`mirror.app_not_answering`: `agc up <name> --detach`) |

With no checks, `agc check` succeeds with `results: []`, a note to add some, and a warning that the review files this as no-checks. A ship with no checks says so in `data.warnings` of `agc ship` and `agc wait`.

## Lint warnings

`agc check` and `agc ship` put plain sentences in `data.warnings` (never a failure) about what is ignored, what weakens your checks, and what agent.cloud's review would file.

### From both `agc check` and `agc ship`

| Warning (start of the text) | Cause | Fix |
|---|---|---|
| `[[check.<kind>]] isn't a check agent.cloud runs …, so it was ignored.` | A kind other than `invariant` or `smoke`, e.g. `[[check.browser]]` | Remove it; use `[[verify]]` |
| `Check "<name>": <keys> isn't read, so it was ignored.` | A key outside `name`, `sql`, `after`, `until`, `hold`, `proves` (invariants) or `name`, `steps`, `headers`, `proves` (smoke), e.g. `replay` | Delete it |
| `Check "<name>": after = "<stem>" names no migration in this app.` (or `until`) | A typo, or no such migration yet | Use a stem from `migrations/`, without `.sql` |
| `Check "<name>": hold = "equal:<x>" names no invariant called "<x>".` | The `equal:` target is missing or misnamed | Name an existing invariant |
| `Check "<name>": hold = "<x>" isn't supported; …` | Unknown hold | Use `empty`, `unchanged` or `equal:<check>` |
| `No smoke flow tries to break your invariants under concurrency. …` | The app has invariants, but no flow has a non-`GET` step with `xN` above 1 | Add a racing write step: `"POST /api/camps/{camp.id}/bookings {…} -> 201\|409 x20"` |
| `<n> lake queries read more than they need: <file>:<line> (…), …` | A lake query is `SELECT *`, or has no `LIMIT` and no `WHERE` on a date column | Name the columns; add a `LIMIT` or a `WHERE` on the date |
| `Lake calls have no timeout (lake-no-deadline, …): <file>:<line>, …` | An app granted a lake connection has a lake client or call with no timeout or deadline | Give the client a timeout, or each call a deadline, and handle the timeout as a failure |
| `Nothing in the code deletes from this table, so it only grows: …` | A table the migrations create that no app code deletes from (tests and seeds don't count) | Delete old rows on a schedule, or `COMMENT ON TABLE <name> IS 'agc:kept: <why>'` |
| `Smoke flow "<name>" step <n> … took <ms> ms …` | A step over 1,000 ms (on the mirror, or in the rehearsal) | Fix what it waits on |
| `The checks got <n> server error(s) (5xx) from the app, and it logged no error-level line …` | A 5xx with no `"level":"error"` log line (mirror or rehearsal) | Log it as one JSON line with `"level":"error"`, the message and path |

### From `agc check` only

| Warning | Cause | Fix |
|---|---|---|
| `<app> has only its default icon, …` | The app still has its default icon | Draw `icon.svg`, set `[app] icon = "icon.svg"`, ship ([App icon](/docs/build/your-apps-icon.md)) |
| `Table <name> has no primary key: …` | A table on the mirror without one | Add one in a new migration |
| `<table>(<cols>) references <ref> with no index on it, …` | A foreign key no index leads with | Add the `CREATE INDEX` it prints, in a new migration |
| `GET <path> answered someone who isn't signed in, …` | An admin-looking route answers a non-admin with 2xx | 401 with no credentials, before reading the body; 403 to non-admins; one flow per path |
| `Copy <name> was last used on <date>, over 5 days ago: …` | A copy unused for over 5 days | Once its work shipped, `agc down <name> --delete` |
| `Migration <stem>: <col> is <type>, a binary float that can't hold money exactly. …` | A `real`, `double precision` or `float` column in any migration, named like money (`amount`, `price`, `total`, `fee`, `balance`, `tax`, `payment` and others) | Store integer minor units (`price_cents bigint`) next to a `currency text NOT NULL` column, with a new migration ([conventions](/docs/data/your-apps-postgres.md#data-modelling-conventions)) |
| `[mirror] egress_allow "*.<domain>" lets the mirror reach every host under <domain>; …` | A wildcard grant | List each `host:port` |
| `[mirror] egress_allow entry "<x>" isn't a host:port, …; it was ignored.` | A malformed grant | Write `host:port` |
| `The organization granted this app the <name> connection (<access>), but agentcloud.toml doesn't say the app needs it. …` | An owner granted a connection the manifest doesn't declare; it's still injected | Add `[connection.<name>] access = "<access>"` |
### From `agc ship` only

| Warning | Cause | Fix |
|---|---|---|
| `<file> hashes passwords itself. …` | The snapshot has code that hashes passwords | Use Agent Cloud sign-in; store no passwords |
| `agentcloud.toml has [[verify]] but it hasn’t run; …` | `[[verify]]` exists and `agc verify` never ran | Run `agc verify`, if the organization allows it |
| `Release verification ran on different code than this ship; …` | Code changed since the last `agc verify` | Run `agc verify` again |
| `[[verify]] was skipped: …` | `agc ship --from-git` never runs verify | Expected; nothing to fix |
| `The rehearsal found <n> copies of this app unused for over 5 days: …` | Copies unused for over 5 days | `agc down <name> --delete` once their work shipped |
| `The snapshot holds changes that aren’t committed, so this release has no message: …` | Uncommitted work shipped without `-m` | Pass `-m "<what the change does>"` |

A wrong-type key is `manifest.invalid` (exit 2), not a warning. All codes: [Error code catalog](/docs/reference/error-code-catalog.md).

## Errors

```json
{
  "ok": false,
  "product": "agent.cloud",
  "command": "check",
  "error": {
    "code": "manifest.invalid",
    "message": "/Users/you/camp-bookings/agentcloud.toml: sql in the 1st [[check.invariant]] is a table; it takes a string.",
    "fix": "Set sql in the 1st [[check.invariant]] in agentcloud.toml to a string, then run the command again.",
    "retryable": false,
    "docs": "agc help manifest"
  },
  "next": [
    { "cmd": "agc help manifest", "why": "what agentcloud.toml takes" },
    { "cmd": "agc doctor", "why": "check the manifest with the rest of the setup" }
  ]
}
```

## Agent notes

- `agc check` migrates but never seeds: checks must not depend on seed rows.
- When fixing a reported problem, add a check that fails without the fix; ship with `--fixes "<what was reported>"`.

## Related

- [Invariants](/docs/checks/invariants.md)
- [Smoke flows](/docs/checks/smoke-flows.md)
- [AI browser verification](/docs/checks/ai-browser-verification.md)
- [Connections](/docs/owners/connections.md)

<!-- feedback:start -->
---
Wrong, outdated or unclear? Run `agc feedback docs "checks/checks-overview: <what is wrong>" --body <file>` with the sentence quoted in the file. No code or app data is sent.
<!-- feedback:end -->
