Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(doctor): connection errors name their URL source; no Supabase advice for other hosts; brain score unknown when DB checks did not run (E10)
garrytanbf92280e1e2b
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex 43d3b141bb..4689034ae0 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -5,7 +5,7 @@# Columns: path max_lines policy notesrc/cli.ts 3211 ratchet +2 agent operator wave A4: observational startup (probe-only connect for startup:observational commands; completeEngineStartup split out of connectEngine, exposed as ctx.completeStartup); +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5232: write-wait import, reporter-owned verdict in the op catch, thin-client writeWaitMs, ctx.writeWaitMs (logic in persistence/write-wait.ts); +1 #4768: serve --access help line; +4 #5433: list_pages TSV cell escaping in formatResult; +2 #lane-h pricing: help line + thin-client refusal hint for `gbrain pricing`; +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5433: list_pages TSV cell escaping in formatResultsrc/commands/autopilot.ts 1642 ratchet refactor wave 1 split target (W4 autopilot, cut line); ceiling rationale: docs/architecture/key-files/commands-1.md entry for src/commands/autopilot.ts; +2 fix wave 5: nosemgrep justifications on the per-brain job launchctl/systemctl calls (#5195); +2 #5813: boot reconcile names attempted and running versions in log + audit; +2 #5855: Bun floor gate before the swap and the swap-refusal hold (logic in core/bun-floor.ts); +3 agent operator wave E9: --dry-run and the persistent_install consent gate before anything is written (logic in autopilot/install-consent.ts)-src/commands/doctor.ts 663 ratchet refactor wave 1 split target (W4 doctor); ceiling rationale: docs/architecture/key-files/commands-2.md entry for src/commands/doctor.ts+src/commands/doctor.ts 666 ratchet refactor wave 1 split target (W4 doctor); ceiling rationale: docs/architecture/key-files/commands-2.md entry for src/commands/doctor.tssrc/commands/embed.ts 2217 ratchet lowered v0.46.26.0: embedBatchWithBackoff + retry cluster peeled to core/embed-retry.ts (core/commands layering fix); grown wave-g (#4530): per-model input-limit wiring; wave-k #3622 reimpl: --stale zero-progress failure quarantine; +29 #4668 (#4530): oversize-heal call sites in both --stale drains — kept low by peeling the healed-row remap to core/embed-oversize-heal.ts (shared with embed-stale.ts); +35 #4647 (refs #4599): per-tick timeout+abort on the single-flight lock heartbeat refresh (interval deliberately NOT unref'd); +122 refs #4599: stall-watchdog race around the drain + shared idempotent flushAndRelease + CLI stall exit mapping (watchdog machinery itself lives in core/embed-stall.ts); +12: adversarial-review hardening (healed_splits progress key + heal-tick comment); #5105: guarded derived projection preparation and read seals; #5105: conditional embedding installer wiring; archived eligibility: active-only dispatch with honest stranded-work reporting; explicit archived admission: live-source snapshots and honest refused-installation failures; +2 fw3: embed --stale --images dispatch (sweep lives in core/embed-stale-images.ts); +5 #5289: dry run reports restamp-only chunks apart from chunks to embed (count lives in core/embedding-invalidation.ts); +6 #4616: keep a partially refused batch in embedPageTexts and name the recovery command in failure samples (guard lives in core/ai/embedding-guard.ts); +5 #5226: embed summary counts distinct pages; +3 #5804: null projection snapshot counted as a failure with one batch summary in embed --stale; +18 wave 8 lane D1: #5527 mixed-space warning subtracts current-model chunks (+4), #5885 takes option/result fields and the stale-drain takes call (pass lives in core/embed-takes.ts); +9 Foundations 1 F4d: time-budget stop result fields, stdout verdict and stop recording in embed --stale (logic in core/embed-budget-stop.ts)src/commands/extract-conversation-facts.ts 2182 ratchet grown v0.46.x per-provider gateway-unavailable copy; grown wave-g (#4482): expected budget/deadline caps classified apart from error halts; wave-k: save-time resolution caller (#4052/#3729 — supersedes wave-g's per-row resolveEntitySlug mapper); +1: key-aware llm-fallback default (#3813); +1: pricingOverrides wiring into the owned BudgetTracker (#4633 adoption); +3: #4869 snapshot-mismatch counts as pages_failed; merged reliability/shared-skills source integration; +19: additive skip reasons and model-free dry-run (#5364); +21 #5757: managed extraction buffers a page's rows and replaces the prior batch in one coordinator transaction (replacement helper lives in core/persistence/derived-facts.ts); +18 #5823: result diagnostics, strict explicit-cap parsing and CLI recovery/help; default-cap decision lives in facts/conversation-budget.ts; +18 fix wave 7 (#5704, #5448): --json envelope on stdout (parser flag, help line, summary block gated behind the human-output branch)src/commands/extract.ts 2528 ratchet grown v0.46.26.0 megawave: FS-walk stamp snapshot + legacy timeline repair wiring (#3957 D4) + PR#4486 rebase onto current master; grown wave-g (#4542): --from-meetings zero-match warning + default-pass note; +29: #3478 federated-only gate on the cross-source 'default' link fallback; +44: #3908 cross_source opt-in — counted drops + deterministic cross-source pick; +36: #4611 configured-sources.default fallback (resolveLinkFallbackDefault); +14: #4890 extractStaleFromDB quiet opt + extractForSlugs jsonMode batch_error stderr fallback; +5: #4855 stroke-letter fold in link extraction; +5: #4793 by-mention scan honours link_resolution.cross_source; +18: wave review — ExtractOpts.quiet threaded through the fs-walk extractors (stdout silence decoupled from jsonMode); +77: shared buildSlugPathIndex — every per-slug extractor resolves the real on-disk path, and the sync hooks report which slugs they actually read; +10 #4999: includeFrontmatter default-resolved inside extractLinksForSlugs + extractStaleFromDB (resolveIncludeFrontmatter), --stale flag absent -> configured knob; +20: pre-landing review of #4967 — resolveSlugRelPath: index miss falls back to the legacy slug+'.md' path so admitted _-prefixed / include_hidden pages keep their edges; T2: source-qualified inference and atomic origin-scoped derived links; standard DB extraction fences captured endpoint revisions; shared authoritative attendance/source reconciliation moved to the core module; +7 A2 preview-bound attendance repair import, help and authority dispatch; bounded incomplete-attendance diagnostics and consistent basename resolution; fail closed before graph mutation when active ontology is unavailable; +16 source-selected ontology cache, type-scoped preflight and non-starving failed stale drain; +7 write-path wave: per-slug extractors replace page links + retract removed timeline rows + rename-alias resolution; +5 fw3 derived-sync: timeline --prune-orphans CLI (#4649) and full-walk page link replacement; +13 fw3 A16/A15: sync link hook reads scoped page metadata and reports per-page extraction errors; +1 fw3 managed-lifecycle: extract --stale dispatches managed brains to the coordinator-safe path; +4 fw3 integration: managed brains refuse the direct timeline orphan prune; +26 #5609: managed extract --stale publishes links, canonical timeline and watermark per page in one coordinated transaction; fix wave 3 x fix wave 2 (v0.60.5.0) composition: +4 at the merge; +6 fix wave 3 lane B: a managed brain routes the extract phase file walk through extractManagedStaleLinks instead of the refused raw timeline batch, keeping the extract.links_fs progress phase; +6 #5761: the unmanaged extract --stale sweep marks unresolved-attendance skips attendance-blocked; +2 eval-wave N9-3/N12-7: a page-type-bound pack attended rule defers to canonical attendance on the filesystem path (ownsAttendanceInference); lowered to 2528 #5904: the DB timeline walk moved to commands/extract-timeline-db.ts (coordinated publication on managed brains, honest refusal + non-zero exit)diff --git a/src/commands/doctor.ts b/src/commands/doctor.tsindex bb7139e4f6..24adeaa161 100644--- a/src/commands/doctor.ts+++ b/src/commands/doctor.ts@@ -138,7 +138,7 @@ export {} from './doctor/checks/verbs-reflex.ts';import type { DoctorContext } from './doctor/context.ts';import { runDoctorRegistry, parseOnlyChecks } from './doctor/registry.ts';-import { finalizeCheckFixes, fixLine, type CheckAgentFields } from './doctor/check-fix.ts';+import { finalizeCheckFixes, fixLine, unknownScoreCategories, type CheckAgentFields } from './doctor/check-fix.ts';import { throttleDoctorHeartbeat } from './doctor/heartbeat.ts';import type { RenderContext } from '../core/agent-output.ts';export interface Check extends CheckAgentFields {@@ -236,6 +236,8 @@ export interface DoctorReport {db_url_source?: DbUrlSource | null;/** E2: capabilities off by choice that bound what this brain can do (e.g. `embeddings_disabled`). Additive. */capped_by?: string[];+ /** E10: category scores that are not evidence because their checks did not run (e.g. `brain` when the DB was unreachable). */+ unknown_scores?: Array<'brain'>;}function _penaltyScore(checks: Check[]): number {@@ -296,6 +298,7 @@ export function computeDoctorReport(...(extras?.engine ? { engine: extras.engine } : {}),...(extras?.db_url_source !== undefined ? { db_url_source: extras.db_url_source } : {}),...(capped_by.length ? { capped_by } : {}),+ ...(unknownScoreCategories(tagged).length ? { unknown_scores: unknownScoreCategories(tagged) } : {}),};}@@ -586,7 +589,7 @@ function outputResults(: null;console.log('');- console.log(`Brain checks: ${report.brain_checks_score}/100 (category penalty)`);+ console.log(`Brain checks: ${report.unknown_scores?.includes('brain') ? 'unknown (database checks did not run)' : `${report.brain_checks_score}/100 (category penalty)`}`);console.log(`Skill checks: ${report.category_scores.skill}/100`);console.log(`Ops checks: ${report.category_scores.ops}/100`);console.log(`Meta checks: ${report.category_scores.meta}/100`);diff --git a/src/commands/doctor/check-fix.ts b/src/commands/doctor/check-fix.tsindex cf530366d2..7dfe66b219 100644--- a/src/commands/doctor/check-fix.ts+++ b/src/commands/doctor/check-fix.ts@@ -134,3 +134,13 @@ export function fixLine(fix: CheckAgentFields['fix']): string | null {if (!step) return r.user_message ? `Ask the user: ${r.user_message}` : null;return r.next === 'run' ? step : `${step} (${r.next.replace(/_/g, ' ')})`;}++/**+ * E10: categories whose score is not evidence because their checks never ran.+ * When the `connection` check is present and not ok, no database check ran, so+ * a `brain` score of 100 would read as "healthy" — it is unknown.+ */+export function unknownScoreCategories(checks: readonly CheckLike[]): Array<'brain'> {+ const conn = checks.find((c) => c.name === 'connection');+ return conn && conn.status !== 'ok' ? ['brain'] : [];+}diff --git a/src/commands/doctor/checks/db-connection.ts b/src/commands/doctor/checks/db-connection.tsindex 6c05a2bf73..2d4322363d 100644--- a/src/commands/doctor/checks/db-connection.ts+++ b/src/commands/doctor/checks/db-connection.ts@@ -10,7 +10,9 @@* src/commands/doctor/registry.ts and src/core/doctor-categories.ts.*/-import { loadConfig, gbrainPath } from '../../../core/config.ts';+import { loadConfig, gbrainPath, configPath, getDbUrlSource, type DbUrlSource } from '../../../core/config.ts';+import type { Action } from '../../../core/agent-output.ts';+import { agentFix, doctorVerify } from '../check-fix.ts';import { startHeartbeat } from '../../../core/progress.ts';import { checkPgliteScratchProbe } from './core-health.ts';import { computePgliteDataDirCheck } from './pglite-worker.ts';@@ -134,16 +136,36 @@ async function pgbouncerPrepareCheck(): Promise<Check | null> {* makeRemediationStep: that lane feeds `--remediate`, whose Minion jobs need* the very DB that's down (db-repair is the engine-free applier here).*/-function classifiedConnectionCheck(e: unknown): Check {+function classifiedConnectionCheck(e: unknown, dbSource?: DbUrlSource): Check {const d = classifyPgAccessError(e, { url: loadConfig()?.database_url ?? null });+ const source = describeUrlSource(dbSource ?? getDbUrlSource());return {name: 'connection',status: 'fail',- message: d.message,- details: { reason: d.reason, transient: d.transient, fix_hint: `${d.remediation} Run: gbrain db-repair` },+ message: source ? `${d.message} (database URL from ${source})` : d.message,+ details: { reason: d.reason, transient: d.transient, fix_hint: `${d.remediation} Run: gbrain db-repair`, ...(source ? { url_source: source } : {}) },+ readiness_state: 'unknown',+ fix: dbRepairFix(d.remediation),};}+/**+ * E10: where the database URL came from, in words an agent can act on: the+ * environment variable, or the key in the config file under GBRAIN_HOME.+ */+export function describeUrlSource(source: DbUrlSource | undefined): string | null {+ if (source === 'env:GBRAIN_DATABASE_URL') return 'the GBRAIN_DATABASE_URL environment variable';+ if (source === 'env:DATABASE_URL') return 'the DATABASE_URL environment variable';+ if (source === 'config-file') return `database_url in ${configPath()}`;+ if (source === 'config-file-path') return `database_path in ${configPath()}`;+ return null;+}++function dbRepairFix(why: string): Action {+ return agentFix(['gbrain', 'db-repair'], `${why} \`gbrain db-repair\` diagnoses the database URL and access without changing anything (it prints the --yes command for a safe fix).`, 'connection',+ { docs: 'docs/ENGINES.md#engine-detection-and-access-repair' });+}+async function runOfflineConnection(ctx: DoctorContext): Promise<Check[]> {const { connectError, dbSource, engine, fastMode } = ctx;const checks: Check[] = [];@@ -157,17 +179,26 @@ async function runOfflineConnection(ctx: DoctorContext): Promise<Check[]> {if (!fastMode && dbSource && connectError !== undefined) {// 2c-bis: a REAL connect failure — synthesize the classified check so// `checks[name=="connection"]` exists in every failure shape.- checks.push(classifiedConnectionCheck(connectError));+ checks.push(classifiedConnectionCheck(connectError, dbSource));} else {let msg: string;if (fastMode && dbSource) {msg = `Skipping DB checks (--fast mode, URL present from ${dbSource})`;} else if (!fastMode && dbSource) {- msg = `Could not connect to configured DB (URL from ${dbSource}); filesystem checks only`;+ msg = `Could not connect to configured DB (URL from ${dbSource}: ${describeUrlSource(dbSource)}); filesystem checks only`;} else {- msg = 'No database configured (filesystem checks only). Set GBRAIN_DATABASE_URL or run `gbrain init`.';+ msg = `No database configured (filesystem checks only; no URL in the environment or in ${configPath()}). Set GBRAIN_DATABASE_URL or run \`gbrain init\`.`;}- checks.push({ name: 'connection', status: 'warn', message: msg });+ checks.push({+ name: 'connection', status: 'warn', message: msg, readiness_state: 'unknown',+ ...(fastMode && dbSource+ ? { fix: agentFix(['gbrain', 'doctor', '--json'], 'Runs the database checks --fast skipped.', 'connection') }+ : dbSource+ ? { fix: dbRepairFix('The configured database did not accept the connection.') }+ : { fix: { argv: ['gbrain', 'init', '--pglite'], consent: [], actor: 'agent', requires_exclusive: false, verify: doctorVerify('connection'),+ why: 'No brain is configured on this machine; init creates a local PGLite brain (keyless unless the user adds a provider key).',+ user_message: 'There is no gbrain brain on this machine yet. Shall I create a local one?' } as Action }),+ });}// URL-only + engine-free checks still run on a dead DB — that is the// point of them.diff --git a/src/core/db.ts b/src/core/db.tsindex a1c86a664e..a1498e3337 100644--- a/src/core/db.ts+++ b/src/core/db.ts@@ -329,7 +329,7 @@ export async function connect(config: EngineConfig, hooks: { onpoisoned?: (statuthrow new GBrainError('Cannot connect to database',msg,- 'Check your connection URL in ~/.gbrain/config.json',+ 'Check the database URL; `gbrain engine status --probe` names where it comes from (environment variable or the config file under GBRAIN_HOME)',);}}diff --git a/src/core/pg-access-classify.ts b/src/core/pg-access-classify.tsindex 822d5bf01a..02ab33a4de 100644--- a/src/core/pg-access-classify.ts+++ b/src/core/pg-access-classify.ts@@ -164,6 +164,8 @@ interface ReasonRow {codePrefixes?: string[];patterns?: RegExp[];remediation: string;+ /** E10: the same advice without Supabase specifics, used when the configured URL is not a Supabase host. */+ plainRemediation?: string;fix?: PgAccessFix;}@@ -260,6 +262,7 @@ const REASON_ROWS: ReadonlyArray<ReasonRow> = [codes: ['ECONNREFUSED'],patterns: [/connection refused/i, /ECONNREFUSED/i],remediation: 'Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it.',+ plainRemediation: 'Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port.',},{reason: 'dns_failed',@@ -267,6 +270,7 @@ const REASON_ROWS: ReadonlyArray<ReasonRow> = [codes: ['ENOTFOUND', 'EAI_AGAIN'],patterns: [/ENOTFOUND/i, /EAI_AGAIN/i, /getaddrinfo/i],remediation: 'The hostname did not resolve. Check the URL; a free-tier Supabase project may be paused — restore it from the dashboard.',+ plainRemediation: 'The hostname did not resolve. Check the host in the database URL and this machine\'s DNS/network.',},{reason: 'network_unreachable',@@ -276,6 +280,7 @@ const REASON_ROWS: ReadonlyArray<ReasonRow> = [codes: ['ENETUNREACH', 'EHOSTUNREACH', 'ETIMEDOUT', 'CONNECT_TIMEOUT'],patterns: [/ENETUNREACH/i, /EHOSTUNREACH/i, /ETIMEDOUT/i, /CONNECT_TIMEOUT/i],remediation: 'The host is unreachable (often an IPv6-only direct host on an IPv4 network). The session pooler is the IPv4 path — gbrain db-repair can switch to it.',+ plainRemediation: 'The database host is unreachable from this machine (routing, firewall or VPN). Check the network path to the host in the database URL.',},{reason: 'conn_dropped',@@ -396,7 +401,7 @@ export function classifyPgAccessError(err: unknown, ctx?: PgAccessContext): PgActransient: row.transient,sqlstate: looksLikeSqlstate(code),message,- remediation: row.remediation,+ remediation: ctx?.url && !looksLikeSupabase(ctx.url) && row.plainRemediation ? row.plainRemediation : row.remediation,fix: contextualFix(row.reason, ctx?.url) ?? row.fix,supabase: supabaseHints(ctx?.url, row.reason),brainId: ctx?.brainId,diff --git a/test/doctor-status-set.test.ts b/test/doctor-status-set.test.tsindex 739114f0ac..b8c264434e 100644--- a/test/doctor-status-set.test.ts+++ b/test/doctor-status-set.test.ts@@ -199,3 +199,31 @@ describe('keyless brain: capability checks are information, not warnings (E2)',});});});++describe('connection errors name their source; brain score unknown when DB checks did not run (E10)', () => {+ test('describeUrlSource names the env var or the config file under GBRAIN_HOME', async () => {+ const { describeUrlSource } = await import('../src/commands/doctor/checks/db-connection.ts');+ const home = mkdtempSync(join(tmpdir(), 'gbrain-url-source-'));+ try {+ await withEnv({ GBRAIN_HOME: home }, async () => {+ expect(describeUrlSource('env:GBRAIN_DATABASE_URL')).toBe('the GBRAIN_DATABASE_URL environment variable');+ expect(describeUrlSource('config-file')).toBe(`database_url in ${join(home, '.gbrain', 'config.json')}`);+ expect(describeUrlSource(null)).toBeNull();+ });+ } finally {+ rmSync(home, { recursive: true, force: true });+ }+ });++ test('a non-ok connection marks the brain score unknown; a live one does not', () => {+ expect(computeDoctorReport([{ name: 'connection', status: 'fail', message: 'refused' }]).unknown_scores).toEqual(['brain']);+ expect(computeDoctorReport([{ name: 'connection', status: 'ok', message: 'Connected, 0 pages' }]).unknown_scores).toBeUndefined();+ });++ test('non-Supabase URLs get no Supabase advice', async () => {+ const { classifyPgAccessError } = await import('../src/core/pg-access-classify.ts');+ const err = Object.assign(new Error('connect ECONNREFUSED 127.0.0.1:5432'), { code: 'ECONNREFUSED' });+ expect(classifyPgAccessError(err, { url: 'postgresql://[email protected]:5432/brain' }).remediation).not.toMatch(/Supabase/);+ expect(classifyPgAccessError(err, { url: 'postgresql://[email protected]:5432/postgres' }).remediation).toMatch(/Supabase/);+ });+});diff --git a/test/fixtures/goldens/cli/engine-free-db-down.json b/test/fixtures/goldens/cli/engine-free-db-down.jsonindex 8752c47de7..24f12b8723 100644--- a/test/fixtures/goldens/cli/engine-free-db-down.json+++ b/test/fixtures/goldens/cli/engine-free-db-down.json@@ -59,7 +59,7 @@"Source: config-file","URL: postgresql://***@127.0.0.1:1/none","Pooler: supabase=false prepare=undefined pool=10",- "Probe: FAIL conn_refused — Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it."+ "Probe: FAIL conn_refused — Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port."],"stdoutFirstLine": "Brain: host","url": "config"@@ -98,7 +98,7 @@" \"reason\": \"conn_refused\","," \"transient\": true,"," \"message\": \"connect ECONNREFUSED <REDACTED:ipv4>:1\",",- " \"remediation\": \"Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it.\",",+ " \"remediation\": \"Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port.\","," \"brainId\": \"host\""," }"," }",@@ -131,7 +131,7 @@"GBRAIN_DB_ACCESS conn_refused","reason: conn_refused (auto tier) connect ECONNREFUSED <REDACTED:ipv4>:1","plan: bounded reconnect; if the server is down, start it and re-run",- "Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it.",+ "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port.","Apply: gbrain db-repair --yes"],"stdoutFirstLine": "GBRAIN_DB_ACCESS conn_refused",@@ -153,7 +153,7 @@" \"reason\": \"conn_refused\","," \"transient\": true,"," \"message\": \"connect ECONNREFUSED <REDACTED:ipv4>:1\",",- " \"remediation\": \"Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it.\",",+ " \"remediation\": \"Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port.\","," \"brainId\": \"host\""," },"," \"plan\": [",@@ -165,7 +165,7 @@" \"reason\": \"conn_refused\","," \"transient\": true,"," \"message\": \"connect ECONNREFUSED <REDACTED:ipv4>:1\",",- " \"remediation\": \"Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it.\",",+ " \"remediation\": \"Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port.\","," \"brainId\": \"host\""," }","}"@@ -182,7 +182,7 @@"GBRAIN_DB_ACCESS conn_refused","reason: conn_refused (auto tier) connect ECONNREFUSED <REDACTED:ipv4>:1","plan: bounded reconnect; if the server is down, start it and re-run",- "Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it.",+ "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port.","Apply: gbrain db-repair --yes"],"stdoutFirstLine": "GBRAIN_DB_ACCESS conn_refused",@@ -362,8 +362,8 @@"exitCode": 1,"stderr": ["GBRAIN_DB_ACCESS conn_refused",- "Cannot connect to database: connect ECONNREFUSED <REDACTED:ipv4>:1. Fix: Check your connection URL in ~/.gbrain/config.json",- "Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it. Run: gbrain db-repair"+ "Cannot connect to database: connect ECONNREFUSED <REDACTED:ipv4>:1. Fix: Check the database URL; `gbrain engine status --probe` names where it comes from (environment variable or the config file under GBRAIN_HOME)",+ "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port. Run: gbrain db-repair"],"stderrFirstLine": "GBRAIN_DB_ACCESS conn_refused","stdout": [],@@ -375,8 +375,8 @@"exitCode": 1,"stderr": ["GBRAIN_DB_ACCESS conn_refused",- "Cannot connect to database: connect ECONNREFUSED <REDACTED:ipv4>:1. Fix: Check your connection URL in ~/.gbrain/config.json",- "Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it. Run: gbrain db-repair"+ "Cannot connect to database: connect ECONNREFUSED <REDACTED:ipv4>:1. Fix: Check the database URL; `gbrain engine status --probe` names where it comes from (environment variable or the config file under GBRAIN_HOME)",+ "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port. Run: gbrain db-repair"],"stderrFirstLine": "GBRAIN_DB_ACCESS conn_refused","stdout": [],@@ -388,8 +388,8 @@"exitCode": 1,"stderr": ["GBRAIN_DB_ACCESS conn_refused",- "Cannot connect to database: connect ECONNREFUSED <REDACTED:ipv4>:1. Fix: Check your connection URL in ~/.gbrain/config.json",- "Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it. Run: gbrain db-repair"+ "Cannot connect to database: connect ECONNREFUSED <REDACTED:ipv4>:1. Fix: Check the database URL; `gbrain engine status --probe` names where it comes from (environment variable or the config file under GBRAIN_HOME)",+ "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port. Run: gbrain db-repair"],"stderrFirstLine": "GBRAIN_DB_ACCESS conn_refused","stdout": [],diff --git a/test/fixtures/goldens/doctor/early-stop-connection-failure.json b/test/fixtures/goldens/doctor/early-stop-connection-failure.jsonindex 90c47afd8f..2b0af146bb 100644--- a/test/fixtures/goldens/doctor/early-stop-connection-failure.json+++ b/test/fixtures/goldens/doctor/early-stop-connection-failure.json@@ -304,10 +304,32 @@"details": {"fix_hint": "Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it. Run: gbrain db-repair","reason": "conn_refused",- "transient": true+ "transient": true,+ "url_source": "database_url in <home>/.gbrain/config.json"},- "message": "connect ECONNREFUSED <REDACTED:ipv4>:1",+ "fix": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "db-repair"+ ],+ "consent": [],+ "docs": "docs/ENGINES.md#engine-detection-and-access-repair",+ "requires_exclusive": false,+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "connection",+ "--json"+ ]+ },+ "why": "Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it. `gbrain db-repair` diagnoses the database URL and access without changing anything (it prints the --yes command for a safe fix)."+ },+ "message": "connect ECONNREFUSED <REDACTED:ipv4>:1 (database URL from database_url in <home>/.gbrain/config.json)","name": "connection",+ "readiness_state": "unknown","status": "fail"}],diff --git a/test/fixtures/goldens/doctor/early-stop-null-engine-connect-error.json b/test/fixtures/goldens/doctor/early-stop-null-engine-connect-error.jsonindex 937a0bee81..9bdabc56a8 100644--- a/test/fixtures/goldens/doctor/early-stop-null-engine-connect-error.json+++ b/test/fixtures/goldens/doctor/early-stop-null-engine-connect-error.json@@ -224,12 +224,34 @@},{"details": {- "fix_hint": "Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it. Run: gbrain db-repair",+ "fix_hint": "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port. Run: gbrain db-repair","reason": "conn_refused",- "transient": true+ "transient": true,+ "url_source": "database_url in <home>/.gbrain/config.json"},- "message": "connect ECONNREFUSED <REDACTED:ipv4>:1",+ "fix": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "db-repair"+ ],+ "consent": [],+ "docs": "docs/ENGINES.md#engine-detection-and-access-repair",+ "requires_exclusive": false,+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "connection",+ "--json"+ ]+ },+ "why": "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port. `gbrain db-repair` diagnoses the database URL and access without changing anything (it prints the --yes command for a safe fix)."+ },+ "message": "connect ECONNREFUSED <REDACTED:ipv4>:1 (database URL from database_url in <home>/.gbrain/config.json)","name": "connection",+ "readiness_state": "unknown","status": "fail"}],diff --git a/test/fixtures/goldens/doctor/early-stop-null-engine-fast.json b/test/fixtures/goldens/doctor/early-stop-null-engine-fast.jsonindex b34c125412..8df3ac6640 100644--- a/test/fixtures/goldens/doctor/early-stop-null-engine-fast.json+++ b/test/fixtures/goldens/doctor/early-stop-null-engine-fast.json@@ -223,8 +223,29 @@"status": "ok"},{+ "fix": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "doctor",+ "--json"+ ],+ "consent": [],+ "requires_exclusive": false,+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "connection",+ "--json"+ ]+ },+ "why": "Runs the database checks --fast skipped."+ },"message": "Skipping DB checks (--fast mode, URL present from config-file)","name": "connection",+ "readiness_state": "unknown","status": "warn"},{diff --git a/test/fixtures/goldens/doctor/early-stop-null-engine-no-config.json b/test/fixtures/goldens/doctor/early-stop-null-engine-no-config.jsonindex b4ee619f32..357494ce98 100644--- a/test/fixtures/goldens/doctor/early-stop-null-engine-no-config.json+++ b/test/fixtures/goldens/doctor/early-stop-null-engine-no-config.json@@ -218,8 +218,30 @@"status": "ok"},{- "message": "No database configured (filesystem checks only). Set GBRAIN_DATABASE_URL or run `gbrain init`.",+ "fix": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "init",+ "--pglite"+ ],+ "consent": [],+ "requires_exclusive": false,+ "user_message": "There is no gbrain brain on this machine yet. Shall I create a local one?",+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "connection",+ "--json"+ ]+ },+ "why": "No brain is configured on this machine; init creates a local PGLite brain (keyless unless the user adds a provider key)."+ },+ "message": "No database configured (filesystem checks only; no URL in the environment or in <home>/.gbrain/config.json). Set GBRAIN_DATABASE_URL or run `gbrain init`.","name": "connection",+ "readiness_state": "unknown","status": "warn"}],diff --git a/test/fixtures/goldens/doctor/json-pglite-fast.json b/test/fixtures/goldens/doctor/json-pglite-fast.jsonindex 2b8004080e..c21f42999b 100644--- a/test/fixtures/goldens/doctor/json-pglite-fast.json+++ b/test/fixtures/goldens/doctor/json-pglite-fast.json@@ -270,9 +270,31 @@},{"category": "ops",- "fix_unavailable_reason": "unstructured",+ "fix": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "doctor",+ "--json"+ ],+ "command": "gbrain doctor --json",+ "consent": [],+ "next": "run",+ "requires_exclusive": false,+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "connection",+ "--json"+ ]+ },+ "why": "Runs the database checks --fast skipped."+ },"message": "Skipping DB checks (--fast mode, URL present from config-file-path)","name": "connection",+ "readiness_state": "unknown","status": "warn"}],@@ -282,6 +304,28 @@"status": "warnings","top_issues": [{+ "action": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "doctor",+ "--json"+ ],+ "command": "gbrain doctor --json",+ "consent": [],+ "next": "run",+ "requires_exclusive": false,+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "connection",+ "--json"+ ]+ },+ "why": "Runs the database checks --fast skipped."+ },"fix": "Skipping DB checks (--fast mode, URL present from config-file-path)","name": "connection","status": "warn",@@ -293,6 +337,9 @@"status": "warn","tier": "symptom"}+ ],+ "unknown_scores": [+ "brain"]},"stderr": [],diff --git a/test/fixtures/goldens/doctor/json-postgres-unreachable-fast.json b/test/fixtures/goldens/doctor/json-postgres-unreachable-fast.jsonindex 0d9b41ce8d..46e30b525a 100644--- a/test/fixtures/goldens/doctor/json-postgres-unreachable-fast.json+++ b/test/fixtures/goldens/doctor/json-postgres-unreachable-fast.json@@ -263,9 +263,31 @@},{"category": "ops",- "fix_unavailable_reason": "unstructured",+ "fix": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "doctor",+ "--json"+ ],+ "command": "gbrain doctor --json",+ "consent": [],+ "next": "run",+ "requires_exclusive": false,+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "connection",+ "--json"+ ]+ },+ "why": "Runs the database checks --fast skipped."+ },"message": "Skipping DB checks (--fast mode, URL present from config-file)","name": "connection",+ "readiness_state": "unknown","status": "warn"}],@@ -275,6 +297,28 @@"status": "warnings","top_issues": [{+ "action": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "doctor",+ "--json"+ ],+ "command": "gbrain doctor --json",+ "consent": [],+ "next": "run",+ "requires_exclusive": false,+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "connection",+ "--json"+ ]+ },+ "why": "Runs the database checks --fast skipped."+ },"fix": "Skipping DB checks (--fast mode, URL present from config-file)","name": "connection","status": "warn",@@ -286,6 +330,9 @@"status": "warn","tier": "symptom"}+ ],+ "unknown_scores": [+ "brain"]},"stderr": [],diff --git a/test/fixtures/goldens/doctor/json-postgres-unreachable.json b/test/fixtures/goldens/doctor/json-postgres-unreachable.jsonindex bb503bf9b6..214cd3e070 100644--- a/test/fixtures/goldens/doctor/json-postgres-unreachable.json+++ b/test/fixtures/goldens/doctor/json-postgres-unreachable.json@@ -263,13 +263,36 @@{"category": "ops","details": {- "fix_hint": "Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it. Run: gbrain db-repair",+ "fix_hint": "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port. Run: gbrain db-repair","reason": "conn_refused",- "transient": true+ "transient": true,+ "url_source": "database_url in <home>/.gbrain/config.json"},- "fix_unavailable_reason": "unstructured",- "message": "Cannot connect to database: connect ECONNREFUSED <REDACTED:ipv4>:1. Fix: Check your connection URL in ~/.gbrain/config.json",+ "fix": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "db-repair"+ ],+ "command": "gbrain db-repair",+ "consent": [],+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/ENGINES.md#engine-detection-and-access-repair",+ "next": "run",+ "requires_exclusive": false,+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "connection",+ "--json"+ ]+ },+ "why": "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port. `gbrain db-repair` diagnoses the database URL and access without changing anything (it prints the --yes command for a safe fix)."+ },+ "message": "Cannot connect to database: connect ECONNREFUSED <REDACTED:ipv4>:1. Fix: Check the database URL; `gbrain engine status --probe` names where it comes from (environment variable or the config file under GBRAIN_HOME) (database URL from database_url in <home>/.gbrain/config.json)","name": "connection",+ "readiness_state": "unknown","status": "fail"}],@@ -279,7 +302,29 @@"status": "unhealthy","top_issues": [{- "fix": "Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it. Run: gbrain db-repair",+ "action": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "db-repair"+ ],+ "command": "gbrain db-repair",+ "consent": [],+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/ENGINES.md#engine-detection-and-access-repair",+ "next": "run",+ "requires_exclusive": false,+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "connection",+ "--json"+ ]+ },+ "why": "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port. `gbrain db-repair` diagnoses the database URL and access without changing anything (it prints the --yes command for a safe fix)."+ },+ "fix": "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port. Run: gbrain db-repair","name": "connection","status": "fail","tier": "root"@@ -290,12 +335,15 @@"status": "warn","tier": "symptom"}+ ],+ "unknown_scores": [+ "brain"]},"stderr": [- "[doctor] DB-backed doctor run failed (Cannot connect to database: connect ECONNREFUSED <REDACTED:ipv4>:1. Fix: Check your connection URL in ~/.gbrain/config.json) — falling back to filesystem-only checks",+ "[doctor] DB-backed doctor run failed (Cannot connect to database: connect ECONNREFUSED <REDACTED:ipv4>:1. Fix: Check the database URL; `gbrain engine status --probe` names where it comes from (environment variable or the config file under GBRAIN_HOME)) — falling back to filesystem-only checks","GBRAIN_DB_ACCESS conn_refused",- "Connection refused. If this is a Supabase direct URL (db.<ref>...:5432), switch to the transaction pooler (port 6543): gbrain db-repair can rewrite it. Run: gbrain db-repair"+ "Connection refused: nothing accepted the connection at the configured host and port. Check that the database server is running and that the URL names the right host and port. Run: gbrain db-repair"],"stdout": "<json>"},