Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
GBRA-130 PR 2: structured run failures with provider-like filename text stay run-scoped (review F3); trim key-files EOF
garrytan69cb1fd983b2
diff --git a/docs/architecture/key-files/commands-4.md b/docs/architecture/key-files/commands-4.mdindex bec7a66ea0..f2d30de8b0 100644--- a/docs/architecture/key-files/commands-4.md+++ b/docs/architecture/key-files/commands-4.md@@ -41,5 +41,3 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `src/commands/pages-unsearchable.ts` — `gbrain pages unsearchable --source <id> [--state <state>] [--limit N] [--json]` (#6696 B3, read-only): one row per (page, embedding state) from `listEmbeddingStateRows` with reason, chunks, bytes and the state's rendered fix; every state but `embedded` unless `--state` names one; `--limit` 1-1000 (default 50) with `complete`; an unknown `--state` or bad `--limit` throws `invalid_params` naming the valid values. Test: `test/pages-unsearchable.test.ts`.- `src/commands/persistence-admin.ts` + `src/core/persistence/{admin-contract,administration,transfer-administration}.ts` — trusted local `sources writer status|failures|claim|transfer` (failures: [Managed sync bookkeeping](managed-sync-bookkeeping.md)) and `auth local-writer list|register|revoke`. Parse and resolve the brain before opening PGLite; an existing owner receives a separate private administration envelope verified against the current CLI registration. These names never enter the public MCP operation registry; stdio, hook credentials, forged trust fields and revoked CLI registrations cannot administer. Transfer requires exact manifest and owner epoch; status `--probe` acquires/releases a real native lock. Explicit credential replacement commits old revocation and new registration together before atomically publishing the private file, preserving old credentials for recovery without keeping their authority. No credential/hash appears in output. `test/persistence-administration.test.ts` covers database rollback, parallel rotations, transfer conflicts, real sockets and real CLI subprocesses. `retry-effects <source> --request-id <original-uuid> --dry-run --json` previews a failed embedding effect without work; applying the same reviewed request requires original/current authority, selected-brain config, source/page/owner CAS and one additional allowance. For a request with parked Git or withdrawal effects the same command previews the parked targets (`--dry-run`) or authorizes one more attempt per parked target, reporting each effect's state and whether it is terminal. It never claims ownership or rewrites canonical receipts. `transfer-administration.ts` owns `transfer prepare|accept|cancel`: `cancel <source> --expected-epoch <n>` (intent `writer_transfer_cancel`, `--dry-run` previews) runs `cancelWriterTransfer` in `ownership.ts` on the owner host under the coordination lock and `FOR UPDATE`, requires `draining` at that epoch, returns the worktree to `active` and clears the prepared manifest while keeping the epoch, so an accept bound to it refuses `writer_transfer_conflict`. Prepare stamps `prepared_at`. Test: `test/pathological/c5-writer-transfer-cancel.test.ts` (both engines).--diff --git a/test/pathological/item-failure.test.ts b/test/pathological/item-failure.test.tsindex 2f9fdeba06..dad56305cf 100644--- a/test/pathological/item-failure.test.ts+++ b/test/pathological/item-failure.test.ts@@ -133,6 +133,9 @@ test('a model provider\'s transport failure is the item\'s transient failure, neexpect(classifyItemFailure(new Error('fetch failed: ECONNRESET'))).toMatchObject({ code: 'provider_error', scope: 'item', class: 'transient' });expect(classifyItemFailure(Object.assign(new Error("ENOSPC: no space left on device, open '/brain/fetch failed.md'"), { code: 'ENOSPC' }))).toMatchObject({ code: 'disk_full', scope: 'run' });expect(classifyItemFailure(Object.assign(new Error('could not write notes/fetch failed.md'), { code: '42501' }))).toMatchObject({ code: 'permission_denied', scope: 'run' });+ expect(classifyItemFailure(Object.assign(new Error('current transaction is aborted while importing /brain/fetch failed.md'), { code: '25P02' }))).toMatchObject({ code: 'database_contention', scope: 'run' });+ expect(classifyItemFailure(Object.assign(new Error('fetch failed.md: connection terminated'), { code: '08006' }))).toMatchObject({ code: 'database_contention', scope: 'run' });+ expect(classifyItemFailure(new OperationError('disk_full', "No space left writing '/brain/fetch failed.md'.", 'Free space, then rerun.'))).toMatchObject({ code: 'disk_full', scope: 'run' });expect(classifyItemFailure(new AITransientError('[chat(openai:gpt-example)] socket hang up', Object.assign(new Error('read ECONNRESET'), { code: 'ECONNRESET' })))).toMatchObject({ code: 'provider_error', scope: 'item' });expect(classifyItemFailure(Object.assign(new Error('Connection terminated unexpectedly'), { code: '08006' })).scope).toBe('run');