Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
docs(repair): wave 5 recovery runbook, refusal codes and explicit-only repair kinds
garrytan28e7929987fd
diff --git a/AGENTS.md b/AGENTS.mdindex 0db4332934..99ba758b07 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -132,7 +132,7 @@ writing or reviewing an operation, consult `src/core/operations.ts` for the contcumulative across `--resume`; a paid step that would exceed it is notstarted while free steps still run. Without `--include-repairs`, repairsteps are listed as skipped. `--json` classifies each finding `cleared`,- `pending`, `consent_required`, `operator_required` or `unsupported`.+ `pending`, `consent_required`, `operator_required`, `explicit_kind_required` or `unsupported`.Stale extraction uses source-scoped database pages, including DB-onlypages; it does not require a repository sync first. Empty brains (noentity pages) or unconfigured embedding keys hit a `max_reachable_score`diff --git a/docs/guides/bootstrap.md b/docs/guides/bootstrap.mdindex 459afd8a8b..08c422f2f5 100644--- a/docs/guides/bootstrap.md+++ b/docs/guides/bootstrap.md@@ -39,6 +39,20 @@ follows is `BOOTSTRAP_FOR_AGENTS.md` at the repo root, fetched at the| Private GitHub repo | your account, created by `bootstrap repo` (or an empty repo you made yourself, adopted) | privacy verified via API || Machine receipt | `~/.gbrain/bootstrap/receipt.json` | uninstall is keyed to it |+**What session start shows:** the SessionStart hook prints your+allowlisted MEMORY.md sections, push status and hook health, plus a warm+context pack. It never shows another session's activity. Releases before+v0.60.27.0 printed a `Last session activity` line from the newest session+buffer on the machine, whichever agent or session wrote it (#5558). That line+and the stop-hook buffer behind it are gone, and there is deliberately no+opt-in to bring them back. Buffers an older release left in+`~/.gbrain/transcripts/live/` are deleted by the stop hook once they are 7+days old; you can delete them now. If you set `GBRAIN_HOOKS=0` as a+workaround, remove it from the environment the harness starts from (shell+profile or service) after upgrading the `gbrain` the harness runs, then+restart the harness: `GBRAIN_HOOKS=0` also turns off capture, session+persistence and crash recovery.+**What does NOT run:** anything while the harness is closed. Session-triggeredschedules fire at turn/session boundaries only. True 24/7 operation is what ahosted brain provides — this is the honest desktop contract.diff --git a/docs/guides/concurrent-writes.md b/docs/guides/concurrent-writes.mdindex 3e0ac9e7df..321370c939 100644--- a/docs/guides/concurrent-writes.md+++ b/docs/guides/concurrent-writes.md@@ -311,6 +311,15 @@ bytes, revisions, chunks and embedding signatures remain unchanged. Managedwithdrawals retain a versioned target manifest for the mirror, Git and embeddingworkers; each worker checkpoints one affected page at a time.+A withdrawal mirror or Git scan no longer parks on a page whose file is a+sync-skip metafile (`RESOLVER.md`, which carries the managed durability block+by design) or whose file holds an uncoordinated local edit (#5396): the+withdrawal is recorded in the database, the page is listed in the effect's+`data.skipped` with reason `metafile` or `file_database_drift`, and the+request's Git and embedding effects proceed. Reconcile a `file_database_drift`+page as described in+[Repair a file/database disagreement](#repair-a-filedatabase-disagreement).+Stop older mutation workers before upgrading the owner and restarting work. Olderbinaries do not understand the target manifest and must not share the brain withthe upgraded worker. This is a quiesced upgrade, not a mixed-version rollout.diff --git a/docs/guides/repair.md b/docs/guides/repair.mdindex b22d268f67..7d7020269b 100644--- a/docs/guides/repair.md+++ b/docs/guides/repair.md@@ -6,6 +6,8 @@ visibility, pages indexed before the safe-chunk fence, pages importedwithout a contextual retrieval mode, and connector checkpoint rows no sourcecan load. `gbrain repair` fixes those five kinds. Every run is a previewunless you pass `--apply`.+Two explicit-only kinds, `stale-atoms` and `extractor-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(see [Run repairs through doctor](#run-repairs-through-doctor)).@@ -18,7 +20,7 @@ agent runs `gbrain repair` to preview and, after you agree,## Preview first```bash-gbrain repair # preview every kind+gbrain repair # preview every automatic kindgbrain repair timeline # preview one kindgbrain repair --json # machine-readable preview```@@ -60,7 +62,7 @@ gbrain repair safe-chunks --applygbrain repair safe-chunks --apply --no-embed # re-seal text now, embed latergbrain repair contextual-mode --applygbrain repair request-indexes --apply-gbrain repair --all --apply # every kind in order+gbrain repair --all --apply # every automatic kind in order````--apply` writes without a prompt, so review the preview first. With@@ -70,12 +72,22 @@ refused run changes nothing. To cap paid embedding work, run the repairsthrough `gbrain doctor --remediate --yes --include-repairs --max-usd <n>`. `--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 thefirst kind that stops.+The explicit-only kinds (`stale-atoms`, `extractor-facts`) never run under+`--all`; it lists each with its preview command and still exits 0 when they+are the only findings left. `gbrain repair` with no kind does the same for a+preview. With `--json` the list is `explicit_kinds[]` (`kind`, `code:+"explicit_kind_required"`, `preview_command`, `docs`).Each item is re-checked against the page's current state just before it iswritten, and the write is bound to the revision it just read, so an edit madeafter planning is kept and repaired too. An item that no longer needs therepair, or whose page changes during the write, is counted as `skipped` and-left for the next run. Nothing is deleted.+left for the next run. No kind deletes data except `stale-atoms`, which+soft-deletes the atoms it retires (they stay recoverable through the+`restore_page` operation for 72 hours, and a later extraction that produces+a retired atom again restores it). See [Stale atoms](#stale-atoms).+`extractor-facts` only restores previewed facts (it clears `expired_at` and+gives each a fresh row number); it never deletes or rewrites a page.| Option | Effect || --- | --- |@@ -83,8 +95,10 @@ left for the next run. Nothing is deleted.| `--source <id>` | Limit the run to one active source. The default is every active (non-archived) source. An unknown or archived id is refused. || `--limit <n>` | Repair at most `n` items per kind in this run (a positive integer; with `--all`, up to `n` for each kind). Rerun the same command to continue. || `--no-embed` | `safe-chunks` and `contextual-mode`: skip the embedding provider. Run `gbrain embed --stale` later. `timeline` and `visibility` pages are re-embedded by their publication either way. |-| `--all` | Run every kind in order. |-| `--json` | Print `{ scope, mode, results[], paid_kinds }`, one result per kind with `paid`, `affected`, `sample`, `residuals`, `cost`, `capacity`, `resumed_from`, `applied`, `skipped`, `complete`, `stopped` and `apply_command`. |+| `--all` | Run every automatic kind in order. Explicit-only kinds are listed with their preview command, never run. |+| `--expect <hash>` | Explicit-only kinds: apply exactly the set the preview printed under this hash. Required with `--apply` for `stale-atoms` and `extractor-facts`. |+| `--include-ambiguous` | `extractor-facts` only: widen the hashed set to `ambiguous` facts. Pass it to both the preview and the apply. See [Extractor facts](#extractor-facts). |+| `--json` | Print `{ scope, mode, results[], paid_kinds }`, one result per kind with `paid`, `affected`, `sample`, `residuals`, `cost`, `capacity`, `resumed_from`, `applied`, `skipped`, `complete`, `stopped` and `apply_command`, plus `explicit_kinds[]` when the run skipped explicit-only kinds. |The command exits 1 when a run stops early (capacity, a pending write, or aheld writer). A `--limit` batch that leaves work behind exits 0, so scripts@@ -103,6 +117,8 @@ should also check `results[].complete`.| `embedding-effects` | `stale_embedding_effects` | Settles stale queued and failed embedding effects of committed writes, which block receipt compaction and activation: `reconciled` when current vectors pass the effect verifier, `superseded` when the page was deleted or a newer revision owns its own effect, `retry_queued` for the owner (paid; a used-up retry allowance gets one new bounded cycle per explicit apply). See [stale queued embedding effects](#stale-queued-embedding-effects). | `blocked` effects, counted by reason (`owner_unavailable`, `embedding_disabled`, `embedding_unconfigured`, `projection_pending`, `no_replacement_obligation`). || `safe-chunks` | `safe_index_pending` (also `contextual_retrieval_coverage`, `details.unsealed_pages`) | Rebuilds the chunks of markdown and code pages indexed before the safe-chunk fence, which remote and MCP search withhold. It rebuilds projections only: no page write, no new page version and no request ID. Vectors whose embedding input did not change are kept; the rest are embedded unless you pass `--no-embed` or no embedding model is configured. | `code_without_source_path`: code pages with no recorded file to re-chunk. `unsupported_page_kind`: other page kinds, such as images. Their importer re-seals them. || `contextual-mode` | `contextual_retrieval_coverage` (pages with no recorded mode) | Stamps the contextual retrieval mode on markdown pages imported without one (for example by a large `--no-embed` sync or a connector source before this release), exactly as a fresh import of the page would: the page, source and brain settings decide, and the per-chunk synopsis tier lands at the free title tier. It rebuilds projections only: no page write, no new page version and no request ID. A page whose stored vectors already match the stamped convention keeps them and queues no re-embedding; a page whose embedding input changes has only those vectors cleared and is re-embedded once, unless you pass `--no-embed`. | `unsealed_projection`: pages whose chunks lag their text; `gbrain embed --stale` or `safe-chunks` seals them first, and the next run stamps them. `embed_skip`: pages marked to skip embedding keep their stored vectors and are not stamped. |+| `stale-atoms` (explicit-only) | `atom_provenance_drift` | Retires, by soft delete, live page-bound atoms whose source page is gone (`origin_gone`), or whose source page was edited and its current text already extracted (`origin_changed`). Preview-bound: `--apply --expect <hash>` retires exactly the previewed set. See [Stale atoms](#stale-atoms). | Atoms with `imported_from`, transcript (file-bound) atoms, and atoms of an edited page that was not extracted again yet (the `extract_atoms` backlog). |+| `extractor-facts` (explicit-only) | `extractor_facts_expired` | Restores conversation-extractor facts the pre-v0.60.11.0 canonical projection expired (#5731). Restores `evidenced` facts by default, `ambiguous` ones only with `--include-ambiguous`; database-only. See [Extractor facts](#extractor-facts). | `excluded:<reason>` facts: page missing or deleted, superseded, withdrawn, an active duplicate, or a duplicate candidate. |Timeline rows that an earlier version of a page produced and its current textno longer has are removals, not history, so `timeline` neither counts nor@@ -203,6 +219,63 @@ one more year, the same value `persistence_capacity` prints) and the check tore-run. Request IDs are permanent, so raising the limit is the intervention;nothing is evicted.+<a id="projection-drain"></a>+### Drain queued text projections++After an upgrade that re-queues text projections (for example the 0.51+protocol activation), search and code results stay incomplete until every+queued Markdown and code page is rebuilt (#5401). Doctor+`text_projection_readiness` warns while any visible page is pending.++The upgraded resident owner (`gbrain serve` or autopilot) drains the queue on+its own: each pass rebuilds up to 100 pages and starts no new page after+250 ms, and takes 2 pages while writes are waiting. A page whose rebuild fails+is retried after 30 seconds.++To drain now:++```bash+gbrain projections drain # until every page queued at the start was tried once+gbrain projections drain --limit 5000+gbrain projections drain --json # {rebuilt, superseded, failed: [{source_id, slug, reason}], remaining}+```++| Exit | Meaning |+| --- | --- |+| 0 | Nothing tried failed. "The projection backlog is empty." appears only when `remaining` is 0. |+| 1 | Some pages failed. Each prints `failed: <source>/<slug>: <reason>` and a `next:` action; the pages stay queued. |+| 2 | Did not run: bad usage (`invalid_params`), or [`projection_owner_resident`](#projection-owner-resident). |++On Postgres the drain is safe while `gbrain serve` runs: each page is rebuilt+under its page lock with a revision recheck, so a page is rebuilt once whichever+process gets there first. On PGLite a resident process holds the datastore, so+the drain refuses before opening it (also for a mounted PGLite brain selected+with `--brain`).++Verify: `gbrain doctor` shows `text_projection_readiness` ok.++<a id="embedding-key-source"></a>+### Provider key source++An exported provider key (for example `OPENAI_API_KEY`) wins over the matching+config key (`openai_api_key` in `~/.gbrain/config.json`) (#5137). When both are+set and differ, every gbrain command except `gbrain hook` prints one warning+per process naming the variable, the config key and which one is in effect.+No key or part of one is ever printed.++- To use the config key: remove the variable from the environment of the+ process that printed the warning (shell profile, `~/.gbrain/.env`, or for a+ daemon its service definition) and restart that process.+- If the environment key is intended: `gbrain config unset openai_api_key`+ (or the matching key), which also stops the warning.++Doctor `embedding_key_source` reports the same plus where the embedding key in+effect comes from. It sees only the environment `gbrain doctor` runs in: a+daemon has its own and reports a mismatch in its log, with the startup warning+or `embedding_auth_failed` on the first rejected embedding+([write refusals](write-refusals.md#embedding_auth_failed)). After fixing a+rejected key, `gbrain embed --stale` embeds what was saved meanwhile.+<a id="connector-held-items"></a>### Connector held items@@ -238,6 +311,90 @@ Do not delete binding rows by hand: the repair rechecks, in the samestatement, that the binding is still orphaned and that no pending writerequest uses it.+### Stale atoms++`gbrain repair stale-atoms` (explicit-only, #5770) retires atoms that drifted+before managed re-extraction learned to retire them. It lists live atoms bound+to a source page (`source_slug`) in two classes:++- `origin_gone`: the source page is missing or deleted;+- `origin_changed`: the source page was edited, and its current text has+ already been extracted (a managed brain records a completed extraction at+ the page's current hash; an unmanaged brain has an atom carrying it). Atoms+ of an edited page that was not extracted again yet are the extract_atoms+ backlog, not stale, and are not listed.++It never lists an atom with `imported_from` or a transcript (file-bound)+atom.++```bash+gbrain repair stale-atoms --source <id> # preview: every atom with its class, and a hash+gbrain repair stale-atoms --source <id> --apply --expect <hash>+```++The apply retires exactly the previewed set. Each atom is checked again first;+one whose revision, class, source page or completion evidence changed since+the preview reports `changed_since_preview` and is kept. Retiring is a soft+delete stamped with `retired_by: stale-atoms`: on a managed brain each atom is+one coordinated request (its file is removed through the page deletion path),+on an unmanaged brain a direct soft delete. Retiring also marks the source+page for extraction again, so restoring a deleted page and running+`extract_atoms` brings its atoms back. `--apply` without `--expect` refuses+with the preview and apply commands; a stale hash refuses with+[`preview_changed`](#preview-changed). An apply under a different `--source`+than the preview also refuses with `preview_changed`. Doctor+`atom_provenance_drift` names this command when drift crosses its warn+threshold.++### Extractor facts++Before v0.60.11.0, every managed write to a conversation page without a+Facts fence expired all of that page's conversation-extractor facts+(`expired_at` set, `row_num` cleared), and recall stopped returning them.+`gbrain repair extractor-facts` (#5731) restores them. It is explicit-only and+preview-bound.++```bash+gbrain doctor # extractor_facts_expired+gbrain repair extractor-facts # preview: every candidate with its class+gbrain repair extractor-facts --apply --expect <hash>+gbrain doctor+```++Each candidate gets one class:++| Class | Meaning | Restored |+| --- | --- | --- |+| `evidenced` | A committed write of the page completed in the same transaction that expired the fact (`completed_at = expired_at`), and its consumer was older than v0.60.11.0 (no version stamp, or an older one). | By `--apply --expect <hash>` |+| `ambiguous` | Unmanaged brain (no receipts); no committed write at the exact expiry instant; the expiring write came from a fixed consumer (a fence row may legitimately have taken the fact's position); or the page has carried fence facts. | Only with `--include-ambiguous` and that preview's hash |+| `excluded:<reason>` | Page missing or deleted, superseded (`superseded_by`), withdrawn (`forget`), an active fact with the same text and entity already on the page, or an earlier candidate with the same text and entity. | Never |++Ambiguous rows are restored as the hashed set; `--limit` is the only+narrowing. Run `gbrain repair extractor-facts --include-ambiguous`, review+the list, then `gbrain repair extractor-facts --include-ambiguous --apply+--expect <hash>`.++The apply restores exactly the previewed set. A fact that changed since the+preview (edited, withdrawn, superseded, its page deleted or recreated)+reports `changed_since_preview` and stays expired; `preview_changed` means+the hash names no saved preview, the preview is older than 7 days, or the+apply's `--source` / `--include-ambiguous` differs from the preview's.+Restored facts get a fresh row number above the page's rows. Nothing is+written to any page or file. On a managed brain each page publishes one+database-only `managed_maintenance_restore_extractor_facts` request; a+rerun after a crash replays it and restores no new candidate.++Receipts are retained (compaction keeps `completed_at`), so a history older+than the 30-day receipt retention is still evidenced. Not recoverable+automatically: facts whose extractor batch was since replaced by a+re-extraction (the old rows are gone), and facts on unmanaged brains without+`--include-ambiguous`. On PGLite the same-transaction rule holds only to the+millisecond (PGLite's clock resolution).++The preview warns, naming the host, when a consumer older than this release+published writes after `writer_version_cutoff`: an old consumer expires+restored facts again. Upgrade and restart it first.+## ResumeRuns are resumable. After each page commits, the position is saved under the@@ -320,6 +477,13 @@ Apply everything after the user agrees: gbrain doctor --remediate --yes --includAsk the user before applying any repair step.```+The plan never includes an explicit-only kind as a repair step. It prints them+in an `Explicit-only repairs` block instead, one line per kind with its+read-only preview command (`stale-atoms: gbrain repair stale-atoms`), and+`--json` lists them as `explicit_repairs[]` (`kind`, `code:+"explicit_kind_required"`, `preview_command`, `docs`). Run each by name after+the user agrees (see [Explicit-only repair kinds](#explicit-only-repair-kinds)).+`gbrain doctor --remediate --yes` runs job steps only. Repair steps run onlywhen you also pass `--include-repairs`, which records the user's agreement;without it they are listed as `N repair steps skipped (user agreement required):@@ -370,11 +534,12 @@ With `--json`, the result adds `repairs[]` (one entry per repair step, with| `pending` | A repairable finding remains: its step stopped, was refused by the budget, left items behind, or the check could not run. || `consent_required` | A repairable finding whose step was skipped for lack of `--include-repairs`; `command` applies it. || `operator_required` | Needs a named manual action on the brain host (`instruction`), for example raising a journal limit, retrying a parked effect, or quarantining self-captures. |+| `explicit_kind_required` | Only an explicit-only kind clears it (for example `atom_provenance_drift` and `stale-atoms`); `command` is that kind's read-only preview. It never runs under `--remediate` and does not fail the exit status. || `unsupported` | No command can clear it yet; it is reported so it is never hidden (a stale queued embedding effect). |Exit status: `0` when no automatically repairable finding remains and no step-failed, even if operator-required or unsupported findings remain (they are-listed); `1` when a repairable finding remains, a step failed, or the budget+failed, even if operator-required, explicit-only or unsupported findings+remain (they are listed); `1` when a repairable finding remains, a step failed, or the budgetran out; `2` when the score target is unreachable and there was no repair stepto run, or a resume was refused. `healthy` is true only when every wave checkis clean; `repairs_completed` counts the repair steps that finished.@@ -412,7 +577,69 @@ as one line each, for exampleA line that says `Unknown:` means the check could not run; it is not a cleanresult. Ask the brain host's operator to run the steps above.-### Symptoms from the lifecycle fixes in this release+<a id="fix-wave-5"></a>+### Upgrading to v0.60.27.0 (fix wave 5)++**Say to your agent:** *"We upgraded gbrain to v0.60.27.0. Restart everything+that runs it, then walk me through what doctor finds, in order, before+changing anything."*++Most wave 5 fixes take effect only in a process that runs the new binary, so+restart first. `gbrain sources writer status --json` lists, in+`writer_versions[]`, the latest version each host and principal was seen+writing with in the retained requests. That is history, not proof: an idle+older `gbrain serve` never shows up there. Restart in this order:++1. Stop autopilot and workers (`gbrain autopilot --status` names the job;+ `gbrain jobs work` or your supervisor for workers).+2. Stop each resident `gbrain serve`: HTTP services through their service+ manager, and harness-owned stdio servers by quitting the harness.+3. Upgrade each host: `gbrain upgrade`.+4. Run `gbrain --version` through each launcher's own binary path (the path in+ the service definition, the harness MCP command, the hook commands) and+ confirm it prints `0.60.27.0`.+5. Restart services, harnesses, workers and autopilot.+6. Make one write from each host, then confirm a fresh `last_seen` for that+ host in `gbrain sources writer status --json` (`writer_versions[]`).++Then recover what doctor names, in this order (skip a step whose check is ok):++1. `gbrain doctor`.+2. Legacy jobs (`legacy_job_authority`): see+ [Legacy job authority](#legacy-job-authority).+3. Projections (`text_projection_readiness`): `gbrain projections drain`+ (Postgres, or PGLite with no resident); on PGLite with a resident, let it+ drain or stop, drain and restart it. See+ [Drain queued text projections](#projection-drain).+4. Stale atoms (`atom_provenance_drift`): `gbrain repair stale-atoms --source <id>`,+ then after the user agrees `gbrain repair stale-atoms --source <id> --apply --expect <hash>`.+5. Extractor facts (`extractor_facts_expired`): `gbrain repair extractor-facts`,+ then after the user agrees `gbrain repair extractor-facts --apply --expect <hash>`+ (add `--include-ambiguous` to both for ambiguous facts). See+ [Extractor facts](#extractor-facts).+6. `gbrain doctor` again, then `gbrain doctor --remediation-plan` for the+ automatic kinds.++| Symptom | Check or code | Issue | Preview | Apply | Verify |+| --- | --- | --- | --- | --- | --- |+| synthesize fails every run; `POST /ingest` 409 (was 500); workers refuse to start with "legacy jobs have missing or unsupported authority" | `legacy_job_authority` / `permission_denied` ([legacy job authority](#legacy-job-authority)) | #5157, #5114 | stop `gbrain serve`, autopilot and workers; `gbrain jobs cancel <active id>`; `gbrain jobs authorize-legacy --select "status=waiting\|delayed\|waiting-children\|paused"` | `gbrain jobs authorize-legacy --select "<same filter>" --expect <hash> --yes`, then restart | `gbrain doctor` shows `legacy_job_authority` ok; `/ingest` returns 202 |+| Search returns atoms quoting text a page no longer has, or atoms of deleted pages | doctor `atom_provenance_drift` | #5770 | `gbrain repair stale-atoms --source <id>` | `gbrain repair stale-atoms --source <id> --apply --expect <hash>` | `gbrain doctor` (`atom_provenance_drift` drops by the retired count) |+| `sources add`, `claim`, `rebind`, `archive`, `remove`, clone, reclone or `sources writer transfer` on a repo with more than ~10k files fails with "The verified source manifest exceeds the 1 MiB administration metadata bound" | `request_too_large` | #5790 | none: upgrade and restart every writer host and resident `gbrain serve` | Re-run the failed command (with the same `--request-id` if you kept it) | `gbrain sources writer status --json` shows the source bound, and its `manifest_digest` is set |+| A stdio agent bound with `GBRAIN_SOURCE` (or `.gbrain-source`) gets `permission_denied` naming the binding when it passes `source_id` | `permission_denied` (hint starts "This connection is bound to source …") | #5081 | `gbrain sources list` (the source must show `federated`, not `isolated` or `unset`) | `gbrain sources federate <id>` on the brain host | Repeat the read with `source_id: "<id>"`; it returns only that source's rows. See [explicit reads from a bound agent connection](multi-source-brains.md#explicit-reads-from-a-bound-agent-connection) |+| A new session's start-up context showed another session's text (`Last session activity: …`) | none | #5558 | none | Upgrade the `gbrain` each harness runs its hooks with and restart the harness. If you set `GBRAIN_HOOKS=0` as a workaround, remove it from the environment the harness starts from (shell profile or service) and restart the harness again | A new session shows no `Last session activity` line, and `gbrain doctor` reports `bootstrap_hooks_heartbeat` again after a few turns (capture and session persistence are back) |+| `connect --harness codex\|claude-code\|opencode --install` stored the bearer token inline in the harness config without telling you | receipt `token_storage: "inline"` | #5775 | On the brain host: `gbrain mcp admin invalidate-tokens <client_id> --url <mcp_url> --admin-token-file <owner-admin-token-file> --json` (only if the config file was exposed) | `gbrain mcp admin invalidate-tokens <client_id> --yes --if-version <revision> --url <mcp_url> --admin-token-file <owner-admin-token-file> --json`, then `gbrain connect <mcp_url> --harness <harness> --credentials-file <handoff> --install --fresh-token`, then reload the harness | The new receipt prints `token_storage`, `config_path`, `renew_command` and `if_exposed`, and the harness answers a memory round trip |+| A second brain's autopilot replaced the first one's job, logs interleave in `~/.gbrain/autopilot.log`, or `gbrain autopilot --status --json` shows `job.needs_reinstall: "legacy_shared_job"` (or `"wrapper_missing"` after moving a brain); install refuses with `autopilot_job_owned_by_other_brain` | `gbrain autopilot --status --json` (`job.*`) / `autopilot_job_owned_by_other_brain` | #5195 | `GBRAIN_HOME=<brain parent> gbrain autopilot --status --json` | `GBRAIN_HOME=<brain parent> gbrain autopilot --install` (every non-default brain first, then the default brain) | `GBRAIN_HOME=<brain parent> gbrain autopilot --status --json` shows `job.needs_reinstall: null` and the brain's own `launchd_label` / `systemd_unit`. See [several brains on one host](live-sync.md#several-brains-on-one-host) |+| `gbrain serve` started in a `.gbrain-mount` project: CLI writes fail `owner_unavailable` and MCP writes stay `queued` | `owner_unavailable` | #5237 | none | Upgrade and restart the resident `gbrain serve` (the harness that spawns it) | `gbrain sources writer status --probe --json` from the project answers |+| Backup coverage reports `remote evidence: unavailable` for a private remote that is pushed | doctor `backup_coverage` | #5794 | none | Upgrade, then `gbrain backup check` | `gbrain backup status --json` shows `verification.state: "verified"`; see [remote unavailable](../operations/backup-check.md#remote-unavailable) |+| On Windows, a write or `gbrain sync` refuses a colon slug such as `calendar:abc` | [`colon_slug_windows_write_through`](write-refusals.md#colon_slug_windows_write_through) | #5032 | none | Use a slug without `:`, or write the page from a macOS or Linux host that owns the source | The write succeeds, or `gbrain sync` no longer lists the file |+| Search empty or incomplete after upgrading; doctor `text_projection_readiness` warns | `text_projection_readiness` | #5401 | `gbrain doctor` (pending count, also while a PGLite resident runs) | `gbrain projections drain` (Postgres, or PGLite with no resident); on PGLite with a resident, wait or stop, drain and restart per [projection owner resident](#projection-owner-resident) | `gbrain doctor` shows `text_projection_readiness` ok |+| `Error [projection_owner_resident]` from `gbrain projections drain` (exit 2) | [`projection_owner_resident`](#projection-owner-resident) | #5401 | `gbrain doctor` | the printed stop, drain and restart commands | `gbrain doctor` |+| `[gbrain] warning: OPENAI_API_KEY in this process's environment differs from openai_api_key …`; doctor `embedding_key_source` warns | `embedding_key_source` ([provider key source](#embedding-key-source)) | #5137 | `gbrain doctor` (`embedding_key_source`) | remove the variable and restart that process, or `gbrain config unset openai_api_key` | the warning no longer prints; `gbrain doctor` shows `embedding_key_source` ok |+| `The OpenAI embedding provider rejected its key (HTTP 401)` | [`embedding_auth_failed`](write-refusals.md#embedding_auth_failed) | #5137 | `gbrain doctor` (`embedding_key_source`, `embedding_provider`) | the printed fix for the key source in effect, then `gbrain embed --stale` | `gbrain doctor` shows `embedding_provider` ok |+| Conversation facts missing from recall after managed writes | `extractor_facts_expired` | #5731 | `gbrain repair extractor-facts` | `gbrain repair extractor-facts --apply --expect <hash>` (ambiguous: add `--include-ambiguous` to both) | `gbrain doctor` |+++### Symptoms from the lifecycle fixes in v0.60.20.0| Symptom or error text | Issue | Preview | Apply | Verify || --- | --- | --- | --- | --- |@@ -493,43 +720,120 @@ vector is never reconciled; it is re-embedded.## Wave 5 refusal codes-Each heading below is the `docs` anchor a refusal carries. The full recovery-steps land with the fix that raises each code.+Each heading below is the `docs` anchor a refusal carries.### Explicit-only repair kinds`stale-atoms` and `extractor-facts` run only when named:`gbrain repair <kind>` previews, and `gbrain repair <kind> --apply --expect <hash>`-applies exactly the previewed set. `gbrain repair --all`, the remediation plan-and `gbrain doctor --remediate --include-repairs` list them with their preview-command (`explicit_kind_required`) and never run them. A build without the-kind refuses with `unavailable`.+applies exactly the previewed set. They are excluded everywhere else:++- `gbrain repair --all` (and `gbrain repair` with no kind) lists each with its+ preview command (`--json`: `explicit_kinds[]`) and never runs it. A+ `--all --apply` run exits 0 when only explicit-only kinds remain.+- `gbrain doctor --remediation-plan` prints them in an `Explicit-only repairs`+ block (`--json`: `explicit_repairs[]`, each `{kind, code:+ "explicit_kind_required", preview_command, docs}`), never as a repair step.+- `gbrain doctor --remediate --include-repairs` classifies a finding only an+ explicit-only kind clears as `explicit_kind_required`, with the preview as+ its `command`. That class does not fail the exit status.+- The `gbrain post-upgrade` banner prints such a finding as+ `<check>: N (explicit_kind_required; preview with: gbrain repair <kind>)`.++A remediation step or any other runner that reaches an explicit-only kind+without its name refuses with `explicit_kind_required`. A build that does not+implement the kind refuses with `unavailable`.### Preview changed-`preview_changed`: the hash passed with `--expect` names no saved preview, or a-preview older than 7 days. Nothing was applied. Re-run the printed preview-command and apply with the new hash.+`preview_changed`: the hash passed with `--expect` names no saved preview, the+saved preview is older than 7 days, or the selection no longer matches it (for+`stale-atoms`, a different `--source`). Nothing was applied. The message reads+"The preview changed since <hash>; re-run <preview command> and use the new+hash." Re-run the printed preview command and apply with the new hash. It+applies to `gbrain jobs authorize-legacy --select`, `gbrain jobs cancel+--select`, `gbrain repair stale-atoms` and `gbrain repair extractor-facts`.### Legacy job authority-`permission_denied` for a job row with SQL NULL submission authority left by an-upgrade across v0.50.+`permission_denied` with this anchor means a queued job row has SQL NULL+`submission_authority`, left by an upgrade across v0.50 (#5157, #5114).++- A resubmission over a **dead or cancelled** legacy key releases the key and+ queues a fresh job. No step needed.+- A **completed or failed** legacy row is reused by local producers (synthesize,+ autopilot, `POST /ingest`). No step needed. A remote `submit_job` caller is+ refused and resubmits with a new idempotency key.+- A **live** legacy row (waiting, delayed, waiting-children, paused, active)+ blocks every worker, so nothing reuses it. `POST /ingest` returns 409+ `{error, message, hint, docs_url}`, never 500.++`gbrain doctor` (`legacy_job_authority`) counts exactly the rows that block workers,+split into authorizable (SQL NULL) and unsupported (non-NULL) rows, and prints the+filled commands. Recovery, in order:++1. Stop producers and workers: the resident `gbrain serve`, `gbrain autopilot`,+ `gbrain jobs work` / supervisor.+2. Cancel each active job the hint or doctor names: `gbrain jobs cancel <id>`.+ (Stall and timeout sweeps are behind the same gate, so an orphaned active row+ never finishes on its own.)+3. Preview: `gbrain jobs authorize-legacy --select "status=waiting|delayed|waiting-children|paused"`+ (narrow with `,name=<job>|<job>`). It lists counts by job name and status, the+ first 20 ids, marks paid-provider job names, and prints a hash. `--json` has the full rows.+4. Apply exactly that set with the printed command:+ `gbrain jobs authorize-legacy --select "<same filter>" --expect <hash> --yes`.+ To drop work instead, `gbrain jobs cancel --select "<filter>"` previews and its+ printed `--expect <hash> --yes` cancels exactly the previewed set.+5. Unsupported non-NULL rows cannot be authorized: run matching application and+ database versions, or cancel them (`gbrain jobs cancel <id>`, as doctor lists).+6. Restart producers and workers. Verify: `gbrain doctor` shows+ `legacy_job_authority` ok; `POST /ingest` returns 202.### Legacy jobs active-`legacy_jobs_active`: a legacy-job preview found active jobs. Stop producers-and workers and cancel the listed jobs first.+`legacy_jobs_active`: `authorize-legacy --select`/`--ids` or `jobs cancel --select`+found active jobs. Legacy review needs nothing active. Stop producers+(`gbrain serve`, `gbrain autopilot`) and workers, cancel the listed jobs+(`gbrain jobs cancel <id>`; the refusal lists up to 10, the rest with+`gbrain jobs list --status active`), then re-run the preview it names.### Legacy job selection invalid-`legacy_job_selection_invalid`: `--select` named an unknown key or value. The-message lists the valid ones.+`legacy_job_selection_invalid`: `--select` named an unknown key or value, a+flag combination was wrong (`--ids` with `--select`; apply without both+`--expect <hash>` and `--yes`), a selected row no longer exists or is not SQL+NULL, or a `jobs cancel --select` selection would also cancel a job outside it+(the message names those ids; cancel them on purpose or widen the filter). The+grammar is `--select "status=<s>[|<s>…],name=<job-name>[|<name>…]"`; the+message lists the valid statuses, and the hint is a complete example.### Projection owner resident-`projection_owner_resident`: a projection drain was refused because a resident-owner holds the PGLite datastore.+`projection_owner_resident` (exit 2): `gbrain projections drain` did not run+because a gbrain process (named with its pid) holds this PGLite brain. Nothing+changed. The upgraded resident drains the queue itself; re-run `gbrain doctor`+to watch the pending count in `text_projection_readiness` (doctor asks the+resident over its local socket, so the count shows while the resident runs; a+resident that does not answer may predate this release and should be restarted+on the upgraded gbrain).++To drain faster, stop the owner, drain, then restart it. The restart runs+whether or not the drain failed:++| Owner | Stop, drain, restart |+| --- | --- |+| `gbrain serve` service, launchd | `launchctl bootout gui/$(id -u)/com.gbrain.serve && { gbrain projections drain; launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.gbrain.serve.plist; }` |+| `gbrain serve` service, systemd | `systemctl --user stop gbrain-serve.service && { gbrain projections drain; systemctl --user start gbrain-serve.service; }` |+| autopilot, launchd | `launchctl bootout gui/$(id -u)/com.gbrain.autopilot && { gbrain projections drain; launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.gbrain.autopilot.plist; }` |+| autopilot, systemd | `systemctl --user stop gbrain-autopilot.service && { gbrain projections drain; systemctl --user start gbrain-autopilot.service; }` |+| a manual `gbrain serve` | stop it (`kill <pid>`), run `gbrain projections drain`, then start `gbrain serve` again |++The refusal prints these commands filled in (with `--brain <id>` for a mounted+brain). The autopilot launchd label follows `GBRAIN_AUTOPILOT_LABEL` when set.+The autopilot rows name the default brain's job: for a brain under another+`GBRAIN_HOME`, take its job names from+`GBRAIN_HOME=<brain parent> gbrain autopilot --status --json` (`launchd_label`,+`systemd_unit`) instead.## Relateddiff --git a/docs/mcp/CLAUDE_CODE.md b/docs/mcp/CLAUDE_CODE.mdindex 8bf00f4c0a..6372466ff0 100644--- a/docs/mcp/CLAUDE_CODE.md+++ b/docs/mcp/CLAUDE_CODE.md@@ -180,7 +180,10 @@ sub-second, world-visibility by default, and available on `--surface verbs`.installer wires `SessionStart` (injects a warm pack; also fires onpost-compaction re-entry, `source=compact`) and `PreCompact` (banks thewindow's standing entities so that rehydration pack is warm) into- `.claude/settings.local.json`. Nothing to call; `GBRAIN_HOOKS=0` disables.+ `.claude/settings.local.json`. Nothing to call; `GBRAIN_HOOKS=0` disables+ every hook event, including capture. Session start never shows another+ session's activity: the `Last session activity` line older releases printed+ was removed in v0.60.27.0 (#5558), with deliberately no opt-in to restore it.- **Manual (any brain, incl. remote/Postgres):** call the verbs yourself atboundaries — `context_pack(entities, budget_tokens)` at session start /after compaction, `delta(session_id, budget_tokens)` on wakes. See