Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(doctor): drop chat_fallback_chain_inert now that chat() consumes the chain (#5490)
Andrei Neacsu192879b5efd1
diff --git a/docs/architecture/key-files/commands-2.md b/docs/architecture/key-files/commands-2.mdindex 09263e3a75..edd6df4002 100644--- a/docs/architecture/key-files/commands-2.md+++ b/docs/architecture/key-files/commands-2.md@@ -48,4 +48,4 @@ Doctor's embedding-dimension warning treats existing chunks as existing data eve- `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/search-eval.ts` — search, model, and AI-config health checks. `checkChatFallbackChainInert` returns one warning when either the effective file/environment config or the DB plane has a non-empty `chat_fallback_chain`; it returns `null` when both are empty, so clean doctor reports add no line. The local and remote doctor registries both consume the check. `checkSearchMode` (`search_mode`) reports the resolved mode and its `search.*` overrides; when the only override is an explicit `search.reranker.model` row equal to the mode bundle's own default (a row an init may have written on Voyage installs) it is called redundant with the precise `gbrain config unset search.reranker.model` — never a `--reset`, which would also wipe every other tuned search knob.+- `src/commands/doctor/checks/search-eval.ts` — search, model, and AI-config health checks. `checkSearchMode` (`search_mode`) reports the resolved mode and its `search.*` overrides; when the only override is an explicit `search.reranker.model` row equal to the mode bundle's own default (a row an init may have written on Voyage installs) it is called redundant with the precise `gbrain config unset search.reranker.model` — never a `--reset`, which would also wipe every other tuned search knob.diff --git a/scripts/test-weights.json b/scripts/test-weights.jsonindex c372d0758f..a6172db716 100644--- a/scripts/test-weights.json+++ b/scripts/test-weights.json@@ -523,7 +523,6 @@"test/doctor-calibration-checks.test.ts": 34,"test/doctor-categories.test.ts": 6,"test/doctor-cause-rank.test.ts": 5,- "test/doctor-chat-fallback-chain.test.ts": 20,"test/doctor-child-orphans.test.ts": 13,"test/doctor-conversation-facts-backlog.test.ts": 509,"test/doctor-conversation-format-coverage.test.ts": 1305,diff --git a/scripts/ubicloud/weights.json b/scripts/ubicloud/weights.jsonindex e446287924..90b0a4d386 100644--- a/scripts/ubicloud/weights.json+++ b/scripts/ubicloud/weights.json@@ -1144,7 +1144,6 @@"unit:test/doctor-calibration-checks.test.ts": 271,"unit:test/doctor-categories.test.ts": 260,"unit:test/doctor-cause-rank.test.ts": 170,- "unit:test/doctor-chat-fallback-chain.test.ts": 282,"unit:test/doctor-child-orphans.test.ts": 286,"unit:test/doctor-conversation-facts-backlog.test.ts": 2031,"unit:test/doctor-conversation-format-coverage.test.ts": 2179,diff --git a/src/commands/doctor.ts b/src/commands/doctor.tsindex 46df2408ad..6fadb257a5 100644--- a/src/commands/doctor.ts+++ b/src/commands/doctor.ts@@ -95,7 +95,6 @@ export {checkCyclePhaseScope,} from './doctor/checks/routing-federation.ts';export {- checkChatFallbackChainInert,checkSearchMode,checkEvalDrift,checkEmbeddingEnvOverride,diff --git a/src/commands/doctor/checks/search-eval.ts b/src/commands/doctor/checks/search-eval.tsindex fe7f98e430..2d2e83dfee 100644--- a/src/commands/doctor/checks/search-eval.ts+++ b/src/commands/doctor/checks/search-eval.ts@@ -6,51 +6,11 @@*/import type { BrainEngine } from '../../../core/engine.ts';import type { Check } from '../../doctor.ts';-import { loadConfig, type GBrainConfig } from '../../../core/config.ts';// Leaf module (no flag surface of its own) — see that file for why this// isn't imported from extract-conversation-facts.ts directly (#4135).import { ALLOWED_TYPES, conversationFactsEligibleSql, pageTypesForAllowed, isConversationFactsEligiblePage, requireParseableConversationFlag } from '../../../core/facts/conversation-types.ts';import { checkError } from '../check-fix.ts';-function hasNonEmptyChatFallbackChain(value: unknown): boolean {- if (Array.isArray(value)) {- return value.some((entry) => typeof entry === 'string' && entry.trim().length > 0);- }- if (typeof value !== 'string' || value.trim().length === 0) return false;- try {- const parsed: unknown = JSON.parse(value);- if (Array.isArray(parsed)) {- return parsed.some((entry) => typeof entry === 'string' && entry.trim().length > 0);- }- } catch {- // `config set` stores raw strings; any non-empty non-JSON value is set.- }- return true;-}--/**- * `chat_fallback_chain` is accepted by config and reaches the gateway config,- * but no production chat path consumes it. Keep the warning in doctor rather- * than config loading so ordinary commands stay quiet. Returning null for an- * empty value keeps clean doctor reports silent instead of adding an OK line.- */-export async function checkChatFallbackChainInert(- engine: BrainEngine,- effectiveConfig: Pick<GBrainConfig, 'chat_fallback_chain'> | null = loadConfig(),-): Promise<Check | null> {- const fileOrEnvSet = hasNonEmptyChatFallbackChain(effectiveConfig?.chat_fallback_chain);- const dbValue = await engine.getConfig('chat_fallback_chain').catch(() => null);- if (!fileOrEnvSet && !hasNonEmptyChatFallbackChain(dbValue)) return null;- return {- name: 'chat_fallback_chain_inert',- status: 'warn',- message:- '`chat_fallback_chain` is set but currently has no effect: no production chat path consumes it. ' +- 'If you set it expecting fallback behavior, clear it from every plane that still holds a value: ' +- 'the DB (`gbrain config unset chat_fallback_chain`), `~/.gbrain/config.json`, and `GBRAIN_CHAT_FALLBACK_CHAIN`.',- };-}-/*** v0.32.3 [CDX-20]: surface mode + per-key override drift.*diff --git a/src/commands/doctor/checks/sync-search.ts b/src/commands/doctor/checks/sync-search.tsindex 5fc7d1709f..7a11b1b775 100644--- a/src/commands/doctor/checks/sync-search.ts+++ b/src/commands/doctor/checks/sync-search.ts@@ -42,7 +42,7 @@ import {checkStaleLocks,checkCyclePhaseScope,} from './routing-federation.ts';-import { checkChatFallbackChainInert, checkSearchMode, checkEvalDrift } from './search-eval.ts';+import { checkSearchMode, checkEvalDrift } from './search-eval.ts';import type { Check } from '../../doctor.ts';import { connectedEngine, type DoctorContext, type DoctorEntry } from '../context.ts';@@ -123,9 +123,6 @@ async function runSearchMode(ctx: DoctorContext): Promise<Check[]> {// v0.32.3 search-lite — mode + eval_drift surfaces. Status stays 'ok' per// [CDX-20]; hint lives in `message`.if (engine !== null) {- progress.heartbeat('chat_fallback_chain_inert');- const inertFallbackChain = await checkChatFallbackChainInert(engine);- if (inertFallbackChain) checks.push(inertFallbackChain);progress.heartbeat('search_mode');checks.push(await checkSearchMode(engine));// issue #1777 — hidden_by_search_policy: chunked pages withheld from default@@ -217,9 +214,8 @@ async function runSearchMode(ctx: DoctorContext): Promise<Check[]> {}export const searchModeEntry: DoctorEntry = {- name: 'chat_fallback_chain_inert',+ name: 'search_mode',emits: [- 'chat_fallback_chain_inert','search_mode','hidden_by_search_policy','eval_drift',diff --git a/src/commands/doctor/report-remote.ts b/src/commands/doctor/report-remote.tsindex 9d646d10a4..80025746ea 100644--- a/src/commands/doctor/report-remote.ts+++ b/src/commands/doctor/report-remote.ts@@ -40,7 +40,6 @@ import {checkSyncConsolidation,checkPoolBudget,checkLinksExtractionLag,- checkChatFallbackChainInert,checkSearchMode,checkEvalDrift,checkRerankerHealth,@@ -377,8 +376,6 @@ export async function doctorReportRemote(checks.push(await checkSchemaPackSourceDrift(engine));// 7. v0.32.3 search-lite mode + per-key drift surface.- const inertFallbackChain = await checkChatFallbackChainInert(engine);- if (inertFallbackChain) checks.push(inertFallbackChain);checks.push(await checkSearchMode(engine));// 8. v0.32.3 eval_drift: retrieval-affecting files changed since lastdiff --git a/src/core/doctor-categories.ts b/src/core/doctor-categories.tsindex a3d3ec27b3..8e3803fcd8 100644--- a/src/core/doctor-categories.ts+++ b/src/core/doctor-categories.ts@@ -213,7 +213,6 @@ export const OPS_CHECK_NAMES: ReadonlySet<string> = new Set(['brainstorm_health','connectors','dream_paid_loop',- 'chat_fallback_chain_inert','connection','db_only_collector_collision','federation_health',diff --git a/test/doctor-chat-fallback-chain.test.ts b/test/doctor-chat-fallback-chain.test.tsdeleted file mode 100644index b40a6d1c57..0000000000--- a/test/doctor-chat-fallback-chain.test.ts+++ /dev/null@@ -1,66 +0,0 @@-import { describe, expect, test } from 'bun:test';-import { mkdirSync, writeFileSync } from 'node:fs';-import { join } from 'node:path';-import type { BrainEngine } from '../src/core/engine.ts';-import { checkChatFallbackChainInert } from '../src/commands/doctor.ts';-import { emptyHome, withEnv } from './helpers/with-env.ts';--function engineWithDbValue(value: string | null): BrainEngine {- return {- getConfig: async (key: string) => key === 'chat_fallback_chain' ? value : null,- } as unknown as BrainEngine;-}--describe('chat_fallback_chain doctor warning', () => {- test('loads the effective env config in the production one-argument call shape', async () => {- const engine = engineWithDbValue(null);- const configHome = emptyHome();- mkdirSync(join(configHome, '.gbrain'));- writeFileSync(join(configHome, '.gbrain', 'config.json'), '{"engine":"pglite"}');-- await withEnv(- { GBRAIN_HOME: configHome, GBRAIN_CHAT_FALLBACK_CHAIN: 'openai:gpt-5.6-luna' },- async () => {- expect((await checkChatFallbackChainInert(engine))?.status).toBe('warn');- },- );- await withEnv(- { GBRAIN_HOME: configHome, GBRAIN_CHAT_FALLBACK_CHAIN: undefined },- async () => {- expect(await checkChatFallbackChainInert(engine)).toBeNull();- },- );- });-- test('warns with the full remediation message when both planes hold a value', async () => {- const check = await checkChatFallbackChainInert(- engineWithDbValue('["openai:gpt-5.2"]'),- { chat_fallback_chain: ['anthropic:claude-sonnet-4-6'] },- );-- expect(check).toEqual({- name: 'chat_fallback_chain_inert',- status: 'warn',- message:- '`chat_fallback_chain` is set but currently has no effect: no production chat path consumes it. ' +- 'If you set it expecting fallback behavior, clear it from every plane that still holds a value: ' +- 'the DB (`gbrain config unset chat_fallback_chain`), `~/.gbrain/config.json`, and `GBRAIN_CHAT_FALLBACK_CHAIN`.',- });- });-- test('warns when only the DB-plane value is non-empty', async () => {- const check = await checkChatFallbackChainInert(- engineWithDbValue('["openai:gpt-5.2"]'),- { chat_fallback_chain: [] },- );-- expect(check?.status).toBe('warn');- });-- test('stays silent when the key is unset or explicitly empty', async () => {- expect(await checkChatFallbackChainInert(engineWithDbValue(null), null)).toBeNull();- expect(- await checkChatFallbackChainInert(engineWithDbValue('[]'), { chat_fallback_chain: [] }),- ).toBeNull();- });-});diff --git a/test/fixtures/goldens/doctor/registry-build-checks.json b/test/fixtures/goldens/doctor/registry-build-checks.jsonindex ff1428fea1..4c4c6b7532 100644--- a/test/fixtures/goldens/doctor/registry-build-checks.json+++ b/test/fixtures/goldens/doctor/registry-build-checks.json@@ -629,10 +629,6 @@"category": "ops","name": "planner_stats_stale"},- {- "category": "ops",- "name": "chat_fallback_chain_inert"- },{"category": "ops","name": "search_mode"diff --git a/test/fixtures/goldens/doctor/registry-report-remote.json b/test/fixtures/goldens/doctor/registry-report-remote.jsonindex 04d2d22070..3fd71e577f 100644--- a/test/fixtures/goldens/doctor/registry-report-remote.json+++ b/test/fixtures/goldens/doctor/registry-report-remote.json@@ -121,10 +121,6 @@"category": "meta","name": "schema_pack_source_drift"},- {- "category": "ops",- "name": "chat_fallback_chain_inert"- },{"category": "ops","name": "search_mode"