
# Well-Architected review

Agent Cloud reviews every app 5 minutes after each release goes live, daily while it has a live release, and when the owner presses **Review again** on the app's **Findings** page. Each finding has a pillar, a risk, and a fix: a prompt for the agent or a setting only the person can change. `agc review` returns the open ones.

```bash
agc review
```

## Ask your agent

```text
Run agc review and fix whatever you can. Tell me about anything I need to change myself.
```

The person sees fixed findings move to the **Resolved** tab of the app's **Findings** page after the next review.

## Steps

```bash runnable
agc review
```

```json
{
  "ok": true,
  "product": "agent.cloud",
  "command": "review",
  "data": {
    "app": "camp-bookings",
    "reviewed_at": "2026-10-20T14:08:00Z",
    "release": "v12",
    "open": { "high": 1, "medium": 0, "low": 0 },
    "findings": [
      { "key": "3f9a…", "rule": "no-checks", "subject": "release", "pillar": "reliability", "risk": "high",
        "title": "Releases go live with nothing checked", "why": "…",
        "fix": { "kind": "prompt", "prompt": "Fix finding 3f9a… from agc review: releases go live with no checks. …" },
        "new": true, "fixed_by": "agent" },
      { "key": "8b21…", "rule": "blob-in-postgres", "subject": "receipts", "pillar": "cost", "risk": "info",
        "title": "receipts may hold files people upload", "why": "…",
        "fix": { "kind": "prompt", "prompt": "…" },
        "new": false, "fixed_by": "agent" }
    ]
  },
  "next": [
    { "cmd": "agc check", "why": "after fixing \"Releases go live with nothing checked\" (data.findings[0].fix.prompt says how), prove it on your mirror" },
    { "cmd": "agc ship", "why": "release the fix; the next review marks it fixed" }
  ]
}
```

Then fix, check and ship:

```bash
agc check
agc ship
```

**Dismissing (owner, console).** On the app's **Findings** page (open findings split into **Architecture** and **Security**), press **Dismiss** on a finding, type why it doesn't apply (required, up to 300 characters), and press **Dismiss** again. It moves to the **Dismissed** list with your name and reason, drops out of `agc review`, and isn't filed as Work. **Bring it back** undoes it.

## How it works

The review reads only what Agent Cloud already runs: the app's settings, the live release's checks and source, the schema's shape (tables, keys, indexes and row estimates, never rows), and traffic, errors and restarts. Rules are deterministic. A rule whose input is missing is skipped.

Findings are keyed by app, rule and subject, so consecutive reviews diff into new, still open, and fixed. A finding gone from the next review is stored as fixed. Control also files findings as Work items: for the hosted builder when it's on, otherwise as the owner's items on the app's page. The next review closes each one it ran and no longer finds.

Fix prompts come only from templates filled with platform-derived fields. Request paths and table names are reduced to plain segments (`<x>` for anything else) and named only as the finding's subject, never inside the instruction text. Agents get the finding without its evidence; the owner's console shows the evidence.

| Rule | Pillar | Fires when | Fix |
|---|---|---|---|
| `cross-origin-writes` | security | The release's source uses cookie sessions and nothing checks Origin or Sec-Fetch-Site (risk `info` where the edge already refuses cross-origin writes) | prompt |
| `cross-origin-exception` | security | Each path in `[service.web] cross_origin` | prompt |
| `signin-mode` | security | `[auth] provider = "edge"` on a target with no sign-in, or the app signs people in itself on a target that has its own | prompt |
| `no-checks` | reliability | Autonomy isn't `watch` and the live release declares no checks | prompt |
| `oom` / `restarts` | reliability | Any OOM kill or restart in 7 days | prompt |
| `server-errors` | reliability | Over 1% 5xx in 24 hours (at least 50 requests); high above 5% | prompt |
| `slow-route` | performance | Up to 3 routes with p95 over 1,000 ms (high over 3,000 ms), at least 20 requests in 24 hours | prompt |
| `admin-route-answers` | security | Admin-looking paths (`/admin`, `/internal`, `/debug`, `/manage`, `/dashboard`, optionally under `/api`) answered 2xx in 7 days | prompt |
| `silent-errors` | operations | 5 or more 5xx in 7 days and no error-level log line | prompt |
| `no-primary-key` | reliability | A table without a primary key | prompt |
| `unindexed-fk` | performance | A foreign key with no index starting with its columns (medium above about 10,000 rows) | prompt |
| `blob-in-postgres` | cost | A `bytea` or encoded-text column whose name, or its table's, suggests uploaded files (risk `info`) | prompt |
| `idle-copy` | cost | A mirror unused for over 7 days (goes to the owner, who can delete it) | prompt |

**Apps with a lake connection** (`ducklake` or `flightsql`) also get these rules; other apps skip them with "no lake connection":

| Rule | Fires when | Risk |
|---|---|---|
| `lake-unbounded-query` | `SELECT *` to the lake, or a lake query with neither `LIMIT` nor a `WHERE` on a partition column | medium |
| `lake-no-deadline` | A lake call with no timeout on its client or the call | medium |
| `lake-no-port` | A lake address with no explicit port | low |
| `lake-driver-in-bun` | A GizmoSQL or ADBC driver loaded in a process that runs on bun | high |
| `lake-at-boot` | A lake read at module load, in startup, or in the health check's handler | medium |
| `local-lake-files` | `.duckdb` or `.parquet` files written, or an `ATTACH`, in the app's code | medium |
| `unguarded-schedule` | A scheduled job with no `AGC_RUN == "rehearsal"` guard | high |
| `no-status-route` | No `/api/status` that reports peak memory and lake timings | low |
| `unbounded-table` | A table whose estimated rows rose over 30 days of reviews and never fell, with no `DELETE`, `TRUNCATE` or partition drop for it in the code | medium |
| `memory-near-limit` | Peak memory over 80% of the service's limit in 7 days (high over 95%) | medium |

**Design review.** A model also reads the app's code, schema shape, `docs/data-design.md` and `docs/port-plan.md` (when they exist) and its organization's Context, then returns up to 5 findings under rule `design`, each on one topic (`data-model`, `lake-use`, `scheduling`, `failure-handling`, `limits`, `security-boundary`, `cost`) and never above `medium`. It runs after the app's first release, after a release that changed migrations, routes or server code, and when the owner presses **Review again**, at most once a day per app. The **Findings** page header names the model when it ran.

## Reference

| Finding field | Meaning |
|---|---|
| `key` | Stable id: app, rule and subject |
| `risk` | `high`, `medium`, `low`, or `info` (not counted in `open`) |
| `fix.kind` | `prompt` (`fixed_by: "agent"`) or `action` (`fixed_by: "person"`) |
| `new` | First seen in this review |

## Errors

| Code | Exit | Cause | Fix |
|---|---|---|---|
| `review.unavailable` | 1 | Observability didn't answer | Try again in a minute; the app is unaffected |

```json
{
  "ok": false, "product": "agent.cloud", "command": "review",
  "error": { "code": "review.unavailable", "message": "The review is not available right now.",
             "fix": "Try again in a minute; the app itself is unaffected.", "retryable": false },
  "next": [{ "cmd": "agc status", "why": "see the current state before retrying" }]
}
```

With no review yet, `reviewed_at` is null and `next` says one runs after the next release.

## Limits

- One review at a time per app. The daily pick checks hourly and reviews each app with a live release whose last review is over a day old, or ran under a rule set other than today's. The rule set is a hash of the rules file plus the design review's own version, so a changed rule reaches every live app within a day.
- Filing as Work: at most 5 new items per app per review and 10 per app per day; the rest wait for the next review. `high` and `medium` file at once, one item per finding; `low` findings roll into one item per app per week (from Monday 00:00 UTC); `info` is never filed.

## Agent notes

- Don't invent a fix for a `person` finding. Tell them its `fix.label`; instances and autonomy are console settings.
- For `server-errors`, find the cause with `agc logs --level error` and `agc capsule`.
- A finding stays open until the next review after your fix ships, which runs 5 minutes after the release goes live.

## Related

- [Incidents](/docs/ship/after-release-watch-and-rollback.md#incidents)
- [Checks overview](/docs/checks/checks-overview.md)
- [Same-site neighbours, CSRF and webhooks](/docs/security/web-security-for-the-console-and-apps.md#same-site-neighbours-and-webhooks)
- [Autonomy and budget](/docs/owners/release-governance.md#autonomy-and-budget)

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