Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: pre-landing review fixes
garrytan9ed4dea3f927
diff --git a/src/core/brain-writer.ts b/src/core/brain-writer.tsindex 58da6cf77d..bc2535a70b 100644--- a/src/core/brain-writer.ts+++ b/src/core/brain-writer.ts@@ -22,6 +22,7 @@ import { loadBoundedYaml as yamlLoad } from './data-frontmatter.ts';import { existsSync, readFileSync, readdirSync, copyFileSync, writeFileSync, mkdirSync, lstatSync } from 'fs';import { join, relative, resolve, dirname, basename, isAbsolute } from 'path';import type { BrainEngine } from './engine.ts';+import { isConnectorSourceKind } from './persistence/connector-kinds.ts';import type { ProgressReporter } from './progress.ts';import { gbrainPath } from './config.ts';import { collectGitVisibleFiles } from './git-visible-files.ts';@@ -578,6 +579,7 @@ export function writeBrainPage(interface SourceRow {id: string;local_path: string | null;+ kind: string | null;}export interface ScanOpts {@@ -700,6 +702,8 @@ export async function scanBrainSources(}if (!src.local_path) continue;if (!existsSync(src.local_path)) {+ // #5673: a connector syncs from its provider, so a gone local_path is a leftover pointer with nothing on disk to scan.+ if (isConnectorSourceKind(src.kind)) continue;perSource.push({source_id: src.id,source_path: src.local_path,@@ -1004,7 +1008,7 @@ export function walkDir(async function listSources(engine: BrainEngine, sourceId?: string): Promise<SourceRow[]> {if (sourceId) {const rows = await engine.executeRaw<SourceRow>(- `SELECT id, local_path FROM sources WHERE id = $1`,+ `SELECT id, local_path, config->>'kind' AS kind FROM sources WHERE id = $1`,[sourceId],);return rows;@@ -1014,11 +1018,11 @@ async function listSources(engine: BrainEngine, sourceId?: string): Promise<Sour// pickSoleNonDefaultSource).try {return await engine.executeRaw<SourceRow>(- `SELECT id, local_path FROM sources WHERE local_path IS NOT NULL AND archived IS NOT TRUE ORDER BY id`,+ `SELECT id, local_path, config->>'kind' AS kind FROM sources WHERE local_path IS NOT NULL AND archived IS NOT TRUE ORDER BY id`,);} catch {return engine.executeRaw<SourceRow>(- `SELECT id, local_path FROM sources WHERE local_path IS NOT NULL ORDER BY id`,+ `SELECT id, local_path, config->>'kind' AS kind FROM sources WHERE local_path IS NOT NULL ORDER BY id`,);}}diff --git a/test/frontmatter-missing-source-dir-7889.test.ts b/test/frontmatter-missing-source-dir-7889.test.tsindex 8031998b86..69ee9900eb 100644--- a/test/frontmatter-missing-source-dir-7889.test.ts+++ b/test/frontmatter-missing-source-dir-7889.test.ts@@ -57,3 +57,17 @@ test('a registered source whose directory is missing is unverified in the audit}expect(checks.find(c => c.name === 'frontmatter_integrity')!.details).toMatchObject({ missing_sources: ['source-ghost'], partial: false, exact: false });});++// Value: protects=a connector source (google, github, meetings, slack) whose leftover local_path is gone is not reported missing (#7889, #5673);+// fails_when=scanBrainSources marks a connector's stale checkout pointer 'missing', so doctor warns on every run with set-path advice that+// does not apply to a source that syncs from its provider; why_new=the #7889 cases only register filesystem sources;+// seam=scanBrainSources on PGLite; no_claim=a connector whose local_path exists, which is scanned as before.+test('a connector source whose leftover local_path is gone is not reported missing', async () => {+ const stale = join(root, 'connector-checkout-gone');+ await engine.executeRaw("INSERT INTO sources(id,name,local_path,config) VALUES('source-connector','source-connector',$1,'{\"kind\":\"github\"}'::jsonb)", [stale]);+ const report = await scanBrainSources(engine);+ expect(report.missing_sources).toEqual(['source-ghost']);+ expect(report.per_source.find(s => s.source_id === 'source-connector')).toBeUndefined();+ expect((await scanBrainSources(engine, { sourceId: 'source-connector' })).ok).toBe(true);+});+