Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
graduation: goldens for schema v201 and the new engine surface, flag registry, connect gate disconnects outside cli.ts, CI-safe password leak checks
garrytanbd6214300d90
diff --git a/src/cli.ts b/src/cli.tsindex 7fc7c8be95..95411d5b30 100755--- a/src/cli.ts+++ b/src/cli.ts@@ -2811,8 +2811,7 @@ async function connectEngine(opts?: { probeOnly?: boolean }): Promise<BrainEnginconst { connectWithRetry } = await import('./core/db.ts');await exitOnRepairFailed(() => connectWithRetry(engine, toEngineConfig(config), { noRetry }));// Engine graduation: a fenced target or a cut-over source refuses every connect but the run's own.- try { await (await import('./core/persistence/graduation-custody.ts')).assertGraduationConnectAllowed(engine); }- catch (error) { await engine.disconnect().catch(() => {}); throw error; }+ await (await import('./core/persistence/graduation-custody.ts')).gateGraduationConnect(engine);// v0.30.1 (Codex X1 / C2): probeOnly skips both hasPendingMigrations() probe// AND initSchema(). Used by `get_health` MCP op + `gbrain upgrade --status`diff --git a/src/core/cli-flag-registry.generated.ts b/src/core/cli-flag-registry.generated.tsindex 452add3d8b..7ddecc3473 100644--- a/src/core/cli-flag-registry.generated.ts+++ b/src/core/cli-flag-registry.generated.ts@@ -78,7 +78,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'lsd': ['--brain', '--force-resume', '--help', '--json', '--judge-model', '--limit', '--list-runs', '--max-cost', '--max-far-set', '--max-ideas-per-judge-call', '--no-save', '--resume', '--save', '--source', '--strict-budget', '--yes'],'maintain': ['--adopt-columns', '--adopt-permissions', '--all', '--apply', '--background', '--brain', '--break-lock', '--by-mention', '--catch-up', '--concurrency', '--content-audit', '--count', '--detach', '--dim', '--dir', '--drain', '--dry-run', '--expect', '--explain', '--facts', '--fast', '--fix', '--follow', '--force', '--force-retry', '--force-schema', '--from-meetings', '--full', '--harness', '--help', '--http', '--id', '--include-ambiguous', '--include-flagged', '--include-frontmatter', '--include-gitignored', '--include-repairs', '--index-audit', '--infer-dates', '--install', '--json', '--kind', '--lang', '--link-source', '--link-type', '--locks', '--markdown', '--max-cost', '--max-cost-usd', '--max-jobs', '--max-rss', '--max-usd', '--migrate-legacy', '--migrate-only', '--multimodal', '--ner', '--no-autopilot-install', '--no-embed', '--no-pull', '--older-than', '--only', '--operations', '--pack', '--parallel', '--params', '--path', '--pglite', '--phase', '--pid-file', '--plan', '--porcelain', '--preview', '--probe', '--probe-pglite', '--prune-orphans', '--query', '--queue', '--reauth', '--rebuild', '--regenerate', '--remediate', '--remediation-plan', '--remove', '--request-id', '--reset', '--resume', '--retry-failed', '--safe', '--scope', '--scopes', '--show-current', '--since', '--skills-dir', '--skip-failed', '--slot', '--slugs', '--source', '--source-id', '--sources', '--stale', '--status', '--supabase', '--symbol-kind', '--takes-holders', '--target', '--target-score', '--to', '--token', '--top-k', '--type', '--url-env', '--verbose', '--version', '--window', '--workers', '--yes'],'mcp': ['--admin-token-file', '--agent', '--arg', '--bearer-token-env-var', '--bound-brain', '--bound-max-concurrent', '--bound-slug-prefixes', '--bound-source', '--bound-tools', '--brain', '--budget-usd-per-day', '--client', '--credentials-file', '--credentials-out', '--delegate', '--delegated-namespace', '--delegated-slug-prefixes', '--dry-run', '--enable-dcr', '--federated-read', '--flow', '--force', '--funnel', '--harness', '--header', '--help', '--if-version', '--install', '--issuer-url', '--json', '--limit', '--mcp-only', '--mcp-url', '--no-install', '--no-service', '--no-tailscale', '--oauth-client-id', '--oauth-client-secret', '--oauth-request', '--port', '--profile', '--queue', '--redirect-uri', '--remove', '--resume', '--root', '--scope', '--scopes', '--skills', '--source', '--sources', '--status', '--surface', '--timeout-ms', '--token', '--token-endpoint-auth-method', '--token-ttl', '--url', '--yes'],- 'migrate': ['--accept-pending', '--admin-intent', '--all', '--apply', '--background', '--batch-size', '--brain', '--catch-up', '--dim', '--drain-timeout', '--dry-run', '--embedding-dimensions', '--embedding-model', '--expect', '--expected-epoch', '--expected-state', '--explain', '--facts', '--follow', '--force', '--force-retry', '--harness', '--help', '--ignore-env-override', '--images', '--include-null-signature', '--json', '--locks', '--manifest', '--max-cost', '--max-cost-usd', '--max-usd', '--no-accept-pending', '--no-embed', '--no-migrate', '--non-interactive', '--pace', '--pace-max-concurrency', '--path', '--plan', '--priority', '--probe', '--progress-interval', '--progress-json', '--quiet', '--reranker', '--resume', '--retarget', '--rollback-to-source', '--skip-verify', '--slugs', '--source', '--stale', '--status', '--timeout', '--to', '--trigger-bypass', '--trust', '--url', '--url-env', '--wait', '--yes'],+ 'migrate': ['--accept-pending', '--admin-intent', '--all', '--apply', '--background', '--batch-size', '--brain', '--catch-up', '--dim', '--drain-timeout', '--dry-run', '--embedding-dimensions', '--embedding-model', '--expect', '--expected-epoch', '--expected-state', '--explain', '--facts', '--follow', '--force', '--force-retry', '--harness', '--help', '--ignore-env-override', '--images', '--include-null-signature', '--json', '--locks', '--manifest', '--max-cost', '--max-cost-usd', '--max-usd', '--no-accept-pending', '--no-embed', '--no-embedding', '--no-migrate', '--non-interactive', '--pace', '--pace-max-concurrency', '--path', '--pglite', '--plan', '--priority', '--probe', '--progress-interval', '--progress-json', '--quiet', '--reranker', '--resume', '--retarget', '--rollback-to-source', '--scope', '--skip-verify', '--slugs', '--source', '--stale', '--status', '--timeout', '--to', '--trigger-bypass', '--trust', '--url', '--url-env', '--wait', '--yes'],'models': ['--brain', '--dim', '--embedding-dimensions', '--embedding-model', '--help', '--json', '--skip', '--source', '--status', '--to'],'mounts': ['--alias', '--brain', '--database-path', '--database-url', '--db-path', '--db-url', '--engine', '--help', '--id', '--json', '--mcp-url', '--path', '--skills-dir', '--source'],'notability-eval': ['--brain', '--embedding-dimensions', '--embedding-model', '--help', '--in', '--json', '--out', '--repo', '--skip-llm', '--source', '--status', '--target-high', '--target-low', '--target-medium'],diff --git a/src/core/persistence/graduation-custody.ts b/src/core/persistence/graduation-custody.tsindex 652ce6d20e..58cdec07eb 100644--- a/src/core/persistence/graduation-custody.ts+++ b/src/core/persistence/graduation-custody.ts@@ -350,6 +350,12 @@ export async function assertGraduationConnectAllowed(engine: BrainEngine, env: Nthrow cutoverSourceRefusal(row.run_id, row.source_data_dir);}+/** The CLI connect gate: a refused connection is closed before the refusal propagates. */+export async function gateGraduationConnect(engine: BrainEngine): Promise<void> {+ try { await assertGraduationConnectAllowed(engine); }+ catch (error) { await engine.disconnect().catch(() => {}); throw error; }+}+function cutoverSourceRefusal(runId: string, sourceDataDir: string | null): OperationError {const path = sourceDataDir ? inspectGraduationPath(sourceDataDir) : null;if (path?.state === 'graduated') return engineGraduatedFor(path, 'cli');diff --git a/test/cli-dispatch-lifecycle.serial.test.ts b/test/cli-dispatch-lifecycle.serial.test.tsindex 7775fdacd0..7ef47c5450 100644--- a/test/cli-dispatch-lifecycle.serial.test.ts+++ b/test/cli-dispatch-lifecycle.serial.test.ts@@ -39,6 +39,8 @@ function fakeEngine(): Record<string, unknown> {getConfig: async (key: string) => (key === 'version' ? '100000' : null),setConfig: async () => {},initSchema: async () => {},+ // The connect path's graduation gate probes for a persistence_graduation row; none exists here.+ executeRaw: async () => [],};}diff --git a/test/e2e/graduation-clients.test.ts b/test/e2e/graduation-clients.test.tsindex 01e4f4a805..6ec15a5fe3 100644--- a/test/e2e/graduation-clients.test.ts+++ b/test/e2e/graduation-clients.test.ts@@ -28,7 +28,7 @@ import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFimport { dirname, join } from 'node:path';import type { Tombstone } from '../../src/core/persistence/engine-graduation.types.ts';import {- codeOf, custodyPaths, DATABASE_URL, digestChanges, fixOf, freePort, gbrain, graduationTest, mcpStdioSession, olderReleaseBinary,+ codeOf, custodyPaths, leakNeedle, passwordOf, DATABASE_URL, digestChanges, fixOf, freePort, gbrain, graduationTest, mcpStdioSession, olderReleaseBinary,previousReleaseTags, release, REPO, startGbrain, stateDigest, TARGET_ENV, waitForEvent, type GbrainResult,} from '../helpers/graduation-e2e.ts';import { configuredEngine, expectGraduated, legacyCase, planAndRun, scratchRoot, targetRowState, withTarget, type Case } from '../helpers/graduation-scenarios.ts';@@ -266,7 +266,7 @@ describe.skipIf(!DATABASE_URL)('graduation: stale clients recover in one step',expect(codeOf(refused.json)).toBe('engine_graduated');const fix = fixOf(refused.json)!;expect(['run', 'tell_user_to_run']).toContain(fix.next);- expect(JSON.stringify(fix)).not.toContain(new URL(c.target.url).password);+ expect(JSON.stringify(fix)).not.toContain(leakNeedle(passwordOf(c.target.url)));const fixed = await runFix(fix, home, c);expect({ code: fixed.code, stderr: fixed.code === 0 ? '' : fixed.stderr.slice(-1500) }).toEqual({ code: 0, stderr: '' });const retried = await gbrain(['get', 'people/alice-example', '--source', 'default'], { home });diff --git a/test/engine-surface-coverage.test.ts b/test/engine-surface-coverage.test.tsindex 8a2ef8a5f3..ec53c793d5 100644--- a/test/engine-surface-coverage.test.ts+++ b/test/engine-surface-coverage.test.ts@@ -131,6 +131,9 @@ const ENGINE_INTERNAL_HELPERS: readonly string[] = ['codeEdgesDeps',// refactor wave 1 C9: per-call engine-sql executor getter (EO1).'engineSql',+ // Engine graduation: PGLite close/open that keeps the kernel lock across the custody window.+ 'closeRetainingLock',+ 'connectWithHeldLock',];/**diff --git a/test/fix-wave-structural.test.ts b/test/fix-wave-structural.test.tsindex 4a90141704..505db7eca8 100644--- a/test/fix-wave-structural.test.ts+++ b/test/fix-wave-structural.test.ts@@ -216,7 +216,7 @@ describe('v0.42.20.0 — background-work registry drains every sink before discotest('#4284 caller timeout retains ownership while the actual close drains under its watchdog', () => {const pglite = surfaceFileSource('pglite-engine', 'src/core/pglite-engine.ts');- const closeStart = pglite.indexOf('private async _closeInternal()');+ const closeStart = pglite.indexOf('private async _closeInternal(');const armIdx = pglite.indexOf("label: 'pglite-disconnect-watchdog'", closeStart);const stopIdx = pglite.indexOf('for (const stop of this._beforeDisconnect) await stop()', closeStart);const drainIdx = pglite.indexOf('await drainBackgroundWorkBeforeDisconnect()', closeStart);diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-default.json b/test/fixtures/goldens/catalog/pglite-engine-init-default.jsonindex 99a6d7000e..23726d5bac 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-default.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-default.json@@ -177,6 +177,11 @@"persistence_effects.persistence_effects_request_id_kind_key": "u UNIQUE (request_id, kind)","persistence_effects.persistence_effects_state_check": "c CHECK ((state = ANY (ARRAY['queued'::text, 'running'::text, 'committed'::text, 'failed'::text])))","persistence_effects.persistence_effects_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)",+ "persistence_graduation.persistence_graduation_pkey": "p PRIMARY KEY (singleton)",+ "persistence_graduation.persistence_graduation_role_check": "c CHECK ((role = ANY (ARRAY['source'::text, 'target'::text])))",+ "persistence_graduation.persistence_graduation_singleton_check": "c CHECK ((singleton = 1))",+ "persistence_graduation.persistence_graduation_state_check": "c CHECK ((state = ANY (ARRAY['quiesced'::text, 'cutover'::text, 'rolled_back'::text, 'copying'::text, 'verifying'::text, 'verified'::text, 'authoritative'::text, 'verify_failed'::text, 'rollback_fenced'::text, 'rollback_approved'::text, 'source_restoring'::text, 'abandoned'::text])))",+ "persistence_graduation.persistence_graduation_trigger_bypass_check": "c CHECK (((trigger_bypass IS NULL) OR (trigger_bypass = ANY (ARRAY['session_replication_role'::text, 'disable_trigger'::text]))))","persistence_host_bindings.persistence_host_bindings_pkey": "p PRIMARY KEY (worktree_id, host_id)","persistence_host_bindings.persistence_host_bindings_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)","persistence_local_writers.persistence_local_writers_credential_hash_key": "u UNIQUE (credential_hash)",@@ -311,6 +316,7 @@"gbrain_fact_fingerprint(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=666cc212d15431ede62a3d1e8932676a950705717852262f86df6d836d526ab4","gbrain_fact_fingerprint_v1(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=38f7cfc0016f2b34d6f54652f4910cf1dd5240fbec5fd636c782e46fb70a6c7d","gbrain_fact_normalize(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=5fff22c689f79bb28b4cc66254ca3a42c2fc809be193c6ceaf75c3200a353035",+ "gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803","gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=e8b5589dafd4a355106104daffdf57c7776d34fe18c5b5f5336a27de188688a1","gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=f27354966c25d961fcecbffebba0e45747ad3de23575351319f6aee4f9aefd47","gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=12baf1d365a8aa3009ac0fe6605497e6433304e8d5915a3fc0b0b39ad748f6c2",@@ -528,6 +534,9 @@"persistence_effects": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_graduation": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_host_bindings": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -891,6 +900,7 @@"persistence_effects_pkey": "CREATE UNIQUE INDEX persistence_effects_pkey ON public.persistence_effects USING btree (id)","persistence_effects_recovery": "CREATE INDEX persistence_effects_recovery ON public.persistence_effects USING btree (worktree_id) WHERE (recovery IS NOT NULL)","persistence_effects_request_id_kind_key": "CREATE UNIQUE INDEX persistence_effects_request_id_kind_key ON public.persistence_effects USING btree (request_id, kind)",+ "persistence_graduation_pkey": "CREATE UNIQUE INDEX persistence_graduation_pkey ON public.persistence_graduation USING btree (singleton)","persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",@@ -2141,6 +2151,27 @@],"flags": "relkind=r rls=false force_rls=false"},+ "persistence_graduation": {+ "columns": [+ "1 singleton smallint/int2 NOT NULL DEFAULT 1",+ "2 role text/text NOT NULL",+ "3 run_id uuid/uuid NOT NULL",+ "4 state text/text NOT NULL",+ "5 source_brain_id uuid/uuid NULL",+ "6 source_data_dir text/text NULL",+ "7 cutover_sequence bigint/int8 NULL",+ "8 trigger_bypass text/text NULL",+ "9 table_receipts jsonb/jsonb NULL",+ "10 replay_probe jsonb/jsonb NULL",+ "11 timings jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "12 doctor jsonb/jsonb NULL",+ "13 rollback jsonb/jsonb NULL",+ "14 graduated_at timestamp with time zone/timestamptz NULL",+ "15 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "16 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },"persistence_host_bindings": {"columns": ["1 worktree_id uuid/uuid NOT NULL",diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.jsonindex db8a7c1b35..3232c743d7 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json@@ -177,6 +177,11 @@"persistence_effects.persistence_effects_request_id_kind_key": "u UNIQUE (request_id, kind)","persistence_effects.persistence_effects_state_check": "c CHECK ((state = ANY (ARRAY['queued'::text, 'running'::text, 'committed'::text, 'failed'::text])))","persistence_effects.persistence_effects_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)",+ "persistence_graduation.persistence_graduation_pkey": "p PRIMARY KEY (singleton)",+ "persistence_graduation.persistence_graduation_role_check": "c CHECK ((role = ANY (ARRAY['source'::text, 'target'::text])))",+ "persistence_graduation.persistence_graduation_singleton_check": "c CHECK ((singleton = 1))",+ "persistence_graduation.persistence_graduation_state_check": "c CHECK ((state = ANY (ARRAY['quiesced'::text, 'cutover'::text, 'rolled_back'::text, 'copying'::text, 'verifying'::text, 'verified'::text, 'authoritative'::text, 'verify_failed'::text, 'rollback_fenced'::text, 'rollback_approved'::text, 'source_restoring'::text, 'abandoned'::text])))",+ "persistence_graduation.persistence_graduation_trigger_bypass_check": "c CHECK (((trigger_bypass IS NULL) OR (trigger_bypass = ANY (ARRAY['session_replication_role'::text, 'disable_trigger'::text]))))","persistence_host_bindings.persistence_host_bindings_pkey": "p PRIMARY KEY (worktree_id, host_id)","persistence_host_bindings.persistence_host_bindings_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)","persistence_local_writers.persistence_local_writers_credential_hash_key": "u UNIQUE (credential_hash)",@@ -311,6 +316,7 @@"gbrain_fact_fingerprint(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=666cc212d15431ede62a3d1e8932676a950705717852262f86df6d836d526ab4","gbrain_fact_fingerprint_v1(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=38f7cfc0016f2b34d6f54652f4910cf1dd5240fbec5fd636c782e46fb70a6c7d","gbrain_fact_normalize(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=5fff22c689f79bb28b4cc66254ca3a42c2fc809be193c6ceaf75c3200a353035",+ "gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803","gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=e8b5589dafd4a355106104daffdf57c7776d34fe18c5b5f5336a27de188688a1","gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=f27354966c25d961fcecbffebba0e45747ad3de23575351319f6aee4f9aefd47","gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=12baf1d365a8aa3009ac0fe6605497e6433304e8d5915a3fc0b0b39ad748f6c2",@@ -528,6 +534,9 @@"persistence_effects": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_graduation": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_host_bindings": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -891,6 +900,7 @@"persistence_effects_pkey": "CREATE UNIQUE INDEX persistence_effects_pkey ON public.persistence_effects USING btree (id)","persistence_effects_recovery": "CREATE INDEX persistence_effects_recovery ON public.persistence_effects USING btree (worktree_id) WHERE (recovery IS NOT NULL)","persistence_effects_request_id_kind_key": "CREATE UNIQUE INDEX persistence_effects_request_id_kind_key ON public.persistence_effects USING btree (request_id, kind)",+ "persistence_graduation_pkey": "CREATE UNIQUE INDEX persistence_graduation_pkey ON public.persistence_graduation USING btree (singleton)","persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",@@ -2141,6 +2151,27 @@],"flags": "relkind=r rls=false force_rls=false"},+ "persistence_graduation": {+ "columns": [+ "1 singleton smallint/int2 NOT NULL DEFAULT 1",+ "2 role text/text NOT NULL",+ "3 run_id uuid/uuid NOT NULL",+ "4 state text/text NOT NULL",+ "5 source_brain_id uuid/uuid NULL",+ "6 source_data_dir text/text NULL",+ "7 cutover_sequence bigint/int8 NULL",+ "8 trigger_bypass text/text NULL",+ "9 table_receipts jsonb/jsonb NULL",+ "10 replay_probe jsonb/jsonb NULL",+ "11 timings jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "12 doctor jsonb/jsonb NULL",+ "13 rollback jsonb/jsonb NULL",+ "14 graduated_at timestamp with time zone/timestamptz NULL",+ "15 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "16 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },"persistence_host_bindings": {"columns": ["1 worktree_id uuid/uuid NOT NULL",diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.jsonindex 796685335b..9eb098ddab 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json@@ -177,6 +177,11 @@"persistence_effects.persistence_effects_request_id_kind_key": "u UNIQUE (request_id, kind)","persistence_effects.persistence_effects_state_check": "c CHECK ((state = ANY (ARRAY['queued'::text, 'running'::text, 'committed'::text, 'failed'::text])))","persistence_effects.persistence_effects_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)",+ "persistence_graduation.persistence_graduation_pkey": "p PRIMARY KEY (singleton)",+ "persistence_graduation.persistence_graduation_role_check": "c CHECK ((role = ANY (ARRAY['source'::text, 'target'::text])))",+ "persistence_graduation.persistence_graduation_singleton_check": "c CHECK ((singleton = 1))",+ "persistence_graduation.persistence_graduation_state_check": "c CHECK ((state = ANY (ARRAY['quiesced'::text, 'cutover'::text, 'rolled_back'::text, 'copying'::text, 'verifying'::text, 'verified'::text, 'authoritative'::text, 'verify_failed'::text, 'rollback_fenced'::text, 'rollback_approved'::text, 'source_restoring'::text, 'abandoned'::text])))",+ "persistence_graduation.persistence_graduation_trigger_bypass_check": "c CHECK (((trigger_bypass IS NULL) OR (trigger_bypass = ANY (ARRAY['session_replication_role'::text, 'disable_trigger'::text]))))","persistence_host_bindings.persistence_host_bindings_pkey": "p PRIMARY KEY (worktree_id, host_id)","persistence_host_bindings.persistence_host_bindings_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)","persistence_local_writers.persistence_local_writers_credential_hash_key": "u UNIQUE (credential_hash)",@@ -311,6 +316,7 @@"gbrain_fact_fingerprint(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=666cc212d15431ede62a3d1e8932676a950705717852262f86df6d836d526ab4","gbrain_fact_fingerprint_v1(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=38f7cfc0016f2b34d6f54652f4910cf1dd5240fbec5fd636c782e46fb70a6c7d","gbrain_fact_normalize(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=5fff22c689f79bb28b4cc66254ca3a42c2fc809be193c6ceaf75c3200a353035",+ "gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803","gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=e8b5589dafd4a355106104daffdf57c7776d34fe18c5b5f5336a27de188688a1","gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=f27354966c25d961fcecbffebba0e45747ad3de23575351319f6aee4f9aefd47","gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=12baf1d365a8aa3009ac0fe6605497e6433304e8d5915a3fc0b0b39ad748f6c2",@@ -528,6 +534,9 @@"persistence_effects": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_graduation": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_host_bindings": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -887,6 +896,7 @@"persistence_effects_pkey": "CREATE UNIQUE INDEX persistence_effects_pkey ON public.persistence_effects USING btree (id)","persistence_effects_recovery": "CREATE INDEX persistence_effects_recovery ON public.persistence_effects USING btree (worktree_id) WHERE (recovery IS NOT NULL)","persistence_effects_request_id_kind_key": "CREATE UNIQUE INDEX persistence_effects_request_id_kind_key ON public.persistence_effects USING btree (request_id, kind)",+ "persistence_graduation_pkey": "CREATE UNIQUE INDEX persistence_graduation_pkey ON public.persistence_graduation USING btree (singleton)","persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",@@ -2137,6 +2147,27 @@],"flags": "relkind=r rls=false force_rls=false"},+ "persistence_graduation": {+ "columns": [+ "1 singleton smallint/int2 NOT NULL DEFAULT 1",+ "2 role text/text NOT NULL",+ "3 run_id uuid/uuid NOT NULL",+ "4 state text/text NOT NULL",+ "5 source_brain_id uuid/uuid NULL",+ "6 source_data_dir text/text NULL",+ "7 cutover_sequence bigint/int8 NULL",+ "8 trigger_bypass text/text NULL",+ "9 table_receipts jsonb/jsonb NULL",+ "10 replay_probe jsonb/jsonb NULL",+ "11 timings jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "12 doctor jsonb/jsonb NULL",+ "13 rollback jsonb/jsonb NULL",+ "14 graduated_at timestamp with time zone/timestamptz NULL",+ "15 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "16 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },"persistence_host_bindings": {"columns": ["1 worktree_id uuid/uuid NOT NULL",diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-default.json b/test/fixtures/goldens/catalog/postgres-engine-init-default.jsonindex 65013754c1..d3ca09e144 100644--- a/test/fixtures/goldens/catalog/postgres-engine-init-default.json+++ b/test/fixtures/goldens/catalog/postgres-engine-init-default.json@@ -181,6 +181,11 @@"persistence_effects.persistence_effects_request_id_kind_key": "u UNIQUE (request_id, kind)","persistence_effects.persistence_effects_state_check": "c CHECK ((state = ANY (ARRAY['queued'::text, 'running'::text, 'committed'::text, 'failed'::text])))","persistence_effects.persistence_effects_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)",+ "persistence_graduation.persistence_graduation_pkey": "p PRIMARY KEY (singleton)",+ "persistence_graduation.persistence_graduation_role_check": "c CHECK ((role = ANY (ARRAY['source'::text, 'target'::text])))",+ "persistence_graduation.persistence_graduation_singleton_check": "c CHECK ((singleton = 1))",+ "persistence_graduation.persistence_graduation_state_check": "c CHECK ((state = ANY (ARRAY['quiesced'::text, 'cutover'::text, 'rolled_back'::text, 'copying'::text, 'verifying'::text, 'verified'::text, 'authoritative'::text, 'verify_failed'::text, 'rollback_fenced'::text, 'rollback_approved'::text, 'source_restoring'::text, 'abandoned'::text])))",+ "persistence_graduation.persistence_graduation_trigger_bypass_check": "c CHECK (((trigger_bypass IS NULL) OR (trigger_bypass = ANY (ARRAY['session_replication_role'::text, 'disable_trigger'::text]))))","persistence_host_bindings.persistence_host_bindings_pkey": "p PRIMARY KEY (worktree_id, host_id)","persistence_host_bindings.persistence_host_bindings_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)","persistence_local_writers.persistence_local_writers_credential_hash_key": "u UNIQUE (credential_hash)",@@ -314,6 +319,7 @@"gbrain_fact_fingerprint(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=666cc212d15431ede62a3d1e8932676a950705717852262f86df6d836d526ab4","gbrain_fact_fingerprint_v1(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=38f7cfc0016f2b34d6f54652f4910cf1dd5240fbec5fd636c782e46fb70a6c7d","gbrain_fact_normalize(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=5fff22c689f79bb28b4cc66254ca3a42c2fc809be193c6ceaf75c3200a353035",+ "gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803","gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=e8b5589dafd4a355106104daffdf57c7776d34fe18c5b5f5336a27de188688a1","gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=f27354966c25d961fcecbffebba0e45747ad3de23575351319f6aee4f9aefd47","gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=12baf1d365a8aa3009ac0fe6605497e6433304e8d5915a3fc0b0b39ad748f6c2",@@ -535,6 +541,9 @@"persistence_effects": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_graduation": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_host_bindings": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -895,6 +904,7 @@"persistence_effects_pkey": "CREATE UNIQUE INDEX persistence_effects_pkey ON public.persistence_effects USING btree (id)","persistence_effects_recovery": "CREATE INDEX persistence_effects_recovery ON public.persistence_effects USING btree (worktree_id) WHERE (recovery IS NOT NULL)","persistence_effects_request_id_kind_key": "CREATE UNIQUE INDEX persistence_effects_request_id_kind_key ON public.persistence_effects USING btree (request_id, kind)",+ "persistence_graduation_pkey": "CREATE UNIQUE INDEX persistence_graduation_pkey ON public.persistence_graduation USING btree (singleton)","persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",@@ -2153,6 +2163,27 @@],"flags": "relkind=r rls=true force_rls=false"},+ "persistence_graduation": {+ "columns": [+ "1 singleton smallint/int2 NOT NULL DEFAULT 1",+ "2 role text/text NOT NULL",+ "3 run_id uuid/uuid NOT NULL",+ "4 state text/text NOT NULL",+ "5 source_brain_id uuid/uuid NULL",+ "6 source_data_dir text/text NULL",+ "7 cutover_sequence bigint/int8 NULL",+ "8 trigger_bypass text/text NULL",+ "9 table_receipts jsonb/jsonb NULL",+ "10 replay_probe jsonb/jsonb NULL",+ "11 timings jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "12 doctor jsonb/jsonb NULL",+ "13 rollback jsonb/jsonb NULL",+ "14 graduated_at timestamp with time zone/timestamptz NULL",+ "15 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "16 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },"persistence_host_bindings": {"columns": ["1 worktree_id uuid/uuid NOT NULL",diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.jsonindex ecdff86800..c63ccab414 100644--- a/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json+++ b/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json@@ -181,6 +181,11 @@"persistence_effects.persistence_effects_request_id_kind_key": "u UNIQUE (request_id, kind)","persistence_effects.persistence_effects_state_check": "c CHECK ((state = ANY (ARRAY['queued'::text, 'running'::text, 'committed'::text, 'failed'::text])))","persistence_effects.persistence_effects_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)",+ "persistence_graduation.persistence_graduation_pkey": "p PRIMARY KEY (singleton)",+ "persistence_graduation.persistence_graduation_role_check": "c CHECK ((role = ANY (ARRAY['source'::text, 'target'::text])))",+ "persistence_graduation.persistence_graduation_singleton_check": "c CHECK ((singleton = 1))",+ "persistence_graduation.persistence_graduation_state_check": "c CHECK ((state = ANY (ARRAY['quiesced'::text, 'cutover'::text, 'rolled_back'::text, 'copying'::text, 'verifying'::text, 'verified'::text, 'authoritative'::text, 'verify_failed'::text, 'rollback_fenced'::text, 'rollback_approved'::text, 'source_restoring'::text, 'abandoned'::text])))",+ "persistence_graduation.persistence_graduation_trigger_bypass_check": "c CHECK (((trigger_bypass IS NULL) OR (trigger_bypass = ANY (ARRAY['session_replication_role'::text, 'disable_trigger'::text]))))","persistence_host_bindings.persistence_host_bindings_pkey": "p PRIMARY KEY (worktree_id, host_id)","persistence_host_bindings.persistence_host_bindings_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)","persistence_local_writers.persistence_local_writers_credential_hash_key": "u UNIQUE (credential_hash)",@@ -314,6 +319,7 @@"gbrain_fact_fingerprint(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=666cc212d15431ede62a3d1e8932676a950705717852262f86df6d836d526ab4","gbrain_fact_fingerprint_v1(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=38f7cfc0016f2b34d6f54652f4910cf1dd5240fbec5fd636c782e46fb70a6c7d","gbrain_fact_normalize(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=5fff22c689f79bb28b4cc66254ca3a42c2fc809be193c6ceaf75c3200a353035",+ "gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803","gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=e8b5589dafd4a355106104daffdf57c7776d34fe18c5b5f5336a27de188688a1","gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=f27354966c25d961fcecbffebba0e45747ad3de23575351319f6aee4f9aefd47","gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=12baf1d365a8aa3009ac0fe6605497e6433304e8d5915a3fc0b0b39ad748f6c2",@@ -535,6 +541,9 @@"persistence_effects": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_graduation": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_host_bindings": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -895,6 +904,7 @@"persistence_effects_pkey": "CREATE UNIQUE INDEX persistence_effects_pkey ON public.persistence_effects USING btree (id)","persistence_effects_recovery": "CREATE INDEX persistence_effects_recovery ON public.persistence_effects USING btree (worktree_id) WHERE (recovery IS NOT NULL)","persistence_effects_request_id_kind_key": "CREATE UNIQUE INDEX persistence_effects_request_id_kind_key ON public.persistence_effects USING btree (request_id, kind)",+ "persistence_graduation_pkey": "CREATE UNIQUE INDEX persistence_graduation_pkey ON public.persistence_graduation USING btree (singleton)","persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",@@ -2153,6 +2163,27 @@],"flags": "relkind=r rls=true force_rls=false"},+ "persistence_graduation": {+ "columns": [+ "1 singleton smallint/int2 NOT NULL DEFAULT 1",+ "2 role text/text NOT NULL",+ "3 run_id uuid/uuid NOT NULL",+ "4 state text/text NOT NULL",+ "5 source_brain_id uuid/uuid NULL",+ "6 source_data_dir text/text NULL",+ "7 cutover_sequence bigint/int8 NULL",+ "8 trigger_bypass text/text NULL",+ "9 table_receipts jsonb/jsonb NULL",+ "10 replay_probe jsonb/jsonb NULL",+ "11 timings jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "12 doctor jsonb/jsonb NULL",+ "13 rollback jsonb/jsonb NULL",+ "14 graduated_at timestamp with time zone/timestamptz NULL",+ "15 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "16 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },"persistence_host_bindings": {"columns": ["1 worktree_id uuid/uuid NOT NULL",diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json b/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.jsonindex a815cd1c99..72d43c05df 100644--- a/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json+++ b/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json@@ -181,6 +181,11 @@"persistence_effects.persistence_effects_request_id_kind_key": "u UNIQUE (request_id, kind)","persistence_effects.persistence_effects_state_check": "c CHECK ((state = ANY (ARRAY['queued'::text, 'running'::text, 'committed'::text, 'failed'::text])))","persistence_effects.persistence_effects_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)",+ "persistence_graduation.persistence_graduation_pkey": "p PRIMARY KEY (singleton)",+ "persistence_graduation.persistence_graduation_role_check": "c CHECK ((role = ANY (ARRAY['source'::text, 'target'::text])))",+ "persistence_graduation.persistence_graduation_singleton_check": "c CHECK ((singleton = 1))",+ "persistence_graduation.persistence_graduation_state_check": "c CHECK ((state = ANY (ARRAY['quiesced'::text, 'cutover'::text, 'rolled_back'::text, 'copying'::text, 'verifying'::text, 'verified'::text, 'authoritative'::text, 'verify_failed'::text, 'rollback_fenced'::text, 'rollback_approved'::text, 'source_restoring'::text, 'abandoned'::text])))",+ "persistence_graduation.persistence_graduation_trigger_bypass_check": "c CHECK (((trigger_bypass IS NULL) OR (trigger_bypass = ANY (ARRAY['session_replication_role'::text, 'disable_trigger'::text]))))","persistence_host_bindings.persistence_host_bindings_pkey": "p PRIMARY KEY (worktree_id, host_id)","persistence_host_bindings.persistence_host_bindings_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)","persistence_local_writers.persistence_local_writers_credential_hash_key": "u UNIQUE (credential_hash)",@@ -314,6 +319,7 @@"gbrain_fact_fingerprint(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=666cc212d15431ede62a3d1e8932676a950705717852262f86df6d836d526ab4","gbrain_fact_fingerprint_v1(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=38f7cfc0016f2b34d6f54652f4910cf1dd5240fbec5fd636c782e46fb70a6c7d","gbrain_fact_normalize(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=5fff22c689f79bb28b4cc66254ca3a42c2fc809be193c6ceaf75c3200a353035",+ "gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803","gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=e8b5589dafd4a355106104daffdf57c7776d34fe18c5b5f5336a27de188688a1","gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=f27354966c25d961fcecbffebba0e45747ad3de23575351319f6aee4f9aefd47","gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=12baf1d365a8aa3009ac0fe6605497e6433304e8d5915a3fc0b0b39ad748f6c2",@@ -535,6 +541,9 @@"persistence_effects": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_graduation": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_host_bindings": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -891,6 +900,7 @@"persistence_effects_pkey": "CREATE UNIQUE INDEX persistence_effects_pkey ON public.persistence_effects USING btree (id)","persistence_effects_recovery": "CREATE INDEX persistence_effects_recovery ON public.persistence_effects USING btree (worktree_id) WHERE (recovery IS NOT NULL)","persistence_effects_request_id_kind_key": "CREATE UNIQUE INDEX persistence_effects_request_id_kind_key ON public.persistence_effects USING btree (request_id, kind)",+ "persistence_graduation_pkey": "CREATE UNIQUE INDEX persistence_graduation_pkey ON public.persistence_graduation USING btree (singleton)","persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",@@ -2149,6 +2159,27 @@],"flags": "relkind=r rls=true force_rls=false"},+ "persistence_graduation": {+ "columns": [+ "1 singleton smallint/int2 NOT NULL DEFAULT 1",+ "2 role text/text NOT NULL",+ "3 run_id uuid/uuid NOT NULL",+ "4 state text/text NOT NULL",+ "5 source_brain_id uuid/uuid NULL",+ "6 source_data_dir text/text NULL",+ "7 cutover_sequence bigint/int8 NULL",+ "8 trigger_bypass text/text NULL",+ "9 table_receipts jsonb/jsonb NULL",+ "10 replay_probe jsonb/jsonb NULL",+ "11 timings jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "12 doctor jsonb/jsonb NULL",+ "13 rollback jsonb/jsonb NULL",+ "14 graduated_at timestamp with time zone/timestamptz NULL",+ "15 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "16 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=true force_rls=false"+ },"persistence_host_bindings": {"columns": ["1 worktree_id uuid/uuid NOT NULL",diff --git a/test/fixtures/goldens/cli/help-and-errors.json b/test/fixtures/goldens/cli/help-and-errors.jsonindex 2dd82bd490..bf53cd2d71 100644--- a/test/fixtures/goldens/cli/help-and-errors.json+++ b/test/fixtures/goldens/cli/help-and-errors.json@@ -20,7 +20,7 @@" engine status [--json] [--probe] Which engine + URL source, engine-free"," db-repair [--yes] [--json] Diagnose/fix Postgres access, engine-free"," (--yes --apply-rewrites for config rewrites)",- " migrate --to <supabase|pglite> Transfer brain between engines",+ " migrate --to <postgres|pglite> Move the brain between engines (PGLite -> Postgres graduates: plan, then --yes --expect)"," migrate embeddings --to <p:model> Re-embed onto another embedding provider"," embeddings enable --embedding-model <p:model> Turn on embeddings in place (keeps pages/facts)"," upgrade Self-update",@@ -230,7 +230,7 @@" engine status [--json] [--probe] Which engine + URL source, engine-free"," db-repair [--yes] [--json] Diagnose/fix Postgres access, engine-free"," (--yes --apply-rewrites for config rewrites)",- " migrate --to <supabase|pglite> Transfer brain between engines",+ " migrate --to <postgres|pglite> Move the brain between engines (PGLite -> Postgres graduates: plan, then --yes --expect)"," migrate embeddings --to <p:model> Re-embed onto another embedding provider"," embeddings enable --embedding-model <p:model> Turn on embeddings in place (keeps pages/facts)"," upgrade Self-update",@@ -440,7 +440,7 @@" engine status [--json] [--probe] Which engine + URL source, engine-free"," db-repair [--yes] [--json] Diagnose/fix Postgres access, engine-free"," (--yes --apply-rewrites for config rewrites)",- " migrate --to <supabase|pglite> Transfer brain between engines",+ " migrate --to <postgres|pglite> Move the brain between engines (PGLite -> Postgres graduates: plan, then --yes --expect)"," migrate embeddings --to <p:model> Re-embed onto another embedding provider"," embeddings enable --embedding-model <p:model> Turn on embeddings in place (keeps pages/facts)"," upgrade Self-update",diff --git a/test/fixtures/goldens/doctor/json-pglite-degraded.json b/test/fixtures/goldens/doctor/json-pglite-degraded.jsonindex 22c4a12451..96e9a19b27 100644--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json@@ -507,7 +507,7 @@},{"category": "meta",- "message": "Version 200 (latest: 200)",+ "message": "Version 201 (latest: 201)","name": "schema_version","status": "ok"},diff --git a/test/fixtures/goldens/doctor/json-pglite-fresh.json b/test/fixtures/goldens/doctor/json-pglite-fresh.jsonindex 153d996111..a93014abc8 100644--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json@@ -510,7 +510,7 @@},{"category": "meta",- "message": "Version 200 (latest: 200)",+ "message": "Version 201 (latest: 201)","name": "schema_version","status": "ok"},diff --git a/test/fixtures/goldens/doctor/json-postgres-fresh.json b/test/fixtures/goldens/doctor/json-postgres-fresh.jsonindex 9ebd3e303b..fec0a85688 100644--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json@@ -497,13 +497,13 @@},{"category": "ops",- "message": "RLS enabled on 103/103 public tables",+ "message": "RLS enabled on 104/104 public tables","name": "rls","status": "ok"},{"category": "meta",- "message": "Version 200 (latest: 200)",+ "message": "Version 201 (latest: 201)","name": "schema_version","status": "ok"},diff --git a/test/fixtures/goldens/exports/runtime.json b/test/fixtures/goldens/exports/runtime.jsonindex 829c615c1b..09b2b73585 100644--- a/test/fixtures/goldens/exports/runtime.json+++ b/test/fixtures/goldens/exports/runtime.json@@ -20,9 +20,11 @@"applyForwardReferenceBootstrap","batchLoadEmotionalInputs","batchRetry",+ "closeRetainingLock","codeEdgesDeps","connect","connectForRestore",+ "connectWithHeldLock","consolidateFact","countChunklessPagesWithContent","countStaleChunks",@@ -729,6 +731,7 @@"./pglite-lock": ["LiveServeLockError","PgliteBusyError",+ "acquireKernelLockOnly","acquireLock","getPgliteKernelLockPath","getPgliteMigrationLockPath",@@ -738,6 +741,7 @@"isProcessAlive","msSinceLastReap","peekLock",+ "pgliteLockDirFor","readBootId","readPidNs","releaseLock"diff --git a/test/fixtures/goldens/exports/types.json b/test/fixtures/goldens/exports/types.jsonindex fb4aa5732c..7535d33148 100644--- a/test/fixtures/goldens/exports/types.json+++ b/test/fixtures/goldens/exports/types.json@@ -1032,7 +1032,7 @@"getTimelineForDate: (date: string, opts?: ChronicleTimelineOpts) => Promise<ChronicleTimelineRow[]>","getUnverifiedExtractionPageIds: (pageIds: number[], opts?: PageReadScope) => Promise<Map<number, { unverified: boolean; status: string; }>>","getVersions: (slug: string, opts?: { sourceId?: string; sourceIds?: string[]; excludePrivate?: boolean; }) => Promise<PageVersion[]>",- "initSchema: () => Promise<void>",+ "initSchema: (opts?: { embedding?: { dimensions: number; model: string; }; }) => Promise<void>","insertFact: (input: NewFact, ctx: { source_id: string; supersedeId?: number; }) => Promise<{ id: number; status: FactInsertStatus; }>","insertFacts: (rows: Array<NewFact & { row_num: number; source_markdown_slug: string; superseded_by_row?: number; }>, ctx: { source_id: string; }, opts?: { deleteForPageFirst?: { slug: string; excludeSourcePrefixes?: string[]; preserveExpiredLegacy?: boolean; }; }) => Promise<{ inserted: number; ids: number[]; warnings: string[]; deleted: number; }>","invalidateContentDriftEmbeddings: (opts?: { sourceId?: string; }) => Promise<number>",@@ -2473,6 +2473,7 @@"mcp?: { instructions?: string; publish_skills?: boolean; publish_advisor?: boolean; skills_dir?: string; strict_params?: \"warn\" | \"reject\"; default_surface_dcr?: \"verbs\" | \"starter\" | \"full\"; result_rows?: \"lean\" | \"full\"; } | undefined","mcp_surface?: \"verbs\" | \"starter\" | \"full\" | undefined","memory?: { auto_writeback?: string; auto_writeback_transient_ttl?: string; visibility_posture?: string; } | undefined",+ "migrate?: { graduation?: boolean; } | undefined","openai_api_key?: string | undefined","openrouter_api_key?: string | undefined","persistence?: { write_wait_ms?: number | string; } | undefined",@@ -5625,7 +5626,7 @@{"kind": "class","members": [- "canonical?: \"unknown\" | \"projection_pending\" | \"timeout\" | \"writer_lock_unavailable\" | \"writer_pool_capacity\" | \"owner_unavailable\" | \"recovery_required\" | \"queue_capacity\" | \"revision_required\" | \"revision_conflict\" | \"idempotency_conflict\" | \"source_changed\" | \"write_pending\" | \"storage_error\" | \"cancelled\" | \"permission_denied\" | \"scope_denied\" | \"invalid_params\" | \"not_found\" | \"page_not_found\" | \"page_identity_changed\" | \"write_claim_lost\" | \"request_too_large\" | \"response_too_large\" | \"writer_registration_required\" | \"writer_identity_invalid\" | \"writer_not_initialized\" | \"writer_coordinator_required\" | \"fact_already_expired\" | \"source_writeback_required\" | \"unsupported_mutation_protocol\" | \"writer_upgrade_required\" | \"writer_not_quiesced\" | \"skill_bundle_required\" | \"take_row_collision\" | \"invalid_source_uri\" | \"writer_admin_locked\" | \"connector_account_changed\" | \"connector_intent_outdated\" | \"checkpoint_validation_timeout\" | \"invalid_connector_text\" | \"connector_holds_exhausted\" | \"connector_fence_below_timeline\" | \"embedding_failed\" | \"bucket_not_found\" | \"database_error\" | \"unknown_transport\" | \"rate_limited\" | \"extraction_failed\" | \"fact_not_found\" | \"provenance_required\" | \"unavailable\" | \"budget_unsatisfiable\" | \"embedding_budget_below_worst_case\" | \"access_command_failed\" | \"access_denied_test_user\" | \"access_env_missing\" | \"acknowledgment_unavailable\" | \"admin_policy_enforced\" | \"ambiguous_id\" | \"ambiguous_skill\" | \"api_not_enabled\" | \"approval_required\" | \"autopilot_job_owned_by_other_brain\" | \"benchmark_duplicate_task_id\" | \"benchmark_empty\" | \"benchmark_exists\" | \"benchmark_judge_llm_no_rubric\" | \"benchmark_judge_qrels_no_expected\" | \"benchmark_judge_rule_no_checks\" | \"benchmark_judge_unknown_kind\" | \"benchmark_malformed\" | \"benchmark_missing_judge\" | \"benchmark_missing_task\" | \"benchmark_missing_task_id\" | \"benchmark_not_found\" | \"benchmark_rule_check_bad_arg\" | \"benchmark_rule_check_malformed\" | \"benchmark_rule_check_unknown_op\" | \"bootstrap_empty\" | \"bootstrap_pending_review\" | \"bridge_ownership_conflict\" | \"catalog_unavailable\" | \"changed_since_preview\" | \"chronicle_skipped\" | \"no_pricing\" | \"checkpoint_missing\" | \"claim_already_used\" | \"client_json_unreadable\" | \"client_json_wrong_type\" | \"client_shape_invalid\" | \"code_callees_requires_symbol\" | \"code_callers_requires_symbol\" | \"code_def_requires_symbol\" | \"code_refs_requires_symbol\" | \"code_reused\" | \"colon_slug_windows_write_through\" | \"command_failed\" | \"config_error\" | \"confirmation_required\" | \"conflicting_source_scope\" | \"consent_timeout\" | \"content_rejected\" | \"cost_cap_exceeded\" | \"cost_preview_requires_yes\" | \"cycle_failed\" | \"d_sel_too_small\" | \"demo_graph_failed\" | \"demo_import_failed\" | \"demo_verification_failed\" | \"derived_cap_exhausted\" | \"destination_not_ready\" | \"dirty_tree\" | \"effect_not_failed\" | \"embedding_auth_failed\" | \"embedding_configuration\" | \"embedding_disabled\" | \"embedding_model_mismatch\" | \"embedding_plane_split\" | \"embedding_storage_unavailable\" | \"embedding_unavailable\" | \"embedding_unconfigured\" | \"embedding_width_mismatch\" | \"export_limit\" | \"extractor_identity_mismatch\" | \"facts_absorb_write_refused\" | \"facts_payload_expired\" | \"fetch_failed\" | \"file_too_large\" | \"frontmatter_slug_conflict\" | \"full_resync_required\" | \"gate_failed\" | \"git_index_locked\" | \"git_index_stale\" | \"git_push_unavailable\" | \"git_target_unsafe\" | \"git_unavailable\" | \"graph_incomplete\" | \"held_out_overlaps_benchmark\" | \"held_out_required_for_bundled\" | \"independent_principal_required\" | \"insufficient_scope\" | \"internal\" | \"internal_error\" | \"interrupted\" | \"invalid_client\" | \"invalid_frontmatter\" | \"invalid_grant_clock_skew\" | \"invalid_grant_revoked\" | \"invalid_grant_testing_expiry\" | \"invalid_request\" | \"invalid_source\" | \"invalid_source_pin\" | \"invalid_token\" | \"invalid_write_wait\" | \"legacy_job_selection_invalid\" | \"legacy_jobs_active\" | \"local_conflict\" | \"lock_busy\" | \"managed_pull_skipped\" | \"method_not_allowed\" | \"migration_failed\" | \"migrations_pending\" | \"migrations_running\" | \"missing_source_scope\" | \"missing_source_value\" | \"models_strict_violation\" | \"no_refresh_token\" | \"no_routing_eval\" | \"no_skill_md\" | \"no_worker\" | \"no_worker_surface\" | \"not_a_git_repo\" | \"not_connected\" | \"no_brain\" | \"overlapping_path\" | \"parse_error\" | \"parser_regression\" | \"pasted_wrong_url\" | \"payload_too_large\" | \"pending_writes\" | \"pglite_busy\" | \"plan_output_failed\" | \"plan_stale\" | \"port_in_use\" | \"preview_changed\" | \"profile_incompatible\" | \"projection_owner_resident\" | \"publication_pending\" | \"redirect_uri_mismatch\" | \"refresh_dirty\" | \"refresh_diverged\" | \"refresh_drain_timeout\" | \"refresh_no_upstream\" | \"refresh_not_managed\" | \"refresh_not_owner\" | \"refresh_source_changed\" | \"relay_disabled\" | \"relay_session_expired\" | \"relay_unreachable\" | \"rename_held\" | \"request_already_submitted\" | \"requirements_changed\" | \"requires_local_engine\" | \"resume_spec_mismatch\" | \"revision_unavailable\" | \"scope_missing\" | \"serve_port_in_use\" | \"serve_status_only\" | \"shared_skills_unavailable\" | \"shared_skills_unsupported\" | \"skill_asset_not_found\" | \"skill_candidate_invalid\" | \"skill_not_found\" | \"skill_retention_capacity\" | \"source_binding_required\" | \"source_id_taken\" | \"source_not_ready\" | \"source_profile_no_backfill\" | \"source_referenced\" | \"source_root_conflict\" | \"split_bad_ratio\" | \"split_unparseable\" | \"state_mismatch\" | \"sync_not_applicable\" | \"sync_in_progress\" | \"sync_parser_regression\" | \"target_escape\" | \"topology_change_required\" | \"trusted_local_only\" | \"unexpected_file_bytes\" | \"unexpected_staging_bytes\" | \"unknown_command\" | \"unknown_flag\" | \"unknown_method\" | \"unknown_source\" | \"unknown_tool\" | \"unmanaged_path\" | \"unsupported_export_data\" | \"upstream\" | \"verification_failed\" | \"withdrawal_capacity\" | \"withdrawal_provenance\" | \"writer_admin_intent_required\" | \"writer_admin_state_changed\" | \"writer_busy\" | \"writer_identity_publish_failed\" | \"writer_manifest_mismatch\" | \"writer_manifest_unsafe\" | \"writer_regrant_required\" | \"writer_transfer_conflict\" | \"writer_transfer_required\" | \"wrong_account_consented\" | undefined",+ "canonical?: \"unknown\" | \"projection_pending\" | \"timeout\" | \"writer_lock_unavailable\" | \"writer_pool_capacity\" | \"owner_unavailable\" | \"recovery_required\" | \"queue_capacity\" | \"revision_required\" | \"revision_conflict\" | \"idempotency_conflict\" | \"source_changed\" | \"write_pending\" | \"storage_error\" | \"cancelled\" | \"permission_denied\" | \"scope_denied\" | \"invalid_params\" | \"not_found\" | \"page_not_found\" | \"page_identity_changed\" | \"write_claim_lost\" | \"request_too_large\" | \"response_too_large\" | \"writer_registration_required\" | \"writer_identity_invalid\" | \"writer_not_initialized\" | \"writer_coordinator_required\" | \"fact_already_expired\" | \"source_writeback_required\" | \"unsupported_mutation_protocol\" | \"writer_upgrade_required\" | \"writer_not_quiesced\" | \"skill_bundle_required\" | \"take_row_collision\" | \"invalid_source_uri\" | \"writer_admin_locked\" | \"connector_account_changed\" | \"connector_intent_outdated\" | \"checkpoint_validation_timeout\" | \"invalid_connector_text\" | \"connector_holds_exhausted\" | \"connector_fence_below_timeline\" | \"embedding_failed\" | \"bucket_not_found\" | \"database_error\" | \"unknown_transport\" | \"rate_limited\" | \"extraction_failed\" | \"fact_not_found\" | \"provenance_required\" | \"unavailable\" | \"budget_unsatisfiable\" | \"embedding_budget_below_worst_case\" | \"access_command_failed\" | \"access_denied_test_user\" | \"access_env_missing\" | \"acknowledgment_unavailable\" | \"admin_policy_enforced\" | \"ambiguous_id\" | \"ambiguous_skill\" | \"api_not_enabled\" | \"approval_required\" | \"autopilot_job_owned_by_other_brain\" | \"benchmark_duplicate_task_id\" | \"benchmark_empty\" | \"benchmark_exists\" | \"benchmark_judge_llm_no_rubric\" | \"benchmark_judge_qrels_no_expected\" | \"benchmark_judge_rule_no_checks\" | \"benchmark_judge_unknown_kind\" | \"benchmark_malformed\" | \"benchmark_missing_judge\" | \"benchmark_missing_task\" | \"benchmark_missing_task_id\" | \"benchmark_not_found\" | \"benchmark_rule_check_bad_arg\" | \"benchmark_rule_check_malformed\" | \"benchmark_rule_check_unknown_op\" | \"bootstrap_empty\" | \"bootstrap_pending_review\" | \"bridge_ownership_conflict\" | \"catalog_unavailable\" | \"changed_since_preview\" | \"chronicle_skipped\" | \"no_pricing\" | \"checkpoint_missing\" | \"claim_already_used\" | \"client_json_unreadable\" | \"client_json_wrong_type\" | \"client_shape_invalid\" | \"code_callees_requires_symbol\" | \"code_callers_requires_symbol\" | \"code_def_requires_symbol\" | \"code_refs_requires_symbol\" | \"code_reused\" | \"colon_slug_windows_write_through\" | \"command_failed\" | \"config_error\" | \"confirmation_required\" | \"conflicting_source_scope\" | \"consent_timeout\" | \"content_rejected\" | \"cost_cap_exceeded\" | \"cost_preview_requires_yes\" | \"cycle_failed\" | \"d_sel_too_small\" | \"demo_graph_failed\" | \"demo_import_failed\" | \"demo_verification_failed\" | \"derived_cap_exhausted\" | \"destination_not_ready\" | \"dirty_tree\" | \"effect_not_failed\" | \"embedding_auth_failed\" | \"embedding_configuration\" | \"embedding_disabled\" | \"embedding_model_mismatch\" | \"embedding_plane_split\" | \"embedding_storage_unavailable\" | \"embedding_unavailable\" | \"embedding_unconfigured\" | \"embedding_width_mismatch\" | \"engine_graduated\" | \"export_limit\" | \"extractor_identity_mismatch\" | \"facts_absorb_write_refused\" | \"facts_payload_expired\" | \"fetch_failed\" | \"file_too_large\" | \"frontmatter_slug_conflict\" | \"full_resync_required\" | \"gate_failed\" | \"git_index_locked\" | \"git_index_stale\" | \"git_push_unavailable\" | \"git_target_unsafe\" | \"git_unavailable\" | \"graduation_drain_timeout\" | \"graduation_embedding_dimension_mismatch\" | \"graduation_foreign_host_binding\" | \"graduation_in_progress\" | \"graduation_interrupted\" | \"graduation_rollback_writes_lost\" | \"graduation_source_writer_held\" | \"graduation_split_brain\" | \"graduation_target_auth_failed\" | \"graduation_target_ddl_unreachable\" | \"graduation_target_not_empty\" | \"graduation_target_unsupported\" | \"graduation_unclassified_table\" | \"graduation_unsupported_platform\" | \"graduation_verify_failed\" | \"graph_incomplete\" | \"held_out_overlaps_benchmark\" | \"held_out_required_for_bundled\" | \"independent_principal_required\" | \"insufficient_scope\" | \"internal\" | \"internal_error\" | \"interrupted\" | \"invalid_client\" | \"invalid_frontmatter\" | \"invalid_grant_clock_skew\" | \"invalid_grant_revoked\" | \"invalid_grant_testing_expiry\" | \"invalid_request\" | \"invalid_source\" | \"invalid_source_pin\" | \"invalid_token\" | \"invalid_write_wait\" | \"legacy_job_selection_invalid\" | \"legacy_jobs_active\" | \"local_conflict\" | \"lock_busy\" | \"managed_pull_skipped\" | \"method_not_allowed\" | \"migration_failed\" | \"migrations_pending\" | \"migrations_running\" | \"missing_source_scope\" | \"missing_source_value\" | \"models_strict_violation\" | \"no_refresh_token\" | \"no_routing_eval\" | \"no_skill_md\" | \"no_worker\" | \"no_worker_surface\" | \"not_a_git_repo\" | \"not_connected\" | \"no_brain\" | \"overlapping_path\" | \"parse_error\" | \"parser_regression\" | \"pasted_wrong_url\" | \"payload_too_large\" | \"pending_writes\" | \"pglite_busy\" | \"plan_output_failed\" | \"plan_stale\" | \"port_in_use\" | \"preview_changed\" | \"profile_incompatible\" | \"projection_owner_resident\" | \"publication_pending\" | \"redirect_uri_mismatch\" | \"refresh_dirty\" | \"refresh_diverged\" | \"refresh_drain_timeout\" | \"refresh_no_upstream\" | \"refresh_not_managed\" | \"refresh_not_owner\" | \"refresh_source_changed\" | \"relay_disabled\" | \"relay_session_expired\" | \"relay_unreachable\" | \"rename_held\" | \"request_already_submitted\" | \"requirements_changed\" | \"requires_local_engine\" | \"resume_spec_mismatch\" | \"revision_unavailable\" | \"scope_missing\" | \"serve_port_in_use\" | \"serve_status_only\" | \"shared_skills_unavailable\" | \"shared_skills_unsupported\" | \"skill_asset_not_found\" | \"skill_candidate_invalid\" | \"skill_not_found\" | \"skill_retention_capacity\" | \"source_binding_required\" | \"source_id_taken\" | \"source_not_ready\" | \"source_profile_no_backfill\" | \"source_referenced\" | \"source_root_conflict\" | \"split_bad_ratio\" | \"split_unparseable\" | \"state_mismatch\" | \"sync_not_applicable\" | \"sync_in_progress\" | \"sync_parser_regression\" | \"target_escape\" | \"topology_change_required\" | \"trusted_local_only\" | \"unexpected_file_bytes\" | \"unexpected_staging_bytes\" | \"unknown_command\" | \"unknown_flag\" | \"unknown_method\" | \"unknown_source\" | \"unknown_tool\" | \"unmanaged_path\" | \"unsupported_export_data\" | \"upstream\" | \"verification_failed\" | \"withdrawal_capacity\" | \"withdrawal_provenance\" | \"writer_admin_intent_required\" | \"writer_admin_state_changed\" | \"writer_busy\" | \"writer_identity_publish_failed\" | \"writer_manifest_mismatch\" | \"writer_manifest_unsafe\" | \"writer_regrant_required\" | \"writer_transfer_conflict\" | \"writer_transfer_required\" | \"wrong_account_consented\" | undefined","canonicalCode: string","cause?: unknown","code: ErrorCode",@@ -5832,8 +5833,10 @@"addTimelineEntriesBatch: (entries: TimelineBatchInput[], opts?: BatchOpts) => Promise<number>","addTimelineEntry: (slug: string, entry: TimelineInput, opts?: { skipExistenceCheck?: boolean; sourceId?: string; }) => Promise<boolean>","batchLoadEmotionalInputs: (slugs?: string[]) => Promise<EmotionalWeightInputRow[]>",+ "closeRetainingLock: () => Promise<LockHandle>","connect: (config: EngineConfig) => Promise<void>","connectForRestore: (config: EngineConfig) => Promise<void>",+ "connectWithHeldLock: (config: EngineConfig, lock: LockHandle) => Promise<void>","consolidateFact: (id: number, takeId: number) => Promise<void>","countChunklessPagesWithContent: (opts?: { sourceId?: string; }) => Promise<number>","countStaleChunks: (opts?: { sourceId?: string; signature?: string; includeNullSignature?: boolean; }) => Promise<number>",@@ -5935,6 +5938,7 @@"markPagesExtractedBatch: (refs: Array<{ slug: string; source_id: string; extractedAt?: string; }>, defaultExtractedAt: string) => Promise<number>","mergeOntologyFact: (obs: OntologyObservationInput) => Promise<OntologyMergeResult>","migrateFactsToCanonical: (phantomSlug: string, canonicalSlug: string, sourceId: string) => Promise<{ migrated: number; }>",+ "private _adoptedLock","private _attachDatabase","private _beforeDisconnect","private _bulkRetryOptsCache",@@ -6202,6 +6206,13 @@"stackTraceLimit: number"]},+ {+ "kind": "function",+ "name": "acquireKernelLockOnly",+ "signature": [+ "(dataDir: string, opts: { lockDir: string; timeoutMs?: number; signal?: AbortSignal; }) => Promise<LockHandle>"+ ]+ },{"kind": "function","name": "acquireLock",@@ -6265,6 +6276,13 @@"(dataDir: string | undefined) => LockPeekResult"]},+ {+ "kind": "function",+ "name": "pgliteLockDirFor",+ "signature": [+ "(dataDir: string) => string"+ ]+ },{"kind": "function","name": "readBootId",diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.jsonindex 190c942fa0..3412cdfbaf 100644--- a/test/fixtures/goldens/migrations/records.json+++ b/test/fixtures/goldens/migrations/records.json@@ -1,6 +1,6 @@{"golden": {- "count": 195,+ "count": 196,"gaps": [17,18,@@ -28,7 +28,7 @@"slugifyPath": "401dbca23580865d8b168dd8d84db4a6c708c6610d7cb61abafc7d0ee9809063","verifyProjectionStatistics": "59d9ccfea1c53384d8607874a51209a9c2dfd51b2b85a2cb6269fa4120faf1f3"},- "latest": 200,+ "latest": 201,"records": [{"handler": {@@ -2968,6 +2968,19 @@"transaction": "absent","verify": "absent","version": 200+ },+ {+ "handler": "absent",+ "idempotent": true,+ "name": "persistence_graduation",+ "sql": {+ "length": 1498,+ "sha256": "79590a9d55a008e72d52b9b2482a4071b0b0736bac505bdfebf8d23a5ff7b098"+ },+ "sqlFor": "absent",+ "transaction": "absent",+ "verify": "absent",+ "version": 201}],"versions": [@@ -3165,7 +3178,8 @@197,198,199,- 200+ 200,+ 201]},"normalizer": "migrations-record-v1"diff --git a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.jsonindex 40df5ecbfd..c1a538bef0 100644--- a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json+++ b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json@@ -177,6 +177,11 @@"persistence_effects.persistence_effects_request_id_kind_key": "u UNIQUE (request_id, kind)","persistence_effects.persistence_effects_state_check": "c CHECK ((state = ANY (ARRAY['queued'::text, 'running'::text, 'committed'::text, 'failed'::text])))","persistence_effects.persistence_effects_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)",+ "persistence_graduation.persistence_graduation_pkey": "p PRIMARY KEY (singleton)",+ "persistence_graduation.persistence_graduation_role_check": "c CHECK ((role = ANY (ARRAY['source'::text, 'target'::text])))",+ "persistence_graduation.persistence_graduation_singleton_check": "c CHECK ((singleton = 1))",+ "persistence_graduation.persistence_graduation_state_check": "c CHECK ((state = ANY (ARRAY['quiesced'::text, 'cutover'::text, 'rolled_back'::text, 'copying'::text, 'verifying'::text, 'verified'::text, 'authoritative'::text, 'verify_failed'::text, 'rollback_fenced'::text, 'rollback_approved'::text, 'source_restoring'::text, 'abandoned'::text])))",+ "persistence_graduation.persistence_graduation_trigger_bypass_check": "c CHECK (((trigger_bypass IS NULL) OR (trigger_bypass = ANY (ARRAY['session_replication_role'::text, 'disable_trigger'::text]))))","persistence_host_bindings.persistence_host_bindings_pkey": "p PRIMARY KEY (worktree_id, host_id)","persistence_host_bindings.persistence_host_bindings_worktree_id_fkey": "f FOREIGN KEY (worktree_id) REFERENCES persistence_worktrees(id)","persistence_local_writers.persistence_local_writers_credential_hash_key": "u UNIQUE (credential_hash)",@@ -311,6 +316,7 @@"gbrain_fact_fingerprint(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=666cc212d15431ede62a3d1e8932676a950705717852262f86df6d836d526ab4","gbrain_fact_fingerprint_v1(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=38f7cfc0016f2b34d6f54652f4910cf1dd5240fbec5fd636c782e46fb70a6c7d","gbrain_fact_normalize(claim text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[] body_sha256=5fff22c689f79bb28b4cc66254ca3a42c2fc809be193c6ceaf75c3200a353035",+ "gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803","gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=e8b5589dafd4a355106104daffdf57c7776d34fe18c5b5f5336a27de188688a1","gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=f27354966c25d961fcecbffebba0e45747ad3de23575351319f6aee4f9aefd47","gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=12baf1d365a8aa3009ac0fe6605497e6433304e8d5915a3fc0b0b39ad748f6c2",@@ -528,6 +534,9 @@"persistence_effects": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_graduation": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_host_bindings": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -891,6 +900,7 @@"persistence_effects_pkey": "CREATE UNIQUE INDEX persistence_effects_pkey ON public.persistence_effects USING btree (id)","persistence_effects_recovery": "CREATE INDEX persistence_effects_recovery ON public.persistence_effects USING btree (worktree_id) WHERE (recovery IS NOT NULL)","persistence_effects_request_id_kind_key": "CREATE UNIQUE INDEX persistence_effects_request_id_kind_key ON public.persistence_effects USING btree (request_id, kind)",+ "persistence_graduation_pkey": "CREATE UNIQUE INDEX persistence_graduation_pkey ON public.persistence_graduation USING btree (singleton)","persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",@@ -2141,6 +2151,27 @@],"flags": "relkind=r rls=false force_rls=false"},+ "persistence_graduation": {+ "columns": [+ "1 singleton smallint/int2 NOT NULL DEFAULT 1",+ "2 role text/text NOT NULL",+ "3 run_id uuid/uuid NOT NULL",+ "4 state text/text NOT NULL",+ "5 source_brain_id uuid/uuid NULL",+ "6 source_data_dir text/text NULL",+ "7 cutover_sequence bigint/int8 NULL",+ "8 trigger_bypass text/text NULL",+ "9 table_receipts jsonb/jsonb NULL",+ "10 replay_probe jsonb/jsonb NULL",+ "11 timings jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "12 doctor jsonb/jsonb NULL",+ "13 rollback jsonb/jsonb NULL",+ "14 graduated_at timestamp with time zone/timestamptz NULL",+ "15 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "16 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },"persistence_host_bindings": {"columns": ["1 worktree_id uuid/uuid NOT NULL",diff --git a/test/helpers/graduation-e2e.ts b/test/helpers/graduation-e2e.tsindex 80b4c57f63..f5ef8798b7 100644--- a/test/helpers/graduation-e2e.ts+++ b/test/helpers/graduation-e2e.ts@@ -204,12 +204,22 @@ export async function graduateViaAgentFlow(home: string, url: string, opts: { exreturn { plan, hash, run };}+/**+ * The byte pattern that proves a password leaked. A distinctive password is searched for raw; a short or+ * common one (CI's `postgres:postgres`) appears legitimately in redacted URLs and paths, so only its+ * URL-credential form `:<password>@` counts.+ */+export function leakNeedle(password: string): string {+ return password.length >= 12 && !/^(postgres|test|password)/i.test(password) ? password : `:${encodeURIComponent(password)}@`;+}+/** Assert no output byte names the target password (stdout, stderr, files under the fixture except the 0600 manifest and config). */export function passwordLeaks(password: string, results: GbrainResult[], fixtureDir: string): string[] {const leaks: string[] = [];+ const needle = leakNeedle(password);for (const [i, r] of results.entries()) {- if (r.stdout.includes(password)) leaks.push(`result ${i} stdout`);- if (r.stderr.includes(password)) leaks.push(`result ${i} stderr`);+ if (r.stdout.includes(needle)) leaks.push(`result ${i} stdout`);+ if (r.stderr.includes(needle)) leaks.push(`result ${i} stderr`);}const allowed = new Set(['graduation-manifest.json', 'config.json']);const walk = (dir: string) => {@@ -219,7 +229,7 @@ export function passwordLeaks(password: string, results: GbrainResult[], fixtureconst info = lstatSync(path);if (info.isDirectory()) { if (!name.endsWith('.pglite') && !name.includes('.graduated-') && name !== '.git') walk(path); continue; }if (!info.isFile() || info.size > 4 * 1024 * 1024 || allowed.has(name)) continue;- if (readFileSync(path).includes(password)) leaks.push(path);+ if (readFileSync(path).includes(needle)) leaks.push(path);}};walk(fixtureDir);