Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

docs: plan-bound --expect in remediate examples, doctor --only verify cells, non-TTY notice note

garrytan06f6404edbd0
diff --git a/AGENTS.md b/AGENTS.md
index c1efbaa5c9..61c60b14b9 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -129,9 +129,10 @@ writing or reviewing an operation, consult `src/core/operations.ts` for the cont
- **Drive the brain to a target health score:** preview, then agree.
`gbrain doctor --remediation-plan --json` previews job steps and the
PROTECTED repair steps (each marked "requires user agreement", with its
- exact command); after the user agrees,
- `gbrain doctor --remediate --yes --include-repairs --target-score 90 --max-usd 5`
- runs the repairs (even when the score target is unreachable) and walks the
+ exact command and the `plan_hash` the approval binds); after the user agrees,
+ `gbrain doctor --remediate --yes --include-repairs --expect <plan_hash> --target-score 90 --max-usd 5`
+ (`<plan_hash>` from that `--remediation-plan --json` output; a changed plan
+ refuses with `preview_changed`, so preview and ask again) runs the repairs (even when the score target is unreachable) and walks the
dependency-ordered job plan, re-checking score between steps. The cap is
cumulative across `--resume`; a paid step that would exceed it is not
started while free steps still run. Without `--include-repairs`, repair
diff --git a/BOOTSTRAP_FOR_AGENTS.md b/BOOTSTRAP_FOR_AGENTS.md
index d5d19f4a86..807429a717 100644
--- a/BOOTSTRAP_FOR_AGENTS.md
+++ b/BOOTSTRAP_FOR_AGENTS.md
@@ -240,14 +240,14 @@ placeholder). Trust the CLI's detection over your own guesses.
|---|---|---|---|---|---|
| `interview --status` exits nonzero forever | A required answer is genuinely missing | Ask the human. Do not default it. | user (answers the question) | none | `gbrain bootstrap interview --status` |
| Render refuses with unresolved tokens | Interview incomplete or a template edit broke a token | Finish the interview; `status` names the tokens. | user | none | `gbrain bootstrap status` |
-| `verify` fails the magic-moment check | The fact never landed (keyless: the Facts fence was not written) | Re-run the write step it names; check `gbrain doctor`. | agent | none | `gbrain doctor --json` |
+| `verify` fails the magic-moment check | The fact never landed (keyless: the Facts fence was not written) | Re-run the write step it names; check `gbrain doctor`. | agent | none | `gbrain doctor --only bootstrap_last_verify --json` |
| Secret-scan block on push | A credential-shaped string in a tracked file | Fix or allowlist deliberately (`.gbrain-scan-allow`); never force. | user (decides what to allowlist) | none | the next push's scan output |
| "bootstrap already running (pid N)" | A concurrent bootstrap holds the lock | Wait or investigate that pid; the lock self-clears when stale. | agent | none | `gbrain bootstrap status` |
-| Brain tools fail with a lock error | Another live session's serve owns the database | Close the other session; sequential use is the v1 contract. | user (closes the other session) | none | `gbrain doctor --json` |
-| Hook reports "brain context unavailable" | serve not running or degraded | `gbrain doctor` names it; hooks fail open by design. | agent | none | `gbrain doctor --json` |
+| Brain tools fail with a lock error | Another live session's serve owns the database | Close the other session; sequential use is the v1 contract. | user (closes the other session) | none | `gbrain doctor --only bootstrap_serve_lock --json` |
+| Hook reports "brain context unavailable" | serve not running or degraded | `gbrain doctor` names it; hooks fail open by design. | agent | none | `gbrain doctor --only bootstrap_hooks_heartbeat --json` |
| gh answers 403 "not enabled for this session" | Cloud proxy scoping — the repo is not attached to the session | Expected in cloud; the visibility ladder falls back to git protocol. NEVER shim gh. | agent (nothing to fix) | none | none needed |
| "crontab: command not found" / cron skipped | Containers and cloud sandboxes ship without a scheduler | Expected; event-driven pushes cover it — the skip message says exactly this. | agent (nothing to fix) | none | none needed |
-| A turn shows "workspace push is FAILING" | The background push is refusing (visibility, secret-scan, or network reasons) | Run `gbrain doctor`; the banner repeats every 30 min until fixed. | agent | none | `gbrain doctor --json` |
+| A turn shows "workspace push is FAILING" | The background push is refusing (visibility, secret-scan, or network reasons) | Run `gbrain doctor`; the banner repeats every 30 min until fixed. | agent | none | `gbrain doctor --only bootstrap_push_health --json` |
## Hand off
diff --git a/INSTALL_FOR_AGENTS.md b/INSTALL_FOR_AGENTS.md
index 2cdb4851e4..ac197c7627 100644
--- a/INSTALL_FOR_AGENTS.md
+++ b/INSTALL_FOR_AGENTS.md
@@ -509,8 +509,10 @@ Verify: `gbrain integrations doctor` (after at least one is configured)
## Step 9: Verify
For memory-only installs, run the install check from the
-[first-run protocol](docs/protocol/AGENT_OPERATOR_v1.md#first-run): a read-only
-`harness_wiring` smoke check, then `remember` an install-check marker with
+[first-run protocol](docs/protocol/AGENT_OPERATOR_v1.md#first-run): the read-only
+smoke check `gbrain doctor --only harness_wiring --json` (it reads the
+registration and runs initialize, tools/list and one `recall` against it), then
+`remember` an install-check marker with
provenance `install-check`, ask the user to restart the harness, `recall` it in
the new session and `forget` it. Never save a made-up fact about the user.
Also save one user-approved generic test note or fact with
@@ -656,4 +658,10 @@ grants.
```bash
export GBRAIN_NO_ONBOARD_NUDGE=1
```
-Init + upgrade banners auto-skip in non-TTY too.
+Init and upgrade notices do not skip themselves when there is no terminal:
+non-interactive callers get the onboarding nudge, the init decision bundle and
+the post-upgrade summary as `[AGENT]` blocks (or the `notices` key under
+`--json`), and stdio MCP sessions get the post-upgrade summary once as a notice
+block. `GBRAIN_NO_ONBOARD_NUDGE=1` silences the onboarding nudges and the
+post-upgrade summary everywhere. Only the remote-brain identity banner stays
+TTY-only (`GBRAIN_BANNER=1` forces it, `GBRAIN_NO_BANNER=1` hides it).
diff --git a/docs/architecture/key-files/commands-5.md b/docs/architecture/key-files/commands-5.md
index 3e952f806b..2fd1ac6745 100644
--- a/docs/architecture/key-files/commands-5.md
+++ b/docs/architecture/key-files/commands-5.md
@@ -3,7 +3,7 @@
[Subsystem index](../KEY_FILES.md). Read only the entries relevant to your change.
Current behavior and load-bearing invariants; history belongs in Git and CHANGELOG.
-- `src/commands/repair.ts` — `gbrain repair [<kind>] [--apply] [--source <id>] [--limit <n>] [--no-embed] [--json]` and `gbrain repair --all`. Kinds `timeline` (#5567 materialize), `visibility` (#5525 tighten-only backfill) `safe-chunks` (#5050/#5247 projection-only re-seal of pages of every kind below the safe-chunk fence; `--no-embed` defers embedding to `embed --stale`), `contextual-mode` (#5621 projection-only stamp of the import-time contextual retrieval mode on pages that have none; honors `--no-embed`) `connector-checkpoints` (#5686 brain-wide cleanup of connector checkpoint rows no source can load), `orphan-bindings` (#5732 brain-wide cleanup of persistence source bindings whose source or incarnation is gone) and `embedding-effects` (#5629/#5734 settlement of stale queued and failed embedding effects: reconciled, superseded, retry_queued or blocked, reported per item in `outcomes` / `outcome_items`) and `google-file-modes` (clears group/other bits on gbrain's own files under Google source dirs outside `~/.gbrain`; filesystem only); no kind previews every kind. Dry run unless `--apply` (no prompt; `--yes` refused). `parseRepairArgs` is strict: any unknown option or a second positional refuses `invalid_params` before anything runs, and `--max-usd`/`--max-cost` name the capped route `gbrain doctor --remediate --yes --include-repairs --max-usd <n>`. Help lines come from `REPAIR_REGISTRY`; `--json` adds `paid` per kind and `paid_kinds`. Output carries the resolved scope, affected count, a capped `source:slug` sample, residual counts, request-ID / receipt-byte / re-embedding cost and capacity, and the apply command; `--json` has the same fields. Host-only: thin clients refuse via `THIN_CLIENT_REFUSED_COMMANDS`. Logic lives in `src/core/repair/`.
+- `src/commands/repair.ts` — `gbrain repair [<kind>] [--apply] [--source <id>] [--limit <n>] [--no-embed] [--json]` and `gbrain repair --all`. Kinds `timeline` (#5567 materialize), `visibility` (#5525 tighten-only backfill) `safe-chunks` (#5050/#5247 projection-only re-seal of pages of every kind below the safe-chunk fence; `--no-embed` defers embedding to `embed --stale`), `contextual-mode` (#5621 projection-only stamp of the import-time contextual retrieval mode on pages that have none; honors `--no-embed`) `connector-checkpoints` (#5686 brain-wide cleanup of connector checkpoint rows no source can load), `orphan-bindings` (#5732 brain-wide cleanup of persistence source bindings whose source or incarnation is gone) and `embedding-effects` (#5629/#5734 settlement of stale queued and failed embedding effects: reconciled, superseded, retry_queued or blocked, reported per item in `outcomes` / `outcome_items`) and `google-file-modes` (clears group/other bits on gbrain's own files under Google source dirs outside `~/.gbrain`; filesystem only); no kind previews every kind. Dry run unless `--apply` (no prompt; `--yes` refused). `parseRepairArgs` is strict: any unknown option or a second positional refuses `invalid_params` before anything runs, and `--max-usd`/`--max-cost` name the capped route `gbrain doctor --remediate --yes --include-repairs --max-usd <n> --expect <plan_hash>` (hash from `doctor --remediation-plan --json`). Help lines come from `REPAIR_REGISTRY`; `--json` adds `paid` per kind and `paid_kinds`. Output carries the resolved scope, affected count, a capped `source:slug` sample, residual counts, request-ID / receipt-byte / re-embedding cost and capacity, and the apply command; `--json` has the same fields. Host-only: thin clients refuse via `THIN_CLIENT_REFUSED_COMMANDS`. Logic lives in `src/core/repair/`.
- `src/commands/reindex.ts` — `gbrain reindex --markdown [--type PAGE_TYPE] [--limit N] [--workers N] [--dry-run] [--json] [--no-embed] [--repo PATH]`. The writer pool is sized once from the run's page target (pending, capped by `--limit`) through `resolveWorkersWithClamp`, so Postgres runs over 100 pages default to `DEFAULT_PARALLEL_WORKERS` while PGLite stays at one; `--workers` overrides and the used count is reported as `workers` in the result and JSON (pinned by `test/e2e/reindex-auto-workers-5181.test.ts`). Walks markdown pages with stale `chunker_version` (plus unstamped contextual-retrieval mode when embedding is enabled; `--no-embed` still stamps the mode of every page it re-chunks) in 100-row id-keyset batches; a failed row cannot starve later batches in the same invocation. `--type` adds a bound-parameter `pages.type = $N` scope for focused backfills such as atom pages and is rejected by reindex modes that do not consume it. Current-version chunkless healing deliberately remains owned by the native, bounded `embed --stale` path. Rows with non-null `source_path` re-import via `importFromFile`; rows without fall back to `importFromContent`. Both paths pass `forceRechunk: true` to bypass `importFromContent`'s `content_hash` short-circuit — without it the chunker version bump never reaches pages whose source content hasn't changed, AND the stripFactsFence privacy strip never applies to chunks stored without it. Wired into `src/commands/upgrade.ts:runPostUpgrade` after `apply-migrations`. The DB-only fallback (no source file on disk) does NOT pass body-only `compiled_truth` to `importFromContent` (that path re-parses with EMPTY frontmatter and OVERWRITES the page's real frontmatter/title/timeline); it `getPage`+`getTags`, reconstructs FULL markdown via `serializeMarkdown(frontmatter, compiled_truth, timeline, {type, title, tags})`, and re-imports THAT so re-chunking a DB-only page preserves everything while bumping `chunker_version`. Pinned by `test/reindex-preserve-tags.test.ts` and `test/reindex.test.ts`.
- `src/commands/repair-jsonb.ts` — `gbrain repair-jsonb [--dry-run] [--json]`: rewrites `jsonb_typeof='string'` rows in place across 8 affected columns (pages.frontmatter, raw_data.data, ingest_log.pages_updated, files.metadata, page_versions.frontmatter, subagent_messages.content_blocks, subagent_tool_executions.input, subagent_tool_executions.output). The subagent targets are `jsonPayloadOnly`: those columns can legitimately hold jsonb string scalars (persistToolExec binds a tool's pre-serialized string payload as-is), so their damage predicate additionally requires container-shaped content (`^\s*[\[{]`) that `pg_input_is_valid(..., 'jsonb')` (PG16+ floor, same as the IS JSON predicate `updateSourceConfig` relies on) actually parses — a plain-text value that merely starts with `[` or `{` is never flagged or corrupted. Targets whose table doesn't exist on the brain are skipped via `to_regclass` (brains without the subagent tables), and one target's failure is recorded on stderr while the run continues — earlier repairs are already committed and the v0_12_2 migration orchestrator JSON-parses stdout. `runDoctor`'s `jsonb_integrity` check counts damage with the same predicate over the same target list. Repairs double-encoded rows on Postgres; PGLite no-ops. Idempotent. Pinned by `test/repair-jsonb.test.ts` + `test/doctor.test.ts`.
diff --git a/docs/guides/hosted-harness-access.md b/docs/guides/hosted-harness-access.md
index 61501cf630..ef2c3dea56 100644
--- a/docs/guides/hosted-harness-access.md
+++ b/docs/guides/hosted-harness-access.md
@@ -313,7 +313,7 @@ policy history, revocations, or receipts. See
| Symptom | Next action | Who acts | Consent | Verify |
| --- | --- | --- | --- | --- |
-| PGLite is busy | Use authenticated host administration (`--admin-token-file ~/.gbrain/serve/admin-token` against the running server) or wait for the current owner to close. Never remove a live lock. | brain host | none | `gbrain doctor --json` on the host |
+| PGLite is busy | Use authenticated host administration (`--admin-token-file ~/.gbrain/serve/admin-token` against the running server) or wait for the current owner to close. Never remove a live lock. | brain host | none | `gbrain doctor --only connection --json` on the host |
| Published URL unreachable from the agent | On the host, `gbrain mcp expose --status`. A cloud agent needs `--funnel`; tailnet-only reach serves only the owner's own devices. Certificate issuance can leave tailnet health `pending` for a minute. See the [remote MCP troubleshooting table](remote-mcp.md#troubleshooting). | brain host | `egress` when switching to `--funnel` | `gbrain mcp expose --status --json` |
| Configuration conflict | Select a fresh connection name/root or inspect the changed entry; do not overwrite unrelated settings. | agent | none | re-read the harness's MCP configuration |
| `grant_conflict` | Fetch the new revision and preview again. | agent, after the user agrees | none | preview the grant again |
diff --git a/docs/guides/remote-mcp.md b/docs/guides/remote-mcp.md
index 5662b1e8a2..e6767a1170 100644
--- a/docs/guides/remote-mcp.md
+++ b/docs/guides/remote-mcp.md
@@ -433,7 +433,7 @@ check. Logs: `~/.gbrain/serve/serve.log` and `serve.err`.
| Another device cannot resolve `your-machine.your-tailnet.ts.net` | Resolution needs **MagicDNS** on the tailnet (https://login.tailscale.com/admin/dns) and "Use Tailscale DNS settings" turned on in that device's Tailscale client. Reaching the name over HTTPS additionally needs the tailnet's **HTTPS Certificates** toggle on the same page (the `tailscale_https_not_enabled` pre-check catches that on the host). | user | none | the other device resolves the name |
| Service not starting (`--status` reports the service stopped) | Read `~/.gbrain/serve/serve.err`. Typical causes: `gbrain` not on `PATH` for a login-less shell (the wrapper falls back to `type -P gbrain`; install into `~/.bun/bin` or reinstall), a key missing from `~/.gbrain/env`, or the port already taken. `launchctl print gui/$(id -u)/com.gbrain.serve` / `systemctl --user status gbrain-serve.service` show the supervisor's view. | brain host | none | `gbrain mcp expose --status --json` |
| `foreign_listener` — "Something already answers on 127.0.0.1:<port> and no expose receipt claims it. Stop it, pick another --port, or pass --no-service to only publish it. If this is a gbrain server left behind by an interrupted `gbrain mcp expose`, run `gbrain mcp expose --remove --yes` first." | **Anything** listening on `127.0.0.1:<port>` counts as occupied — an accepted TCP connect (a database, a non-HTTP service) as much as a 404 or 500 on `/health` — and no receipt claims that port. Refused during `plan`, before anything is published. Stop it, choose another `--port`, or pass `--no-service` to only publish the server you already run. A gbrain server left behind by an interrupted run is cleaned up by `gbrain mcp expose --remove --yes` (receipt-less recovery, see [`--remove`](#--remove)). | user | none | `gbrain mcp expose --status --json` |
-| `no_brain_config` (exit 1, `plan` fails) — "No brain is configured on this host (gbrain init first), so a service would only crash-loop; pass --no-service to publish a server you run yourself." | This host has no `gbrain` config (or it cannot be read), so `gbrain serve` would have nothing to open and the supervisor would restart it forever. Run `gbrain init` on this host first, then re-run; or pass `--no-service` to only publish a server you start yourself. `--dry-run` still shows the plan. | agent, after the user agrees | none | `gbrain doctor --json` |
+| `no_brain_config` (exit 1, `plan` fails) — "No brain is configured on this host (gbrain init first), so a service would only crash-loop; pass --no-service to publish a server you run yourself." | This host has no `gbrain` config (or it cannot be read), so `gbrain serve` would have nothing to open and the supervisor would restart it forever. Run `gbrain init` on this host first, then re-run; or pass `--no-service` to only publish a server you start yourself. `--dry-run` still shows the plan. | agent, after the user agrees | none | `gbrain doctor --only connection --json` |
| `pglite_lock` warn — "a live process holds this PGLite brain (pid N, …): the service cannot start until it exits" | PGLite is single-writer and a process other than gbrain's own running service holds the lock, so the freshly installed service will crash-loop until it exits. Stop that process (or let it finish), then `gbrain mcp expose --status`; for concurrent local use move to Postgres ([ENGINES.md](../ENGINES.md)). The publish itself still completes. | user | none | `gbrain mcp expose --status --json` |
| "could not read tailscale serve status" — `tailscale.publish` fails during publish (exit 1, reason `tailscale_<kind>`), `--status` (exit 1) or `--remove` (exit 1, `tailscale_serve_status_unreadable`: with a receipt, receipt and wrapper kept; without one, the service is still removed but the wrapper is kept as the corroboration the re-run needs) | `tailscale serve status --json` exited non-zero, was killed, or printed something that is not JSON. The command fails closed rather than guess: nothing is published over, removed from, or reported about a config it could not read. Run `tailscale serve status --json` by hand and apply the classified fix (operator, daemon, login), then re-run the same command. | user | none | `gbrain mcp expose --status --json` |
| An interrupted `gbrain mcp expose` (no receipt, but a handler / service / wrapper is left behind) — `gbrain mcp expose --status` reports `leftovers_without_receipt` (exit 1) naming each artifact | Run the command `--status` prints: `gbrain mcp expose --remove --yes` (add `--port N` if you published a non-default port; `--force` when only a handler stands) recovers without a receipt: it removes the service, the wrapper and the `:443` handler proxying that port, and leaves the admin token. A handler with no wrapper, unit or service next to it is left in place until you add `--force`. See [`--remove`](#--remove). | agent, after the user agrees | none | `gbrain mcp expose --status --json` |
diff --git a/docs/guides/repair.md b/docs/guides/repair.md
index 7e6dad4de3..c3901eab59 100644
--- a/docs/guides/repair.md
+++ b/docs/guides/repair.md
@@ -11,7 +11,7 @@ you pass `--apply`.
Five explicit-only kinds, `google-file-modes`, `stale-atoms`, `extractor-facts`,
`captured-facts` and `loop-facts`, run only when you name them (see [Explicit-only repair kinds](#explicit-only-repair-kinds)).
`gbrain doctor --remediation-plan` lists the same kinds as repair steps, and
-`gbrain doctor --remediate --yes --include-repairs` runs them under a budget
+`gbrain doctor --remediate --yes --include-repairs --expect <plan_hash>` runs them under a budget
(see [Run repairs through doctor](#run-repairs-through-doctor)).
**Say to your agent:** *"Doctor says some timeline history is only in the
@@ -72,7 +72,8 @@ gbrain repair --all --apply # every automatic kind in order
`--apply` you must name a kind or pass `--all`; `--yes` is refused, and so is
any other option the table below does not list, including `--max-usd`: a
refused run changes nothing. To cap paid embedding work, run the repairs
-through `gbrain doctor --remediate --yes --include-repairs --max-usd <n>`. `--all`
+through `gbrain doctor --remediate --yes --include-repairs --expect <plan_hash> --max-usd <n>`
+(`<plan_hash>` comes from `gbrain doctor --remediation-plan --json`). `--all`
runs `timeline`, then `visibility`, then `safe-chunks`, then `contextual-mode`, then `connector-checkpoints`, then `request-indexes`, then `connector-fences`, then `orphan-bindings`, then `embedding-effects`, and stops at the
first kind that stops.
The explicit-only kinds (`google-file-modes`, `stale-atoms`, `extractor-facts`) never run under
@@ -588,7 +589,7 @@ Repair steps: 2 (requires user agreement; PROTECTED, run on this host only; inde
R2. safe-chunks — 40 item(s) (~$0.0031 embeddings) [requires user agreement]
apply: gbrain repair safe-chunks --apply
-Apply everything after the user agrees: gbrain doctor --remediate --yes --include-repairs --max-usd 0.01
+Apply everything after the user agrees: gbrain doctor --remediate --yes --include-repairs --max-usd 0.01 --expect ph_3f9c2a1b7d4e5f60a1b2c3d4
Ask the user before applying any repair step.
```
@@ -670,8 +671,10 @@ walk me through it before changing anything."*
2. Preview: `gbrain doctor --remediation-plan`. Show the user the repair steps
and their estimated cost, and ask before applying.
3. After the user agrees, apply with a budget:
- `gbrain doctor --remediate --yes --include-repairs --max-usd <n>`
- (the plan prints `<n>` filled in).
+ `gbrain doctor --remediate --yes --include-repairs --max-usd <n> --expect <plan_hash>`
+ (the plan prints `<n>` and `<plan_hash>` filled in; `--remediation-plan --json`
+ reports the hash as `plan_hash`). If the plan changed since the preview, the
+ run refuses with `preview_changed` and changes nothing: preview and ask again.
4. If it stops as budget-exhausted, ask the user again, then run the printed
resume command (raise `--max-usd` only with their agreement).
5. Follow each `operator_required` instruction the run prints, and note the
@@ -682,15 +685,15 @@ walk me through it before changing anything."*
| Symptom or error text | Issue | Preview | Apply | Verify | Who acts | Consent |
| --- | --- | --- | --- | --- | --- | --- |
-| Sync `BLOCKED` with `checkpoint_validation_timeout` | #5762 | `gbrain doctor` (`persistence_request_indexes`) | `gbrain repair request-indexes --apply` when an index is missing or INVALID, then the printed `gbrain sync --source <source> --no-pull --retry-failed …` | `gbrain doctor` shows `persistence_request_indexes` ok; `gbrain sources status` shows the new `last_commit` | brain host | none |
-| Doctor `persistence_request_indexes` warns | #5762 | `gbrain repair request-indexes` | `gbrain repair request-indexes --apply` | `gbrain doctor` | brain host | none |
-| Doctor `persistence_request_growth` warns | #5751, #5762 | `gbrain doctor --json` | the printed `gbrain config set persistence.limits.<limit> <value>` | `gbrain doctor --json` (check `persistence_request_growth`) | brain host | none |
+| Sync `BLOCKED` with `checkpoint_validation_timeout` | #5762 | `gbrain doctor` (`persistence_request_indexes`) | `gbrain repair request-indexes --apply` when an index is missing or INVALID, then the printed `gbrain sync --source <source> --no-pull --retry-failed …` | `gbrain doctor --only persistence_request_indexes --json` reports `ok`; `gbrain sources status` shows the new `last_commit` | brain host | none |
+| Doctor `persistence_request_indexes` warns | #5762 | `gbrain repair request-indexes` | `gbrain repair request-indexes --apply` | `gbrain doctor --only persistence_request_indexes --json` | brain host | none |
+| Doctor `persistence_request_growth` warns | #5751, #5762 | `gbrain doctor --json` | the printed `gbrain config set persistence.limits.<limit> <value>` | `gbrain doctor --only persistence_request_growth --json` | brain host | none |
| Working-tree sync prints `legacy file(s) skipped … no contextual retrieval mode` | #5751 | `gbrain repair contextual-mode` | `gbrain repair contextual-mode --apply` | the next `gbrain sync --working-tree` no longer prints the line | brain host, after the user agrees | none |
| Working-tree sync prints `legacy file(s) skipped … not valid UTF-8` | #5751 | `find <checkout> -name '*.md' ! -exec iconv -f UTF-8 -t UTF-8 -o /dev/null {} \; -print` | re-save each listed file as UTF-8 | the next `gbrain sync --working-tree` no longer prints the line | user (re-saves the files) | none |
-| Doctor `google_file_modes` warns, or the upgrade printed `[google] Google source <id> keeps its files in <dir>, outside ~/.gbrain` | #5080 | `gbrain repair google-file-modes --source <id>` | `gbrain repair google-file-modes --source <id> --apply` | `gbrain doctor` (`google_file_modes` ok) | brain host, after the user agrees | none |
-| Recall or hot memory returns facts from gbrain's own claude-cli sessions or from pasted text; doctor `captured_facts_active` warns; the upgrade banner prints `captured_facts_active: N (explicit_kind_required; …)` | #5812, #5820 | `gbrain repair captured-facts` (add `--include-ambiguous` to include paste candidates) | `gbrain repair captured-facts --apply --expect <hash>` with the hash that preview printed | `gbrain doctor` (`captured_facts_active` ok) | brain host, after the user agrees | `destructive` (quarantines facts) |
-| A finished promise still shows on entity cards and in recall after its loop was closed; doctor `loop_facts_drift` warns; the upgrade banner prints `loop_facts_drift: N (explicit_kind_required; …)` | #5869 | `gbrain repair loop-facts` | `gbrain repair loop-facts --apply --expect <hash>` | `gbrain doctor` (`loop_facts_drift` ok) | brain host, after the user agrees | `destructive` (retires facts) |
-| `gbrain upgrade` refuses with `requires Bun >=<floor>` (exit 78), or doctor `self_upgrade_health` says `Auto-upgrade to <target> held` | #5855 | `bun --version` | `bun upgrade`, then `gbrain upgrade` ([Bun floor](upgrades-auto-update.md#bun-floor)) | `gbrain --version` shows the target; `gbrain doctor` (`self_upgrade_health` ok) | user | `persistent_install` |
+| Doctor `google_file_modes` warns, or the upgrade printed `[google] Google source <id> keeps its files in <dir>, outside ~/.gbrain` | #5080 | `gbrain repair google-file-modes --source <id>` | `gbrain repair google-file-modes --source <id> --apply` | `gbrain doctor --only google_file_modes --json` (`google_file_modes` ok) | brain host, after the user agrees | none |
+| Recall or hot memory returns facts from gbrain's own claude-cli sessions or from pasted text; doctor `captured_facts_active` warns; the upgrade banner prints `captured_facts_active: N (explicit_kind_required; …)` | #5812, #5820 | `gbrain repair captured-facts` (add `--include-ambiguous` to include paste candidates) | `gbrain repair captured-facts --apply --expect <hash>` with the hash that preview printed | `gbrain doctor --only captured_facts_active --json` (`captured_facts_active` ok) | brain host, after the user agrees | `destructive` (quarantines facts) |
+| A finished promise still shows on entity cards and in recall after its loop was closed; doctor `loop_facts_drift` warns; the upgrade banner prints `loop_facts_drift: N (explicit_kind_required; …)` | #5869 | `gbrain repair loop-facts` | `gbrain repair loop-facts --apply --expect <hash>` | `gbrain doctor --only loop_facts_drift --json` (`loop_facts_drift` ok) | brain host, after the user agrees | `destructive` (retires facts) |
+| `gbrain upgrade` refuses with `requires Bun >=<floor>` (exit 78), or doctor `self_upgrade_health` says `Auto-upgrade to <target> held` | #5855 | `bun --version` | `bun upgrade`, then `gbrain upgrade` ([Bun floor](upgrades-auto-update.md#bun-floor)) | `gbrain --version` shows the target; `gbrain doctor --only self_upgrade_health --json` (`self_upgrade_health` ok) | user | `persistent_install` |
**Say to your agent:** *"After the upgrade, preview the captured-facts and
loop-facts repairs and tell me what each would expire before applying
@@ -798,7 +801,7 @@ Then recover what doctor names, in this order (skip a step whose check is ok):
| Symptom or error text | Issue | Preview | Apply | Verify | Who acts | Consent |
| --- | --- | --- | --- | --- | --- | --- |
-| `gbrain upgrade` said the upgrade failed, or migrations ran twice | #5693 | `gbrain apply-migrations --list` | `gbrain apply-migrations --yes` | `gbrain doctor` (`minions_migration` ok) | agent, after the user agrees | none |
+| `gbrain upgrade` said the upgrade failed, or migrations ran twice | #5693 | `gbrain apply-migrations --list` | `gbrain apply-migrations --yes` | `gbrain doctor --only minions_migration --json` (`minions_migration` ok) | agent, after the user agrees | none |
| `another apply-migrations is running (host …, pid …)` | #5693 | `gbrain doctor` | wait, then `gbrain apply-migrations --yes` | `gbrain apply-migrations --list` | agent | none |
| doctor `orphan_persistence_bindings`; a re-added source fails with `writer_coordinator_required` | #5732 | `gbrain repair orphan-bindings` | `gbrain repair orphan-bindings --apply` | `gbrain doctor` | brain host, after the user agrees | none |
| doctor `stale_embedding_effects`; `writer_not_quiesced` names an embedding effect | #5629, #5734 | `gbrain repair embedding-effects --source <id>` | `gbrain repair embedding-effects --source <id> --apply` | `gbrain doctor` (pending until the owner run commits a `retry_queued` effect) | brain host, after the user agrees | none |
@@ -868,7 +871,7 @@ Each effect ends in exactly one outcome; no obligation is dropped without one:
`retry_queued` is not success: doctor keeps the effect pending until the
owner's run commits it. The preview marks retries as paid work; through
-`gbrain doctor --remediate --yes --include-repairs --max-usd <n>`, the estimate
+`gbrain doctor --remediate --yes --include-repairs --expect <plan_hash> --max-usd <n>`, the estimate
covers the whole retry budget each grant authorizes. A resumed run replays the
grant it already made instead of granting another cycle. A signature-mismatched
vector is never reconciled; it is re-embedded.
diff --git a/docs/guides/troubleshooting.md b/docs/guides/troubleshooting.md
index ebf1111ed0..8c8a8bf853 100644
--- a/docs/guides/troubleshooting.md
+++ b/docs/guides/troubleshooting.md
@@ -15,18 +15,18 @@
| A gbrain call failed with a code you don't recognize | follow `fix.next` ([protocol](../protocol/AGENT_OPERATOR_v1.md)); `gbrain errors <code>` | agent | as the fix's `consent` | the fix's `verify` |
| A command exited 3 (`confirmation_required`) | relay `user_message`; run `fix.command` only after the user agrees | agent, after the user agrees | the payload's `effects` | the fix's `verify` |
| [Database unreachable or `GBRAIN_DB_ACCESS <reason>`](#database-unreachable) | `gbrain engine status --probe`, then `gbrain db-repair` (diagnose); `gbrain db-repair --yes` applies safe fixes | agent; `--yes` after the user agrees | none to diagnose; `--apply-rewrites` rewrites the config URL (undoable) | `gbrain engine status --probe --json` |
-| [PGLite `RuntimeError: Aborted()` at startup](#pglite-aborted) | automatic repair on the next command; else `gbrain pglite-repair --dry-run`, then `gbrain pglite-repair --yes` | agent; `--yes` after the user agrees | `destructive` (a WAL backup is kept and the restore command printed) | `gbrain doctor --json` |
-| [`expected N dimensions, not M` on import](#embedding-dimensions) | `gbrain doctor` prints the exact `gbrain config set …` or `gbrain migrate embeddings --to <provider:model>` command | agent, after the user agrees | `migrate embeddings`: `paid`, needs the brain's writer lock | `gbrain doctor --json` (check `embeddings`) |
-| [Keyword-only recall; the user wants semantic search](#embedding-dimensions) | the readiness fix: `gbrain init --force --embedding-model <provider:model> --path <brain path>` (keeps pages and facts) | agent, after the user agrees | `credentials`, `paid`; needs the brain's writer lock | `gbrain doctor --json` (check `embeddings`) |
-| [Doctor residue (`timeline_history`, `derived_visibility`, `safe_index_pending`)](#doctor-residue) | preview `gbrain doctor --remediation-plan --json` or `gbrain repair`; then `gbrain repair <kind> --apply` | brain host, after the user agrees | `destructive` (rewrites derived rows) | `gbrain doctor --json` |
-| Low health score | preview `gbrain doctor --remediation-plan --json`; then `gbrain doctor --remediate --yes --target-score 90 --max-usd 5` | agent, after the user agrees | `paid`; `destructive` with `--include-repairs` | `gbrain doctor --json` |
-| [A Google or GitHub item is held (`connector_held_items`)](#held-connector-items) | `gbrain sources status <id>`, fix the cause, then `gbrain sources retry-held <id>` and `gbrain sync --source <id>` | agent, after the user agrees | `egress` (fetches from the provider again) | `gbrain sources status <id> --json` |
+| [PGLite `RuntimeError: Aborted()` at startup](#pglite-aborted) | automatic repair on the next command; else `gbrain pglite-repair --dry-run`, then `gbrain pglite-repair --yes` | agent; `--yes` after the user agrees | `destructive` (a WAL backup is kept and the restore command printed) | `gbrain doctor --only connection --json` |
+| [`expected N dimensions, not M` on import](#embedding-dimensions) | `gbrain doctor` prints the exact `gbrain config set …` or `gbrain migrate embeddings --to <provider:model>` command | agent, after the user agrees | `migrate embeddings`: `paid`, needs the brain's writer lock | `gbrain doctor --only embeddings,embedding_width_consistency --json` |
+| [Keyword-only recall; the user wants semantic search](#embedding-dimensions) | the readiness fix: `gbrain init --force --embedding-model <provider:model> --path <brain path>` (keeps pages and facts) | agent, after the user agrees | `credentials`, `paid`; needs the brain's writer lock | `gbrain doctor --only embeddings --json` |
+| [Doctor residue (`timeline_history`, `derived_visibility`, `safe_index_pending`)](#doctor-residue) | preview `gbrain doctor --remediation-plan --json` or `gbrain repair`; then `gbrain repair <kind> --apply` | brain host, after the user agrees | `destructive` (rewrites derived rows) | `gbrain doctor --only timeline_history,derived_visibility,safe_index_pending --json` |
+| Low health score | preview `gbrain doctor --remediation-plan --json`; then `gbrain doctor --remediate --yes --target-score 90 --max-usd 5` | agent, after the user agrees | `paid`; `destructive` with `--include-repairs` (approve with `--expect <plan_hash>` from the preview) | `gbrain doctor --json` |
+| [A Google or GitHub item is held (`connector_held_items`)](#held-connector-items) | `gbrain sources status <id>`, fix the cause, then `gbrain sources retry-held <id>` and `gbrain sync --source <id>` | agent, after the user agrees | `egress` (fetches from the provider again) | `gbrain doctor --only connector_held_items --json` |
| [A write was refused with a named reason](#write-refused) | the reason's recovery in [write refusal reasons](write-refusals.md) | as the refusal's `fix` | as the refusal's `fix` | the refusal's `verify` |
-| [Managed sync blocked with `checkpoint_validation_timeout`](#checkpoint-validation-timeout) | `gbrain repair request-indexes --apply` when an index is missing or INVALID, then the printed `gbrain sync --source <id> --no-pull --retry-failed …` | brain host | none | `gbrain doctor --json` |
-| [`queue_capacity`, `persistence_capacity` or `persistence_request_growth`](#write-capacity) | run the printed `gbrain config set persistence.limits.<limit> <value>` | brain host | none | `gbrain doctor --json` |
-| [`dream_paid_loop`, or dream keeps skipping one transcript](#dream-paid-loop) | fix the cause, then `gbrain dream reset-key --list` and `gbrain dream reset-key '<key>'` | agent, after the user agrees | `paid` (the key is retried) | `gbrain doctor --json` |
-| [Search answers look keyword-only on a large Postgres brain](#hybrid-search-returns-only-keyword-hits) | read doctor's `vector_plan`; run the index command it prints | brain host | none | `gbrain doctor --json` (check `vector_plan`) |
-| A second `gbrain serve` cannot open the brain | the readiness `harness_wiring` fix: every session shares one `gbrain serve --http` | user | `persistent_install`, `credentials` | `gbrain doctor --json` (check `harness_wiring`) |
+| [Managed sync blocked with `checkpoint_validation_timeout`](#checkpoint-validation-timeout) | `gbrain repair request-indexes --apply` when an index is missing or INVALID, then the printed `gbrain sync --source <id> --no-pull --retry-failed …` | brain host | none | `gbrain doctor --only persistence_request_indexes --json` |
+| [`queue_capacity`, `persistence_capacity` or `persistence_request_growth`](#write-capacity) | run the printed `gbrain config set persistence.limits.<limit> <value>` | brain host | none | `gbrain doctor --only persistence_capacity,persistence_request_growth --json` |
+| [`dream_paid_loop`, or dream keeps skipping one transcript](#dream-paid-loop) | fix the cause, then `gbrain dream reset-key --list` and `gbrain dream reset-key '<key>'` | agent, after the user agrees | `paid` (the key is retried) | `gbrain doctor --only dream_paid_loop --json` |
+| [Search answers look keyword-only on a large Postgres brain](#hybrid-search-returns-only-keyword-hits) | read doctor's `vector_plan`; run the index command it prints | brain host | none | `gbrain doctor --only vector_plan --json` |
+| A second `gbrain serve` cannot open the brain | the readiness `harness_wiring` fix: every session shares one `gbrain serve --http` | user | `persistent_install`, `credentials` | `gbrain doctor --only harness_wiring --json` |
| A tool the fix names is missing after a serve recovered | restart the gbrain MCP server in the harness, or start a new session ([why](../protocol/AGENT_OPERATOR_v1.md#tool-catalog-changes-toolslist_changed)) | user | none | list the tools again |
| A command waits on stdin with no terminal | close stdin (`</dev/null`) or set `GBRAIN_NON_INTERACTIVE=1`; prompts then decline | agent | none | re-run the read-only part of the command |
| [An outdated build (brainstorm `judge_failed`, lost tags, Windows `ENOTFOUND`)](#outdated-build) | `gbrain upgrade`, then the steps in [recover after upgrading](repair.md#recover-after-upgrading-to-this-release) | agent, after the user agrees | `persistent_install` when it rewrites services | `gbrain --version`, then `gbrain doctor --json` |
diff --git a/docs/guides/write-refusals.md b/docs/guides/write-refusals.md
index 9b382d4db4..c63fbfb52a 100644
--- a/docs/guides/write-refusals.md
+++ b/docs/guides/write-refusals.md
@@ -62,7 +62,7 @@ of making a duplicate.
| <a id="migrations_running"></a>`migrations_running` | `migrations_running` (exit 75) | `gbrain apply-migrations` (or the post-upgrade step of `gbrain upgrade`) found another runner holding the brain's orchestration lock and stopped before touching the migration ledger, so migrations never run twice in parallel. The message names the holder's host and pid. A holder that died is taken over automatically on the next run. `gbrain upgrade` reports this as `Migrations: running`, not as a failed upgrade. | Wait for the other run to finish; `gbrain doctor` shows migration progress. Then `gbrain apply-migrations --yes` confirms everything is applied. |
| <a id="writer_deactivate"></a>`writer_deactivate` blockers | `writer_not_quiesced`, `writer_admin_locked`, `writer_admin_state_changed`, `writer_lock_unavailable` | `gbrain sources writer deactivate` found pending work (a queued, running or recovering write, a topology change or effect that is not settled, a held connector item, or a live connector or maintenance lease), the writer admin lock, a changed admin state, or a local process holding a worktree lock. Nothing changed. The suggestion names each blocker and its exit. | Run `gbrain sources writer deactivate --dry-run` for the full list, run each named exit (`gbrain cancel-write-request <request_id>`, `gbrain sync --source <id> --no-pull --retry-failed`, `gbrain repair embedding-effects --source <id>`, `gbrain sources writer retry-effects <source> --request-id <id> --dry-run`, `gbrain sources writer unlock`, `gbrain sources retry-held <id>`), then deactivate again with a fresh `--expected-state` from `gbrain sources writer status --json`. See the [deactivate runbook](../architecture/topologies.md#deactivate-runbook). |
| <a id="extract-timeline-refused"></a>timeline extract refused | the printed code, usually `writer_coordinator_required` | `gbrain extract timeline --source db` (or a timeline-only `gbrain extract timeline` on a managed brain) could not write a page's timeline rows. It prints `refused: <code>; nothing written; existing timeline rows are untouched` per page, a summary of written versus refused, and exits 1. The rows import already stored for each page stay as they were. | `gbrain extract --stale` (add `--source-id <id>` when you scoped the run) publishes links and missing timeline rows on the managed path. If it refuses too, follow the row for the printed code. |
-| unknown option (repair) | `invalid_params` | `gbrain repair` refuses any option it does not list, so a mistyped flag or `--max-usd` never runs a repair silently without it. | Fix the option (`gbrain repair --help`). To cap paid repair work, run `gbrain doctor --remediate --yes --include-repairs --max-usd <n>`. |
+| unknown option (repair) | `invalid_params` | `gbrain repair` refuses any option it does not list, so a mistyped flag or `--max-usd` never runs a repair silently without it. | Fix the option (`gbrain repair --help`). To cap paid repair work, preview with `gbrain doctor --remediation-plan --json` and, after the user agrees, run `gbrain doctor --remediate --yes --include-repairs --expect <plan_hash> --max-usd <n>`. |
| <a id="colon_slug_windows_write_through"></a>`colon_slug_windows_write_through` | `colon_slug_windows_write_through` | A page slug such as `calendar:abc` is valid, but its canonical file name would contain `:`, which Windows cannot store (it names an alternate data stream). On Windows, a write that would publish that file is refused before admission, and `gbrain sync` skips each such file with this reason instead of failing the run. Database-only writes of the same slug (no repo configured, `sync.write_through` off, an unbound source, or a [read-only mirror](multi-source-brains.md#read-only-mirror-sources) source and pages created while it was one) still succeed, and macOS and Linux are unchanged. | Use a slug without `:` (the suggestion names one), or write the page from a macOS or Linux host that owns the source. For a skipped sync file, rename it without `:` on a macOS or Linux checkout, commit, then run `gbrain sync --source <source> --no-pull` on the Windows host. |
| <a id="embedding_auth_failed"></a>`embedding_auth_failed` | `embedding_auth_failed` | The embedding provider rejected the configured key (HTTP 401 or 403). Printed once per process on stderr, naming the key source in effect: an environment variable (for example `OPENAI_API_KEY`, which wins over the config key) or the config key in `~/.gbrain/config.json`. No key or part of one is printed. | Environment key in effect but the config key is right: remove the variable from the environment of the process that reported it (shell profile, `~/.gbrain/.env`, or a daemon's service definition) and restart that process. Environment key intended: replace it with a valid key, restart, and run `gbrain config unset openai_api_key` (or the matching key). Config key in effect: `gbrain config set openai_api_key <valid key>`. Then `gbrain embed --stale` embeds what was saved meanwhile. `gbrain doctor` (`embedding_key_source`) shows the key source in doctor's own environment. |
| <a id="managed_pull_skipped"></a>`managed_pull_skipped` (cycle warn); doctor `sync_freshness` "upstream unknown" or "upstream N commit(s) ahead" | `managed_pull_skipped` | A managed brain never runs `git pull` inside a cycle: Git pull needs an explicit drained maintenance window, so an explicit `gbrain sync` without `--no-pull` is refused with `writer_coordinator_required`. An unattended cycle asked to pull (autopilot passes `pull: true`, `gbrain dream --pull`) instead syncs the checkout as it is and reports it: the sync phase result carries `details.upstream_refresh` (`pulled`, `failed`, `skipped_managed` or `not_requested`), and when the checkout tracks an upstream the phase is `warn` with `details.warning` (`code`, `cause`, `fix`, `docs`). Every sync also records the checkout's last upstream observation (the upstream commit, when it was last fetched or pushed, and how many upstream commits the synced commit lacks) in the source row. Doctor `sync_freshness` reports that separately from the local projection: a source with a `remote_url` whose observation is missing or older than 24 hours is "upstream unknown", and any source whose observation saw upstream commits it has not synced is "behind"; neither is reported fresh. `details.upstream_unknown_count` and `details.upstream_behind_count` count them. | `gbrain sources refresh <source>` (the printed `fix` fills in the source). It drains writes to the source's checkout, fast-forwards it to its upstream and runs the managed sync for every source bound to that checkout; see [worktree refresh refusals](#worktree-refresh-refusals) for what it can refuse. On a brain that is not managed, `gbrain sync --source <source>` pulls and records the observation. |
diff --git a/docs/memorable-agents.md b/docs/memorable-agents.md
index f92534c133..44dab3f24c 100644
--- a/docs/memorable-agents.md
+++ b/docs/memorable-agents.md
@@ -216,12 +216,12 @@ cannot empty is not one they can trust.
| Something asks you to choose an embedding model, provider, or dimensions | You are in gbrain's own initialization, not Memorable's setup | Back out; run `memorable init` | agent | none | `memorable doctor` |
| `memorable init gbrain` cannot connect | gbrain is not initialized on this machine | Run `memorable init` (standalone). It is a complete, supported backend | agent, after the user agrees | none | `memorable doctor` |
| `stored WITHOUT an embedding` on stderr | The extraction API could not return a vector | The procedure is stored and recall still works on exact + lexical. `memorable doctor` prints why | agent | none | `memorable doctor` |
-| `record` says no session receipt found | The gbrain relay is off, or this harness has no capture lane (capture: Claude Code + Codex at session end, OpenClaw per compaction) | Enable it with `gbrain config set integrations.memorable.enabled true` (a HUMAN must accept the disclosure — agents relay the command, or append `--yes` only when the human already consented), or use `memorable ingest -` with your own trace | user (a human must opt in) | `egress` | `gbrain doctor --json` |
-| Relay stays off even after `memorable enable` | `memorable enable` flips gbrain's config flag, but gbrain's own disclosure consent is separate and can only be granted through gbrain | Run `gbrain config set integrations.memorable.enabled true` and accept the disclosure; `gbrain doctor` names this state (`disclosure_missing`) | user | `egress` | `gbrain doctor --json` |
+| `record` says no session receipt found | The gbrain relay is off, or this harness has no capture lane (capture: Claude Code + Codex at session end, OpenClaw per compaction) | Enable it with `gbrain config set integrations.memorable.enabled true` (a HUMAN must accept the disclosure — agents relay the command, or append `--yes` only when the human already consented), or use `memorable ingest -` with your own trace | user (a human must opt in) | `egress` | `gbrain doctor --only memorable_relay_health --json` |
+| Relay stays off even after `memorable enable` | `memorable enable` flips gbrain's config flag, but gbrain's own disclosure consent is separate and can only be granted through gbrain | Run `gbrain config set integrations.memorable.enabled true` and accept the disclosure; `gbrain doctor` names this state (`disclosure_missing`) | user | `egress` | `gbrain doctor --only memorable_relay_health --json` |
| A consent error on write | The human has not opted in | `memorable enable`. Never work around a consent refusal | user | `egress` | `memorable doctor` |
-| OpenClaw relays rejected with `no_decisive_steps` | OpenClaw capture is name-only for now (no tool arguments) and the extraction API refuses traces with nothing replayable | Expected until argument capture lands; `gbrain doctor` reports it as ok-with-note (`expected_openclaw_rejection`) so the ladder stays meaningful for real failures. The note is deferred, never a mask: on a host that also wires codex, a codex hook that never fired still warns first (`codex_hooks_never_fired`) | agent (nothing to fix) | none | `gbrain doctor --json` |
-| Codex hook wired but nothing ever recorded | Codex hooks fail SILENTLY when their config.toml trust entry is stale (e.g. the SessionEnd groups were reordered) | Re-run `gbrain bootstrap hooks --harness codex` to re-trust; `gbrain doctor` warns (`codex_hooks_never_fired`) | agent, after the user agrees | `persistent_install` | `gbrain doctor --json` |
-| Commands hang, then time out against the brain | Something else holds gbrain's single-writer PGLite lock — often a long-running process like a viewer or `gbrain serve` | `cat <data-dir>/.gbrain-lock/lock` names the holder's PID and subcommand. Stop that process; the lock releases. A live holder is deliberately never stolen, because stealing a live lock corrupts the data directory | user | none | `gbrain doctor --json` |
+| OpenClaw relays rejected with `no_decisive_steps` | OpenClaw capture is name-only for now (no tool arguments) and the extraction API refuses traces with nothing replayable | Expected until argument capture lands; `gbrain doctor` reports it as ok-with-note (`expected_openclaw_rejection`) so the ladder stays meaningful for real failures. The note is deferred, never a mask: on a host that also wires codex, a codex hook that never fired still warns first (`codex_hooks_never_fired`) | agent (nothing to fix) | none | `gbrain doctor --only memorable_relay_health --json` |
+| Codex hook wired but nothing ever recorded | Codex hooks fail SILENTLY when their config.toml trust entry is stale (e.g. the SessionEnd groups were reordered) | Re-run `gbrain bootstrap hooks --harness codex` to re-trust; `gbrain doctor` warns (`codex_hooks_never_fired`) | agent, after the user agrees | `persistent_install` | `gbrain doctor --only memorable_relay_health --json` |
+| Commands hang, then time out against the brain | Something else holds gbrain's single-writer PGLite lock — often a long-running process like a viewer or `gbrain serve` | `cat <data-dir>/.gbrain-lock/lock` names the holder's PID and subcommand. Stop that process; the lock releases. A live holder is deliberately never stolen, because stealing a live lock corrupts the data directory | user | none | `gbrain doctor --only connection --json` |
`memorable doctor` checks every integration point at once and prints a support
bundle; run it before reporting anything as broken.
diff --git a/docs/tutorials/connect-coding-agent.md b/docs/tutorials/connect-coding-agent.md
index bc68d6ed89..44c252dd43 100644
--- a/docs/tutorials/connect-coding-agent.md
+++ b/docs/tutorials/connect-coding-agent.md
@@ -249,13 +249,13 @@ configuration does not delete memory or revoke credentials.
| Symptom | Next step | Who acts | Consent | Verify |
| --- | --- | --- | --- | --- |
-| PGLite busy | Close the current owner before opening another process. Never delete a live lock. | user | none | `gbrain doctor --json` |
+| PGLite busy | Close the current owner before opening another process. Never delete a live lock. | user | none | `gbrain doctor --only connection --json` |
| Wrong or empty brain | Inspect root, engine, brain, and source routing; do not initialize over existing memory. | agent | none | `gbrain engine status --json` |
| Only seven tools visible | Expected for the verbs surface; use `recall` and `remember` rather than classic tool names. | agent | none | the harness's tool list |
| Hosted read works but write fails | Inspect issued/current scopes, operation grants, source access, and write fences. | brain host | none | the token's scopes in the client list |
| Credential delivery interrupted | Resume delivery on the host with the existing client ID. | brain host | `credentials` | the client list |
| Server checks pass, new conversation fails | Reload the client, confirm native instruction activation, and observe the actual GBrain call. | user (reloads the client) | none | a `recall` in a new conversation |
-| Optional embeddings unavailable | Continue keyless or explicitly configure the capability; do not silently spend. | agent, after the user agrees | `credentials`, `paid` to enable embeddings | `gbrain doctor --json` |
+| Optional embeddings unavailable | Continue keyless or explicitly configure the capability; do not silently spend. | agent, after the user agrees | `credentials`, `paid` to enable embeddings | `gbrain doctor --only embeddings --json` |
As of **2026-09-10**, local CLI and HTTP tests establish the server behavior
described in [validation evidence](../guides/harness-validation.md).
diff --git a/skills/maintain/SKILL.md b/skills/maintain/SKILL.md
index 86c06155df..92b14d1937 100644
--- a/skills/maintain/SKILL.md
+++ b/skills/maintain/SKILL.md
@@ -75,8 +75,8 @@ and ask before applying anything:
```bash
gbrain doctor --remediation-plan --json # preview: job steps + repair steps
# Show the user the repair steps (each "requires user agreement") and the cost.
-# Only after the user agrees:
-gbrain doctor --remediate --yes --include-repairs --target-score 90 --max-usd 5
+# Only after the user agrees (plan_hash from the preview binds the approval):
+gbrain doctor --remediate --yes --include-repairs --expect <plan_hash> --target-score 90 --max-usd 5
```
`--remediation-plan` prints a dependency-ordered list of job steps (sync before
@@ -490,7 +490,7 @@ This creates an audit trail for brain health over time.
Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) for any gbrain error `code`, exit code, `[AGENT]` block or notice block. Specific to this skill:
-- `gbrain doctor --remediate` steps marked "requires user agreement" (PROTECTED repairs, paid steps): show the plan and cost, and run with `--yes --include-repairs --max-usd <n>` only after the user agrees. A step that would exceed the cap is not started.
+- `gbrain doctor --remediate` steps marked "requires user agreement" (PROTECTED repairs, paid steps): show the plan and cost, and run with `--yes --include-repairs --expect <plan_hash> --max-usd <n>` (the hash from `--remediation-plan --json`) only after the user agrees; `preview_changed` means the plan moved, so preview and ask again. A step that would exceed the cap is not started.
- A finding classified `operator_required`: follow its instruction or relay it to the brain host's operator. `consent_required`: ask the user.
- A writer-coordination refusal (`writer_coordinator_required`, `writer_not_quiesced`, `recovery_required`): inspect `gbrain sources writer status` and hand the blocked recovery to the operator; never claim a checkout or delete a lock.
- `gbrain dream` stops on a budget (exit 11): run the printed `resume_command` within the agreed budget.
diff --git a/skills/migrations/v0.60.11.0.md b/skills/migrations/v0.60.11.0.md
index f56399e9cf..c6b40fb362 100644
--- a/skills/migrations/v0.60.11.0.md
+++ b/skills/migrations/v0.60.11.0.md
@@ -84,9 +84,12 @@ user's agreement first.
5. **Apply only what the user agreed to**, with their cap:
```bash
- gbrain doctor --remediate --yes --include-repairs --max-usd <n>
+ gbrain doctor --remediate --yes --include-repairs --expect <plan_hash> --max-usd <n>
```
+ `<plan_hash>` is the `plan_hash` from `gbrain doctor --remediation-plan --json`
+ (gbrain v0.60.38.0 and later bind repair approval to the previewed plan).
+
Pass `--no-embed` if they want no paid embeddings (then `gbrain embed
--stale` later). If the run stops as budget-exhausted, ask again before
running the printed resume command; the cap is cumulative across resumes.
diff --git a/src/cli/help/doctor.ts b/src/cli/help/doctor.ts
index 6c1b6719be..a1100a7415 100644
--- a/src/cli/help/doctor.ts
+++ b/src/cli/help/doctor.ts
@@ -5,12 +5,14 @@ export const help: CliHelpSpec = {
summary: 'Check brain health; preview and run remediation.',
usage: [
'gbrain doctor [--fast] [--json] [--fix [--dry-run]] [--scope=brain] [--source <id>] [--no-migrate] [--locks]',
+ 'gbrain doctor --only <check>[,<check>…] [--json]',
'gbrain doctor --remediation-plan [--target-score <n>] [--no-embed] [--json]',
'gbrain doctor --remediate [--yes [--expect <plan_hash>]] [--include-repairs] [--max-usd <n>] [--target-score <n>]',
' [--max-jobs <n>] [--no-embed] [--dry-run] [--resume [<plan_hash>]] [--json]',
].join('\n'),
flags: [
{ name: '--json', type: 'boolean', desc: 'Print one JSON document (checks, score, findings) on stdout.' },
+ { name: '--only', type: 'string', desc: 'Read-only: run just the named checks (comma-separated or repeated; no migrations). The usual fix.verify. An unknown name exits 2 with the valid list.' },
{ name: '--fast', type: 'boolean', desc: 'Skip database checks; filesystem and config checks only.' },
{ name: '--fix', type: 'boolean', desc: 'Apply the local fixes doctor knows (skill files, stale locks); pair with --dry-run to preview.' },
{ name: '--dry-run', type: 'boolean', desc: 'Preview --fix or --remediate without changing anything.' },
@@ -36,6 +38,7 @@ export const help: CliHelpSpec = {
],
examples: [
'gbrain doctor --json',
+ 'gbrain doctor --only harness_wiring --json',
'gbrain doctor --remediation-plan --json',
'gbrain doctor --remediate --yes --max-usd 5 --target-score 90',
'gbrain doctor --remediate --yes --include-repairs --expect <plan_hash> --max-usd 5',
diff --git a/src/commands/repair.ts b/src/commands/repair.ts
index b3bf591817..1a4f7cebd1 100644
--- a/src/commands/repair.ts
+++ b/src/commands/repair.ts
@@ -54,7 +54,8 @@ Options:
--json Machine-readable output with a stable shape.
Any other option is refused. There is no --max-usd here: to cap paid embedding
-work, run the repairs through gbrain doctor --remediate --yes --include-repairs --max-usd <n>.
+work, preview gbrain doctor --remediation-plan --json and, after the user agrees, run
+gbrain doctor --remediate --yes --include-repairs --max-usd <n> --expect <plan_hash>.
With no kind, previews every kind. Run it on the brain host.`;
const BOOLEAN_FLAGS = new Set(['--apply', '--all', '--json', '--no-embed', '--include-ambiguous']);
@@ -75,7 +76,7 @@ export function parseRepairArgs(args: string[]): RepairArgs {
if (flag === '--max-usd' || flag === '--max-cost') {
const cap = equal < 0 ? args[i + 1] : token.slice(equal + 1);
throw new OperationError('invalid_params', `${flag} is not a gbrain repair option; the repair did not run.`,
- `To cap paid repair work, run: gbrain doctor --remediate --yes --include-repairs --max-usd ${cap && !cap.startsWith('-') ? cap : '<n>'}`);
+ `To cap paid repair work, preview gbrain doctor --remediation-plan --json, then after the user agrees run: gbrain doctor --remediate --yes --include-repairs --max-usd ${cap && !cap.startsWith('-') ? cap : '<n>'} --expect <plan_hash> (plan_hash from the preview)`);
}
if (BOOLEAN_FLAGS.has(flag)) {
if (equal >= 0) throw new OperationError('invalid_params', `${flag} does not accept a value.`);
@@ -151,7 +152,7 @@ export async function runRepairCommand(engine: BrainEngine, args: string[]): Pro
console.log(`Scope: brain ${scope.brain_id}; sources ${scope.source_ids.join(', ') || '(none)'}`);
for (const result of results) console.log(human(result));
if (!apply && paidKinds.length) console.log(`Kinds that may queue paid embeddings: ${paidKinds.join(', ')} (pass --no-embed to skip; `
- + 'page-write kinds are re-embedded by their publication either way; cap spend with gbrain doctor --remediate --yes --include-repairs --max-usd <n>).');
+ + 'page-write kinds are re-embedded by their publication either way; cap spend with gbrain doctor --remediate --yes --include-repairs --max-usd <n> --expect <plan_hash> from gbrain doctor --remediation-plan --json).');
if (explicitKindsNotRun.length) console.log(`Explicit-only kinds (not run without their name; preview each): ${explicitKindsNotRun.map(n => n.preview_command).join('; ')}`);
}
if (results.some(r => r.stopped)) setCliExitVerdict(1);