Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(persistence): an owner exception's public message names no class, errno or build (#5929)
garrytan8f8e1b69bdd6
diff --git a/docs/ENGINES.md b/docs/ENGINES.mdindex 782fa17018..caab704c36 100644--- a/docs/ENGINES.md+++ b/docs/ENGINES.md@@ -652,7 +652,7 @@ the SQLSTATE (for example `53300` when a pooler's client limit is reached),a write-error code, `storage_error`, or `deadline_exceeded` when the phaseoverran its five-second budget. `message` is the redacted error text, one line,at most 200 characters. When an unexpected exception in the owner failed a-write (`storage_error` "Publication failed (TypeError in owner build 0.60.x)"),+write (`storage_error` with a generic public message; the class and frame stay owner-only),the line also carries `class=`, `errno=` and `frame=` (the top gbrain sourceframe, repo-relative, for example `src/core/persistence/page-prepare.ts:120`):the owner diagnostics the receipt points at. The stored receipt keeps the samediff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex 66b0d20eb0..273df8fcbd 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -281,7 +281,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }{ since: '0.60.103.0', text: '`gbrain repair failed-writes` now replays subagent and restricted-namespace writes (they were all refused "via subagent requires ctx.subagentId"), under the original writer\'s stored authority re-checked against its live grant; replayed writes are attributed to that original writer.' },{ since: '0.60.103.0', text: 'Inline `[Source: ..., date]` citations no longer file an adjacent HTML comment (such as `<!-- AUTO:slack END -->`) as a timeline entry, and a timeline row carrying comment markup is never written back into a page (it would duplicate a section END marker); `gbrain repair timeline-comments --source <id>` previews and cleans rows and bullets stored before this release.' },{ since: '0.60.103.0', text: 'On a managed brain, `gbrain files upload-raw` of a small file now refuses before creating anything (it used to leave an empty `.raw/` directory); configure a storage backend and use `gbrain files upload <file> --page <slug>`.' },- { since: '0.60.103.0', text: 'A managed write that fails on an unexpected owner exception now reports `storage_error` "Publication failed (<ErrorClass> in owner build <version>)" instead of a bare message, the owner log line names the class and source frame, and `gbrain write-request <id>` (`owner_build`) says when the owner that ran it is on another build than the CLI and needs a restart.' },+ { since: '0.60.103.0', text: 'A managed write that fails on an unexpected owner exception keeps its class, errno and source frame owner-only (the public `storage_error` message stays generic), the owner log line names the class and source frame, and `gbrain write-request <id>` (`owner_build`) says when the owner that ran it is on another build than the CLI and needs a restart.' },{ since: '0.60.103.0', text: 'Doctor\'s new `persistence_write_stall` check warns when a managed write has held its claim longer than `persistence.max_claim_ms` (default 10 minutes) and names the stuck phase; `gbrain sources writer status --json` shows each running request\'s `claim` phase.' },{ since: '0.60.103.0', text: 'On a brain whose managed persistence was never activated, `gbrain sources writer deactivate` now releases sources claimed before activation (the dry run lists them as `pre_activation_claims`), so classic `gbrain sync` of them works again; `gbrain sources writer deactivate --dry-run --json` previews it.' },{ since: '0.60.103.0', text: 'Writer transfer, `gbrain sources set-path` and reclone now compare only the files Git tracks in a Git checkout, so ignored files such as `.env.local` are never read or need copying and a clean `git clone` verifies; a transfer prepared before this release is prepared again (`writer_manifest_rescope_required`), and upgrading drops the per-file path and hash maps older releases stored.' },diff --git a/src/core/persistence/publication-failure.ts b/src/core/persistence/publication-failure.tsindex 405690f795..88bdbdaf13 100644--- a/src/core/persistence/publication-failure.ts+++ b/src/core/persistence/publication-failure.ts@@ -94,15 +94,20 @@ function gbrainFrame(stack: unknown): string | undefined {return undefined;}-/** #5929: the bounded identity of an unexpected owner exception, with a message naming only the class, errno and owner build. */+/**+ * #5929: the public message of an unexpected owner exception. Remote submitters read it, so it names no class,+ * errno or build; those stay in the owner-only detail, `gbrain write-request <id>` on the brain host and the consumer log.+ */+export const OWNER_EXCEPTION_MESSAGE = 'Publication failed on an unexpected owner exception. On the brain host, gbrain write-request <request_id> and the persistence consumer log name its class, source frame and owner build.';++/** #5929: the bounded identity of an unexpected owner exception (class, errno, frame), kept owner-only. */export function ownerExceptionFailure(error: unknown): PublicationFailure {const e = (error && typeof error === 'object' ? error : {}) as { constructor?: { name?: unknown }; code?: unknown; errno?: unknown; stack?: unknown };const errorClass = ident(e.constructor?.name);const raw = typeof e.code === 'string' ? e.code : typeof e.errno === 'number' ? String(e.errno) : undefined;const errno = raw && ERRNO.test(raw) ? raw : undefined;const frame = gbrainFrame(e.stack);- const what = [errorClass, errno].filter(Boolean).join(' ');- return { code: 'storage_error', message: `Publication failed (${what ? `${what} in ` : ''}owner build ${writerStamp().version}). Inspect owner diagnostics.`,+ return { code: 'storage_error', message: OWNER_EXCEPTION_MESSAGE,detail: { origin: 'owner_exception', ...(errorClass ? { error_class: errorClass } : {}), ...(errno ? { errno } : {}), ...(frame ? { frame } : {}) } };}diff --git a/test/publication-failure-owner-exception.test.ts b/test/publication-failure-owner-exception.test.tsindex 36a425f0f0..24c7469574 100644--- a/test/publication-failure-owner-exception.test.ts+++ b/test/publication-failure-owner-exception.test.ts@@ -18,7 +18,7 @@ import { receiptFor } from '../src/core/persistence/journal.ts';import type { WriteRequest } from '../src/core/persistence/model.ts';import { claimWorktree } from '../src/core/persistence/ownership.ts';import { submitPageMutation } from '../src/core/persistence/page-mutations.ts';-import { publicFailureDetail } from '../src/core/persistence/publication-failure.ts';+import { publicFailureDetail, OWNER_EXCEPTION_MESSAGE } from '../src/core/persistence/publication-failure.ts';import { disposePersistenceConsumer } from '../src/core/persistence/service.ts';import { VERSION } from '../src/version.ts';import { withEnv } from './helpers/with-env.ts';@@ -62,7 +62,9 @@ describe('#5929 owner exceptions keep a bounded identity', () => {expect(thrown).toBeInstanceOf(OperationError);expect(thrown.code).toBe('storage_error');expect(row.error_code).toBe('storage_error');- expect(row.error_message).toBe(`Publication failed (TypeError in owner build ${VERSION}). Inspect owner diagnostics.`);+ expect(row.error_message).toBe(OWNER_EXCEPTION_MESSAGE);+ expect(row.error_message).not.toContain('TypeError');+ expect(row.error_message).not.toContain(VERSION);const detail = row.error_detail as Record<string, any>;expect(detail).toMatchObject({ origin: 'owner_exception', error_class: 'TypeError', stage: 'publication', attempt: { consumer_version: VERSION } });expect(detail.frame).toBe('src/core/persistence/page-prepare.ts:120');@@ -73,7 +75,8 @@ describe('#5929 owner exceptions keep a bounded identity', () => {test('an errno-bearing error keeps the errno', async () => {const { row } = await failingWrite(Object.assign(new Error('no space left on /home/alice-example/brain'), { code: 'ENOSPC' }));expect(row.error_detail).toMatchObject({ origin: 'owner_exception', error_class: 'Error', errno: 'ENOSPC' });- expect(row.error_message).toBe(`Publication failed (Error ENOSPC in owner build ${VERSION}). Inspect owner diagnostics.`);+ expect(row.error_message).toBe(OWNER_EXCEPTION_MESSAGE);+ expect(row.error_message).not.toContain('ENOSPC');expect(JSON.stringify(row)).not.toContain('alice-example');});