Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
docs(foundations-1): CHANGELOG, upgrade skill, fix-wave notes
garrytan37201caa6f39
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4995407985..5edb9c6415 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,100 @@ credits are retained; no result has been reassigned to another provider. Originaidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [0.60.36.0] - 2026-10-03++**Foundations 1: a 10,000-page PGLite brain answers health and orphan checks in well under a second instead of 12 to 15 seconds, imports about 40% faster, records who wrote each page version, fact, take and timeline entry, lets several agents share one brain without losing track of whose session produced what, and gives every legacy token the same grant shape as an OAuth client.**++On a big local (PGLite) brain, several everyday reads were painfully slow because the database had no statistics about its own tables and planned every query as if the tables were empty. On 10,000 pages `get_health` took 12 seconds, `find_orphans` 15 seconds and a keyword search scoped to one source 39 seconds. Most of that jump comes from GBRA-39's fix that analyzes the tables after bulk writes (#5932, also carried in this release). This release adds what keeps those statistics fresh: each statement on the busy tables now counts the rows it changed, and the brain re-analyzes a table once enough of it changed, during import, sync, the cycle and the first read after a big write. That halves import time compared with analyzing only at the end, and the vector arm of `query` uses its index again once the statistics see the new embeddings.++The rest is groundwork for brains that several agents and people share. Journaled and coordinated writes now stamp who created each row. This is creation attribution: some legacy writers still record nobody, and the list is in the docs. `gbrain attribution <slug>` shows it. A captured session remembers which agent seat it came from. Legacy tokens move to the same grant shape as OAuth clients, lazily, with one `gbrain auth rescope` command for both. `gbrain sources refresh <id>` fast-forwards a managed checkout safely while other writers wait.++| 10,000-page PGLite brain, as shipped (no manual ANALYZE) | v0.60.34.0 | + #5932's ANALYZE fix | This release |+| --- | --- | --- | --- |+| `get_health` (computation, memo off) | 12,073 ms | 208 ms | 158 ms |+| `find_orphans` | 14,989 ms | 43.5 ms | 34.3 ms |+| Keyword search scoped to one source | 38,645 ms | 18.2 ms | 22.1 ms |+| Agent (MCP) search | 118 ms | 41.4 ms | 42.5 ms |+| `query` with an injected vector (hybrid) | 306 ms | 375 ms | 26.3 ms |+| Import of 10,000 files | 119 s | 99 s | 62 s |+| Per-page import cost, last 10% vs first 10% | 1.74x | 0.85x | 0.84x |+| Hot tables with planner statistics when measured | 1 of 6 | 2 of 6 | 6 of 6 |++Each cell is the median of per-run p50s from `bun run test:scale -- --pages 10000 --seed 1` on one Ubicloud standard-8 VM: five runs each for the last two columns, interleaved, and two runs for v0.60.34.0. Keyword search scoped to one source moved from 18 to 22 ms in this release; the run-to-run spread overlaps (17-19 ms vs 19-25 ms). The first two columns check statistics right after import; this release checks after the first timed read, because it analyzes on that read by design. A repeat `get_health` within 30 seconds with no page or config change is served from memory (about 0.3 ms).++The CI scale tier now runs this harness at 10k pages on every change that touches search, import, sync, doctor or the engines, and nightly at 10k and 20k pages (50k once `scripts/scale/trend.ts` adds it), on PGLite and Postgres. It fails on a slow import, a wrong answer, a quadratic plan or missing statistics.++## To take advantage of v0.60.36.0++`gbrain upgrade` installs the binary and runs four schema migrations: v193 creation attribution columns and triggers, v194 the worktree refresh checkpoint table, v195 the unified grant columns on `access_tokens`, and v196 planner-statistics accounting (PGLite only; a no-op on Postgres). Restart every `gbrain serve`, autopilot and worker afterwards.++1. **Run the orchestrator if the upgrade did not:**+ ```bash+ gbrain apply-migrations --yes --no-autopilot-install+ ```+2. **Your agent reads `skills/migrations/v0.60.36.0.md` the next time you talk to it.** It lists the new commands and the opt-outs. Nothing in it spends money.+3. **Optional, free: fill attribution for history the write journal proves.**+ ```bash+ gbrain repair attribution-backfill # preview+ gbrain repair attribution-backfill --apply # resumable+ ```+4. **Optional: move legacy tokens to the unified grant shape now** instead of on their next grant change:+ ```bash+ gbrain auth rescope --migrate-legacy --dry-run+ gbrain auth rescope --migrate-legacy+ ```+5. **Check scripts that run `gbrain embed --stale`.** A run that stops at its 30-minute budget with work left now exits 3 and prints the remaining count and `gbrain embed --stale --catch-up`.+6. **Verify:**+ ```bash+ gbrain doctor # planner_stats_stale, legacy_token_grant_shape, worktree_refresh_stuck, embeddings backlog+ gbrain attribution <a-page-you-just-wrote>+ ```+7. **If any step fails,** file an issue at https://github.com/garrytan/gbrain/issues with the output of `gbrain doctor` and `~/.gbrain/upgrade-errors.jsonl` if it exists.++### Behavior changes++- **PGLite keeps planner statistics fresh on its own.** Every statement on pages, links, facts, takes, content chunks and timeline entries records how many rows it changed, in the same transaction. A table whose changes pass max(500 rows, 10% of the table) is re-analyzed by import and managed sync every 500 pages (`import.analyze_every_pages`), by the cycle, by the idle consumer and by the first planner-sensitive read (within `planner.first_read_budget_ms`, 2 s; slower tables are analyzed right after the read answers). Turn off: `gbrain config set planner.auto_analyze false` or `GBRAIN_PLANNER_AUTO_ANALYZE=0`. Doctor `planner_stats_stale` and `gbrain repair planner-stats --apply` keep working either way. Postgres is unchanged (autovacuum).+- **`get_health` is computed in three SQL statements** and repeat calls are served from an in-process memo keyed by scope, page clock and config, for up to `health.cache_ttl_ms` (30000; `GBRAIN_HEALTH_CACHE_TTL_MS`; 0 disables). The response gains `computed_at`. Doctor, remediation and repair always read fresh numbers, and `gbrain repair --apply` and `gbrain doctor --remediate` clear the memo.+- **Rows carry creation attribution.** Journaled and coordinated writes, and the unmanaged legacy imports, fact reconcile, take extraction and stale-atom retirement, stamp the request id and principal on page versions, facts, takes, timeline entries and the live page revision. Writers listed as unattributed in `docs/architecture/system-of-record.md` still write without an actor until Foundations 2. Attribution lives in the database only; Markdown never carries it.+- **`get_versions` returns `written_by` and `archived_by`** to trusted local callers and `admin` holders only; other callers see the same columns as before.+- **A captured session records its agent seat,** and pages the dream cycle synthesizes from it carry `seat: <label>` in frontmatter. The seat is `GBRAIN_SEAT` when set and valid, else a hashed seat per harness home. Turn off: `GBRAIN_SEAT=off` or `gbrain bootstrap hooks --seat off`.+- **Legacy tokens migrate to the unified grant shape on their next grant change.** No token is re-issued and no effective grant changes. Doctor `legacy_token_grant_shape` counts tokens still on the old shape, and `legacy_token_grant_drift` warns when an older gbrain edited a migrated token's permissions JSON (`gbrain auth rescope --token <name> --adopt-permissions` or `--adopt-columns` resolves it).+- **`gbrain embed --stale` stopped by its 30-minute budget with chunks left exits 3** (was 0) and prints `remaining_stale` and the resume command; failures still exit 1. Doctor `embeddings` reports the backlog with `gbrain embed --stale --catch-up`, and reports "not applicable" on a keyless brain.+- **A sync that keeps making progress is no longer stopped by its default or environment deadline.** It stops only after `GBRAIN_SYNC_STALL_ABORT_SECONDS` (900) without progress, with `code=sync_deadline_stop` and the resume command. `--hard-deadline` and `--timeout` stay strict.+- **`gbrain serve`'s boot deadline counts time without progress,** so a large brain's slow but advancing boot (or a serve already answering tool calls) is not killed. `GBRAIN_SERVE_BOOT_TIMEOUT_SECONDS=0` still disables it.+- **Writes to a checkout that `gbrain sources refresh` is draining or merging are refused** with `worktree_refreshing` (retry the same request id after about a second); database-only memory writes are not affected.++### Itemized changes++#### Planner statistics and scale (F4)++- `src/core/planner-stats.ts` + `planner-stats-schema.ts`: AFTER STATEMENT transition-table triggers count modifications into `planner_stats_deltas` (migration v196, `sqlFor.pglite` only); ANALYZE and the watermark publish share one statistics transaction, so a concurrent modification stays pending. `gbrain import` and managed sync analyze every `import.analyze_every_pages` pages.+- `src/core/engine-sql/health.ts`: `get_health` for both engines as three planner-proof statements; the shared orphan exclusion SQL (`orphanExclusionSql`) is pinned against `gbrain orphans` by a parity test. `src/core/health-memo.ts` is the op-level memo.+- Scale tier (`scripts/scale/`, `.github/workflows/scale-tier.yml`): seeded two-source fixture with facts, takes, island pages and dense injected vectors; known answers for every op, a no-op re-import, cross-source duplicates, a cold-process query and two concurrent writers. Planner health (statistics on hot tables above 500 rows after the first timed op, Nested Loop inner loops at most 10x pages) and the budgets phase timer are enforced; interactive ceilings and calibrated budgets (`scripts/scale/budgets.json`, PGLite and Postgres at 10k) stay report-only until `scripts/scale/trend.ts` reports five stable nightly runs.+- `src/core/forward-progress.ts`: progress notes extend the sync watchdog and the serve boot window; `src/core/embed-budget-stop.ts`: the loud embed budget stop. `gbrain sources add` registers a 20,000-file checkout (pinned by test).++#### Creation attribution (F1)++- Migration v193 adds nullable attribution columns on `pages`, `page_versions`, `facts`, `takes` and `timeline_entries` and BEFORE ROW triggers that copy three transaction-local settings; `withCoordinatedWrite` requires an attribution, and `maintenanceTransaction` stamps the local maintenance principal (CLI registration, else this host, else `host:unregistered`; never creates an identity file).+- `get_write_attribution` (scope `admin`) and `gbrain attribution <slug> [--fact <id>] [--take <row>] [--timeline <id>] [--versions]` join request, operation, principal name and time at read time. `gbrain repair attribution-backfill` fills only rows exactly one committed request proves, in resumable batches of 1,000, and is part of `gbrain repair --all`.++#### Seats (F2, #4618)++- `src/core/context/seat.ts`: `<sessionId>.seat.json` sidecars written by session-end, compact and the stop hook's writeback bank, reaped with their session after a 10-minute grace. `gbrain bootstrap hooks|harness --seat <label>` writes `GBRAIN_SEAT` into local hook commands; a re-install keeps the seat and `--no-seat` clears it. Codex reads its seat from `CODEX_HOME`, and OpenClaw keeps one per agent.++#### Grants (F3)++- Migration v195 adds the unified grant columns to `access_tokens`. `gbrain auth rescope --token <name>|--id <uuid>|--client <id>` edits sources, read sources, takes holders and operations in place for tokens and OAuth clients; `auth rescope-token` and `auth permissions <name> set-takes-holders` are aliases. `--sources none` denies every source for a token.++#### Worktree refresh (F0)++- Migration v194 adds `persistence_worktree_refreshes`. `gbrain sources refresh <source-id> [--dry-run] [--wait-drain <s>] [--fetch-timeout-ms <ms>] [--resume | --abandon] [--json]` drains the worktree's writers, fast-forwards it (refusing only dirt that overlaps the incoming change), syncs every member source and records each step, so a restart converges and an interrupted refresh names its `--resume` or `--abandon` command. Doctor `worktree_refresh_stuck` reports a refresh active longer than 15 minutes, and `gbrain sources writer status` lists active refreshes.++### For contributors++- `bun run test:scale -- --pages <n> [--engine postgres] [--enforce] [--calibrate]` reproduces any scale-tier failure locally; `PLANNER_HEALTH_ENFORCED` in `scripts/scale/gates.ts` is the switch for the stats-dependent gates.+- `test/write-attribution-legacy.test.ts` pins the attributed and unattributed writer lists in `docs/architecture/system-of-record.md` against a grep of `src`.+## [0.60.34.0] - 2026-10-03**Fix wave 8: Postgres stops poisoning its connection pool after one failed statement, managed brains keep ingesting remote sources, Windows can publish skills and run the write queue, scripts can tell a pending write from a failed one, agents can edit one line of a page without resending it, and legacy tokens can be granted (or denied) exactly the sources they should see.**diff --git a/docs/fix-wave-notes/capy-foundations-1.md b/docs/fix-wave-notes/capy-foundations-1.mdnew file mode 100644index 0000000000..1c2e418a8a--- /dev/null+++ b/docs/fix-wave-notes/capy-foundations-1.md@@ -0,0 +1,80 @@+# Foundations 1 notes (`capy/foundations-1`, v0.60.36.0)++One integrated PR. Ten lanes (F0, F1a, F1b, F1c, F2, F3, F4a, F4b, F4c, F4d)+were built in parallel on the fix wave 8 collector (`capy/fix-wave-8`), merged+here in the order F1c (with F1a), F1b, F0, F3, F4a, F2, F4d, F4c, F4b, then+merged with master. Migrations were renumbered once at integration: v193+`f1_write_attribution`, v194 `f0_worktree_refreshes`, v195+`f3_access_token_grants`, v196 `f4_planner_stats` (PGLite only). Generated+files (schema blobs, migration registry, CLI flag registry, goldens, llms) were+regenerated, never hand-merged.++## Headline++10,000-page PGLite brain, as shipped with no manual ANALYZE+(`bun run test:scale -- --pages 10000 --seed 1`). Each cell is the median of+per-run p50s (five timed runs after a warmup in each harness run). All runs+were on one Ubicloud standard-8 VM, with the same fixture for every build:+five interleaved runs each for the last two columns and two runs for the+first.++| Metric | v0.60.34.0 (fix wave 8) | + #5932's ANALYZE fix (ad7252a) | Foundations 1 |+| --- | --- | --- | --- |+| `get_health` (memo off) | 12,073 ms | 208 ms | 158 ms |+| `find_orphans` | 14,989 ms | 43.5 ms | 34.3 ms |+| Keyword search scoped to one source | 38,645 ms | 18.2 ms | 22.1 ms |+| MCP search (headline) | 118 ms | 41.4 ms | 42.5 ms |+| `query` with injected vector (hybrid) | 306 ms | 375 ms | 26.3 ms |+| Import of 10,000 files | 119 s | 99 s | 62 s |+| Import rate ratio (last/first 10%) | 1.74 | 0.85 | 0.84 |+| Enforced gates | n/a (report-only build) | `planner_stats` fails | all pass |++Most of the drop from fix wave 8 comes from GBRA-39's full ANALYZE after bulk+writes (#5932, cherry-picked into F4b as f1970519). Foundations adds what+keeps statistics fresh between syncs: import time falls from 99 s to 62 s, and+the hybrid query from 375 ms to 26 ms, because the vector arm uses its HNSW+index once statistics see the injected embeddings. Keyword search scoped to+one source moved from 18.2 to 22.1 ms; the run ranges overlap (17.4-19.4 vs+18.7-25.0 ms).++Two harness fixes came out of the enforced runs:++- With statistics, PGLite plans the vector arm on HNSW, and the fixture's+ two-hot vectors (almost every pair at the same distance) gave HNSW nothing+ to navigate. On one kept 10k brain the injected-vector probe found its page+ in 2 to 5 of 10 probes per index build, across 6 rebuilds, and one enforced+ run failed its hybrid known answer. Seeded dense vectors in 16 dimensions+ found 30 of 30 on each of 6 rebuilds (421836c2).+- `get_health` is timed with its memo off (fb7f3657); with the memo on, repeat+ calls return in about 0.3 ms and say nothing about the computation.++## Items++| Item | What shipped | Commits | Tests |+| --- | --- | --- | --- |+| F0 | `gbrain sources refresh <id>`: drained worktree-wide ff-only refresh with a durable checkpoint, admission fence (`worktree_refreshing`), restart recovery, doctor `worktree_refresh_stuck` | 9aff60d3 d4d112f2 f1236021 e0e5da3e f6687f66 e79cb322 6350d022 33ab99d6 5456bf10 2e020343 a689d909 37d274af; integration 9a128ddd | `test/persistence-worktree-refresh.test.ts`, `test/persistence-worktree-refresh-restart.test.ts`, `test/e2e/worktree-refresh-postgres.test.ts` |+| F1a | Creation attribution columns and BEFORE ROW triggers on pages, page versions, facts, takes and timeline entries; `withCoordinatedWrite` requires an attribution | 9a1b55a1 5a10097c 3f906834 15b942f5 f0b4863d 716407a4 e31618ac 7b7199ee | `test/write-attribution.test.ts`, `test/e2e/write-attribution-postgres.test.ts` |+| F1b | `get_write_attribution` / `gbrain attribution`, `get_versions` `written_by`/`archived_by` for trusted and admin callers, `gbrain repair attribution-backfill` | d0bbecfc 3eb948d3 b05ec9ae 8f1bc288 311ccdcf 3e9b826b 4cb56ad2; integration 6cad517b (test-only column helper dropped) | `test/write-attribution-read.test.ts`, `test/e2e/write-attribution-read-parity.test.ts`, repair kind lists in `test/fix-wave-3-integration.test.ts`, `test/fix-wave-4-integration.test.ts`, `test/repair-command.test.ts` |+| F1c | Unmanaged legacy writers (direct imports, `extract_facts` reconcile, `extract-takes`, stale-atom retirement) carry the maintenance principal; pinned attributed and unattributed writer lists | 0d3efb10 23fdce0f | `test/write-attribution-legacy.test.ts` |+| F2 | Seat sidecar on session capture, stamped into dream-synthesized frontmatter; `bootstrap --seat/--no-seat`, `GBRAIN_SEAT=off` opt-out (#4618) | d9d97e8d e19c78d9 99b4e4f9 871cad5e 8daf0456 | `test/session-seat-capture.serial.test.ts`, `test/session-seat-synthesize.test.ts`, `test/transcript-discovery-seat.test.ts`, `test/bootstrap-seat.serial.test.ts`, `test/e2e/session-seat-synthesize.test.ts` |+| F3 | Unified grant columns for legacy tokens with lazy migration, one `gbrain auth rescope` for tokens and clients, `--migrate-legacy`, doctor `legacy_token_grant_shape` and `legacy_token_grant_drift` | 05c507f8 fa2601d3 6540b458 02bdc04b c31ef930 ec681332 9bcebb49 32f8ec09 | `test/access-token-grants.test.ts`, `test/auth-rescope-unified.serial.test.ts`, `test/e2e/access-token-grants.test.ts` |+| F4a | `get_health` in three SQL statements for both engines, shared orphan exclusion SQL, scoped memo with `computed_at` | 5976a6f0 fe286548 1424edf5 c3dd9c69 3d30b4c5 7a0bfbe8; integration 5f606673 (config key) | `test/engine-sql-health-equality.test.ts`, `test/orphan-policy-sql-parity.test.ts`, `test/health-memo.test.ts`, `test/e2e/engine-sql-health-parity.test.ts`, `test/brain-score-timeline-grading.test.ts` (#5828 grading kept) |+| F4b | PGLite transactional planner-stats accounting, row-delta ANALYZE (import, sync, cycle, idle, first read), doctor `planner_stats_stale`, repair `planner-stats`; carries #5932's ad7252a | f1970519 (cherry-pick) fd23e871 db13caf7; integration 2b985cb8 902f462e | `test/planner-stats.test.ts`, `test/planner-stats-catalog.test.ts`, `test/planner-stats-restart.serial.test.ts`, `test/planner-stats-import.slow.test.ts`, `test/declared-lineage-visibility.test.ts`, `test/e2e/planner-stats-postgres.test.ts` |+| F4c | CI scale tier: harness, gates, trend, nightly workflow; planner health and budgets phase enforced, PGLite budgets calibrated | 05c39c21 24ecac22 934a65cd 3e161719 dcb72da0 8ec8d046 22241075 07fe8c41; integration a704696c 421836c2 fb7f3657 54b6a890 | `test/scripts/scale-gates.test.ts`, `test/scripts/scale-harness.slow.test.ts`, `test/scripts/scale-trend.test.ts`, `test/scripts/scale-fixture.test.ts` |+| F4d | Large-brain ceilings: progress-aware sync deadline, `sources add` on a 20k-file checkout, loud `embed --stale` budget stop (exit 3), doctor embeddings backlog, serve boot no-progress window | 120fcfe2 6e0c6169 f3e11973 80ca07a6 53314706 5c1057c0 9fc2e201 94226d1f 2c9241cf | `test/large-brain-ceilings.serial.test.ts`, `test/doctor-embedding-backlog.test.ts`, `test/sync-hard-deadline.test.ts`, `test/process-watchdog.serial.test.ts`, `test/serve-stdio-lifecycle.test.ts`, `test/embed.serial.test.ts` |++Integration-only fixes: the F0 refresh test passes an attribution to+`withCoordinatedWrite` (9a128ddd); `core-persistence.md` split under the 60 KB+key-files cap (49303357); the reindex perf fixture classifies a bare `ANALYZE`+as statistics (from #5932's 77dcf414, in 902f462e).++## Gates++- `bun run typecheck`, `bun run verify` (67 checks).+- `bun run ci:ubicloud`: gitleaks, unit, slow, serial, E2E (Postgres and+ PgBouncer), verify; all green at every integration push.+- OpenClaw native context-engine startup test against pgvector pg16+ (`test/openclaw-context-engine-native.serial.test.ts`, openclaw 2026.9.4),+ run locally because the Ubicloud gate does not include it.+- Enforced scale tier at 10k PGLite pages: 5 of 5 runs pass every enforced gate.+- gstack credential pre-push guard on every push: no HIGH findings.diff --git a/skills/migrations/v0.60.36.0.md b/skills/migrations/v0.60.36.0.mdnew file mode 100644index 0000000000..1611d298db--- /dev/null+++ b/skills/migrations/v0.60.36.0.md@@ -0,0 +1,107 @@+# Upgrade to v0.60.36.0: Foundations 1++This release makes large PGLite brains fast without manual tuning, records who+created each row, tracks which agent seat a captured session came from, moves+legacy tokens to the same grant shape as OAuth clients, and adds a safe way to+fast-forward a managed checkout. Most of it needs nothing from you. The steps+below are the ones an agent or a script around gbrain should know about.++Grant changes and anything that spends money need the user's agreement. Never+run `gbrain auth rescope` with a grant flag or `gbrain embed --stale --catch-up`+on the user's behalf without asking. The repairs below are free.++1. **Finish the migration.** `gbrain upgrade` runs it. To be sure, run on the+ brain host:+ ```bash+ gbrain apply-migrations --yes --no-autopilot-install+ ```+ Four schema migrations run (v193-v196): creation attribution columns and+ triggers, the worktree refresh checkpoint table, the unified grant columns+ on `access_tokens`, and planner-statistics accounting (PGLite only). None+ rewrites existing rows. Restart every `gbrain serve`, autopilot and worker.++2. **Know that PGLite now analyzes itself.** Import, managed sync, the cycle,+ the idle consumer and the first read after a big write re-analyze tables+ whose rows changed enough. If the user asks why a read paused for a second+ after a large import, this is it. To check or force it:+ ```bash+ gbrain doctor # planner_stats_stale names each stale table+ gbrain repair planner-stats --apply # analyze the stale tables now+ ```+ Opt out (not recommended; large PGLite brains get slow again):+ `gbrain config set planner.auto_analyze false` or `GBRAIN_PLANNER_AUTO_ANALYZE=0`.+ `gbrain config set import.analyze_every_pages <n>` changes the import cadence+ (0 turns it off).++3. **Use the new commands.**+ - `gbrain attribution <slug> [--fact <id>] [--take <row>] [--timeline <id>] [--versions]`+ shows who created and who last changed a page or one of its facts, takes+ or timeline entries (admin read). `origin: unrecorded` means the row was+ written before this release or by a writer listed as unattributed in+ `docs/architecture/system-of-record.md`; it is not evidence of tampering.+ - `gbrain repair attribution-backfill` (preview) and `--apply` fill+ attribution only where the write journal proves the writer. Free and+ resumable; `gbrain repair --all` includes it.+ - `gbrain sources refresh <source-id>` fast-forwards a managed checkout+ while writers wait, then syncs every source in the worktree. Use it when+ a managed sync says the upstream moved. `--dry-run` previews; an+ interrupted refresh prints its `--resume` or `--abandon` command.+ Writes refused with `worktree_refreshing` during a refresh: retry the+ same request id after about a second.+ - `gbrain auth rescope --token <name>|--id <uuid>|--client <client-id>`+ changes a token's or OAuth client's sources, read sources, takes holders+ or operations in place. With no grant flag it prints the stored grants.+ `gbrain auth rescope-token` and `gbrain auth permissions <name> set-takes-holders`+ still work as aliases.+ - `gbrain auth rescope --migrate-legacy --dry-run`, then without+ `--dry-run`, writes the unified grant columns for every token still on+ the old shape. It changes no effective grant, so it does not need the+ user's agreement, but tell them it ran. Tokens otherwise migrate on+ their next grant change. Doctor `legacy_token_grant_shape` counts the+ rest; `legacy_token_grant_drift` means an older gbrain edited a migrated+ token: ask the user which grant is right, then run+ `gbrain auth rescope --token <name> --adopt-permissions` (keep the JSON+ edit) or `--adopt-columns` (keep the columns).++4. **Name agent seats when several agents share one brain.** Captured+ sessions record a seat, and dream-synthesized pages carry `seat: <label>`.+ By default each harness home gets its own hashed seat. To give this agent+ a readable name:+ ```bash+ gbrain bootstrap hooks --harness claude-code --seat <label> # or: gbrain bootstrap harness --seat <label>+ ```+ A re-install keeps the seat; `--no-seat` clears it. Opt out of seat+ capture: `--seat off` or `GBRAIN_SEAT=off`. Codex, opencode and cloud+ carriers print where to set `GBRAIN_SEAT` instead.++5. **Handle exit 3 from `gbrain embed --stale`.** A run that stops at its+ 30-minute budget with chunks left now exits 3 (was 0) and prints the+ remaining count and the resume command. Failures still exit 1. Treat 3 as+ "partial, resume later". Draining the rest makes paid embedding calls:+ ask the user before running+ ```bash+ gbrain embed --stale --catch-up+ ```+ Doctor `embeddings` shows the backlog and says "not applicable" on a+ keyless brain.++6. **Expect long syncs and slow boots to finish.** A sync under its default+ or `GBRAIN_SYNC_MAX_RUNTIME_SECONDS` deadline keeps going while it makes+ progress and stops only after `GBRAIN_SYNC_STALL_ABORT_SECONDS` (900)+ without progress, printing `code=sync_deadline_stop` and the resume+ command. `--hard-deadline` and `--timeout` stay strict. `gbrain serve`'s+ boot deadline counts time without progress, so a big brain's slow boot is+ not killed.++7. **Know about the `get_health` memo.** Repeat `get_health` calls within 30+ seconds with no page or config change return memoized counters with+ `computed_at`. `gbrain config set health.cache_ttl_ms 0` (or+ `GBRAIN_HEALTH_CACHE_TTL_MS=0`) turns it off. Doctor always reads fresh.++8. **Verify:**+ ```bash+ gbrain doctor+ gbrain attribution <slug of a page written after the upgrade> # origin: request, with the writer named+ ```+ If a step fails, file an issue at https://github.com/garrytan/gbrain/issues+ with `gbrain doctor` output and `~/.gbrain/upgrade-errors.jsonl` if it exists.