Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(#7630): writer failures rows show the fault operation; Windows-absolute default path; --clear on a cleared path is a no-op; doctor names every blocked source
garrytanff980801d9da
diff --git a/docs/guides/troubleshooting.md b/docs/guides/troubleshooting.mdindex eb41dce801..2ef673cd21 100644--- a/docs/guides/troubleshooting.md+++ b/docs/guides/troubleshooting.md@@ -857,8 +857,8 @@ edits stored pages, managed activation refuses it (`source_changed`, detailmaintenance cycles and `gbrain maintain` run only their database phases,`sources set-path` does not count it as another source's tree, thewrite-through leak guard counts a live source's relative path as owning any-tree (so a `default` source with no `local_path` saves its pages to the-database only, `source_repo_belongs_to_other_source`, until that path is set+tree (so every source with no `local_path`, the `default` source and any+`.sources/<id>` source, saves its pages to the database only, `source_repo_belongs_to_other_source`, until that path is setor cleared), `gbrain autopilot--install` asks for `--repo`, a remote `submit_job` for the source isrefused, import does not count the folder as a configured root or stamp itdiff --git a/llms-full.txt b/llms-full.txtindex 362b861fea..f553cebd7b 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -11014,8 +11014,8 @@ edits stored pages, managed activation refuses it (`source_changed`, detailmaintenance cycles and `gbrain maintain` run only their database phases,`sources set-path` does not count it as another source's tree, thewrite-through leak guard counts a live source's relative path as owning any-tree (so a `default` source with no `local_path` saves its pages to the-database only, `source_repo_belongs_to_other_source`, until that path is set+tree (so every source with no `local_path`, the `default` source and any+`.sources/<id>` source, saves its pages to the database only, `source_repo_belongs_to_other_source`, until that path is setor cleared), `gbrain autopilot--install` asks for `--repo`, a remote `submit_job` for the source isrefused, import does not count the folder as a configured root or stamp itdiff --git a/src/commands/doctor/checks/default-source-path.ts b/src/commands/doctor/checks/default-source-path.tsindex 7835f11a7e..ef448abf32 100644--- a/src/commands/doctor/checks/default-source-path.ts+++ b/src/commands/doctor/checks/default-source-path.ts@@ -85,7 +85,7 @@ export async function defaultSourceLocalPathCheck(engine: BrainEngine): Promise<`${relative.map(row => `source "${row.id}" has the relative local_path "${row.local_path}"`).join('; ')}, which names whatever directory ` +'gbrain runs from, so sync refuses it (sync_anchor_relative). Ask the user which directory holds its files, then run ' +'`gbrain sources set-path <id> <absolute-directory>`, or clear the pointer with `gbrain sources set-path <id> --clear`.' +- (blockedByRelative ? ' Until then, default-source pages are saved to the database only, not written under sync.repo_path.' : '');+ (blockedByRelative ? ' Until then, pages of every source with no local_path (the default source and any `.sources/<id>` source) are saved to the database only, not written under sync.repo_path.' : '');return {name: 'default_source_local_path',status: relative.length > 0 || assessment.status === 'skip' ? 'warn' : assessment.status,diff --git a/src/core/default-source-path-check.ts b/src/core/default-source-path-check.tsindex 901f6b5ac5..ed21bc9056 100644--- a/src/core/default-source-path-check.ts+++ b/src/core/default-source-path-check.ts@@ -34,7 +34,7 @@* npm-squat-check.ts / pglite-leftovers-check.ts. The gathering wrapper* lives on the doctor surface (doctor/checks/default-source-path.ts).*/-import { isAbsolute } from 'path';+import { isAbsolute, posix, win32 } from 'path';export interface DefaultSourcePathInput {/** The `default` sources row, or undefined when no such row exists. */@@ -68,7 +68,7 @@ export function assessDefaultSourcePath(// integrity.return { status: 'skip', message: '' };}- if (defaultSource.local_path && !isAbsolute(defaultSource.local_path)) {+ if (defaultSource.local_path && !posix.isAbsolute(defaultSource.local_path) && !win32.isAbsolute(defaultSource.local_path)) {return {status: 'warn',message:@@ -89,9 +89,9 @@ export function assessDefaultSourcePath(status: 'warn',message:`default source has no local_path and sync.repo_path is the relative path "${repoPath}", which names whatever ` +- 'directory gbrain runs from, so sync refuses it (sync_anchor_relative) and default-source page writes skip the ' +- 'repository. Ask the user which directory holds the brain, then run ' +- '`gbrain config set sync.repo_path <absolute-directory>`.',+ 'directory gbrain runs from, so default-source page writes skip the repository. Ask the user which directory holds ' ++ 'the brain, then run `gbrain sources set-path default <absolute-directory>` (or ' ++ '`gbrain config set sync.repo_path <absolute-directory>`).',};}// null local_path — the designed fallback topology. Only warn when thediff --git a/src/core/persistence/connector-path.ts b/src/core/persistence/connector-path.tsindex de81124f7d..5ce9746619 100644--- a/src/core/persistence/connector-path.ts+++ b/src/core/persistence/connector-path.ts@@ -24,7 +24,7 @@ export async function clearConnectorLocalPath(engine: BrainEngine, sourceId: str"SELECT local_path, config->>'kind' AS kind, incarnation FROM sources WHERE id=$1 FOR UPDATE", [sourceId]);if (!source) throw new OperationError('not_found', `Source "${sourceId}" not found.`, "Run 'gbrain sources list' to see registered sources.");const connector = isConnectorSourceKind(source.kind);- if (!connector && (source.local_path === null || posix.isAbsolute(source.local_path) || win32.isAbsolute(source.local_path))) {+ if (!connector && source.local_path !== null && (posix.isAbsolute(source.local_path) || win32.isAbsolute(source.local_path))) {throw new OperationError('invalid_params', `--clear applies only to connector sources (google, github) and to a relative local_path; "${sourceId}" is a filesystem source whose path is its canonical checkout.`,`Point it at its checkout with gbrain sources set-path ${sourceId} <path>, or remove it with gbrain sources remove ${sourceId}.`);}diff --git a/src/core/persistence/terminal-failures.ts b/src/core/persistence/terminal-failures.tsindex e8f30947e6..86c1a88c18 100644--- a/src/core/persistence/terminal-failures.ts+++ b/src/core/persistence/terminal-failures.ts@@ -282,7 +282,7 @@ export interface TerminalFailureQuery {code?: string;origin?: string;category?: string;- /** #7630: the receipt's operation; a sync-fault group's drill-down narrows by it. */+ /** #7630: the receipt's operation, or a reconcile or managed put_page's intent kind (`faultOperation`); `--operation` narrows by it. */operation?: string;}export interface TerminalFailureRow {@@ -326,7 +326,6 @@ export async function readTerminalFailures(engine: BrainEngine, q: TerminalFailuconst out: TerminalFailureRow[] = [];// #6712 PR 2: the oldest admission per drift group, so the group's file-drift fix selects every page in it with one concrete --since.const driftSince = new Map<string, string>();- const faultOperationOf = new Map<string, string>();let cursor = q.before ?? null, scanned = 0, exhausted = false;const want = q.groupBy ? MAX_SCAN : limit + 1;while (out.length < want && scanned < MAX_SCAN && !exhausted) {@@ -353,8 +352,7 @@ export async function readTerminalFailures(engine: BrainEngine, q: TerminalFailuconst historical = !row.has_recovery && (disposition !== 'unknown' || v.historical);const matches = (!q.category || v.category === q.category) && (!q.code || v.code === q.code)&& (q.origin === undefined || (v.origin ?? NO_ORIGIN) === q.origin) && (!q.operation || faultOperation(row.operation, row.intent_kind) === q.operation) && (state === 'all' || !historical);- if (matches) faultOperationOf.set(row.request_id, faultOperation(row.operation, row.intent_kind));- if (matches) out.push({ request_id: row.request_id, slug: row.slug, operation: row.operation, state: row.state, code: v.code, origin: v.origin, category: v.category, public_category: v.public_category, class: v.class,+ if (matches) out.push({ request_id: row.request_id, slug: row.slug, operation: faultOperation(row.operation, row.intent_kind), state: row.state, code: v.code, origin: v.origin, category: v.category, public_category: v.public_category, class: v.class,safe_actions: v.safe_actions, needs_human: v.needs_human, ...(v.human_reason ? { human_reason: v.human_reason } : {}), disposition, blocking: row.has_recovery, historical,compacted: row.compacted, ended_at: row.ended_at, cursor: row.sequence, ...(v.root_request_id ? { root_request_id: v.root_request_id } : {}),inspect: { argv: terminalInspectArgv(row.request_id), consent: [], actor: 'agent', requires_exclusive: false, why: 'The receipt with its diagnosis and structured fix, read-only.' },@@ -375,7 +373,7 @@ export async function readTerminalFailures(engine: BrainEngine, q: TerminalFailu}const groups = new Map<string, TerminalFailureGroup>();for (const row of out) {- const operation = row.category === 'sync_fault' ? faultOperationOf.get(row.request_id) : undefined;+ const operation = row.category === 'sync_fault' ? row.operation : undefined;const key = `${row.code}\0${row.origin ?? ''}\0${row.category}${operation === undefined ? '' : `\0${operation}`}`;let g = groups.get(key);if (!g) {diff --git a/test/sync-relative-anchor-refusal-7630.test.ts b/test/sync-relative-anchor-refusal-7630.test.tsindex 359b3e4690..f29b9d72cb 100644--- a/test/sync-relative-anchor-refusal-7630.test.ts+++ b/test/sync-relative-anchor-refusal-7630.test.ts@@ -227,6 +227,7 @@ for (const backend of testBackends()) {await engine.executeRaw("UPDATE sources SET local_path='.' WHERE id='default'");expect(await clearConnectorLocalPath(engine, 'default')).toEqual({ prior: '.', connector: false });expect((await engine.executeRaw<{ local_path: string | null }>("SELECT local_path FROM sources WHERE id='default'"))[0]!.local_path).toBeNull();+ expect(await clearConnectorLocalPath(engine, 'default')).toEqual({ prior: null, connector: false });await engine.executeRaw("UPDATE sources SET local_path=$1 WHERE id='default'", [folder]);expect((await clearConnectorLocalPath(engine, 'default').catch(error => error)).code).toBe('invalid_params');expect((await engine.executeRaw<{ local_path: string | null }>("SELECT local_path FROM sources WHERE id='default'"))[0]!.local_path).toBe(folder);@@ -235,6 +236,9 @@ for (const backend of testBackends()) {expect((await clearConnectorLocalPath(engine, 'notes-w').catch(error => error)).code).toBe('invalid_params');expect((await defaultSourceLocalPathCheck(engine))?.message ?? '').not.toContain('notes-w');await engine.executeRaw("DELETE FROM sources WHERE id='notes-w'");+ await engine.executeRaw("UPDATE sources SET local_path=$1 WHERE id='default'", ['C:\\brain-example']);+ expect((await defaultSourceLocalPathCheck(engine))?.message ?? '').not.toContain('relative path');+ await engine.executeRaw("UPDATE sources SET local_path=$1 WHERE id='default'", [folder]);// Value: protects=a relative local_path whose source has a canonical owner binding is never cleared (writer_transfer_required);// fails_when=the relative-path clear is moved ahead of the binding check; why_new=sources-set-path-clear covers only a bound// connector; seam=none; no_claim=a real activated managed brain (the binding row is inserted directly)@@ -532,7 +536,7 @@ for (const backend of testBackends()) {const check = await defaultSourceLocalPathCheck(engine);expect(check?.status).toBe('warn');expect(check?.message).toContain('source "notes-a" has the relative local_path "."');- expect(check?.message).toContain('default-source pages are saved to the database only');+ expect(check?.message).toContain('pages of every source with no local_path (the default source and any `.sources/<id>` source) are saved to the database only');expect(check?.message).not.toContain('own working tree');expect(check?.message).not.toContain('write through sync.repo_path');expect(check?.message).not.toContain('notes-b');diff --git a/test/terminal-failures-6650.test.ts b/test/terminal-failures-6650.test.tsindex 6c09969afc..fd1fe6894c 100644--- a/test/terminal-failures-6650.test.ts+++ b/test/terminal-failures-6650.test.ts@@ -419,6 +419,10 @@ for (const kind of testBackends()) describe(`the aggregate, doctor and the drillconst flat = await readTerminalFailures(engine, { sourceId: SOURCE, limit: 50 });if (flat.status !== 'ok') throw new Error('unknown');for (const g of stalled) for (const s of g.samples) expect(flat.rows!.find(r => r.request_id === s.request_id)!.fix).toEqual(g.fix);+ expect(flat.rows!.find(r => r.slug === 'notes/mi')!.operation).toBe('managed_file_import');+ const putPages = await readTerminalFailures(engine, { sourceId: SOURCE, operation: 'put_page', limit: 50 });+ if (putPages.status !== 'ok') throw new Error('unknown');+ expect(putPages.rows!.map(r => r.slug)).toEqual(['notes/p']);for (const op of ['put_page', 'remember', 'takes_supersede', 'takes_resolve']) {const g = stalled.find(x => x.operation === op)!;expect(g.rows).toBe(1);