Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

graduation(G3): docs — Move a PGLite brain to Postgres guide, ENGINES rewrite, migrate --to references, exit-codes row, CONTRIBUTING smoke recipe, TODOS, skills, llms

garrytan9d7b8eff5813
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f22459886f..174344d9d6 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -276,6 +276,52 @@ uncommitted edits included; see "Ubicloud fan-out" in
Fail-closed selector: an unmapped `src/` change runs ALL E2E files. Hand-tune
narrower mappings via `scripts/e2e-test-map.ts`.
+### Local graduation smoke (PGLite → Postgres)
+
+A five-minute end-to-end check of `gbrain migrate --to postgres` on the E2E
+container conventions from [`docs/TESTING.md`](docs/TESTING.md) (pinned
+`pgvector/pgvector:pg16`, a database name carrying "test", tear down when done).
+It uses its own container name and port so it never touches `gbrain-test-pg`,
+and an isolated `GBRAIN_HOME` so it never touches your brain. Unset
+`DATABASE_URL` and `GBRAIN_DATABASE_URL` first: the plan lists either one as a
+blocker when it points anywhere but the target.
+
+```bash
+# 1. Target database
+docker run -d --name gbrain-graduation-pg \
+ -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres \
+ -e POSTGRES_DB=gbrain_graduation_test \
+ -p 5436:5432 pgvector/pgvector:pg16
+until docker exec gbrain-graduation-pg pg_isready -U postgres; do sleep 1; done
+
+# 2. Source brain with write history, in a throwaway home
+export GBRAIN_HOME="$(mktemp -d)"
+bun run src/cli.ts init --pglite --no-embedding
+echo "Alice Example runs the acme-example pilot." | bun run src/cli.ts put people/alice-example
+
+# 3. Plan (exit 3, nothing changes), then run with the plan hash
+export GBRAIN_TARGET_URL=postgresql://postgres:postgres@localhost:5436/gbrain_graduation_test
+bun run src/cli.ts migrate --to postgres --url-env GBRAIN_TARGET_URL --json > plan.json; echo "exit $?"
+bun run src/cli.ts migrate --to postgres --url-env GBRAIN_TARGET_URL --yes --expect "$(jq -r .plan_hash plan.json)"
+
+# 4. The brain answers from Postgres
+bun run src/cli.ts doctor --no-migrate --json
+bun run src/cli.ts get people/alice-example
+bun run src/cli.ts migrate --status --json
+
+# 5. Clean up (always, pass or fail)
+docker rm -f gbrain-graduation-pg
+rm -rf "$GBRAIN_HOME" plan.json
+unset GBRAIN_HOME GBRAIN_TARGET_URL
+```
+
+Expected: step 3 prints `exit 3` and then a run that ends with the target's
+doctor result, `get` returns the page, and `ls "$GBRAIN_HOME/.gbrain"` before
+cleanup shows `brain.pglite` as a tombstone file next to the retained
+`brain.pglite.graduated-<run_id>` copy. For rollback,
+run `bun run src/cli.ts migrate --rollback-to-source` before step 5 and check
+that `get` answers from PGLite again.
+
### PR-side security checks
Besides the test gate, PRs may trigger three security workflows: Semgrep CE
diff --git a/INSTALL_FOR_AGENTS.md b/INSTALL_FOR_AGENTS.md
index ac197c7627..c6ebdbef47 100644
--- a/INSTALL_FOR_AGENTS.md
+++ b/INSTALL_FOR_AGENTS.md
@@ -167,7 +167,7 @@ rung prints a one-line note and falls through; only the PGLite floor is terminal
| 2. Supabase discovery | Management-API project discovery (10s timeouts; the candidate URL is connect-probed before anything persists; discovery only — project CREATION stays dashboard guidance) | `SUPABASE_ACCESS_TOKEN` + `SUPABASE_DB_PASSWORD` (+ `SUPABASE_PROJECT_REF` on multi-project accounts) |
| 3. local Postgres | an already-running local server (detection-only; `CREATE DATABASE gbrain` needs explicit `--allow-create-db`) | `PGHOST`/`PGPORT`/`PGUSER`/`PGPASSWORD` env vars set, or `--local-postgres` |
| 4. docker | gbrain's own container `gbrain-postgres` (image `pgvector/pgvector:pg16`, loopback-only port 5434, data on the named `gbrain-pgdata` volume, `--restart unless-stopped`; idempotent reuse recovers credentials via `docker inspect`; refuses to share a container/volume that already holds a brain this home's config doesn't record; gbrain never stops or removes it) | explicit `--allow-docker` |
-| 5. PGLite floor | zero-config fallback, with an upgrade-later note (`gbrain migrate --to supabase`) | nothing |
+| 5. PGLite floor | zero-config fallback, with an upgrade-later note (the later move is `gbrain migrate --to postgres`; see [Move a PGLite brain to Postgres](docs/guides/move-to-postgres.md)) | nothing |
The ladder REFUSES to run over an already-configured brain — rung choice is
environment-dependent, so a re-run during an outage could silently repoint a
diff --git a/TODOS.md b/TODOS.md
index 47d9c605e6..acf4bcdb8d 100644
--- a/TODOS.md
+++ b/TODOS.md
@@ -1,5 +1,16 @@
# TODOS
+## Engine graduation follow-ups (filed 2026-10-04, GBRA-50)
+
+Context: `docs/guides/move-to-postgres.md`, `docs/ENGINES.md#engine-migration-refused`.
+
+- [ ] **P2 — Postgres → PGLite graduation.**
+ **What:** `gbrain migrate --to pglite` uses the legacy copier, which refuses any brain with write history, withdrawals or worktree ownership. **Why:** a brain that moved to Postgres (or started there) cannot come back to a single-machine PGLite brain without losing its history. **Fix:** a reverse adapter (Postgres source, PGLite target) for the graduation inventory, copier and verify in `src/core/persistence/engine-graduation.ts`, with the same plan, fence, verify, cutover and crash tests. **Effort:** L. **Priority:** P2.
+- [ ] **P3 — `gbrain migrate --discard-source`.**
+ **What:** after a verified graduation the PGLite copy stays at `<path>.graduated-<run_id>` and the user deletes it by hand (doctor's `pglite_leftovers` names the command). **Why:** the copy still holds private memory and token hashes. **Fix:** a confirmation-gated command that deletes the retained copy and the tombstone only when the run is `graduated` and no rollback is pending, with `--yes --expect` and a dry run. **Effort:** S. **Priority:** P3.
+- [ ] **P2 — Windows graduation.**
+ **What:** on Windows a PGLite brain with history gets `graduation_unsupported_platform` (history-free brains use the legacy copier). **Why:** the tombstone, kernel-lock retention and SIGKILL crash tests have not run on a Windows runner, so custody across a crash is unproven there. **Fix:** run the tombstone, older-binary and crash suites on a Windows CI runner, fix what fails, then lift the platform refusal. **Effort:** M. **Priority:** P2.
+
## Held files follow-ups (filed 2026-10-04, follow-up from v0.60.47.0)
Context: `docs/guides/repair.md#held-files`, `docs/guides/write-refusals.md#held-files-and-content-refusals`.
diff --git a/docs/ENGINES.md b/docs/ENGINES.md
index f639adb721..bc21992653 100644
--- a/docs/ENGINES.md
+++ b/docs/ENGINES.md
@@ -19,7 +19,7 @@ Different users have different constraints:
| Researcher | Analytics, bulk exports, embeddings | DuckDBEngine (someday) |
| Edge/mobile | Offline-first, sync later | PGLiteEngine + sync (someday) |
-The engine interface means we don't have to choose. PGLite is the zero-friction default. Supabase is the production scale path. `gbrain migrate --to supabase/pglite` moves between them.
+The engine interface means we don't have to choose. PGLite is the zero-friction default. Supabase is the production scale path. `gbrain migrate --to postgres` moves a PGLite brain to Postgres with its history ([guide](guides/move-to-postgres.md)); `gbrain migrate --to pglite` moves a brain without write history the other way.
## The interface
@@ -293,26 +293,47 @@ Details in INSTALL_FOR_AGENTS.md ("Engine preference for harness installs").
| Concurrency | Single process | Connection pooling |
| Backups | Manual (file copy) | Managed by Supabase |
-**Migration:** `gbrain migrate --to supabase` exports everything (pages, chunks, embeddings, links, tags, timeline, facts) and imports into Supabase. Config rows copy in full minus the engine-local denylist (`MIGRATE_CONFIG_ENGINE_LOCAL_KEYS`: the target-owned `engine`/`version` connection + schema ledger and the physical embedding-column registry keys); skipped keys are printed, never silent, and the run ends with a per-table copied-count summary. `gbrain migrate --to pglite` goes the other direction. The copy is lossless for what it carries, but it refuses two kinds of brain: a managed brain (`writer_coordinator_required`, "cannot mutate a managed brain through the legacy writer") and any brain with durable write history, fact withdrawals or canonical worktree ownership (rows in `persistence_requests`, `fact_withdrawals` or `persistence_worktrees`), because the copier cannot carry request IDs, withdrawals or ownership. A brain that has saved memory through the write coordinator (`remember`, `put_page` from an agent or a resident `gbrain serve`) has that history, so in practice `migrate --to` works only for brains that never used it. For those brains, keep the datastore and repair forward (`gbrain doctor`, `gbrain repair`) instead of migrating, and choose Postgres up front if you expect 1000+ files or several machines. An engine move that preserves request IDs, withdrawals, attribution, grants and ownership is planned, not shipped.
-
-The migration and the autopilot daemon do not race: `migrate --to` claims a
-cooperative pause marker before touching the target. The marker doubles as a
-migration mutex — a second concurrent migrate refuses to run, and a marker
-that cannot be written refuses the migration outright. Background job workers
-stop picking up new work while it is parked, and the migration waits for
-in-flight sync/embed/cycle work and running jobs to actually drain (watching
-the DB lock table, capped by `GBRAIN_MIGRATE_QUIESCE_SECONDS` — default 300;
-`0` skips the wait). Cleanup registers the moment the claim lands, so the
-marker is released on failure and on catchable signals; a marker orphaned by
-an uncleanly killed run is adopted by a later migrate only after a
-pid-liveness check (a live migrate's marker is never stolen), and the daemon
-clears an orphan whose owning process died on its next poll. `gbrain
-autopilot --status` reports `paused` (exit 1) while the marker is parked and
-prints the marker path; on a host with no daemon running to self-heal,
-remove an orphan by hand only after confirming the pid it names is dead.
-After a clean flip the daemon detects the engine change on its next
-tick and relaunches onto the new engine, and the migration warns if an
-exported connection-string env var would override the new config.
+**Migration:** on a PGLite brain, `gbrain migrate --to postgres` (alias `--to supabase`) graduates the brain to Postgres. Without `--yes` it prints the plan and exits 3; `--yes --expect <plan_hash>` runs it. Graduation drains pending writes, copies every table verbatim with its primary keys (pages, facts, takes, versions, links, timeline, embeddings, transcripts and paid caches, request history and withdrawals, token and OAuth rows) into a fenced target, verifies row counts and digests, runs `gbrain doctor` on the target, and only then flips routing. It works for brains with write history and for managed brains. The PGLite data dir is retained as `<path>.graduated-<run_id>` and a tombstone file takes its place. Walkthrough, recovery by error code, rollback and what stays on this computer: [Move a PGLite brain to Postgres](guides/move-to-postgres.md).
+
+**Say to your agent:** *"Upgrade my brain to Postgres. Show me the plan first."*
+
+The legacy copier handles every other direction: `gbrain migrate --to pglite`, PGLite to Postgres when `gbrain config set migrate.graduation false` opts out of graduation, and history-free brains on Windows. It re-creates pages through `putPage` (chunks, embeddings, links, tags, timeline, facts) and copies config rows minus the engine-local denylist (`MIGRATE_CONFIG_ENGINE_LOCAL_KEYS`: the target-owned `engine`/`version` connection + schema ledger and the physical embedding-column registry keys); skipped keys are printed, never silent, and the run ends with a per-table copied-count summary. It does not carry request IDs, withdrawals, attribution or ownership, so it refuses a managed brain and any brain with durable write history, fact withdrawals or canonical worktree ownership (rows in `persistence_requests`, `fact_withdrawals` or `persistence_worktrees`).
+
+<a id="engine-migration-refused"></a>**Engine migration refused (`writer_coordinator_required`).** The legacy copier's refusal is an agent-contract envelope whose `fix` names the refusing side; every branch verifies with the read-only `gbrain doctor --no-migrate --json`, and nothing has changed in either datastore:
+
+| Refusing side | `fix.next` | Next step |
+|---|---|---|
+| A PGLite brain with history moving to Postgres with graduation turned off | `ask_user` | Relay `user_message`: graduation moves this brain (`gbrain config set migrate.graduation true`, then the [two-command flow](guides/move-to-postgres.md#move-the-brain)), or keep it on PGLite and share it through `gbrain mcp expose`. |
+| A Postgres brain moving to PGLite | `report` | The brain stays on Postgres; moving down would drop its history. |
+| A target that already holds persistence history | `tell_user_to_run` | Rerun with an empty database the user provides (`--path` for a PGLite target). |
+
+On Windows, a PGLite brain with history gets `graduation_unsupported_platform` instead: it stays on PGLite and is shared with `gbrain mcp expose`.
+
+<a id="graduation-writer-held"></a>**Graduation refused: the brain is held (`graduation_source_writer_held`).** Graduation needs the PGLite kernel lock. A live stdio `gbrain serve` hands the brain over through the intent marker `<path>.gbrain-graduation.json` and exits; autopilot pauses. When another holder (an HTTP serve, a daemon, another command) does not release the brain within 30 seconds, the run refuses and names it with its pid and transport (`fix.next: tell_user_to_run`). The user stops that process, then the agent reruns the same `gbrain migrate` command. Verify with the read-only `gbrain migrate --status --json`. Nothing has changed in either datastore.
+
+The migration and the autopilot daemon do not race: both graduation and the
+legacy copier claim a cooperative pause marker before touching the target. The
+marker doubles as a migration mutex — a second concurrent migrate refuses to
+run (graduation exits 75 with `graduation_in_progress`), and a marker that
+cannot be written refuses the migration outright. Background job workers stop
+picking up new work while it is parked. The legacy copier then waits for
+in-flight sync/embed/cycle work and running jobs to drain (watching the DB lock
+table, capped by `GBRAIN_MIGRATE_QUIESCE_SECONDS` — default 300; `0` skips the
+wait). Graduation holds the PGLite kernel lock instead, so no other process has
+the brain open: expired run locks and active job leases are orphans it resets
+at once, and it waits only for queued write requests, bounded by
+`--drain-timeout` (default 60 seconds; exhaustion exits 11 with a
+`resume_command`). Cleanup registers the moment the claim lands, so the marker
+is released on failure and on catchable signals; a marker orphaned by an
+uncleanly killed run is adopted by a later migrate only after a pid-liveness
+check (a live migrate's marker is never stolen), and the daemon clears an
+orphan whose owning process died on its next poll. `gbrain autopilot --status`
+reports `paused` (exit 1) while the marker is parked and prints the marker
+path; on a host with no daemon running to self-heal, remove an orphan by hand
+only after confirming the pid it names is dead. After a clean flip the daemon
+detects the engine change on its next tick and relaunches onto the new engine,
+and the migration warns if an exported connection-string env var would
+override the new config (graduation lists such a variable as a plan blocker).
### Troubleshooting: startup abort (`RuntimeError: Aborted()`)
diff --git a/docs/INSTALL.md b/docs/INSTALL.md
index 4641dbd794..6d4217be3c 100644
--- a/docs/INSTALL.md
+++ b/docs/INSTALL.md
@@ -81,10 +81,12 @@ gbrain init --prefer-postgres # env URL → Supabase token discovery → loca
To switch later:
```bash
-gbrain migrate --to supabase # PGLite → Postgres
-gbrain migrate --to pglite # Postgres → PGLite (rare)
+gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --json # PGLite → Postgres: prints the plan, exits 3
+gbrain migrate --to pglite # Postgres → PGLite (rare; brains without write history)
```
+The move to Postgres carries the brain's full history and runs after the user approves the plan (`--yes --expect <plan_hash>`). Walkthrough: [Move a PGLite brain to Postgres](guides/move-to-postgres.md).
+
If Postgres access ever breaks at runtime, `gbrain engine status --probe` diagnoses it and `gbrain db-repair` fixes it — see the "Engine detection and access repair" section of [`docs/ENGINES.md`](ENGINES.md).
For shared / large / multi-machine deployments (a team or company brain with multiple users hitting one server over HTTP MCP with OAuth scoping per user), follow the dedicated walkthrough: **[Tutorial: set up GBrain as your company brain](tutorials/company-brain.md)**.
diff --git a/docs/TESTING.md b/docs/TESTING.md
index 638d34f94b..5156ec593c 100644
--- a/docs/TESTING.md
+++ b/docs/TESTING.md
@@ -2167,7 +2167,7 @@ E2E tests live in `test/e2e/` and run against real Postgres+pgvector (require `D
- `test/e2e/serve-http-oauth.test.ts` — real-Postgres E2E against `gbrain serve --http` with full OAuth 2.1. Spawns a subprocess server, registers a client via the CLI, mints `client_credentials` tokens, exercises the `/mcp` JSON-RPC pipeline. Real DCR `/register` HTTP-level response-shape test (asserts `typeof body.client_id_issued_at === 'number'` over the wire, RFC 7591 §3.2.1); real CLI subprocess test for `revoke-client` (registers → mints token → revokes via `execSync` → asserts token rejected at `/mcp` → asserts re-run exits 1); server fixture flips on `--enable-dcr` so `/register` is reachable. **bun execSync env-inheritance contract:** bun's `execSync` does NOT inherit env mutations done via `process.env.X = ...`, only OS-level env from before bun started. helpers.ts loads `.env.testing` and sets `DATABASE_URL` via `process.env` mutation, which is invisible to subprocesses unless `env: { ...process.env }` is passed explicitly — every subprocess call in this file passes `env: { ...process.env }`. The same contract applies to the sibling sync/cycle/dream/claw-test E2Es. `afterAll` cleanup is guarded on `clientId` (won't throw if `beforeAll` failed before registration); cleanup errors surface to stderr without throwing so real test failures aren't masked. Also covers the trust boundary: an HTTP MCP `submit_job` for `name: "shell"` MUST reject with a permission error (request handler sets `remote: true` and `submit_job`'s protected-name guard fires), and the same guard rejects subagent submission. Skips without `DATABASE_URL`.
- `test/e2e/sync-parallel.test.ts` — `DATABASE_URL`-gated. 60-file Postgres sync at concurrency=4 imports all + no connection leak (probes `pg_stat_activity` before/after to confirm worker engines disconnected). 120-file serial-vs-parallel benchmark prints `SYNC_PARALLEL_BENCH N files | serial=Xms | parallel(4)=Yms | speedup=Zx`. Asserts parallel ≤ serial × 1.5 (CI-noise tolerant; not a strict speedup gate).
- `test/e2e/multi-source-bug-class.test.ts` — PGLite in-memory regression suite pinning every multi-source bug site: `listAllPageRefs` ordering by `(source_id, slug)`, `getPage` with sourceId picks the right `(source, slug)` row, `extract-takes` processes both overlapping `people/alice` rows independently, `listPages` filters correctly with `PageFilters.sourceId`, `addLinksBatch` with `from/to_source_id` targets the right rows, `validateSourceId` rejects path traversal, reverse-write disk layout uses `brainDir/.sources/<id>/<slug>.md` for non-default sources, `copyMigrationSources` lands source metadata before overlapping-slug pages. No `DATABASE_URL` needed. Wired into `scripts/e2e-test-map.ts` so changes to extract-takes / patterns / synthesize / embed / extract / migrate-engine auto-trigger it.
-- `test/e2e/migrate-engine-sources-postgres.test.ts` — `DATABASE_URL`-gated companion for `gbrain migrate --to`: migrates a PGLite brain carrying two non-default sources with overlapping slugs into real Postgres and asserts `copyMigrationSources` created every `sources` FK parent (config JSONB intact, not double-encoded) before any page write. Unit-level manifest identity (crash manifest resumes only against the SAME target; legacy engine-only manifests start fresh) is `test/migrate-engine-resume.test.ts`.
+- `test/e2e/migrate-engine-sources-postgres.test.ts` — `DATABASE_URL`-gated companion for the legacy engine copier (`gbrain migrate --to pglite`, and `--to postgres` with `migrate.graduation false`): migrates a PGLite brain carrying two non-default sources with overlapping slugs into real Postgres and asserts `copyMigrationSources` created every `sources` FK parent (config JSONB intact, not double-encoded) before any page write. Unit-level manifest identity (crash manifest resumes only against the SAME target; legacy engine-only manifests start fresh) is `test/migrate-engine-resume.test.ts`.
- `test/e2e/facts-fence-reconcile-postgres.test.ts` — `DATABASE_URL`-gated round-trip for the escape-aware fence parser: renders a `## Facts` fence whose cells carry literal pipes, backslashes (Windows paths), and empty cells via `renderFactsTable`, runs the wipe-and-reinsert reconcile (`runExtractFacts`) on real Postgres, and asserts every cell survives byte-identically with no column shift.
- `test/e2e/source-isolation-pglite.test.ts` — PGLite in-memory regression suite pinning the source-isolation seal at two layers. Engine layer: `searchKeyword` / `searchVector` / `searchKeywordChunks` / `listPages` / `getPage` / `traverseGraph` / `traversePaths` apply `sourceId` (scalar fast path) and `sourceIds` (array path) correctly across both engines. Op-handler layer: routes through `sourceScopeOpts(ctx)` so a `read+write`-scoped OAuth client bound to `--source dept-x` cannot see rows from neighboring sources via `search`, `query`, `list_pages`, `get_page`, or `find_experts`. Covers both `ctx.sourceId` (single-source clients) and `ctx.auth.allowedSources` (federated_read clients) precedence; federated array wins over scalar wins over nothing. No `DATABASE_URL` needed.
- `test/e2e/think-source-isolation-pglite.test.ts` — PGLite in-memory suite pinning the `think` gather stage's source scope: seeds three sources with cross-source links and embedded takes, then asserts `runGather` under a federated `sourceIds` grant (and under a scalar `sourceId`) keeps every stream — hybrid retrieval, takes keyword + vector (`searchTakes`/`searchTakesVector`), and the `traversePaths` graph walk — inside the grant while still reaching authorized neighboring sources. No `DATABASE_URL` needed.
diff --git a/docs/architecture/key-files/commands-4.md b/docs/architecture/key-files/commands-4.md
index 6860ca5651..5f7d3048d2 100644
--- a/docs/architecture/key-files/commands-4.md
+++ b/docs/architecture/key-files/commands-4.md
@@ -24,7 +24,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL
- `src/commands/migrate-embeddings.ts` — `gbrain migrate embeddings --to <provider:model> [--dim N] [--dry-run] [--yes] [--json] [--no-embed] [--status] [--reranker auto|off|keep|<model>] [--retarget] [--batch-size N] [--pace[=mode]] [--ignore-env-override]` (alias: `gbrain retrieval-upgrade`). ONE shared orchestrator for CLI and the `migrate_embeddings` op: `planMigrationFlow` (plan + `verifyMigrationComplete` + env presence + un-merged file plane + brain/DB identity via `redactPgUrl` + concurrent-writer census + reranker plan + in-flight-other marker) and `executeMigrationFlow` (global `gbrain-embedding-migration` DbLock → retarget gate under it → all-source embed locks sorted with `includeArchived` → worst-case authorization under the locks (a cap below it returns `refused_budget` / op `refused` with `embedding_budget_below_worst_case` before any provider call or invalidation) → live embed probe → apply → reranker probe + switch → drain via `runEmbedCore({heldLocks, …})` so the migration never lock_skips itself, with a 5-min heartbeat whose refresh-false/3-errors ABORTS as `lock_lost` → reconcile → completion smoke check stamped into the marker → transactional complete; locks released in finally). The skip path exits 0 ONLY on `verify.complete` with no pending retarget decision and no pending reranker action (a resolved switch/disable runs as a config-only completion). `--status` is read-only/spend-free and never refuses on env (it REPORTS planes, key PRESENCE booleans only, censuses, markers verbatim incl. corrupt, the exact resume command, and the last completion + smoke-check outcome). `persistEmbeddingFileConfig` writes through `loadConfigFileOnly` (never persists env-sourced keys) and supports env-canonical no-file deployments (env pins target ⇒ proceed with notice). Exit codes: 0 completed/verified-no-work, 1 locked/refused/failed/incomplete (message names which; lock_skipped and lock_lost get their own copy), 3 consent required (agent operator wave C2: `requireConsent` with effects `paid` + `destructive`; `spend.posture=tokenmax` covers only the paid part, `--json` never implies consent, the payload's fix repeats the caller's argv plus `--yes`; the TTY prompt is interaction.readLine, and the `confirm`/`isTTY` test seams map onto ConsentEnv). Spend stays bounded by the durable `--max-cost-usd` authorization, not the consent cap. Pinned by `test/migrate-embeddings-flow.serial.test.ts`, `test/migrate-embeddings-boundary.serial.test.ts`, `test/migrate-embeddings-hardening.serial.test.ts`. Migration guidance uses `renderCanonicalMigrationCommands` (`src/core/ai/defaults.ts`) to keep supported targets and dimensions consistent.
-- `src/commands/migrate-engine.ts` — Bidirectional engine migration (`gbrain migrate --to supabase/pglite`). Copies the complete source catalog FIRST (`copyMigrationSources` — every `sources` row incl. archived rows and sync/routing metadata, `ON CONFLICT (id) DO UPDATE`, `default` ordered first) so every page write has a valid `pages.source_id` FK parent and the target preserves per-source behavior; pages copy afterward: `listAllPageRefs` lists every live page's `(source_id, slug)` in one uncapped query, `copyMigrationPages` reads each body with `getPage(slug, { sourceId })` (a page soft-deleted after the listing reads null and is skipped, reported, and kept out of the link copy; it is not a failure), and each page is tracked in the resume manifest by composite `(source_id, slug)` key. Link copy preserves each row's `to_source_id` (falling back to the origin source only for legacy rows without it), and failed-target filtering uses that same target composite key, so cross-source links migrate without being rebound to the origin source. The resume manifest is target-aware: `migrationTargetId(config)` hashes `(engine, locator)` (`database_url` for Postgres, resolved `database_path` for PGLite) and `manifestMatchesTarget` requires `schema_version === 2` plus a matching `target_id` — a legacy engine-only manifest, or one from a DIFFERENT target of the same engine kind, starts fresh instead of skipping "completed" pages the new target never received. After links, `copyMigrationFacts` carries the facts table verbatim (conversation facts have no markdown fence to re-sync from): source∩target column intersection via information_schema (older source schemas still copy), delete-and-recopy so every re-run converges to source truth, two-pass `superseded_by` restore (the self-FK points old→newer id, so id-ordered single-pass inserts would violate it), embeddings round-tripped as text into whichever physical type (`vector`/`halfvec`) the target column has with a NULL-embedding retry on per-row cast failure, and a `setval` bump so post-migration inserts don't collide with copied ids; fact-row failures block the config flip and force a non-zero exit, same contract as page failures. Takes are deliberately NOT copied (fence-canonical, keyed on target-reassigned `page_id`; the next extract cycle rebuilds them). `copyMigrationConfig` then copies EVERY DB-plane config row except the explicit engine-local denylist `MIGRATE_CONFIG_ENGINE_LOCAL_KEYS` (`engine`, `version` = target-owned schema ledger, `embedding_columns` + `search_embedding_column` = physical-column registry the copy doesn't materialize); skipped keys print in the end-of-run per-table copied-count summary, so nothing is dropped silently. Pinned by `test/migrate-engine-resume.test.ts` (manifest identity) + `test/e2e/migrate-engine-sources-postgres.test.ts` (source catalog lands before overlapping-slug pages, PGLite → real Postgres) + `test/e2e/multi-source-bug-class.test.ts` (cross-source links) + `test/migrate-engine-completeness.serial.test.ts` (facts chains/embeddings/sequence, config copy-all + denylist, summary) + `test/migrate-engine-pagination.serial.test.ts` (no listing cap; a page deleted mid-copy). Legacy engine copies explicitly include stored unverified chunks and queue sanitized text rebuilding under the target revision; retrieval stays gated until rebuilt. Both source and target refuse any durable request history, withdrawal ledger, or ownership record before copying/clearing because this copier cannot preserve those identities.
+- `src/commands/migrate-engine.ts` — Legacy engine copier (`gbrain migrate --to pglite`, and PGLite → Postgres when `migrate.graduation` is `false`). A PGLite → Postgres move routes to `src/commands/migrate-graduation.ts` (engine graduation) before connect and never reaches this file. Copies the complete source catalog FIRST (`copyMigrationSources` — every `sources` row incl. archived rows and sync/routing metadata, `ON CONFLICT (id) DO UPDATE`, `default` ordered first) so every page write has a valid `pages.source_id` FK parent and the target preserves per-source behavior; pages copy afterward: `listAllPageRefs` lists every live page's `(source_id, slug)` in one uncapped query, `copyMigrationPages` reads each body with `getPage(slug, { sourceId })` (a page soft-deleted after the listing reads null and is skipped, reported, and kept out of the link copy; it is not a failure), and each page is tracked in the resume manifest by composite `(source_id, slug)` key. Link copy preserves each row's `to_source_id` (falling back to the origin source only for legacy rows without it), and failed-target filtering uses that same target composite key, so cross-source links migrate without being rebound to the origin source. The resume manifest is target-aware: `migrationTargetId(config)` hashes `(engine, locator)` (`database_url` for Postgres, resolved `database_path` for PGLite) and `manifestMatchesTarget` requires `schema_version === 2` plus a matching `target_id` — a legacy engine-only manifest, or one from a DIFFERENT target of the same engine kind, starts fresh instead of skipping "completed" pages the new target never received. After links, `copyMigrationFacts` carries the facts table verbatim (conversation facts have no markdown fence to re-sync from): source∩target column intersection via information_schema (older source schemas still copy), delete-and-recopy so every re-run converges to source truth, two-pass `superseded_by` restore (the self-FK points old→newer id, so id-ordered single-pass inserts would violate it), embeddings round-tripped as text into whichever physical type (`vector`/`halfvec`) the target column has with a NULL-embedding retry on per-row cast failure, and a `setval` bump so post-migration inserts don't collide with copied ids; fact-row failures block the config flip and force a non-zero exit, same contract as page failures. Takes are deliberately NOT copied (fence-canonical, keyed on target-reassigned `page_id`; the next extract cycle rebuilds them). `copyMigrationConfig` then copies EVERY DB-plane config row except the explicit engine-local denylist `MIGRATE_CONFIG_ENGINE_LOCAL_KEYS` (`engine`, `version` = target-owned schema ledger, `embedding_columns` + `search_embedding_column` = physical-column registry the copy doesn't materialize); skipped keys print in the end-of-run per-table copied-count summary, so nothing is dropped silently. Pinned by `test/migrate-engine-resume.test.ts` (manifest identity) + `test/e2e/migrate-engine-sources-postgres.test.ts` (source catalog lands before overlapping-slug pages, PGLite → real Postgres) + `test/e2e/multi-source-bug-class.test.ts` (cross-source links) + `test/migrate-engine-completeness.serial.test.ts` (facts chains/embeddings/sequence, config copy-all + denylist, summary) + `test/migrate-engine-pagination.serial.test.ts` (no listing cap; a page deleted mid-copy). Legacy engine copies explicitly include stored unverified chunks and queue sanitized text rebuilding under the target revision; retrieval stays gated until rebuilt. Both source and target refuse any durable request history, withdrawal ledger, or ownership record before copying/clearing because this copier cannot preserve those identities.
- `src/commands/migrations/` — TS migration registry (compiled into the binary; no runtime walk of `skills/migrations/*.md`). `index.ts` lists migrations in semver order. `v0_11_0.ts` = Minions adoption orchestrator (8 phases). `v0_12_0.ts` = Knowledge Graph auto-wire orchestrator (5 phases: schema → config check → backfill links → backfill timeline → verify); `phaseASchema` has a 600s timeout for duplicate-heavy brains; the config check reads `auto_link` in-process (file/env plane, then the database), never through a `gbrain config get` child. `v0_12_2.ts` = JSONB double-encode repair orchestrator (4 phases: schema → repair-jsonb → verify → record). `v0_14_0.ts` = shell-jobs + autopilot cooperative (pending-host-work ping for skills/migrations/v0.14.0.md; raises `minion_jobs.max_stalled`'s default to 3 only when it is below 3, so it never lowers schema v15's 5). Fresh installs (E8): `Migration.fresh_install_noop: true` marks an orchestrator that changes nothing on a brain `gbrain init` just created; `fresh-install.ts:recordFreshInstallMigrations` (one call in each init engine path, only when init created the database) appends a `complete` ledger entry with `fresh_install: true` + `installed_version` for each, and every other migration lists as `pending_fresh_install` (`src/core/migration-ledger.ts:freshInstallVersion`/`isPendingFreshInstall`) in `apply-migrations --list [--json]`/`--dry-run`, `get_health.migrations` and doctor's `minions_migration` (an `ok`/`info` row with `gbrain apply-migrations --yes --no-autopilot-install`); stamps never count as forward progress over a real partial. Each flag is proven by `test/migrations-fresh-install-audit.serial.test.ts` (schema, row counts, config table and GBRAIN_HOME file tree unchanged by the real orchestrator on a keyless `init --pglite --no-embedding` brain); unit coverage `test/migrations-fresh-install.test.ts`. `shared-content.ts` names its read-only next step as phase `argv` (`SHARED_CONTENT_INSPECT_ARGV`), which the runner prints and the ledger keeps. All orchestrators are idempotent and resumable from `partial` status. The RUNNER owns all ledger writes — orchestrators return `OrchestratorResult` and `apply-migrations.ts` persists a canonical `{version, status, phases}` shape (orchestrators never call `appendCompletedMigration`). `statusForVersion` prefers `complete` over `partial` (never regresses); 3 consecutive partials → wedged → `--force-retry <version>` writes a `'retry'` reset marker. Schema-only migrations v14 (`pages_updated_at_index`) + v15 (`minion_jobs_max_stalled_default_5` with UPDATE backfill) live in `src/core/schema-migrations/v014-pages-updated-at-index.ts` and `v015-minion-jobs-max-stalled-default-5.ts` (one file per schema migration; `migrate.ts` is the runner). `in-process.ts` exports `runMigrateOnlyCore({timeoutMs?})` — single source of truth for "bring schema to head" (`configureGateway` → `createEngine` → `connect` → `initSchema` → `disconnect`, idempotent, 600s `MIGRATE_ONLY_TIMEOUT_MS` guard, throws `MigrateOnlyError` on no-config / timeout); the orchestrators' 9 schema phases AND `init.ts:initMigrateOnly` both delegate to it so schema bring-up can't drift (in-process, so no spawn can die with `getaddrinfo ENOTFOUND` on Windows + bun + Supabase pooler). `runGbrainSubprocess` is the diagnostic wrapper for the remaining non-schema spawns (extract/repair/stats): captures child stderr (64MB buffer) into the thrown error. `v0_13_1.ts:phaseCGrandfather` is a CHUNKED bulk SQL pass keyed on `pages.id` (globally unique PK, NOT slug — slug uniqueness is `(source_id, slug)`), filters `deleted_at IS NULL` (no tombstones), chunked in `CHUNK_SIZE` batches (DELETE_BATCH_SIZE convention) for bounded lock-hold; the rollback log carries `{id, slug, source_id, pre_frontmatter}` so rollback is unambiguous across sources; idempotent + resumable (each UPDATE flips its rows out of `GRANDFATHER_WHERE`). Pinned by `test/migration-in-process.serial.test.ts` and `test/migrations-v0_13_1-grandfather.test.ts`.
diff --git a/docs/architecture/system-of-record.md b/docs/architecture/system-of-record.md
index 3750c6d9c7..5aa43068ed 100644
--- a/docs/architecture/system-of-record.md
+++ b/docs/architecture/system-of-record.md
@@ -174,9 +174,11 @@ Nothing is inferred for older rows. `gbrain repair attribution-backfill` fills
only rows the write journal proves exactly (the page write whose recorded
result is that revision, the `remember` that inserted that fact) and leaves the
rest `unrecorded`. Attribution is not file-backed: rebuilding from Markdown
-loses it, and `gbrain migrate --to` copies it verbatim only for facts (pages, takes
-and timeline rows are re-created on the target and start `unrecorded`; version
-history is not copied).
+loses it. Graduation (`gbrain migrate --to postgres` on a PGLite brain) copies
+every attributed row verbatim, version history included. The legacy copier
+(`gbrain migrate --to pglite`, or graduation turned off) copies it verbatim only
+for facts (pages, takes and timeline rows are re-created on the target and
+start `unrecorded`; version history is not copied).
- **Managed brains:** creation attribution is complete. The writer guard
refuses a canonical write outside `withCoordinatedWrite`, so a direct writer
diff --git a/docs/guides/error-codes.md b/docs/guides/error-codes.md
index 13f925c9a0..99d9e6b6cb 100644
--- a/docs/guides/error-codes.md
+++ b/docs/guides/error-codes.md
@@ -685,6 +685,16 @@ More: [docs/guides/write-refusals.md#embedding_auth_failed](../../docs/guides/wr
|---|---|---|---|---|---|---|
| The embedding model cannot produce the width of the brain's vector column; nothing was changed. | The request itself was wrong or no longer matches the brain; nothing was changed. | Correct the request using the message above, then retry. | agent | `repeat the read that failed` | 1 | no |
+### engine_graduated
+
+<a id="engine_graduated"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| A client opened a PGLite brain that moved to Postgres; its old path holds a tombstone. | The request itself was wrong or no longer matches the brain; nothing was changed. | Correct the request using the message above, then retry. | agent | `repeat the read that failed` | 1 | no |
+
+More: [docs/guides/move-to-postgres.md#graduated-datastore](../../docs/guides/move-to-postgres.md#graduated-datastore)
+
### export_limit
<a id="export_limit"></a>
@@ -825,6 +835,166 @@ More: [docs/guides/write-refusals.md#fetch_failed](../../docs/guides/write-refus
|---|---|---|---|---|---|---|
| A git command did not complete. | A temporary condition (a lock, a pending write, a rate limit); the same request can succeed later. | Wait briefly, then retry the same request (writes: reuse the same request_id). | agent | `repeat the read that failed` | 1 | yes |
+### graduation_drain_timeout
+
+<a id="graduation_drain_timeout"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| Queued or running writes did not drain within --drain-timeout; the move stopped before copying and the source is unchanged. | A temporary condition (a lock, a pending write, a rate limit); the same request can succeed later. | Wait briefly, then retry the same request (writes: reuse the same request_id). | agent | `repeat the read that failed` | 11 | yes |
+
+Reasons: `progressing`, `blocked`.
+
+More: [docs/guides/move-to-postgres.md#drain](../../docs/guides/move-to-postgres.md#drain)
+
+### graduation_embedding_dimension_mismatch
+
+<a id="graduation_embedding_dimension_mismatch"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| An existing, non-empty target database has a different embedding column layout than the brain being moved. | The request itself was wrong or no longer matches the brain; nothing was changed. | Correct the request using the message above, then retry. | agent | `repeat the read that failed` | 1 | no |
+
+More: [docs/guides/move-to-postgres.md#embeddings](../../docs/guides/move-to-postgres.md#embeddings)
+
+### graduation_foreign_host_binding
+
+<a id="graduation_foreign_host_binding"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| A source's worktree is owned by another host, so this host cannot move it to Postgres. | Only the operator of the brain host can change what blocks this. | Only the brain host's operator can resolve this. Tell the user the message and run `gbrain doctor --json` on the brain host. | host_admin | `gbrain doctor --json` | 1 | no |
+
+More: [docs/guides/move-to-postgres.md#hosts](../../docs/guides/move-to-postgres.md#hosts)
+
+### graduation_in_progress
+
+<a id="graduation_in_progress"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| Another process is moving this brain to Postgres; neither engine may be opened until it finishes. | A temporary condition (a lock, a pending write, a rate limit); the same request can succeed later. | Wait briefly, then retry the same request (writes: reuse the same request_id). | agent | `repeat the read that failed` | 75 | yes |
+
+More: [docs/guides/move-to-postgres.md#in-progress](../../docs/guides/move-to-postgres.md#in-progress)
+
+### graduation_interrupted
+
+<a id="graduation_interrupted"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| An engine graduation stopped before it finished and no process owns it. | A capability this request needs is not configured or not reachable on this brain. | A required capability is not available on this brain. Run `gbrain doctor --json` to see what is missing. | agent | `gbrain doctor --json` | 1 | no |
+
+More: [docs/guides/move-to-postgres.md#resume](../../docs/guides/move-to-postgres.md#resume)
+
+### graduation_rollback_writes_lost
+
+<a id="graduation_rollback_writes_lost"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| Rolling back to PGLite would drop changes made on Postgres since the move. | The step needs the user's decision before it runs. | Stop and ask the user; re-run only with the authorization the message names. | user | `repeat the read that failed` | 1 | no |
+
+Reasons: `user_data`, `security_changes`.
+
+More: [docs/guides/move-to-postgres.md#rollback](../../docs/guides/move-to-postgres.md#rollback)
+
+### graduation_source_writer_held
+
+<a id="graduation_source_writer_held"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| A live serve or daemon holds the PGLite brain and did not hand it over to the move. | Only the operator of the brain host can change what blocks this. | Only the brain host's operator can resolve this. Tell the user the message and run `gbrain doctor --json` on the brain host. | host_admin | `gbrain doctor --json` | 1 | no |
+
+More: [docs/ENGINES.md#graduation-writer-held](../../docs/ENGINES.md#graduation-writer-held)
+
+### graduation_split_brain
+
+<a id="graduation_split_brain"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| A different brain appeared at the graduated brain's old path; the target is withheld from authority until the user decides. | A capability this request needs is not configured or not reachable on this brain. | A required capability is not available on this brain. Run `gbrain doctor --json` to see what is missing. | agent | `gbrain doctor --json` | 1 | no |
+
+More: [docs/guides/move-to-postgres.md#split-brain](../../docs/guides/move-to-postgres.md#split-brain)
+
+### graduation_target_auth_failed
+
+<a id="graduation_target_auth_failed"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| The target database rejected the credentials recorded for this move. | The request itself was wrong or no longer matches the brain; nothing was changed. | Correct the request using the message above, then retry. | agent | `repeat the read that failed` | 1 | no |
+
+More: [docs/guides/move-to-postgres.md#credentials](../../docs/guides/move-to-postgres.md#credentials)
+
+### graduation_target_ddl_unreachable
+
+<a id="graduation_target_ddl_unreachable"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| The target's direct (schema) connection is unreachable or names a different database than its main URL. | A capability this request needs is not configured or not reachable on this brain. | A required capability is not available on this brain. Run `gbrain doctor --json` to see what is missing. | agent | `gbrain doctor --json` | 1 | no |
+
+More: [docs/guides/move-to-postgres.md#ddl-connection](../../docs/guides/move-to-postgres.md#ddl-connection)
+
+### graduation_target_not_empty
+
+<a id="graduation_target_not_empty"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| The target database already holds data that is not this move's. | The request itself was wrong or no longer matches the brain; nothing was changed. | Correct the request using the message above, then retry. | agent | `repeat the read that failed` | 1 | no |
+
+More: [docs/guides/move-to-postgres.md#target-not-empty](../../docs/guides/move-to-postgres.md#target-not-empty)
+
+### graduation_target_unsupported
+
+<a id="graduation_target_unsupported"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| The target database is missing a prerequisite (server version, vector extension with halfvec, CREATE privilege or a matching column). | The request itself was wrong or no longer matches the brain; nothing was changed. | Correct the request using the message above, then retry. | agent | `repeat the read that failed` | 1 | no |
+
+Reasons: `server_version`, `vector`, `halfvec`, `create_privilege`, `column`, `env_override`.
+
+More: [docs/guides/move-to-postgres.md#target-requirements](../../docs/guides/move-to-postgres.md#target-requirements)
+
+### graduation_unclassified_table
+
+<a id="graduation_unclassified_table"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| A database has a relation the graduation inventory does not classify, so moving it could lose data. | The server failed; this is not a caller mistake. | Server-side failure, not a caller mistake. Run `gbrain doctor --json` on the brain host; if it repeats, report it to the user. | host_admin | `gbrain doctor --json` | 1 | no |
+
+Reasons: `newer_target`, `missing_row`.
+
+More: [docs/guides/move-to-postgres.md#inventory](../../docs/guides/move-to-postgres.md#inventory)
+
+### graduation_unsupported_platform
+
+<a id="graduation_unsupported_platform"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| Moving a brain with write history to Postgres is not available on this platform yet. | Only the operator of the brain host can change what blocks this. | Only the brain host's operator can resolve this. Tell the user the message and run `gbrain doctor --json` on the brain host. | host_admin | `gbrain doctor --json` | 1 | no |
+
+More: [docs/guides/move-to-postgres.md#platforms](../../docs/guides/move-to-postgres.md#platforms)
+
+### graduation_verify_failed
+
+<a id="graduation_verify_failed"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| The moved copy did not verify against the source; the target stays fenced and the source stays authoritative. | The server failed; this is not a caller mistake. | Server-side failure, not a caller mistake. Run `gbrain doctor --json` on the brain host; if it repeats, report it to the user. | host_admin | `gbrain doctor --json` | 1 | no |
+
+Reasons: `count`, `digest`, `sequence`, `fk`, `trigger`, `relation_set`, `replay`, `doctor`.
+
+More: [docs/guides/move-to-postgres.md#verify](../../docs/guides/move-to-postgres.md#verify)
+
### graph_incomplete
<a id="graph_incomplete"></a>
diff --git a/docs/guides/exit-codes.md b/docs/guides/exit-codes.md
index ec8d12d5ba..ac1c37048c 100644
--- a/docs/guides/exit-codes.md
+++ b/docs/guides/exit-codes.md
@@ -45,3 +45,4 @@ they need the user's confirmation (documented legacy; changing it is a v2 item).
| `gbrain doctor --remediate` without a terminal and without `--yes` | 0 (it ran) | 3 | paid and destructive work waits for the user |
| `gbrain autopilot --interval`, `serve --port`, `dream --phase`, `init --mcp-only` missing flags, `delta --since` with a bad value | 1 | 2 | invalid input |
| `gbrain jobs submit` on PGLite without `--follow` or `--queue-only` | 0 (queued, no worker) | 1 (`no_worker`) | the job would wait for a worker that is not running |
+| `gbrain migrate --to postgres` on a PGLite brain with write history | 1 (`writer_coordinator_required`) | 3 (plan; run with `--yes --expect`) | graduation carries the history; the bare command shows the plan and asks |
diff --git a/docs/guides/move-to-postgres.md b/docs/guides/move-to-postgres.md
new file mode 100644
index 0000000000..ef15b779a3
--- /dev/null
+++ b/docs/guides/move-to-postgres.md
@@ -0,0 +1,433 @@
+# Move a PGLite brain to Postgres
+
+`gbrain migrate --to postgres` moves a PGLite brain on this computer to a
+Postgres database, history included: pages, facts, takes, versions, write
+requests, withdrawals, tokens and OAuth clients all carry over with their IDs
+unchanged. The move is a verified graduation: gbrain drains pending writes,
+copies every table into a fenced target, checks every row against the source,
+runs `gbrain doctor` on the target, and only then switches the brain over. At
+every instant exactly one engine accepts writes, including across crashes.
+
+The move takes one command and one confirmation. The first command prints the
+plan and exits 3 without changing anything; the second runs it after the user
+agrees.
+
+**Say to your agent:** *"Upgrade my brain to Postgres. Show me the plan first."*
+
+**Say to your agent:** *"Move my brain to Supabase, then tell me what still
+depends on this computer."*
+
+**Say to your agent:** *"The brain move to Postgres stopped. Where is it, and
+what do I do next?"*
+
+The [postgres-adopt skill](../../skills/postgres-adopt/SKILL.md) walks the
+same flow for an agent.
+
+## Before you start
+
+- **A PGLite brain on this computer.** `gbrain engine status --json` reports
+ `effective_engine: "pglite"`. Graduation is CLI-only and runs on the brain
+ host; a thin client gets a refusal.
+- **An empty Postgres database.** Empty means no gbrain tables, or a gbrain
+ schema holding only the rows a fresh `gbrain init` writes. A database with
+ other data refuses with `graduation_target_not_empty`.
+- **The `vector` extension with `halfvec` support** (pgvector 0.7 or newer),
+ a server version gbrain supports, and the `CREATE` privilege on the
+ database. The plan checks each one and names the fix.
+- **Linux or macOS.** On Windows, a brain with write history stays on PGLite
+ (see [Platforms](#platforms)).
+- **No other client pointed at the target yet.** The target refuses writes
+ from anything but the graduation run until cutover; point other machines at
+ it afterwards.
+
+A running `gbrain serve` or autopilot on this brain does not need to be
+stopped: a stdio serve hands the brain over and exits, and autopilot pauses.
+
+## Put the target URL in an environment variable
+
+Keep the connection string out of shell history, process listings and agent
+transcripts:
+
+```bash
+read -rs GBRAIN_TARGET_URL && export GBRAIN_TARGET_URL # paste the URL, press Enter
+```
+
+Every graduation command takes `--url-env GBRAIN_TARGET_URL`, and every
+command gbrain prints shows `--url-env GBRAIN_TARGET_URL` or the redacted host,
+never the URL or password. Two alternatives exist: `--url -` reads the URL from
+stdin, and `--url <url>` takes it as an argument (visible in `ps` and shell
+history).
+
+The run records the full URL in `~/.gbrain/graduation-manifest.json`
+(mode 0600, like `config.json`), so `--status`, `--resume` and
+`--rollback-to-source` work in a fresh shell without the variable.
+
+### Supabase connection topology
+
+Use the **transaction pooler** string (port 6543) as the target URL. gbrain
+runs schema changes and locks on a separate direct connection, which it derives
+as `db.<project>.supabase.co:5432`; that host is IPv6-only. On an IPv4-only
+machine, set the direct connection to the **session pooler** before planning:
+
+```bash
+read -rs GBRAIN_DIRECT_DATABASE_URL && export GBRAIN_DIRECT_DATABASE_URL # session pooler, port 5432
+```
+
+The plan probes both routes and proves they reach the same database before any
+DDL. Background: [personal-brain tutorial, steps 7b and 7c](../tutorials/personal-brain.md#7b-get-the-transaction-pooler-connection-string-not-the-direct-one).
+
+## Move the brain
+
+### 1. Plan and ask
+
+```bash
+gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --json
+```
+
+Without `--yes` this changes nothing. It prints the plan as a
+`confirmation_required` document and exits 3. It never prompts on stdin.
+
+#### What you'll be asked
+
+The document (abridged) looks like this:
+
+```json
+{
+ "code": "confirmation_required",
+ "effects": ["egress", "destructive"],
+ "user_message": "Move this brain to Postgres at db.example.com?",
+ "plan_hash": "9f3c…",
+ "preview": { "command": "gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --plan --json" },
+ "fix": {
+ "next": "ask_user",
+ "command": "gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --yes --expect 9f3c…"
+ }
+}
+```
+
+The full document also lists what moves and what stays on this computer (see
+[What moves and what stays](#what-moves-and-what-stays)), the tables and row
+counts, blockers with their fixes, and the estimated time. The agent relays
+`user_message` and those two lists to the user and stops.
+
+`--plan` (alias `--dry-run`) prints the same plan read-only and exits 0. It
+runs no schema migration on either side and no DDL on the target.
+
+### 2. Run, after the user agrees
+
+```bash
+gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --yes --expect <plan_hash>
+```
+
+`--expect` binds the run to the plan the user saw. If anything the plan
+depends on changed since then (blockers, target contents, versions), the run
+refuses with `preview_changed`; go back to step 1. `--yes` without `--expect`
+re-plans and returns `confirmation_required` with a fresh hash.
+
+The run drains pending writes, copies, verifies, cuts over and ends with the
+target's `gbrain doctor` result. Its output names:
+
+- the multi-machine next step, `gbrain mcp expose` ([remote MCP](remote-mcp.md));
+- that existing access tokens, OAuth clients and local writer credentials stay
+ valid (see [Credentials](#credentials-after-the-move));
+- when a `gbrain serve` handed the brain over, that the MCP client needs a
+ restart (see [Restart the MCP client](#restart-the-mcp-client)).
+
+`--to supabase` is an alias of `--to postgres`; every command gbrain prints
+echoes the spelling you typed.
+
+### Large brains
+
+A brain with thousands of pages takes a while to move. Run it in the
+background and poll:
+
+```bash
+gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --yes --expect <plan_hash> --json > graduation.json &
+gbrain migrate --status --json
+```
+
+With `--json`, stdout carries one result document and progress goes to stderr
+as described in [progress events](../progress-events.md).
+
+### Exit codes
+
+| Exit | Meaning | What the agent does |
+|---|---|---|
+| 0 | graduated, or the plan was shown with `--plan` | continue |
+| 3 | `confirmation_required`: nothing changed | relay `user_message`; run `fix.command` only after the user agrees |
+| 1 | refused | follow the refusal's `fix` ([recovery by code](#recovery-by-code)) |
+| 2 | usage error | correct the command (`gbrain migrate --help`) |
+| 11 | resumable stop: `--drain-timeout` ran out while blockers still progress | run `resume_command` from the JSON |
+| 75 | `graduation_in_progress`: another run holds the migration | wait, then poll `gbrain migrate --status --json` |
+| 130 | interrupted (SIGINT); the run stopped at the next batch boundary | ask the user, then `gbrain migrate --resume` |
+
+## Check, resume or roll back
+
+These commands act on the run recorded in the manifest, so they need no
+`--to` or `--url`; passing a `--to` or `--url` that contradicts the run
+refuses.
+
+```bash
+gbrain migrate --status --json # read-only: state, tables, receipt, next command
+gbrain migrate --resume # continue from the first incomplete step
+gbrain migrate --rollback-to-source # discard the target; the PGLite brain stays authoritative
+```
+
+`--status` changes nothing, on either side, in any state.
+
+Rollback before cutover always succeeds and loses nothing. After cutover,
+rollback first fences the target, then checks for writes made on Postgres since
+the move:
+
+- With no new writes, the PGLite brain is restored and the target is
+ abandoned.
+- With new user data (pages, facts, takes and similar), rollback refuses with
+ `graduation_rollback_writes_lost` and lists what would be lost. After the
+ user agrees to that loss:
+ `gbrain migrate --rollback-to-source --yes --expect <hash>`.
+- With a fact withdrawal, or a token, OAuth or local-writer revocation or
+ credential change on the target, rollback refuses finally (`fix.next:
+ report`) and the target stays authoritative. Recover forward on Postgres.
+
+Rollback never writes anything back to the PGLite brain. A refused, declined
+or interrupted rollback returns the target to service.
+
+## What moves and what stays
+
+| Moves to the database | Stays on this computer |
+|---|---|
+| pages, facts, takes, versions, links, timeline | file storage object bytes (the storage backend's files) |
+| embeddings, transcripts and paid caches | git worktrees and their host bindings |
+| write request history and withdrawals | the MCP endpoint and OAuth issuer URL |
+| access token and OAuth rows (hashes, not secrets) | the retained `<path>.graduated-<run_id>` copy |
+
+The database side is everything another machine needs to query and write the
+brain. The host side is bound to this computer: worktrees owned by another host
+refuse the move (`graduation_foreign_host_binding`), and an MCP endpoint served
+from this machine keeps its URL.
+
+The `gbrain.graduation_run` setting and the `GBRAIN_GRADUATION_RUN` variable
+are safety interlocks that keep stray clients out during the move. They are
+not security boundaries.
+
+## After the move
+
+**The PGLite copy is retained.** The data dir is renamed to
+`<path>.graduated-<run_id>`. It still holds private memory and token hashes.
+`gbrain doctor` reports it under `pglite_leftovers` with its size and the
+deletion command; deleting it is the user's call.
+
+**The old path is a tombstone.** A small file sits where the data dir was. Any
+gbrain client pointed at it gets `engine_graduated` with a one-step fix
+([below](#graduated-datastore)); an older release fails to open it rather than
+creating an empty brain there.
+
+**Long-running processes follow.** Autopilot restarts onto Postgres. A
+`gbrain serve` started while the move runs exits with `graduation_in_progress`
+(exit 75); a stdio serve that held the brain hands it over through the intent
+marker `<path>.gbrain-graduation.json` and exits; a serve in status-only or
+degraded mode exits for relaunch when the engine changes.
+
+`gbrain engine status --json` reports the graduation state (intent marker,
+manifest state, tombstone, redacted target).
+
+### Credentials after the move
+
+Existing access tokens, OAuth clients and local writer credentials stay valid
+on Postgres. To issue fresh ones anyway:
+
+```bash
+gbrain auth revoke <name> && gbrain auth create <name> # access token
+gbrain auth revoke-client <client_id> && gbrain auth register-client <name> # OAuth client
+gbrain auth local-writer register stdio --replace # local writer (or: cli)
+```
+
+### Restart the MCP client
+
+When a serve handed the brain over, restart the MCP client so it launches a
+fresh `gbrain serve` on Postgres. Some desktop hosts stop relaunching a server
+that exited repeatedly.
+
+| Harness | Step |
+|---|---|
+| Claude Code | run `/mcp` and reconnect `gbrain`, or start a new session |
+| Claude Desktop | quit the app completely and reopen it |
+| Codex | start a new Codex session |
+| Cursor | turn the `gbrain` server off and on in the MCP settings |
+| OpenCode | restart opencode or start a new session |
+| OpenClaw, Hermes and other agents | restart the agent process |
+
+### Other machines
+
+To share the brain, run `gbrain mcp expose` on this host and connect other
+machines over MCP. A machine with its own config pointing at the old path gets
+`engine_graduated`; follow its fix.
+
+## Recovery by code
+
+Each refusal carries `why`, `fix` and a read-only `fix.verify`; follow `fix.next`
+per the [agent operator protocol](../protocol/AGENT_OPERATOR_v1.md). Unless a
+row says otherwise, the PGLite brain stays authoritative and writable.
+
+<a id="inventory"></a>
+### `graduation_unclassified_table`
+
+A table exists that this gbrain release does not know how to move. If the
+target was created by a newer gbrain, upgrade this binary. If the table comes
+from this release's own schema, it is a bug: report it. `--force` never
+overrides this. Verify: `gbrain migrate --plan --json`.
+
+<a id="embeddings"></a>
+### `graduation_embedding_dimension_mismatch`
+
+The target already holds embeddings of a different dimension. An empty target
+is sized from the source automatically, so this only happens with a non-empty
+target. Use an empty database, or `--force --expect <plan_hash>` after the
+plan lists what it wipes (ask the user).
+
+<a id="drain"></a>
+### `graduation_drain_timeout`
+
+Pending writes did not finish within `--drain-timeout` (default 60 seconds).
+When every blocker is still progressing the run exits 11; run the
+`resume_command`, for example `gbrain migrate --resume --drain-timeout 120`.
+A blocker that needs a person (a stuck recovery, a writer admin lock) carries
+its own command. Verify: `gbrain migrate --status --json`.
+
+<a id="target-not-empty"></a>
+### `graduation_target_not_empty`
+
+The target holds data that is not a fresh gbrain schema. Pick an empty
+database, or, after the user has seen `--plan` list what it deletes, rerun
+with `--force --expect <plan_hash>`. `--force` never bypasses the inventory
+check, a held writer or the fenced cutover.
+
+<a id="hosts"></a>
+### `graduation_foreign_host_binding`
+
+A worktree or pending write is bound to another host. Check it with
+`gbrain sources writer status <id>` and transfer ownership to this host first
+(`gbrain sources writer transfer prepare <source>` on the owner, then
+`transfer accept` here). The user runs this on both hosts.
+
+<a id="verify"></a>
+### `graduation_verify_failed`
+
+The target did not match the source (row counts, digests, foreign keys,
+sequences, the replay probe, or a doctor check that fails only on the target).
+The refusal names the table and first differing row. `gbrain migrate --resume`
+re-copies the mismatched tables once; a repeated mismatch is a bug to report,
+and `gbrain migrate --rollback-to-source` is the safe exit.
+
+<a id="resume"></a>
+### `graduation_interrupted`
+
+A run stopped (crash, SIGKILL, reboot) before finishing. `gbrain doctor`
+reports it as failing. Run `gbrain migrate --resume`, or
+`gbrain migrate --rollback-to-source`. Verify: `gbrain migrate --status --json`.
+
+<a id="in-progress"></a>
+### `graduation_in_progress`
+
+Another graduation run holds the brain (exit 75). Also returned to a
+`gbrain serve` started during the move, and to any client that reaches the
+target before cutover. Wait for the run and poll `gbrain migrate --status --json`.
+
+<a id="graduated-datastore"></a>
+### `engine_graduated`
+
+The client opened the old PGLite path after the brain moved. On the host that
+ran the move, `gbrain migrate --resume` finishes any remaining routing step.
+On any other machine, the user points the config at the target and restarts
+the MCP client:
+
+```bash
+gbrain config set database_url "$GBRAIN_TARGET_URL"
+```
+
+<a id="credentials"></a>
+### `graduation_target_auth_failed`
+
+The target rejected the recorded credentials, usually after a password change.
+Put the new URL for the same database in a variable and rerun with
+`--url-env <VAR>` (for example `gbrain migrate --resume --url-env GBRAIN_TARGET_URL`).
+A URL naming a different database is refused.
+
+<a id="ddl-connection"></a>
+### `graduation_target_ddl_unreachable`
+
+The direct connection gbrain uses for schema changes and locks is unreachable,
+or does not reach the same database as the main URL. On Supabase, set
+`GBRAIN_DIRECT_DATABASE_URL` to the session pooler
+([topology](#supabase-connection-topology)) and rerun the plan.
+
+<a id="target-requirements"></a>
+### `graduation_target_unsupported`
+
+The target misses a prerequisite: the server version, the `vector` extension
+with `halfvec`, the `CREATE` privilege, or a column whose type differs from
+the source. The refusal names which one and the fix. Verify:
+`gbrain migrate --plan --json`.
+
+<a id="platforms"></a>
+### `graduation_unsupported_platform`
+
+Windows, brain with write history. Keep the brain on PGLite and share it with
+`gbrain mcp expose`. A Windows brain without history moves with the legacy
+copier.
+
+<a id="rollback"></a>
+### `graduation_rollback_writes_lost`
+
+A rollback after cutover would drop writes made on Postgres. The refusal lists
+them by table and count. For user data, rerun
+`gbrain migrate --rollback-to-source --yes --expect <hash>` only after the user
+agrees to that loss. For withdrawals, revocations and credential changes the
+refusal is final; recover forward on Postgres.
+
+<a id="split-brain"></a>
+### `graduation_split_brain`
+
+A different brain appeared at the old PGLite path during the move, so the
+target is withheld from authority. `gbrain migrate --status --json` shows both
+paths with row counts and newest write times. Ask the user which to keep:
+move the stray brain aside and resume forward, or roll back.
+
+<a id="writer-held"></a>
+### `graduation_source_writer_held`
+
+A process holding the brain did not hand it over within 30 seconds (an HTTP
+serve, a daemon, or another command). The user stops the named process, then
+the agent reruns the command. Details:
+[ENGINES.md](../ENGINES.md#graduation-writer-held).
+
+## Options
+
+| Flag | Effect |
+|---|---|
+| `--url-env <VAR>`, `--url <url>`, `--url -` | the target URL (variable, argument or stdin) |
+| `--plan`, `--dry-run` | read-only plan, exit 0 |
+| `--yes --expect <plan_hash>` | run the plan the user approved |
+| `--drain-timeout <seconds>` | how long to wait for pending writes (default 60) |
+| `--trigger-bypass replica\|disable-trigger` | force the copy's trigger-bypass mechanism (part of the plan hash) |
+| `--batch-size <n>` | override the measured copy batch size (part of the plan hash) |
+| `--force` | wipe a non-empty target the plan listed; requires `--expect` |
+| `--json` | one result document on stdout; progress on stderr |
+| `--status`, `--resume`, `--rollback-to-source` | act on the recorded run |
+
+## Other directions and the legacy copier
+
+- `gbrain config set migrate.graduation false` sends PGLite to Postgres
+ moves through the legacy copier, which refuses brains with write history.
+- Postgres to PGLite (`gbrain migrate --to pglite`) always uses the legacy
+ copier and refuses brains with history.
+- Postgres to Postgres moves use `pg_dump` or the provider's tooling.
+
+## Known limits
+
+If the process is SIGKILLed in the instant between renaming the data dir and
+writing the tombstone, and an older gbrain release then opens the old path
+before this release does, that release can create an empty stray brain there.
+The next graduation command detects it and refuses with
+`graduation_split_brain`; the target is not made authoritative until the user
+decides.
diff --git a/docs/progress-events.md b/docs/progress-events.md
index 5ac77e5e64..dd0e008adf 100644
--- a/docs/progress-events.md
+++ b/docs/progress-events.md
@@ -19,7 +19,8 @@ Any of these commands stream events when `--progress-json` is set:
- `gbrain extract [links|timeline|all]` (fs or db source)
- `gbrain import`
- `gbrain sync`
-- `gbrain migrate --to …`
+- `gbrain migrate --to …` (graduation reports one phase per step and ticks per
+ table and batch; the legacy copier reports the `migrate.copy_*` phases below)
- `gbrain repair-jsonb`
- `gbrain check-backlinks`
- `gbrain lint`
diff --git a/docs/storage-tiering.md b/docs/storage-tiering.md
index 344178fa9d..02d0485d04 100644
--- a/docs/storage-tiering.md
+++ b/docs/storage-tiering.md
@@ -236,7 +236,7 @@ Enables consistent data access across environments:
## PGLite engine note
-On the PGLite engine (gbrain's local-only embedded Postgres), the "DB" your db_only pages live in IS the local file gbrain uses for everything else. The `.gitignore` housekeeping still helps (keeps bulk content out of git history), but the offload-to-DB promise is technically vacuous. A once-per-process soft-warn explains when the engine is detected. To get full tiering, migrate to Postgres with `gbrain migrate --to supabase`.
+On the PGLite engine (gbrain's local-only embedded Postgres), the "DB" your db_only pages live in IS the local file gbrain uses for everything else. The `.gitignore` housekeeping still helps (keeps bulk content out of git history), but the offload-to-DB promise is technically vacuous. A once-per-process soft-warn explains when the engine is detected. To get full tiering, move the brain to Postgres with `gbrain migrate --to postgres` ([guide](guides/move-to-postgres.md)).
## Compatibility
diff --git a/docs/tutorials/company-brain.md b/docs/tutorials/company-brain.md
index 619fc1139a..4d44a86347 100644
--- a/docs/tutorials/company-brain.md
+++ b/docs/tutorials/company-brain.md
@@ -48,13 +48,21 @@ It is also **not** a thin-client-everywhere setup. Your personal agent stays as
The personal-brain install uses Supabase as the embeddings layer but the GBrain runtime itself might be using PGLite (single-machine) depending on which path you took. For a company brain, you want a real Postgres for the runtime too. If your personal-brain install is already on Postgres or Supabase end-to-end, skip to Part 3.
-If you're on PGLite, migrate:
+If you're on PGLite, move the brain. Run from the agent host machine, same one you set up in the personal-brain tutorial, with the Supabase transaction-pooler URL in `GBRAIN_TARGET_URL`:
```bash
-gbrain migrate --to supabase
+gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --json
```
-This copies every page, chunk, embedding, link, and config over to your Supabase project. Run from the agent host machine, same one you set up in the personal-brain tutorial. Takes a few minutes per 10K pages.
+That prints the plan (what moves, what stays on this machine, estimated time) and exits 3 without changing anything. After you agree, run the command it prints:
+
+```bash
+gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --yes --expect <plan_hash>
+```
+
+Every page, fact, take, version, embedding, link, token and OAuth client moves with its history, and the run verifies every table before switching over. It ends with the target's `gbrain doctor` result. Full walkthrough and recovery: [Move a PGLite brain to Postgres](../guides/move-to-postgres.md).
+
+**Say to your agent:** *"Move my brain to Supabase so the team can share it. Show me the plan first."*
Verify:
diff --git a/docs/tutorials/personal-brain.md b/docs/tutorials/personal-brain.md
index d76ea3a142..8546eff253 100644
--- a/docs/tutorials/personal-brain.md
+++ b/docs/tutorials/personal-brain.md
@@ -124,7 +124,7 @@ gbrain init --supabase
gbrain skillpack scaffold --all
```
-`gbrain init --supabase` walks a short wizard that asks for your Supabase connection string and creates the schema. You'll get that connection string in Step 7 — read 7a and 7b first so you paste the right one (the transaction pooler, not the direct connection). If you'd rather try things locally before paying for a database, `gbrain init --pglite` gives you a zero-config embedded engine instead; you can migrate to Supabase later with `gbrain migrate --to supabase`.
+`gbrain init --supabase` walks a short wizard that asks for your Supabase connection string and creates the schema. You'll get that connection string in Step 7 — read 7a and 7b first so you paste the right one (the transaction pooler, not the direct connection). If you'd rather try things locally before paying for a database, `gbrain init --pglite` gives you a zero-config embedded engine instead; you can move it to Supabase later with `gbrain migrate --to postgres` ([guide](../guides/move-to-postgres.md)).
`gbrain skillpack scaffold --all` copies the 50+ bundled skills into your agent workspace as first-class files you can edit freely.
diff --git a/llms-full.txt b/llms-full.txt
index edf49a510b..04cc88e1f1 100644
--- a/llms-full.txt
+++ b/llms-full.txt
@@ -2576,7 +2576,7 @@ rung prints a one-line note and falls through; only the PGLite floor is terminal
| 2. Supabase discovery | Management-API project discovery (10s timeouts; the candidate URL is connect-probed before anything persists; discovery only — project CREATION stays dashboard guidance) | `SUPABASE_ACCESS_TOKEN` + `SUPABASE_DB_PASSWORD` (+ `SUPABASE_PROJECT_REF` on multi-project accounts) |
| 3. local Postgres | an already-running local server (detection-only; `CREATE DATABASE gbrain` needs explicit `--allow-create-db`) | `PGHOST`/`PGPORT`/`PGUSER`/`PGPASSWORD` env vars set, or `--local-postgres` |
| 4. docker | gbrain's own container `gbrain-postgres` (image `pgvector/pgvector:pg16`, loopback-only port 5434, data on the named `gbrain-pgdata` volume, `--restart unless-stopped`; idempotent reuse recovers credentials via `docker inspect`; refuses to share a container/volume that already holds a brain this home's config doesn't record; gbrain never stops or removes it) | explicit `--allow-docker` |
-| 5. PGLite floor | zero-config fallback, with an upgrade-later note (`gbrain migrate --to supabase`) | nothing |
+| 5. PGLite floor | zero-config fallback, with an upgrade-later note (the later move is `gbrain migrate --to postgres`; see [Move a PGLite brain to Postgres](docs/guides/move-to-postgres.md)) | nothing |
The ladder REFUSES to run over an already-configured brain — rung choice is
environment-dependent, so a re-run during an outage could silently repoint a
@@ -4869,7 +4869,7 @@ Different users have different constraints:
| Researcher | Analytics, bulk exports, embeddings | DuckDBEngine (someday) |
| Edge/mobile | Offline-first, sync later | PGLiteEngine + sync (someday) |
-The engine interface means we don't have to choose. PGLite is the zero-friction default. Supabase is the production scale path. `gbrain migrate --to supabase/pglite` moves between them.
+The engine interface means we don't have to choose. PGLite is the zero-friction default. Supabase is the production scale path. `gbrain migrate --to postgres` moves a PGLite brain to Postgres with its history ([guide](guides/move-to-postgres.md)); `gbrain migrate --to pglite` moves a brain without write history the other way.
## The interface
@@ -5143,26 +5143,47 @@ Details in INSTALL_FOR_AGENTS.md ("Engine preference for harness installs").
| Concurrency | Single process | Connection pooling |
| Backups | Manual (file copy) | Managed by Supabase |
-**Migration:** `gbrain migrate --to supabase` exports everything (pages, chunks, embeddings, links, tags, timeline, facts) and imports into Supabase. Config rows copy in full minus the engine-local denylist (`MIGRATE_CONFIG_ENGINE_LOCAL_KEYS`: the target-owned `engine`/`version` connection + schema ledger and the physical embedding-column registry keys); skipped keys are printed, never silent, and the run ends with a per-table copied-count summary. `gbrain migrate --to pglite` goes the other direction. The copy is lossless for what it carries, but it refuses two kinds of brain: a managed brain (`writer_coordinator_required`, "cannot mutate a managed brain through the legacy writer") and any brain with durable write history, fact withdrawals or canonical worktree ownership (rows in `persistence_requests`, `fact_withdrawals` or `persistence_worktrees`), because the copier cannot carry request IDs, withdrawals or ownership. A brain that has saved memory through the write coordinator (`remember`, `put_page` from an agent or a resident `gbrain serve`) has that history, so in practice `migrate --to` works only for brains that never used it. For those brains, keep the datastore and repair forward (`gbrain doctor`, `gbrain repair`) instead of migrating, and choose Postgres up front if you expect 1000+ files or several machines. An engine move that preserves request IDs, withdrawals, attribution, grants and ownership is planned, not shipped.
-
-The migration and the autopilot daemon do not race: `migrate --to` claims a
-cooperative pause marker before touching the target. The marker doubles as a
-migration mutex — a second concurrent migrate refuses to run, and a marker
-that cannot be written refuses the migration outright. Background job workers
-stop picking up new work while it is parked, and the migration waits for
-in-flight sync/embed/cycle work and running jobs to actually drain (watching
-the DB lock table, capped by `GBRAIN_MIGRATE_QUIESCE_SECONDS` — default 300;
-`0` skips the wait). Cleanup registers the moment the claim lands, so the
-marker is released on failure and on catchable signals; a marker orphaned by
-an uncleanly killed run is adopted by a later migrate only after a
-pid-liveness check (a live migrate's marker is never stolen), and the daemon
-clears an orphan whose owning process died on its next poll. `gbrain
-autopilot --status` reports `paused` (exit 1) while the marker is parked and
-prints the marker path; on a host with no daemon running to self-heal,
-remove an orphan by hand only after confirming the pid it names is dead.
-After a clean flip the daemon detects the engine change on its next
-tick and relaunches onto the new engine, and the migration warns if an
-exported connection-string env var would override the new config.
+**Migration:** on a PGLite brain, `gbrain migrate --to postgres` (alias `--to supabase`) graduates the brain to Postgres. Without `--yes` it prints the plan and exits 3; `--yes --expect <plan_hash>` runs it. Graduation drains pending writes, copies every table verbatim with its primary keys (pages, facts, takes, versions, links, timeline, embeddings, transcripts and paid caches, request history and withdrawals, token and OAuth rows) into a fenced target, verifies row counts and digests, runs `gbrain doctor` on the target, and only then flips routing. It works for brains with write history and for managed brains. The PGLite data dir is retained as `<path>.graduated-<run_id>` and a tombstone file takes its place. Walkthrough, recovery by error code, rollback and what stays on this computer: [Move a PGLite brain to Postgres](guides/move-to-postgres.md).
+
+**Say to your agent:** *"Upgrade my brain to Postgres. Show me the plan first."*
+
+The legacy copier handles every other direction: `gbrain migrate --to pglite`, PGLite to Postgres when `gbrain config set migrate.graduation false` opts out of graduation, and history-free brains on Windows. It re-creates pages through `putPage` (chunks, embeddings, links, tags, timeline, facts) and copies config rows minus the engine-local denylist (`MIGRATE_CONFIG_ENGINE_LOCAL_KEYS`: the target-owned `engine`/`version` connection + schema ledger and the physical embedding-column registry keys); skipped keys are printed, never silent, and the run ends with a per-table copied-count summary. It does not carry request IDs, withdrawals, attribution or ownership, so it refuses a managed brain and any brain with durable write history, fact withdrawals or canonical worktree ownership (rows in `persistence_requests`, `fact_withdrawals` or `persistence_worktrees`).
+
+<a id="engine-migration-refused"></a>**Engine migration refused (`writer_coordinator_required`).** The legacy copier's refusal is an agent-contract envelope whose `fix` names the refusing side; every branch verifies with the read-only `gbrain doctor --no-migrate --json`, and nothing has changed in either datastore:
+
+| Refusing side | `fix.next` | Next step |
+|---|---|---|
+| A PGLite brain with history moving to Postgres with graduation turned off | `ask_user` | Relay `user_message`: graduation moves this brain (`gbrain config set migrate.graduation true`, then the [two-command flow](guides/move-to-postgres.md#move-the-brain)), or keep it on PGLite and share it through `gbrain mcp expose`. |
+| A Postgres brain moving to PGLite | `report` | The brain stays on Postgres; moving down would drop its history. |
+| A target that already holds persistence history | `tell_user_to_run` | Rerun with an empty database the user provides (`--path` for a PGLite target). |
+
+On Windows, a PGLite brain with history gets `graduation_unsupported_platform` instead: it stays on PGLite and is shared with `gbrain mcp expose`.
+
+<a id="graduation-writer-held"></a>**Graduation refused: the brain is held (`graduation_source_writer_held`).** Graduation needs the PGLite kernel lock. A live stdio `gbrain serve` hands the brain over through the intent marker `<path>.gbrain-graduation.json` and exits; autopilot pauses. When another holder (an HTTP serve, a daemon, another command) does not release the brain within 30 seconds, the run refuses and names it with its pid and transport (`fix.next: tell_user_to_run`). The user stops that process, then the agent reruns the same `gbrain migrate` command. Verify with the read-only `gbrain migrate --status --json`. Nothing has changed in either datastore.
+
+The migration and the autopilot daemon do not race: both graduation and the
+legacy copier claim a cooperative pause marker before touching the target. The
+marker doubles as a migration mutex — a second concurrent migrate refuses to
+run (graduation exits 75 with `graduation_in_progress`), and a marker that
+cannot be written refuses the migration outright. Background job workers stop
+picking up new work while it is parked. The legacy copier then waits for
+in-flight sync/embed/cycle work and running jobs to drain (watching the DB lock
+table, capped by `GBRAIN_MIGRATE_QUIESCE_SECONDS` — default 300; `0` skips the
+wait). Graduation holds the PGLite kernel lock instead, so no other process has
+the brain open: expired run locks and active job leases are orphans it resets
+at once, and it waits only for queued write requests, bounded by
+`--drain-timeout` (default 60 seconds; exhaustion exits 11 with a
+`resume_command`). Cleanup registers the moment the claim lands, so the marker
+is released on failure and on catchable signals; a marker orphaned by an
+uncleanly killed run is adopted by a later migrate only after a pid-liveness
+check (a live migrate's marker is never stolen), and the daemon clears an
+orphan whose owning process died on its next poll. `gbrain autopilot --status`
+reports `paused` (exit 1) while the marker is parked and prints the marker
+path; on a host with no daemon running to self-heal, remove an orphan by hand
+only after confirming the pid it names is dead. After a clean flip the daemon
+detects the engine change on its next tick and relaunches onto the new engine,
+and the migration warns if an exported connection-string env var would
+override the new config (graduation lists such a variable as a plan blocker).
### Troubleshooting: startup abort (`RuntimeError: Aborted()`)
@@ -9956,6 +9977,7 @@ they need the user's confirmation (documented legacy; changing it is a v2 item).
| `gbrain doctor --remediate` without a terminal and without `--yes` | 0 (it ran) | 3 | paid and destructive work waits for the user |
| `gbrain autopilot --interval`, `serve --port`, `dream --phase`, `init --mcp-only` missing flags, `delta --since` with a bad value | 1 | 2 | invalid input |
| `gbrain jobs submit` on PGLite without `--follow` or `--queue-only` | 0 (queued, no worker) | 1 (`no_worker`) | the job would wait for a worker that is not running |
+| `gbrain migrate --to postgres` on a PGLite brain with write history | 1 (`writer_coordinator_required`) | 3 (plan; run with `--yes --expect`) | graduation carries the history; the bare command shows the plan and asks |
---
diff --git a/llms.txt b/llms.txt
index 15a9d7e9c0..ee8ef61138 100644
--- a/llms.txt
+++ b/llms.txt
@@ -30,6 +30,7 @@ Repo: https://github.com/garrytan/gbrain
## Configuration
- [docs/ENGINES.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/ENGINES.md): PGLite vs Postgres trade-off and when to migrate.
+- [docs/guides/move-to-postgres.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/guides/move-to-postgres.md): Move a PGLite brain to Postgres with its history: --url-env target setup, plan (exit 3) then --yes --expect, status/resume/rollback, what moves vs stays on this computer, recovery by error code.
- [docs/GBRAIN_RECOMMENDED_SCHEMA.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/GBRAIN_RECOMMENDED_SCHEMA.md): MECE directory structure (people/, companies/, concepts/).
- [docs/what-schemas-unlock.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/what-schemas-unlock.md): Why schemas matter: 7 killer use cases (4000 invisible meetings, founder ops brain, research brain, legal brain, team brain, agent-as-co-curator) + the structural argument for typed page kinds. Read this before pitching schema authoring (v0.40.7.0).
- [docs/schema-author-tutorial.md](https://raw.githubusercontent.com/garrytan/gbrain/master/docs/schema-author-tutorial.md): 5-minute walkthrough: fork the bundled pack, add a custom `researcher` type, backfill existing pages via `gbrain schema sync --apply`, prove the T1.5 wiring via `gbrain whoknows` (v0.40.7.0).
diff --git a/plugin-variants/gbrain-coding/skills/db-repair/SKILL.md b/plugin-variants/gbrain-coding/skills/db-repair/SKILL.md
index 5c453d0a22..2b1c8db634 100644
--- a/plugin-variants/gbrain-coding/skills/db-repair/SKILL.md
+++ b/plugin-variants/gbrain-coding/skills/db-repair/SKILL.md
@@ -97,7 +97,7 @@ did not re-probe clean.
5. If the operator wants to change engines (e.g. abandon a dead server for
Supabase), that is NOT this skill — route to
[postgres-adopt](../postgres-adopt/SKILL.md), which wraps
- `gbrain migrate --to` with its guardrails.
+ `gbrain migrate --to postgres` (plan, ask, then run).
## When it fails
diff --git a/plugin-variants/gbrain-coding/skills/postgres-adopt/SKILL.md b/plugin-variants/gbrain-coding/skills/postgres-adopt/SKILL.md
index 7b831f0fd8..781d858655 100644
--- a/plugin-variants/gbrain-coding/skills/postgres-adopt/SKILL.md
+++ b/plugin-variants/gbrain-coding/skills/postgres-adopt/SKILL.md
@@ -4,8 +4,8 @@ description: |
Detect which gbrain engine is in use (PGLite vs Postgres), prefer Postgres
for agent-harness installs, install/provision Postgres (Supabase discovery
via SUPABASE_ACCESS_TOKEN, local Postgres, opt-in Docker), and move an
- existing PGLite brain with the guarded engine migration. Detection is one
- engine-free command; the install ladder is one flag.
+ existing PGLite brain to Postgres with its history (plan, ask, run).
+ Detection is one engine-free command; the install ladder is one flag.
triggers:
- "which gbrain engine"
- "pglite or postgres"
@@ -33,10 +33,13 @@ brain_first: exempt
This skill guarantees:
- Detection is engine-free and read-only: `gbrain engine status --json`
answers with the database down (that is the point of the command).
-- Engine changes NEVER happen by editing config. Moving data uses
- `gbrain migrate --to <supabase|pglite>` — which brings its own guardrails
- (quiesce mutex, resume manifest, non-empty-target guard, and a config flip
- only on a fully clean run). This skill wraps it; it never reimplements it.
+- Engine changes NEVER happen by editing config. A PGLite brain moves with
+ `gbrain migrate --to postgres` (alias `--to supabase`), which graduates it:
+ plan first (exit 3), run only with the user's `--yes --expect <plan_hash>`,
+ verify every table, then flip routing. This skill wraps it; it never
+ reimplements it.
+- The target URL never appears in a command, transcript or output: it lives
+ in `GBRAIN_TARGET_URL` and every command uses `--url-env GBRAIN_TARGET_URL`.
- Provisioning consent is explicit: the docker rung needs `--allow-docker`,
creating a database on a local server needs `--allow-create-db`. Headless
mutation of infrastructure the operator didn't opt into never happens.
@@ -61,6 +64,8 @@ Branch on the output:
belong to that host. Stop.
- `effective_engine: null` (no brain) → Step 2.
- `effective_engine: "pglite"` with data → Step 3.
+- The output reports a graduation state other than `none` (in progress,
+ interrupted, graduated or split) → Step 4.
## Step 2 — Fresh install, Postgres-first
@@ -82,21 +87,54 @@ one-line note and falls through; nothing is silent.
- If the ladder lands on PGLite, that is a fine outcome: say so, and note the
upgrade path below is available whenever they want it.
-## Step 3 — Existing PGLite brain: migrate, don't flip
-
-Confirm with the operator first (this copies every page/fact into the target
-and, only on a fully clean run, flips the config). Then:
+## Step 3 — Existing PGLite brain: plan, ask, run
+
+Full reference: [Move a PGLite brain to Postgres](../../docs/guides/move-to-postgres.md).
+
+1. **Target URL.** Ask the user to put the connection string in an
+ environment variable without pasting it into the conversation
+ (`read -rs GBRAIN_TARGET_URL && export GBRAIN_TARGET_URL`). On Supabase use
+ the transaction pooler; on an IPv4-only host also set
+ `GBRAIN_DIRECT_DATABASE_URL` to the session pooler.
+2. **Plan.** This changes nothing and exits 3 with the
+ `confirmation_required` document:
+ ```bash
+ gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --json
+ ```
+ Relay `user_message`, what moves, what stays on this computer, blockers
+ and the estimate. Stop and wait for the user. A blocker with its own
+ `fix` gets cleared first (ask when it says `ask_user`).
+3. **Run, after the user agrees.** Use `fix.command` from the document:
+ ```bash
+ gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --yes --expect <plan_hash>
+ ```
+ `preview_changed` means the plan changed: go back to step 2. For thousands
+ of pages run it in the background and poll `gbrain migrate --status --json`.
+4. **Report.** Relay the target doctor verdict from the run's output, that
+ existing tokens, OAuth clients and local writers stay valid, the
+ `gbrain mcp expose` follow-up for other machines, and, if a serve handed
+ the brain over, that the user restarts the MCP client.
+
+- A `gbrain serve` holding the brain hands it over on its own; never ask the
+ user to stop it first. `graduation_source_writer_held` names the process to
+ stop when one does not.
+- The old data dir is kept as `<path>.graduated-<run_id>` (doctor's
+ `pglite_leftovers` reports it). Deleting it is the user's call.
+- `gbrain doctor`'s `pglite_scale` check warns at 1000+ pages and points at
+ the plan command — that warning is this skill's cue.
+
+## Step 4 — A move already underway
```bash
-gbrain migrate --to supabase --url <postgres-connection-string>
+gbrain migrate --status --json
```
-- A partial run leaves you on PGLite and exits non-zero; re-running the same
- command resumes from its manifest. Never "fix" a partial by editing config.
-- After a clean run: `gbrain doctor` on the new engine; the old
- `brain.pglite/` dir is preserved (doctor's `pglite_leftovers` tracks it).
-- `gbrain doctor`'s `pglite_scale` check warns at 1000+ pages — that warning
- is this skill's cue.
+It is read-only and names the next command for the state. Exit 75 or a
+run in progress → wait and poll. Interrupted → `gbrain migrate --resume`
+(or `gbrain migrate --rollback-to-source` if the user wants to stay on
+PGLite). Every refusal names its fix; the recovery table is in the guide.
+A rollback that lists data loss runs only with the user's
+`--rollback-to-source --yes --expect <hash>`.
## The tradeoff (say it when recommending)
@@ -112,7 +150,7 @@ otherwise PGLite is genuinely fine.
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:
- `effective_engine: "postgres"` but the probe fails: this is an access problem; run `gbrain engine status --probe`, then the db-repair skill.
-- Provisioning steps (Docker, installing Postgres, copying every page to the target) need the user's explicit agreement; the docker rung needs `--allow-docker`.
+- Provisioning steps (Docker, installing Postgres) and the move itself need the user's explicit agreement; the docker rung needs `--allow-docker`, the move needs `--yes --expect <plan_hash>` after the user saw the plan.
- `gbrain config set engine …` is refused by design: switch engines through the migrate path, never by editing config.
## Anti-Patterns
@@ -120,6 +158,10 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f
- NEVER `gbrain config set engine ...` — it is refused by design; an engine
flip without a data migration splits the brain across two stores.
- NEVER pick Postgres over a healthy PGLite brain without the migrate path.
+- NEVER add `--yes` before the user has seen the plan, and never use
+ `--force` unless the plan listed what it wipes and the user agreed.
+- NEVER put the database URL or password in a command line; use
+ `--url-env GBRAIN_TARGET_URL`.
- NEVER run the docker rung without the operator's explicit yes.
- NEVER paste or echo `SUPABASE_ACCESS_TOKEN` / passwords into output.
@@ -129,7 +171,7 @@ Detection reports in one line; changes report in 2-4:
```
Engine: <pglite|postgres> (source: <db_url_source>) [probe: ok, 42ms]
-Action: <none | init rung that won | migrate --to supabase result>
+Action: <none | init rung that won | migrate --to postgres result>
Next: <upgrade note, or "healthy — nothing to do">
```
diff --git a/plugin-variants/gbrain-daily/skills/db-repair/SKILL.md b/plugin-variants/gbrain-daily/skills/db-repair/SKILL.md
index 5c453d0a22..2b1c8db634 100644
--- a/plugin-variants/gbrain-daily/skills/db-repair/SKILL.md
+++ b/plugin-variants/gbrain-daily/skills/db-repair/SKILL.md
@@ -97,7 +97,7 @@ did not re-probe clean.
5. If the operator wants to change engines (e.g. abandon a dead server for
Supabase), that is NOT this skill — route to
[postgres-adopt](../postgres-adopt/SKILL.md), which wraps
- `gbrain migrate --to` with its guardrails.
+ `gbrain migrate --to postgres` (plan, ask, then run).
## When it fails
diff --git a/plugin-variants/gbrain-daily/skills/postgres-adopt/SKILL.md b/plugin-variants/gbrain-daily/skills/postgres-adopt/SKILL.md
index 7b831f0fd8..781d858655 100644
--- a/plugin-variants/gbrain-daily/skills/postgres-adopt/SKILL.md
+++ b/plugin-variants/gbrain-daily/skills/postgres-adopt/SKILL.md
@@ -4,8 +4,8 @@ description: |
Detect which gbrain engine is in use (PGLite vs Postgres), prefer Postgres
for agent-harness installs, install/provision Postgres (Supabase discovery
via SUPABASE_ACCESS_TOKEN, local Postgres, opt-in Docker), and move an
- existing PGLite brain with the guarded engine migration. Detection is one
- engine-free command; the install ladder is one flag.
+ existing PGLite brain to Postgres with its history (plan, ask, run).
+ Detection is one engine-free command; the install ladder is one flag.
triggers:
- "which gbrain engine"
- "pglite or postgres"
@@ -33,10 +33,13 @@ brain_first: exempt
This skill guarantees:
- Detection is engine-free and read-only: `gbrain engine status --json`
answers with the database down (that is the point of the command).
-- Engine changes NEVER happen by editing config. Moving data uses
- `gbrain migrate --to <supabase|pglite>` — which brings its own guardrails
- (quiesce mutex, resume manifest, non-empty-target guard, and a config flip
- only on a fully clean run). This skill wraps it; it never reimplements it.
+- Engine changes NEVER happen by editing config. A PGLite brain moves with
+ `gbrain migrate --to postgres` (alias `--to supabase`), which graduates it:
+ plan first (exit 3), run only with the user's `--yes --expect <plan_hash>`,
+ verify every table, then flip routing. This skill wraps it; it never
+ reimplements it.
+- The target URL never appears in a command, transcript or output: it lives
+ in `GBRAIN_TARGET_URL` and every command uses `--url-env GBRAIN_TARGET_URL`.
- Provisioning consent is explicit: the docker rung needs `--allow-docker`,
creating a database on a local server needs `--allow-create-db`. Headless
mutation of infrastructure the operator didn't opt into never happens.
@@ -61,6 +64,8 @@ Branch on the output:
belong to that host. Stop.
- `effective_engine: null` (no brain) → Step 2.
- `effective_engine: "pglite"` with data → Step 3.
+- The output reports a graduation state other than `none` (in progress,
+ interrupted, graduated or split) → Step 4.
## Step 2 — Fresh install, Postgres-first
@@ -82,21 +87,54 @@ one-line note and falls through; nothing is silent.
- If the ladder lands on PGLite, that is a fine outcome: say so, and note the
upgrade path below is available whenever they want it.
-## Step 3 — Existing PGLite brain: migrate, don't flip
-
-Confirm with the operator first (this copies every page/fact into the target
-and, only on a fully clean run, flips the config). Then:
+## Step 3 — Existing PGLite brain: plan, ask, run
+
+Full reference: [Move a PGLite brain to Postgres](../../docs/guides/move-to-postgres.md).
+
+1. **Target URL.** Ask the user to put the connection string in an
+ environment variable without pasting it into the conversation
+ (`read -rs GBRAIN_TARGET_URL && export GBRAIN_TARGET_URL`). On Supabase use
+ the transaction pooler; on an IPv4-only host also set
+ `GBRAIN_DIRECT_DATABASE_URL` to the session pooler.
+2. **Plan.** This changes nothing and exits 3 with the
+ `confirmation_required` document:
+ ```bash
+ gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --json
+ ```
+ Relay `user_message`, what moves, what stays on this computer, blockers
+ and the estimate. Stop and wait for the user. A blocker with its own
+ `fix` gets cleared first (ask when it says `ask_user`).
+3. **Run, after the user agrees.** Use `fix.command` from the document:
+ ```bash
+ gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --yes --expect <plan_hash>
+ ```
+ `preview_changed` means the plan changed: go back to step 2. For thousands
+ of pages run it in the background and poll `gbrain migrate --status --json`.
+4. **Report.** Relay the target doctor verdict from the run's output, that
+ existing tokens, OAuth clients and local writers stay valid, the
+ `gbrain mcp expose` follow-up for other machines, and, if a serve handed
+ the brain over, that the user restarts the MCP client.
+
+- A `gbrain serve` holding the brain hands it over on its own; never ask the
+ user to stop it first. `graduation_source_writer_held` names the process to
+ stop when one does not.
+- The old data dir is kept as `<path>.graduated-<run_id>` (doctor's
+ `pglite_leftovers` reports it). Deleting it is the user's call.
+- `gbrain doctor`'s `pglite_scale` check warns at 1000+ pages and points at
+ the plan command — that warning is this skill's cue.
+
+## Step 4 — A move already underway
```bash
-gbrain migrate --to supabase --url <postgres-connection-string>
+gbrain migrate --status --json
```
-- A partial run leaves you on PGLite and exits non-zero; re-running the same
- command resumes from its manifest. Never "fix" a partial by editing config.
-- After a clean run: `gbrain doctor` on the new engine; the old
- `brain.pglite/` dir is preserved (doctor's `pglite_leftovers` tracks it).
-- `gbrain doctor`'s `pglite_scale` check warns at 1000+ pages — that warning
- is this skill's cue.
+It is read-only and names the next command for the state. Exit 75 or a
+run in progress → wait and poll. Interrupted → `gbrain migrate --resume`
+(or `gbrain migrate --rollback-to-source` if the user wants to stay on
+PGLite). Every refusal names its fix; the recovery table is in the guide.
+A rollback that lists data loss runs only with the user's
+`--rollback-to-source --yes --expect <hash>`.
## The tradeoff (say it when recommending)
@@ -112,7 +150,7 @@ otherwise PGLite is genuinely fine.
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:
- `effective_engine: "postgres"` but the probe fails: this is an access problem; run `gbrain engine status --probe`, then the db-repair skill.
-- Provisioning steps (Docker, installing Postgres, copying every page to the target) need the user's explicit agreement; the docker rung needs `--allow-docker`.
+- Provisioning steps (Docker, installing Postgres) and the move itself need the user's explicit agreement; the docker rung needs `--allow-docker`, the move needs `--yes --expect <plan_hash>` after the user saw the plan.
- `gbrain config set engine …` is refused by design: switch engines through the migrate path, never by editing config.
## Anti-Patterns
@@ -120,6 +158,10 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f
- NEVER `gbrain config set engine ...` — it is refused by design; an engine
flip without a data migration splits the brain across two stores.
- NEVER pick Postgres over a healthy PGLite brain without the migrate path.
+- NEVER add `--yes` before the user has seen the plan, and never use
+ `--force` unless the plan listed what it wipes and the user agreed.
+- NEVER put the database URL or password in a command line; use
+ `--url-env GBRAIN_TARGET_URL`.
- NEVER run the docker rung without the operator's explicit yes.
- NEVER paste or echo `SUPABASE_ACCESS_TOKEN` / passwords into output.
@@ -129,7 +171,7 @@ Detection reports in one line; changes report in 2-4:
```
Engine: <pglite|postgres> (source: <db_url_source>) [probe: ok, 42ms]
-Action: <none | init rung that won | migrate --to supabase result>
+Action: <none | init rung that won | migrate --to postgres result>
Next: <upgrade note, or "healthy — nothing to do">
```
diff --git a/plugin/skills/db-repair/SKILL.md b/plugin/skills/db-repair/SKILL.md
index 5c453d0a22..2b1c8db634 100644
--- a/plugin/skills/db-repair/SKILL.md
+++ b/plugin/skills/db-repair/SKILL.md
@@ -97,7 +97,7 @@ did not re-probe clean.
5. If the operator wants to change engines (e.g. abandon a dead server for
Supabase), that is NOT this skill — route to
[postgres-adopt](../postgres-adopt/SKILL.md), which wraps
- `gbrain migrate --to` with its guardrails.
+ `gbrain migrate --to postgres` (plan, ask, then run).
## When it fails
diff --git a/plugin/skills/postgres-adopt/SKILL.md b/plugin/skills/postgres-adopt/SKILL.md
index 7b831f0fd8..781d858655 100644
--- a/plugin/skills/postgres-adopt/SKILL.md
+++ b/plugin/skills/postgres-adopt/SKILL.md
@@ -4,8 +4,8 @@ description: |
Detect which gbrain engine is in use (PGLite vs Postgres), prefer Postgres
for agent-harness installs, install/provision Postgres (Supabase discovery
via SUPABASE_ACCESS_TOKEN, local Postgres, opt-in Docker), and move an
- existing PGLite brain with the guarded engine migration. Detection is one
- engine-free command; the install ladder is one flag.
+ existing PGLite brain to Postgres with its history (plan, ask, run).
+ Detection is one engine-free command; the install ladder is one flag.
triggers:
- "which gbrain engine"
- "pglite or postgres"
@@ -33,10 +33,13 @@ brain_first: exempt
This skill guarantees:
- Detection is engine-free and read-only: `gbrain engine status --json`
answers with the database down (that is the point of the command).
-- Engine changes NEVER happen by editing config. Moving data uses
- `gbrain migrate --to <supabase|pglite>` — which brings its own guardrails
- (quiesce mutex, resume manifest, non-empty-target guard, and a config flip
- only on a fully clean run). This skill wraps it; it never reimplements it.
+- Engine changes NEVER happen by editing config. A PGLite brain moves with
+ `gbrain migrate --to postgres` (alias `--to supabase`), which graduates it:
+ plan first (exit 3), run only with the user's `--yes --expect <plan_hash>`,
+ verify every table, then flip routing. This skill wraps it; it never
+ reimplements it.
+- The target URL never appears in a command, transcript or output: it lives
+ in `GBRAIN_TARGET_URL` and every command uses `--url-env GBRAIN_TARGET_URL`.
- Provisioning consent is explicit: the docker rung needs `--allow-docker`,
creating a database on a local server needs `--allow-create-db`. Headless
mutation of infrastructure the operator didn't opt into never happens.
@@ -61,6 +64,8 @@ Branch on the output:
belong to that host. Stop.
- `effective_engine: null` (no brain) → Step 2.
- `effective_engine: "pglite"` with data → Step 3.
+- The output reports a graduation state other than `none` (in progress,
+ interrupted, graduated or split) → Step 4.
## Step 2 — Fresh install, Postgres-first
@@ -82,21 +87,54 @@ one-line note and falls through; nothing is silent.
- If the ladder lands on PGLite, that is a fine outcome: say so, and note the
upgrade path below is available whenever they want it.
-## Step 3 — Existing PGLite brain: migrate, don't flip
-
-Confirm with the operator first (this copies every page/fact into the target
-and, only on a fully clean run, flips the config). Then:
+## Step 3 — Existing PGLite brain: plan, ask, run
+
+Full reference: [Move a PGLite brain to Postgres](../../docs/guides/move-to-postgres.md).
+
+1. **Target URL.** Ask the user to put the connection string in an
+ environment variable without pasting it into the conversation
+ (`read -rs GBRAIN_TARGET_URL && export GBRAIN_TARGET_URL`). On Supabase use
+ the transaction pooler; on an IPv4-only host also set
+ `GBRAIN_DIRECT_DATABASE_URL` to the session pooler.
+2. **Plan.** This changes nothing and exits 3 with the
+ `confirmation_required` document:
+ ```bash
+ gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --json
+ ```
+ Relay `user_message`, what moves, what stays on this computer, blockers
+ and the estimate. Stop and wait for the user. A blocker with its own
+ `fix` gets cleared first (ask when it says `ask_user`).
+3. **Run, after the user agrees.** Use `fix.command` from the document:
+ ```bash
+ gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --yes --expect <plan_hash>
+ ```
+ `preview_changed` means the plan changed: go back to step 2. For thousands
+ of pages run it in the background and poll `gbrain migrate --status --json`.
+4. **Report.** Relay the target doctor verdict from the run's output, that
+ existing tokens, OAuth clients and local writers stay valid, the
+ `gbrain mcp expose` follow-up for other machines, and, if a serve handed
+ the brain over, that the user restarts the MCP client.
+
+- A `gbrain serve` holding the brain hands it over on its own; never ask the
+ user to stop it first. `graduation_source_writer_held` names the process to
+ stop when one does not.
+- The old data dir is kept as `<path>.graduated-<run_id>` (doctor's
+ `pglite_leftovers` reports it). Deleting it is the user's call.
+- `gbrain doctor`'s `pglite_scale` check warns at 1000+ pages and points at
+ the plan command — that warning is this skill's cue.
+
+## Step 4 — A move already underway
```bash
-gbrain migrate --to supabase --url <postgres-connection-string>
+gbrain migrate --status --json
```
-- A partial run leaves you on PGLite and exits non-zero; re-running the same
- command resumes from its manifest. Never "fix" a partial by editing config.
-- After a clean run: `gbrain doctor` on the new engine; the old
- `brain.pglite/` dir is preserved (doctor's `pglite_leftovers` tracks it).
-- `gbrain doctor`'s `pglite_scale` check warns at 1000+ pages — that warning
- is this skill's cue.
+It is read-only and names the next command for the state. Exit 75 or a
+run in progress → wait and poll. Interrupted → `gbrain migrate --resume`
+(or `gbrain migrate --rollback-to-source` if the user wants to stay on
+PGLite). Every refusal names its fix; the recovery table is in the guide.
+A rollback that lists data loss runs only with the user's
+`--rollback-to-source --yes --expect <hash>`.
## The tradeoff (say it when recommending)
@@ -112,7 +150,7 @@ otherwise PGLite is genuinely fine.
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:
- `effective_engine: "postgres"` but the probe fails: this is an access problem; run `gbrain engine status --probe`, then the db-repair skill.
-- Provisioning steps (Docker, installing Postgres, copying every page to the target) need the user's explicit agreement; the docker rung needs `--allow-docker`.
+- Provisioning steps (Docker, installing Postgres) and the move itself need the user's explicit agreement; the docker rung needs `--allow-docker`, the move needs `--yes --expect <plan_hash>` after the user saw the plan.
- `gbrain config set engine …` is refused by design: switch engines through the migrate path, never by editing config.
## Anti-Patterns
@@ -120,6 +158,10 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f
- NEVER `gbrain config set engine ...` — it is refused by design; an engine
flip without a data migration splits the brain across two stores.
- NEVER pick Postgres over a healthy PGLite brain without the migrate path.
+- NEVER add `--yes` before the user has seen the plan, and never use
+ `--force` unless the plan listed what it wipes and the user agreed.
+- NEVER put the database URL or password in a command line; use
+ `--url-env GBRAIN_TARGET_URL`.
- NEVER run the docker rung without the operator's explicit yes.
- NEVER paste or echo `SUPABASE_ACCESS_TOKEN` / passwords into output.
@@ -129,7 +171,7 @@ Detection reports in one line; changes report in 2-4:
```
Engine: <pglite|postgres> (source: <db_url_source>) [probe: ok, 42ms]
-Action: <none | init rung that won | migrate --to supabase result>
+Action: <none | init rung that won | migrate --to postgres result>
Next: <upgrade note, or "healthy — nothing to do">
```
diff --git a/scripts/llms-config.ts b/scripts/llms-config.ts
index bd4c9b4f40..f1bcab40cf 100644
--- a/scripts/llms-config.ts
+++ b/scripts/llms-config.ts
@@ -110,6 +110,13 @@ export const SECTIONS: DocSection[] = [
description: "PGLite vs Postgres trade-off and when to migrate.",
path: "docs/ENGINES.md",
},
+ {
+ title: "docs/guides/move-to-postgres.md",
+ description:
+ "Move a PGLite brain to Postgres with its history: --url-env target setup, plan (exit 3) then --yes --expect, status/resume/rollback, what moves vs stays on this computer, recovery by error code.",
+ path: "docs/guides/move-to-postgres.md",
+ includeInFull: false,
+ },
{
title: "docs/GBRAIN_RECOMMENDED_SCHEMA.md",
description:
diff --git a/skills/db-repair/SKILL.md b/skills/db-repair/SKILL.md
index 5c453d0a22..2b1c8db634 100644
--- a/skills/db-repair/SKILL.md
+++ b/skills/db-repair/SKILL.md
@@ -97,7 +97,7 @@ did not re-probe clean.
5. If the operator wants to change engines (e.g. abandon a dead server for
Supabase), that is NOT this skill — route to
[postgres-adopt](../postgres-adopt/SKILL.md), which wraps
- `gbrain migrate --to` with its guardrails.
+ `gbrain migrate --to postgres` (plan, ask, then run).
## When it fails
diff --git a/skills/migrations/engine-graduation.md b/skills/migrations/engine-graduation.md
new file mode 100644
index 0000000000..9f5e4ad3b6
--- /dev/null
+++ b/skills/migrations/engine-graduation.md
@@ -0,0 +1,54 @@
+# Upgrade note: PGLite to Postgres moves are graduations
+
+`gbrain migrate --to postgres` (alias `--to supabase`) on a PGLite brain is a
+verified engine graduation. It carries the brain's full history (write
+requests, withdrawals, versions, takes, tokens and OAuth clients, with their
+IDs), so brains with write history and managed brains can move to Postgres.
+
+**The bare command stops at exit 3 for every PGLite to Postgres move**, with
+or without history. It prints the plan as a `confirmation_required` document
+and changes nothing. A script or skill that ran `gbrain migrate --to supabase
+--url <url>` and expected the copy to happen must add the confirmation step.
+
+Never run the move without the user's agreement.
+
+1. **Finish the upgrade.** `gbrain upgrade` runs it. To be sure, on the brain
+ host:
+ ```bash
+ gbrain apply-migrations --yes --no-autopilot-install
+ ```
+ A schema migration adds the `persistence_graduation` table; no rows are
+ rewritten.
+
+2. **Move the URL out of the command line.** Ask the user to put the target
+ URL in `GBRAIN_TARGET_URL` (`read -rs GBRAIN_TARGET_URL && export
+ GBRAIN_TARGET_URL`) and use `--url-env GBRAIN_TARGET_URL` everywhere.
+
+3. **Plan and ask.**
+ ```bash
+ gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --json
+ ```
+ Exit 3. Relay `user_message` and the what-moves / what-stays lists, then
+ stop until the user agrees. `--plan` shows the same plan read-only
+ (exit 0).
+
+4. **Run.** After the user agrees, run `fix.command` from the document:
+ ```bash
+ gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --yes --expect <plan_hash>
+ ```
+ `preview_changed` means the plan changed since the user saw it: plan and
+ ask again.
+
+5. **Afterwards.** Check a stopped or background run with
+ `gbrain migrate --status --json`; continue with `gbrain migrate --resume`.
+ The PGLite data dir is kept as `<path>.graduated-<run_id>`; deleting it is
+ the user's call. Existing tokens, OAuth clients and local writers stay
+ valid.
+
+`gbrain config set migrate.graduation false` sends the move through the legacy
+copier, which refuses brains with write history. Postgres to PGLite moves use
+the legacy copier. On Windows a brain with history stays on PGLite
+(`graduation_unsupported_platform`).
+
+Full walkthrough, exit codes and recovery by error code:
+[Move a PGLite brain to Postgres](../../docs/guides/move-to-postgres.md).
diff --git a/skills/postgres-adopt/SKILL.md b/skills/postgres-adopt/SKILL.md
index 7b831f0fd8..781d858655 100644
--- a/skills/postgres-adopt/SKILL.md
+++ b/skills/postgres-adopt/SKILL.md
@@ -4,8 +4,8 @@ description: |
Detect which gbrain engine is in use (PGLite vs Postgres), prefer Postgres
for agent-harness installs, install/provision Postgres (Supabase discovery
via SUPABASE_ACCESS_TOKEN, local Postgres, opt-in Docker), and move an
- existing PGLite brain with the guarded engine migration. Detection is one
- engine-free command; the install ladder is one flag.
+ existing PGLite brain to Postgres with its history (plan, ask, run).
+ Detection is one engine-free command; the install ladder is one flag.
triggers:
- "which gbrain engine"
- "pglite or postgres"
@@ -33,10 +33,13 @@ brain_first: exempt
This skill guarantees:
- Detection is engine-free and read-only: `gbrain engine status --json`
answers with the database down (that is the point of the command).
-- Engine changes NEVER happen by editing config. Moving data uses
- `gbrain migrate --to <supabase|pglite>` — which brings its own guardrails
- (quiesce mutex, resume manifest, non-empty-target guard, and a config flip
- only on a fully clean run). This skill wraps it; it never reimplements it.
+- Engine changes NEVER happen by editing config. A PGLite brain moves with
+ `gbrain migrate --to postgres` (alias `--to supabase`), which graduates it:
+ plan first (exit 3), run only with the user's `--yes --expect <plan_hash>`,
+ verify every table, then flip routing. This skill wraps it; it never
+ reimplements it.
+- The target URL never appears in a command, transcript or output: it lives
+ in `GBRAIN_TARGET_URL` and every command uses `--url-env GBRAIN_TARGET_URL`.
- Provisioning consent is explicit: the docker rung needs `--allow-docker`,
creating a database on a local server needs `--allow-create-db`. Headless
mutation of infrastructure the operator didn't opt into never happens.
@@ -61,6 +64,8 @@ Branch on the output:
belong to that host. Stop.
- `effective_engine: null` (no brain) → Step 2.
- `effective_engine: "pglite"` with data → Step 3.
+- The output reports a graduation state other than `none` (in progress,
+ interrupted, graduated or split) → Step 4.
## Step 2 — Fresh install, Postgres-first
@@ -82,21 +87,54 @@ one-line note and falls through; nothing is silent.
- If the ladder lands on PGLite, that is a fine outcome: say so, and note the
upgrade path below is available whenever they want it.
-## Step 3 — Existing PGLite brain: migrate, don't flip
-
-Confirm with the operator first (this copies every page/fact into the target
-and, only on a fully clean run, flips the config). Then:
+## Step 3 — Existing PGLite brain: plan, ask, run
+
+Full reference: [Move a PGLite brain to Postgres](../../docs/guides/move-to-postgres.md).
+
+1. **Target URL.** Ask the user to put the connection string in an
+ environment variable without pasting it into the conversation
+ (`read -rs GBRAIN_TARGET_URL && export GBRAIN_TARGET_URL`). On Supabase use
+ the transaction pooler; on an IPv4-only host also set
+ `GBRAIN_DIRECT_DATABASE_URL` to the session pooler.
+2. **Plan.** This changes nothing and exits 3 with the
+ `confirmation_required` document:
+ ```bash
+ gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --json
+ ```
+ Relay `user_message`, what moves, what stays on this computer, blockers
+ and the estimate. Stop and wait for the user. A blocker with its own
+ `fix` gets cleared first (ask when it says `ask_user`).
+3. **Run, after the user agrees.** Use `fix.command` from the document:
+ ```bash
+ gbrain migrate --to postgres --url-env GBRAIN_TARGET_URL --yes --expect <plan_hash>
+ ```
+ `preview_changed` means the plan changed: go back to step 2. For thousands
+ of pages run it in the background and poll `gbrain migrate --status --json`.
+4. **Report.** Relay the target doctor verdict from the run's output, that
+ existing tokens, OAuth clients and local writers stay valid, the
+ `gbrain mcp expose` follow-up for other machines, and, if a serve handed
+ the brain over, that the user restarts the MCP client.
+
+- A `gbrain serve` holding the brain hands it over on its own; never ask the
+ user to stop it first. `graduation_source_writer_held` names the process to
+ stop when one does not.
+- The old data dir is kept as `<path>.graduated-<run_id>` (doctor's
+ `pglite_leftovers` reports it). Deleting it is the user's call.
+- `gbrain doctor`'s `pglite_scale` check warns at 1000+ pages and points at
+ the plan command — that warning is this skill's cue.
+
+## Step 4 — A move already underway
```bash
-gbrain migrate --to supabase --url <postgres-connection-string>
+gbrain migrate --status --json
```
-- A partial run leaves you on PGLite and exits non-zero; re-running the same
- command resumes from its manifest. Never "fix" a partial by editing config.
-- After a clean run: `gbrain doctor` on the new engine; the old
- `brain.pglite/` dir is preserved (doctor's `pglite_leftovers` tracks it).
-- `gbrain doctor`'s `pglite_scale` check warns at 1000+ pages — that warning
- is this skill's cue.
+It is read-only and names the next command for the state. Exit 75 or a
+run in progress → wait and poll. Interrupted → `gbrain migrate --resume`
+(or `gbrain migrate --rollback-to-source` if the user wants to stay on
+PGLite). Every refusal names its fix; the recovery table is in the guide.
+A rollback that lists data loss runs only with the user's
+`--rollback-to-source --yes --expect <hash>`.
## The tradeoff (say it when recommending)
@@ -112,7 +150,7 @@ otherwise PGLite is genuinely fine.
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:
- `effective_engine: "postgres"` but the probe fails: this is an access problem; run `gbrain engine status --probe`, then the db-repair skill.
-- Provisioning steps (Docker, installing Postgres, copying every page to the target) need the user's explicit agreement; the docker rung needs `--allow-docker`.
+- Provisioning steps (Docker, installing Postgres) and the move itself need the user's explicit agreement; the docker rung needs `--allow-docker`, the move needs `--yes --expect <plan_hash>` after the user saw the plan.
- `gbrain config set engine …` is refused by design: switch engines through the migrate path, never by editing config.
## Anti-Patterns
@@ -120,6 +158,10 @@ Follow the [agent operator protocol](../../docs/protocol/AGENT_OPERATOR_v1.md) f
- NEVER `gbrain config set engine ...` — it is refused by design; an engine
flip without a data migration splits the brain across two stores.
- NEVER pick Postgres over a healthy PGLite brain without the migrate path.
+- NEVER add `--yes` before the user has seen the plan, and never use
+ `--force` unless the plan listed what it wipes and the user agreed.
+- NEVER put the database URL or password in a command line; use
+ `--url-env GBRAIN_TARGET_URL`.
- NEVER run the docker rung without the operator's explicit yes.
- NEVER paste or echo `SUPABASE_ACCESS_TOKEN` / passwords into output.
@@ -129,7 +171,7 @@ Detection reports in one line; changes report in 2-4:
```
Engine: <pglite|postgres> (source: <db_url_source>) [probe: ok, 42ms]
-Action: <none | init rung that won | migrate --to supabase result>
+Action: <none | init rung that won | migrate --to postgres result>
Next: <upgrade note, or "healthy — nothing to do">
```
diff --git a/skills/skills.lock.json b/skills/skills.lock.json
index ea8761ea35..4a7d954dee 100644
--- a/skills/skills.lock.json
+++ b/skills/skills.lock.json
@@ -72,7 +72,7 @@
"data-loss-gate/SKILL.md": "790407f6a91dba74d6ca1f482bb2eaa28977e79a5cf9a8e642f71691cab69652",
"data-loss-gate/routing-eval.jsonl": "825358a5600641061a02b25097cd84c1c28bb0359a7608a10b9f25f661bd88f9",
"data-research/SKILL.md": "2b1d7a70772ff8c202604867ed02e08cff473b2da808974f3f0a18b78b112116",
- "db-repair/SKILL.md": "0cd6b3f9fd57b9c7f7bfeb041cb2bec7c4469cb8abcb850839d307e95b78b300",
+ "db-repair/SKILL.md": "0ff994ad468234c9020e8005ec2d8f40c27382ab00fb6f4ea1482cec76f507e5",
"db-repair/routing-eval.jsonl": "45791b0bf2cb9f98b8e58d82e95288ff17ad44cab484ab570cfc2ccb14583935",
"draft-in-voice/SKILL.md": "237ce9c0701d8d2161b118ea41050958e5623a7e507bdbb674ffdd7db96d0061",
"draft-in-voice/routing-eval.jsonl": "590fc16277ed7c3338776e7fac6daf1270b91058941f8101079bb295d2d8f787",
@@ -102,6 +102,7 @@
"meeting-ingestion/routing-eval.jsonl": "1995dc75eff09fd2e5fb403a10c81dc71b4c12035d48c77e57da0134c81f731a",
"migrate/SKILL.md": "97a6c0e8120b2198cc73e27cdccaec06f8636aeb8e87aabffb539df2e9df944e",
"migrations/.gitkeep": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+ "migrations/engine-graduation.md": "95c78f085c3ecebc9165dd0d0833a0903993c2b7e60cecd3b0437d9a6050316e",
"migrations/v0.10.3.md": "1e12db6fdb88d21df479659e236bad111a041a205d47aa0894afde2f04903124",
"migrations/v0.11.0.md": "ac45c6144eeee5033f2b24308a5063ceced2be7831b04e48154aa0b6f8ff55d8",
"migrations/v0.12.0.md": "f30b452caed5ce2679cbd60dc2d0b9e60449bab20c3a3e0c895e6cd167644f44",
@@ -176,7 +177,7 @@
"perplexity-research/routing-eval.jsonl": "f1a40d87e710d5d2acd602a372d83f46c95da022b6e635228fffeaacb3bb2b27",
"plugin-exclusions.json": "797782fd0647e06763febcbe6b8cb6715c717504628af84185cc345804087d35",
"plugin-lanes.json": "ec7fc44821c6a9b40c582db9b39026c84677d3fdd94657d983b7c5ea6216124e",
- "postgres-adopt/SKILL.md": "1b4399fb449e33c24f898ac7ce928a146b9fcc017f5a424475daa9c259c1b961",
+ "postgres-adopt/SKILL.md": "b5df8bf7da596bc0b927ca6352f859c205cbd45577874d1228644c64066b094c",
"postgres-adopt/routing-eval.jsonl": "db91c1fae408a45082979c402c11eff413277ace6cf746297cc86009dcaefe06",
"publish/SKILL.md": "df87df3ab6c0e799f5dc88edaec7f6b4049c49bbee5525874fe24f1765c3028c",
"query/SKILL.md": "8905796d90cae85873cbb9fa6aacba47e51bb0f6037edb72d733981c47f83d3b",