Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(persistence): a non-guard trigger refusal gets its own recovery hint (#5974)

garrytanc1f5ca09f308
diff --git a/src/core/persistence/connector-errors.ts b/src/core/persistence/connector-errors.ts
index bfe5029d54..534dbcf654 100644
--- a/src/core/persistence/connector-errors.ts
+++ b/src/core/persistence/connector-errors.ts
@@ -70,6 +70,12 @@ export const DATABASE_REFUSAL_HINT = 'This is not a content conflict: a gbrain p
+ '(serve, autopilot, sync jobs), then retry with a new request ID. If the builds match, report error_detail (it contains no page text) on the gbrain issue tracker. '
+ 'Do not force-write, edit SQL, or disable the guard; ask the user before changing which hosts own the brain.';
+/** #5974: another database trigger (named in write_error_detail.raiser) refused the write. */
+export const DATABASE_TRIGGER_HINT = 'A database trigger refused this write and nothing was committed; write_error_detail.raiser names it. '
+ + 'On the brain host run gbrain sources writer status --probe --json and compare recent_failures[].error_detail.attempt.consumer_version with gbrain --version '
+ + 'on every gbrain process sharing this database; upgrade or restart the older one, run gbrain apply-migrations --yes, then retry with a new request ID. '
+ + 'If versions match, report error_detail on the gbrain issue tracker. Do not edit SQL or disable triggers.';
+
export function receiptDeliveredHint(receipt: { error_code?: string | null; error_message?: string | null; source_id?: string; slug?: string | null; intent?: Record<string, unknown> | null;
error_detail?: Record<string, unknown> | null }):
{ suggestion: string; detail?: string; docs: string } | null {
@@ -101,7 +107,8 @@ export function receiptDeliveredHint(receipt: { error_code?: string | null; erro
// #5974: a database trigger refused the publication (see publication-failure.ts).
const origin = receipt.error_detail?.origin;
if (origin !== 'database_guard' && origin !== 'database_trigger') return null;
- return { detail: String(origin), docs: docsAnchor('writer_coordinator_required'), suggestion: DATABASE_REFUSAL_HINT };
+ return { detail: String(origin), docs: docsAnchor('writer_coordinator_required'),
+ suggestion: origin === 'database_guard' ? DATABASE_REFUSAL_HINT : DATABASE_TRIGGER_HINT };
}
case 'connector_fence_below_timeline':
return { docs: docsAnchor('connector_fence_below_timeline'), detail: 'fence_not_carried', suggestion: connectorFenceHint(source) };
diff --git a/src/core/persistence/diagnostics.ts b/src/core/persistence/diagnostics.ts
index c371154227..7a465494ff 100644
--- a/src/core/persistence/diagnostics.ts
+++ b/src/core/persistence/diagnostics.ts
@@ -5,7 +5,7 @@ import { publicationConcurrency } from './pool-capacity.ts';
import { WRITER_INSPECTION_HINT } from './admin-intent.ts';
import { writeHealth } from './health.ts';
import type { WriteRequestState } from './types.ts';
-import { DATABASE_REFUSAL_HINT } from './connector-errors.ts';
+import { DATABASE_REFUSAL_HINT, DATABASE_TRIGGER_HINT } from './connector-errors.ts';
export const WRITER_NEXT_ACTIONS: Record<string, string> = {
unexpected_staging_bytes: 'Keep the worktree blocked and retain its staging files and recovery capacity. Compare the recorded staging size and hash, then reconcile unexpected bytes explicitly before retrying; never discard unverified staging files.',
@@ -82,7 +82,7 @@ export async function readWriterDiagnostics(engine: BrainEngine) {
const ingress = persistenceConsumerStatus(engine);
return { ...brain, sampled_at: new Date().toISOString(), publication_concurrency: publicationConcurrency(engine),
ingress, worktrees, counters, queue, effects, limits, capacity: capacityDiagnostics(counters, limits),
- recent_failures: failures.map(row => ({ ...row, next_action: writerNextAction(row.error_code === 'storage_error' ? 'writer_coordinator_required' : row.error_code) })),
+ recent_failures: failures.map(row => ({ ...row, next_action: row.error_detail?.origin === 'database_guard' ? DATABASE_REFUSAL_HINT : DATABASE_TRIGGER_HINT })),
blockers: blockers.map(row => {
const health = writeHealth(row);
const advice = writerNextAction(row.blocked_reason ?? row.error_code);