Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

feat(doctor): embedding_identity_unqualified names the migrate embeddings preview (#6113)

garrytan907d8b7489fe
diff --git a/TODOS.md b/TODOS.md
index ea85cd6726..25a5db89c5 100644
--- a/TODOS.md
+++ b/TODOS.md
@@ -57,7 +57,7 @@ Same-host dead-owner release (G2, "a consumer that finds a running claim whose s
## Fix wave 12 follow-ups (filed 2026-10-07, GBRA-57)
-- [ ] **P2 — Free relabel for a legacy bare `embedding_model` row (#6113, carried from wave 11 W4.7).** **What:** wave 12 ships the refusal that names `gbrain migrate embeddings --to <provider:model> --dry-run`; the zero-cost relabel is not built. **Fix:** a restamp-only branch taken only when bare row, recipe, unambiguous model, dimensions, gateway config and every stored chunk/fact/take stamp agree (a NULL stamp on a non-null vector refuses), translating the model-bound chunk input hashes (`embedding-input-hash.ts`) and recording prior labels; doctor `embedding_identity_unqualified`. Needs a concurrent old-model worker test on Postgres. **Effort:** M-L. **Priority:** P2.
+- [ ] **P2 — Free relabel for a legacy bare `embedding_model` row (#6113, carried from wave 11 W4.7).** **What:** wave 12 ships the refusal that names `gbrain migrate embeddings --to <provider:model> --dry-run`; the zero-cost relabel is not built. **Fix:** a restamp-only branch taken only when bare row, recipe, unambiguous model, dimensions, gateway config and every stored chunk/fact/take stamp agree (a NULL stamp on a non-null vector refuses), translating the model-bound chunk input hashes (`embedding-input-hash.ts`) and recording prior labels (doctor `embedding_identity_unqualified` already names the paid preview). Needs a concurrent old-model worker test on Postgres. **Effort:** M-L. **Priority:** P2.
- [x] **P2 — Hard ceiling for a stuck managed write (W3.3b, #6176).** **Completed: v0.60.112.0** — every managed write's preparation has a budget and a hard ceiling (`persistence.sync_preparation_ms`, `persistence.maintenance_preparation_ms`, `persistence.preparation_ceiling_ms`, `persistence.max_preparation_attempts`; the `preparation_deadlines` switch turns them off), and a write cut off twice (`persistence.max_preparation_attempts`, a kill mid-preparation counts too) is finished `failed` with `preparation_stalled` (#6278; this entry proposed `write_stalled` after 3 releases and reusing `persistence.max_claim_ms`, which keeps its doctor meaning). A sync holds the file and keeps going; publication stays detection-only (see the open entry below). Pinned by `test/persistence-consumer-scheduling.test.ts`, `test/e2e/persistence-preparation-deadline.e2e.test.ts`, `test/e2e/persistence-group-deadline-postgres.test.ts`.
- [ ] **P3 — Transcript budget for dream patterns children (#6236).** **What:** wave 12 de-duplicates claim records and counts deaths per source; a per-job transcript budget and subagent tool wrapper are not built. **Effort:** M. **Priority:** P3.
- [ ] **P3 — Quarantine junk classifier masks code (#6259).** **What:** fenced and inline code still trip junk patterns; wave 12 ships the override only. **Effort:** S. **Priority:** P3.
diff --git a/docs/architecture/key-files/commands-2-continued.md b/docs/architecture/key-files/commands-2-continued.md
index 014ff473e5..0b984c4067 100644
--- a/docs/architecture/key-files/commands-2-continued.md
+++ b/docs/architecture/key-files/commands-2-continued.md
@@ -5,6 +5,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL
- `src/commands/doctor/checks/routing-federation.ts` — `checkOauthClientScopeHealth` (`oauth_client_scope_health`, re-exported by the doctor.ts façade) has three warn arms: (a) dangling federated read grants, (b) orphaned empty `<name>-workspace` sources, (c) privileged self-registered clients — active `oauth_clients` rows whose scope word-matches `DCR_PRIVILEGED_SCOPES` — the DERIVED complement `ALLOWED_SCOPES_LIST \ DCR_REGISTRABLE_SCOPES` (exported; bound as a `$1` regex parameter, never interpolated) — and the `(read/write)` / `--scopes read,write` copy is built from `DCR_REGISTRABLE_SCOPES`; pinned by the set-equality + per-scope loop in `test/doctor-oauth-client-scope-health.test.ts`; rows with `grant_revision = 0` and no `oauth_grant_audit` row with `action = 'register'` (every operator path writes one; the anonymous DCR insert does not). Arm (c) is advisory (the signature also matches operator clients that predate the grant audit log) and carries the `gbrain auth rescope-client <client_id> --scopes read,write` / `gbrain auth revoke-client <client_id>` remedy; when the audit table or `grant_revision` column is absent it fails OPEN and the ok message states the self-registered-client audit was skipped (unknown). Pinned by `test/doctor-oauth-client-scope-health.test.ts`.
+- `src/commands/doctor/checks/embedding-identity.ts` — `embedding_identity_unqualified` (#6113, BRAIN, right after `embedding_env_override`): warns when the DB `config` row `embedding_model` has no provider prefix (managed fact extraction reads only that row and `config set` refuses it). The fix is the read-only `gbrain migrate embeddings --to <provider:model> --dry-run`, filled from `loadConfig()`'s provider-qualified `embedding_model`, or `<PROVIDER_MODEL>` plus an `inputs` entry when none is configured; `details.target_differs` flags a configured model with another name (applying it switches models). Applying re-embeds active facts (paid, user's call). The free relabel is parked (TODOS). Test: `test/doctor-embedding-identity-unqualified.test.ts`.
- `src/commands/doctor/checks/embedding-state.ts` — `embedding_state` (#6696 B3, BRAIN, `tier: 'ops'`, `opsPglite: 'not_applicable'`, after `embeddings`): `readEmbeddingState` in `ops` mode on the ops tier, `full` otherwise. Warns only on chunks of pages soft-deleted past the 72 h purge window (`deleted_page_chunks_overdue`, fix `pages purge-deleted`) and, on a keyed brain, live pages with body text but no chunks (`chunkless_pages_healable`, fix `embed --stale`); the pending backlog stays `embeddings`' warning and quarantined pages `quarantined_pages`'. keyword_only, deleted chunks inside the window and a keyless brain are `infoCheck`; ops without a covering index warns with `details.health: 'unknown'` (`embedding_state_unknown`). Test: `test/doctor-embedding-state.test.ts`.
- `src/commands/doctor/checks/persistence-consumers.ts` — #6317 (B3, T1c): doctor `two_consumers_on_host` (warn only when two live rows of resident kinds on this host have both been alive longer than 30 s; every other row, a `put` or a row younger than 30 s, is listed in `details`) and `consumers_without_heartbeat` (a `claim_phase.owner` pid on a running claim of this host with no heartbeat row: an older process that never defers; named with its kind and version from the stamp). Both carry a structured `agentFix` (`gbrain sources writer status --json`) and `doctorVerify`; with `persistence.single_consumer` off the overlap is reported as the configured behavior. `serve_build_drift` (#6696 C6, its own `serveBuildDriftEntry`, one `listHostConsumers` read, ok on PGLite with no read) compares the live resident rows (not this process) with this binary's `VERSION` through `compareWriterVersions` (an unparsable version counts as older): an older row warns "serve is running an older build than this checkout; restart serve and workers" with `details { count, this_version, owner, older, newer }` and a `fix` (actor `user`, `doctorVerify`) whose argv is the installed serve service's restart (`systemctl --user restart gbrain-serve.service` when `systemdUnitPath` exists on Linux, `launchctl kickstart -k gui/<uid>/com.gbrain.serve` when `launchdPlistPath` exists on macOS; `serveBuildDriftCheck`'s `ServiceHost` argument injects platform, home and uid) or else `kill <pid>`; a newer row is reported in an ok message; no rows names `consumers_without_heartbeat` for a pre-heartbeat serve. Registered in `DOCTOR_CHECK_REGISTRY` (the consumer entry, then `serveBuildDriftEntry`) before `searchModeEntry` and categorised `ops` in `src/core/doctor-categories.ts`. Tests: `test/doctor-serve-build-drift.test.ts`.
diff --git a/docs/guides/error-codes.md b/docs/guides/error-codes.md
index a763f639b9..0372844413 100644
--- a/docs/guides/error-codes.md
+++ b/docs/guides/error-codes.md
@@ -936,6 +936,16 @@ More: [docs/guides/write-refusals.md#embedding_auth_failed](../../docs/guides/wr
|---|---|---|---|---|---|---|
| Computing embeddings for the content failed. | 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 |
+### embedding_identity_unqualified
+
+<a id="embedding_identity_unqualified"></a>
+
+| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
+|---|---|---|---|---|---|---|
+| The brain's embedding_model config row names a model with no provider prefix, so managed fact extraction cannot verify its embedding identity. | Rows from older installs stored the bare model name. The managed facts resolver reads only the DB row and `config set` refuses to change it, so the supported rewrite is `gbrain migrate embeddings --to <provider:model>`, which re-embeds active facts (paid). | Preview the rewrite with `gbrain migrate embeddings --to <provider:model> --dry-run`, show the user its cost, and apply it only with their paid authorization. Run: gbrain doctor --only embedding_identity_unqualified --json | agent | `repeat the read that failed` | 1 | no |
+
+More: [docs/guides/troubleshooting.md#embedding-identity-unqualified](../../docs/guides/troubleshooting.md#embedding-identity-unqualified)
+
### embedding_model_mismatch
<a id="embedding_model_mismatch"></a>
diff --git a/docs/guides/troubleshooting.md b/docs/guides/troubleshooting.md
index 4252bc1e87..c3145e8ad9 100644
--- a/docs/guides/troubleshooting.md
+++ b/docs/guides/troubleshooting.md
@@ -367,6 +367,8 @@ completes in seconds on an 80K-page PGLite brain.
<a id="maintenance-write-drift"></a>**Writes to the same pages keep refusing `source_changed` with `file_database_drift`, or doctor `maintenance_write_drift` warns?** Each of those pages has a canonical file that differs from its database copy, usually from an edit outside a coordinated write, so every coordinated write to it refuses and leaves a conflict receipt. Maintenance now checks the file first: `synthesize_concepts` skips a drifted concept before any model call (the phase warns and names the commands below) and other maintenance writes refuse before admission, so the pile stops growing. To list the pages, run `gbrain sources reconcile <id> --brain host --audit --conflicts` (read-only; receipts per slug, whether the file still differs, its drift class and producer; MCP `list_write_conflicts` gives remote readers the database-derived part). Then preview `gbrain repair file-drift --source <id> --all-drifted --prefer file` (add `--class <name>` when the preview reports mixed classes, narrow it with `--only '<path glob>'` / `--skip '<path glob>'` over the canonical file paths, or pick pages with `--slug`), show the user the per-page `exceptions`, and after they agree run the printed `--apply --expect <hash>` command exactly as printed. For derived pages under one directory, such as regenerated concepts: (6) preview `gbrain repair file-drift --source default --all-drifted --only 'concepts/**' --prefer database`, show the user the count and the exceptions, and after they agree run the apply command it prints, which applies exactly the previewed pages. To keep resolving such a directory with the database copy from now on, the user can declare it under `storage:` `keep_db:` in the source's gbrain.yml; the owner host's serve, jobs or autopilot consumer then reconciles drifted pages there at most 10 every 10 minutes, and doctor echoes the policy with its matched count and receipt cost ([keep_db](repair.md#file-drift-keep-db)). `--keep` is refused here: use `--prefer database` or `--prefer file`. See [file drift](repair.md#file-drift). **Say to your agent:** *"Which pages keep refusing source_changed? Preview resolving them and show me before you apply."*
+<a id="embedding-identity-unqualified"></a>**`facts-absorb` dies with `embedding_configuration` ("records its embedding model without a provider") while `gbrain config get embedding_model` shows a valid `provider:model`, or doctor `embedding_identity_unqualified` warns?** The brain's database `config` row `embedding_model` holds a bare model name from an older install (for example `text-embedding-3-small`), and managed fact extraction reads only that row. `gbrain config set` cannot change it. The doctor check prints the preview with the configured model filled in: run `gbrain migrate embeddings --to <provider:model> --dry-run` (read-only), show the user the cost, and only after they approve run it without `--dry-run`, with `--yes --max-cost-usd <cap>`. It re-embeds active facts even when the model is unchanged, so it is a paid step. When no model is configured outside the database, the check asks for the provider-qualified id instead. **Say to your agent:** *"Why did facts extraction stop with an embedding configuration error?"*
+
## Embedding state
**Symptom.** Doctor `embedding_state` warns, `get_brain_health` reports
diff --git a/src/commands/doctor/checks/embedding-identity.ts b/src/commands/doctor/checks/embedding-identity.ts
new file mode 100644
index 0000000000..01d3a70286
--- /dev/null
+++ b/src/commands/doctor/checks/embedding-identity.ts
@@ -0,0 +1,63 @@
+/**
+ * Doctor `embedding_identity_unqualified` (#6113): the brain's DB `config`
+ * row `embedding_model` holds a model name with no provider prefix (a row
+ * from an older install). The managed facts resolver reads only that row, so
+ * facts-absorb stops with `embedding_configuration` while `gbrain config get
+ * embedding_model` shows a valid `provider:model` from the file plane, and
+ * `config set` cannot change the row. The supported rewrite is
+ * `gbrain migrate embeddings --to <provider:model>`; the fix is its read-only
+ * `--dry-run` preview, filled from the configured model (an `inputs` entry
+ * only when none is configured). Applying it re-embeds active facts, so it is
+ * the user's paid decision.
+ */
+import type { Check } from '../../doctor.ts';
+import type { Action } from '../../../core/agent-output.ts';
+import { checkError, doctorVerify } from '../check-fix.ts';
+import { connectedEngine, type DoctorContext, type DoctorEntry } from '../context.ts';
+
+const NAME = 'embedding_identity_unqualified';
+const QUALIFIED = /^[^\s:]+:[^\s]+$/;
+
+/** The rewrite preview for a bare row; `configured` is the non-DB plane's `provider:model`, when it has one. */
+export function embeddingIdentityFix(row: string, configured: string | null): Action {
+ const target = configured && QUALIFIED.test(configured) ? configured : null;
+ return {
+ argv: ['gbrain', 'migrate', 'embeddings', '--to', target ?? '<PROVIDER_MODEL>', '--dry-run'],
+ ...(target ? {} : { inputs: [{ name: 'PROVIDER_MODEL', how: `The provider-qualified id of the model that embedded this brain, for example openai:${row}; ask the user when unsure.` }] }),
+ consent: [], actor: 'agent', requires_exclusive: false,
+ why: 'Previews rewriting the brain\'s embedding identity to a provider-qualified model, read-only. Applying it (the same command without --dry-run, with --yes and --max-cost-usd) re-embeds active facts, so show the user the preview\'s cost and ask first.',
+ verify: doctorVerify(NAME),
+ docs: 'docs/guides/troubleshooting.md#embedding-identity-unqualified',
+ };
+}
+
+async function runEmbeddingIdentity(ctx: DoctorContext): Promise<Check[]> {
+ const engine = connectedEngine(ctx);
+ const checks: Check[] = [];
+ ctx.progress.heartbeat(NAME);
+ try {
+ const [row] = await engine.executeRaw<{ value: string }>(`SELECT value FROM config WHERE key = 'embedding_model'`);
+ const stored = row?.value?.trim() ?? '';
+ if (!stored || /[:/]/.test(stored)) {
+ checks.push({ name: 'embedding_identity_unqualified', status: 'ok', message: stored ? `The brain records its embedding model with its provider (${stored}).` : 'The brain records no embedding_model row.' });
+ return checks;
+ }
+ const { loadConfig } = await import('../../../core/config.ts');
+ const configured = loadConfig()?.embedding_model?.trim() || null;
+ const fix = embeddingIdentityFix(stored, configured);
+ const target = fix.argv[4]!;
+ const differs = !fix.inputs && !target.endsWith(`:${stored}`);
+ checks.push({
+ name: 'embedding_identity_unqualified', status: 'warn',
+ message: `The brain's embedding_model row is ${JSON.stringify(stored)} with no provider prefix (a row from an older install), so managed fact extraction stops with embedding_configuration; gbrain config set cannot change it. `
+ + `Preview the rewrite: ${fix.argv.join(' ')}${differs ? ` (the configured model ${target} is not ${stored}, so applying it switches models)` : ''}. Applying it re-embeds active facts and needs the user's paid authorization.`,
+ details: { code: NAME, stored_model: stored, configured_model: configured, target_model: fix.inputs ? null : target, target_differs: differs },
+ fix,
+ });
+ } catch (err) {
+ checks.push(checkError(NAME, 'read the embedding_model config row', err));
+ }
+ return checks;
+}
+
+export const embeddingIdentityEntry: DoctorEntry = { name: 'embedding_identity_unqualified', emits: ['embedding_identity_unqualified'], run: runEmbeddingIdentity };
diff --git a/src/commands/doctor/registry.ts b/src/commands/doctor/registry.ts
index 13da7fe1d3..5ec94a0c44 100644
--- a/src/commands/doctor/registry.ts
+++ b/src/commands/doctor/registry.ts
@@ -48,6 +48,7 @@ import {
embeddingsEntry,
} from './checks/schema-health.ts';
import { embeddingStateEntry } from './checks/embedding-state.ts';
+import { embeddingIdentityEntry } from './checks/embedding-identity.ts';
import {
embeddingProviderEntry,
alternativeProvidersEntry,
@@ -171,6 +172,7 @@ export const DOCTOR_CHECK_REGISTRY: readonly DoctorEntry[] = [
embeddingQueryPrefixEntry,
embeddingColumnRegistryEntry,
embeddingEnvOverrideEntry,
+ embeddingIdentityEntry,
supersessionCalibrationEntry,
factAdmissionFloorsEntry,
chatFallbackChainEntry,
diff --git a/src/core/doctor-categories.ts b/src/core/doctor-categories.ts
index 85ba5b7973..d81971d421 100644
--- a/src/core/doctor-categories.ts
+++ b/src/core/doctor-categories.ts
@@ -104,6 +104,8 @@ export const BRAIN_CHECK_NAMES: ReadonlySet<string> = new Set([
'embed_staleness',
'embedding_column_registry',
'embedding_env_override',
+ // #6113: a bare legacy embedding_model DB row; the fix previews migrate embeddings.
+ 'embedding_identity_unqualified',
// #5137: an env provider key shadowing a different config key.
'embedding_key_source',
'embedding_migration_state',
diff --git a/src/core/error-registry.ts b/src/core/error-registry.ts
index 01178a9914..8654057e9c 100644
--- a/src/core/error-registry.ts
+++ b/src/core/error-registry.ts
@@ -180,6 +180,7 @@ export const CODES = {
embedding_configuration: { class: 'host_only', summary: "The brain's embedding configuration is invalid." },
embedding_disabled: { class: 'unavailable', summary: "Embeddings are disabled on this brain." },
embedding_failed: { class: 'server', summary: "Computing embeddings for the content failed." },
+ embedding_identity_unqualified: { class: 'consent', summary: "The brain's embedding_model config row names a model with no provider prefix, so managed fact extraction cannot verify its embedding identity.", why: 'Rows from older installs stored the bare model name. The managed facts resolver reads only the DB row and `config set` refuses to change it, so the supported rewrite is `gbrain migrate embeddings --to <provider:model>`, which re-embeds active facts (paid).', docs: 'docs/guides/troubleshooting.md#embedding-identity-unqualified', suggestion: 'Preview the rewrite with `gbrain migrate embeddings --to <provider:model> --dry-run`, show the user its cost, and apply it only with their paid authorization.', fix: { argv: ['gbrain', 'doctor', '--only', 'embedding_identity_unqualified', '--json'], consent: [], actor: 'agent', why: 'Names the stored row, the configured model and the exact preview command, read-only.', requires_exclusive: false } },
embedding_model_mismatch: { class: 'unavailable', summary: "The configured provider does not match the active embedding column." },
embedding_plane_split: { class: 'unavailable', summary: "Embedding plane split." },
embedding_state_unknown: { class: 'unavailable', summary: "The ops tier could not count embedding state: the active embedding column has no covering partial index, and the ops tier never scans.", why: 'Without an index on `WHERE <active column> IS NULL`, counting vector-less chunks means a full table scan, which the bounded ops tier refuses.', docs: 'docs/guides/troubleshooting.md#embedding-state', suggestion: 'Run the standard tier (`gbrain doctor --only embedding_state --json`) for exact counts.', fix: { argv: ['gbrain', 'doctor', '--only', 'embedding_state', '--json'], consent: [], actor: 'agent', why: 'The standard tier counts every embedding state exactly; it reads and changes nothing.', requires_exclusive: false, verify: { argv: ['gbrain', 'doctor', '--only', 'embedding_state', '--json'] } } },
diff --git a/test/doctor-embedding-identity-unqualified.test.ts b/test/doctor-embedding-identity-unqualified.test.ts
new file mode 100644
index 0000000000..72651c2956
--- /dev/null
+++ b/test/doctor-embedding-identity-unqualified.test.ts
@@ -0,0 +1,74 @@
+/**
+ * #6113: doctor `embedding_identity_unqualified` names the one supported
+ * repair for a bare legacy `embedding_model` DB row: a read-only
+ * `gbrain migrate embeddings --to <provider:model> --dry-run`, filled from the
+ * model configured outside the database, with an `inputs` entry only when none
+ * is configured. Real PGLite (DB plane), throwaway GBRAIN_HOME (file plane).
+ */
+import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
+import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { PGLiteEngine } from '../src/core/pglite-engine.ts';
+import { DOCTOR_CHECK_REGISTRY } from '../src/commands/doctor/registry.ts';
+import { categorizeCheck } from '../src/core/doctor-categories.ts';
+import type { DoctorContext } from '../src/commands/doctor/context.ts';
+import type { Check } from '../src/commands/doctor.ts';
+import { withEnv } from './helpers/with-env.ts';
+
+let engine: PGLiteEngine;
+beforeAll(async () => { engine = new PGLiteEngine(); await engine.connect({}); await engine.initSchema(); }, 120_000);
+afterAll(async () => { await engine.disconnect(); });
+beforeEach(async () => { await engine.executeRaw(`DELETE FROM config WHERE key = 'embedding_model'`); });
+
+function home(file: Record<string, unknown>): string {
+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-doctor-embedding-identity-'));
+ mkdirSync(join(dir, '.gbrain'), { recursive: true });
+ writeFileSync(join(dir, '.gbrain', 'config.json'), JSON.stringify({ engine: 'pglite', database_path: join(dir, 'brain.pglite'), ...file }));
+ return dir;
+}
+
+async function run(row: string | null, file: Record<string, unknown> = {}): Promise<Check> {
+ if (row !== null) await engine.executeRaw(`INSERT INTO config (key, value) VALUES ('embedding_model', $1)`, [row]);
+ const entry = DOCTOR_CHECK_REGISTRY.find(e => e.emits.includes('embedding_identity_unqualified'));
+ expect(entry).toBeDefined();
+ const ctx = { engine, progress: { heartbeat() {} } } as unknown as DoctorContext;
+ return withEnv({ GBRAIN_HOME: home(file), GBRAIN_EMBEDDING_MODEL: undefined, DATABASE_URL: undefined, GBRAIN_DATABASE_URL: undefined }, async () => {
+ const checks = await entry!.run(ctx) as Check[];
+ return checks.find(c => c.name === 'embedding_identity_unqualified')!;
+ });
+}
+
+describe('doctor embedding_identity_unqualified (#6113)', () => {
+ test('a bare legacy row warns with a copy-paste preview filled from the configured model', async () => {
+ const check = await run('text-embedding-3-small', { embedding_model: 'openai:text-embedding-3-small' });
+ expect(check.status).toBe('warn');
+ expect(check.details).toMatchObject({ code: 'embedding_identity_unqualified', stored_model: 'text-embedding-3-small', target_model: 'openai:text-embedding-3-small', target_differs: false });
+ expect(check.fix?.argv).toEqual(['gbrain', 'migrate', 'embeddings', '--to', 'openai:text-embedding-3-small', '--dry-run']);
+ expect(check.fix?.inputs).toBeUndefined();
+ expect(check.fix?.consent).toEqual([]);
+ expect(check.fix?.verify?.argv).toEqual(['gbrain', 'doctor', '--only', 'embedding_identity_unqualified', '--json']);
+ expect(check.message).toContain('gbrain migrate embeddings --to openai:text-embedding-3-small --dry-run');
+ expect(categorizeCheck('embedding_identity_unqualified')).toBe('brain');
+ });
+
+ test('with no provider-qualified model configured the fix asks for one through inputs', async () => {
+ const check = await run('text-embedding-3-small', { embedding_model: 'text-embedding-3-small' });
+ expect(check.status).toBe('warn');
+ expect(check.fix?.argv).toEqual(['gbrain', 'migrate', 'embeddings', '--to', '<PROVIDER_MODEL>', '--dry-run']);
+ expect(check.fix?.inputs?.map(i => i.name)).toEqual(['PROVIDER_MODEL']);
+ expect(check.details?.target_model).toBeNull();
+ });
+
+ test('a configured model with another name is filled in and called out as a model switch', async () => {
+ const check = await run('text-embedding-3-small', { embedding_model: 'voyage:voyage-4-lite' });
+ expect(check.fix?.argv[4]).toBe('voyage:voyage-4-lite');
+ expect(check.details?.target_differs).toBe(true);
+ expect(check.message).toContain('switches models');
+ });
+
+ test('a provider-qualified row and a missing row are ok', async () => {
+ expect((await run('openai:text-embedding-3-small')).status).toBe('ok');
+ expect((await run(null)).status).toBe('ok');
+ });
+});
diff --git a/test/fixtures/goldens/doctor/json-pglite-degraded.json b/test/fixtures/goldens/doctor/json-pglite-degraded.json
index d98ca1566c..770fc84b2a 100644
--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json
+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json
@@ -890,6 +890,13 @@
"name": "embedding_migration_state",
"status": "ok"
},
+ {
+ "category": "brain",
+ "elapsed_ms": "<volatile>",
+ "message": "The brain records its embedding model with its provider (voyage:voyage-4).",
+ "name": "embedding_identity_unqualified",
+ "status": "ok"
+ },
{
"category": "brain",
"details": {
diff --git a/test/fixtures/goldens/doctor/json-pglite-fresh.json b/test/fixtures/goldens/doctor/json-pglite-fresh.json
index 116c20b1b5..43df16c525 100644
--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json
+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json
@@ -1017,6 +1017,13 @@
"name": "embedding_migration_state",
"status": "ok"
},
+ {
+ "category": "brain",
+ "elapsed_ms": "<volatile>",
+ "message": "The brain records its embedding model with its provider (voyage:voyage-4).",
+ "name": "embedding_identity_unqualified",
+ "status": "ok"
+ },
{
"category": "brain",
"elapsed_ms": "<volatile>",
diff --git a/test/fixtures/goldens/doctor/registry-build-checks.json b/test/fixtures/goldens/doctor/registry-build-checks.json
index f3fc37b7ba..f1e90fceef 100644
--- a/test/fixtures/goldens/doctor/registry-build-checks.json
+++ b/test/fixtures/goldens/doctor/registry-build-checks.json
@@ -361,6 +361,10 @@
"category": "brain",
"name": "embedding_migration_state"
},
+ {
+ "category": "brain",
+ "name": "embedding_identity_unqualified"
+ },
{
"category": "brain",
"name": "supersession_calibration"