Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(dream): patterns breaker and claim-pending skips verify with read-only commands (#6236)

time-attack827105279e39
diff --git a/src/core/cycle/dream-breaker.ts b/src/core/cycle/dream-breaker.ts
index 8742902006..c3c26e1476 100644
--- a/src/core/cycle/dream-breaker.ts
+++ b/src/core/cycle/dream-breaker.ts
@@ -178,7 +178,7 @@ export async function patternsBreakerSkip(engine: BrainEngine, sourceId: string)
base_key: key, why: 'The patterns phase died (or was cancelled after paid work) that many times in a row for this source within 24 hours, so it is not submitted again until reset.',
fix: { argv: ['gbrain', 'dream', 'reset-key', key], consent: ['paid'], actor: 'agent', requires_exclusive: false,
why: 'Re-enables patterns runs for this source; the next cycle pays for a run, so fix the cause and ask the user first.',
- verify: { argv: ['gbrain', 'dream', 'reset-key', '--list', '--json'] } } } };
+ verify: { argv: ['gbrain', 'doctor', '--only', 'dream_paid_loop', '--json'] } } } };
}
/**
diff --git a/src/core/cycle/patterns.ts b/src/core/cycle/patterns.ts
index 80d235bc2e..94e7d4ae00 100644
--- a/src/core/cycle/patterns.ts
+++ b/src/core/cycle/patterns.ts
@@ -835,7 +835,7 @@ async function dedupePatternsBeforeChild(engine: BrainEngine, maintenance: Maint
why: 'Existing pattern pages carried a full reflection list on every quarantined claim; the child reads those pages, so it runs only after they are rewritten.',
fix: { argv: ['gbrain', 'dream', '--phase', 'patterns', '--source', sourceId], consent: ['paid'], actor: 'agent', requires_exclusive: false,
why: 'Re-runs the patterns phase once the held rewrites have landed; it is a paid model run, so ask the user first.',
- verify: { argv: ['gbrain', 'sources', 'writer', 'status', '--source', sourceId, '--json'] } } } };
+ verify: { argv: ['gbrain', 'write-requests', '--source', sourceId] } } } };
}
function skipped(reason: string, summary: string): PhaseResult {
diff --git a/src/core/error-registry.ts b/src/core/error-registry.ts
index 32b6f717c8..e396da78c9 100644
--- a/src/core/error-registry.ts
+++ b/src/core/error-registry.ts
@@ -132,7 +132,7 @@ export const CODES = {
demo_verification_failed: { class: 'server', summary: "Expected ownership or decision provenance is missing." },
derived_cap_exhausted: { class: 'server', summary: "Paid work stopped at the cost cap derived from its estimate; the run is resumable." },
destination_not_ready: { class: 'host_only', summary: "The destination brain is not initialized for this operation." },
- dream_breaker_tripped: { class: 'unavailable', summary: "A dream synthesize or patterns submission died (or, for patterns, was cancelled at its timeout after paid work) the breaker limit of times within 24 hours, so it was not submitted again.", why: "A run that keeps dying keeps paying; the breaker stops resubmitting until the cause is fixed and the key is reset. Patterns count per source (`dream:patterns:source:<id>`) whatever reflections each run read, and a completed run resets that count.", docs: 'docs/operations/spend-controls.md#dream-paid-loop-breaker-dreambreakermax_dead_submissions', fix: { argv: ['gbrain', 'dream', 'reset-key', '--list', '--json'], consent: [], actor: 'agent', why: 'Lists the tripped keys with their counts and reset commands, read-only.', requires_exclusive: false } },
+ dream_breaker_tripped: { class: 'unavailable', summary: "A dream synthesize or patterns submission died (or, for patterns, was cancelled at its timeout after paid work) the breaker limit of times within 24 hours, so it was not submitted again.", why: "A run that keeps dying keeps paying; the breaker stops resubmitting until the cause is fixed and the key is reset. Patterns count per source (`dream:patterns:source:<id>`) whatever reflections each run read, and a completed run resets that count.", docs: 'docs/operations/spend-controls.md#dream-paid-loop-breaker-dreambreakermax_dead_submissions', fix: { argv: ['gbrain', 'doctor', '--only', 'dream_paid_loop', '--json'], consent: [], actor: 'agent', why: 'Shows the tripped dream keys with their counts and reset commands, read-only.', requires_exclusive: false } },
dirty_tree: { class: 'caller', summary: "Commit or stash canonical skill edits before optimization." },
effect_not_failed: { class: 'caller', summary: "Only a failed, non-running embedding effect can be explicitly retried." },
embedding_auth_failed: { class: 'unavailable', summary: "The embedding provider rejected the credentials." },
@@ -255,7 +255,7 @@ export const CODES = {
parser_regression: { class: 'server', summary: "A file whose exact bytes imported before is now refused by gbrain's frontmatter reader.", why: "The same bytes imported under an earlier gbrain version, so only gbrain changed; with `sync.parser_regression=hold` such a file is held and the rest of the sync continues.", suggestion: 'Report it as a gbrain bug with the gbrain version, the file and the code; upgrade or pin the last good version, then sync again with --retry-failed.' },
pasted_wrong_url: { class: 'caller', summary: "Google connect credential error: pasted wrong url.", docs: 'docs/guides/google-connect.md#troubleshooting' },
payload_too_large: { class: 'caller', summary: "The payload exceeds the configured size cap." },
- pattern_claims_pending: { class: 'retryable', summary: "An existing pattern page is waiting on the rewrite that de-duplicates its claim sources, so no patterns child was submitted this run.", why: "The patterns child reads existing pattern pages; until their claim records reference one shared reflection list, the pages can overflow the model's window and the run pays for nothing.", fix: { argv: ['gbrain', 'sources', 'writer', 'status', '--json'], consent: [], actor: 'agent', why: "Shows the source's maintenance writer and the requests still in flight, read-only.", requires_exclusive: false } },
+ pattern_claims_pending: { class: 'retryable', summary: "An existing pattern page is waiting on the rewrite that de-duplicates its claim sources, so no patterns child was submitted this run.", why: "The patterns child reads existing pattern pages; until their claim records reference one shared reflection list, the pages can overflow the model's window and the run pays for nothing.", fix: { argv: ['gbrain', 'write-requests', '--source', '{source_id}'], consent: [], actor: 'agent', why: 'Lists the write receipts of the source, newest first, so the held rewrites show, read-only.', requires_exclusive: false } },
pending_writes: { class: 'retryable', summary: "A pending source write prevents verified completion." },
permission_denied: { class: 'host_only', summary: "This caller is not authorized for the operation." },
persistence_write_stall: { class: 'host_only', summary: "A managed write request has held its claim longer than persistence.max_claim_ms, so later writes on its root wait behind it.", why: "The owner renews a claim for as long as its work is unsettled, so a preparation or publication that hangs never lets the lease lapse; doctor names the stuck phase, the root, the claim's age and whether the same request resumes on its own.", docs: 'docs/guides/troubleshooting.md#persistence-write-stall', suggestion: 'Inspect the request with the command in fix, then restart the gbrain serve that owns the root; attach that status output when reporting the hang.', fix: { argv: ['gbrain', 'sources', 'writer', 'status', '--source', '{source_id}', '--json'], consent: [], actor: 'agent', why: "Shows the owner, the stuck request's claim phase and the writes waiting behind it, read-only.", requires_exclusive: false } },
diff --git a/test/dream-breaker-patterns-source.test.ts b/test/dream-breaker-patterns-source.test.ts
index 17476feee9..3d8b1f1fe0 100644
--- a/test/dream-breaker-patterns-source.test.ts
+++ b/test/dream-breaker-patterns-source.test.ts
@@ -38,7 +38,7 @@ describe('patterns breaker per source (#6236)', () => {
const skip = await patternsBreakerSkip(engine, 'default');
expect(skip?.status).toBe('skipped');
expect(skip?.details).toMatchObject({ reason: 'dream_breaker_tripped', code: 'dream_breaker_tripped',
- fix: { argv: ['gbrain', 'dream', 'reset-key', 'dream:patterns:source:default'], consent: ['paid'], verify: { argv: ['gbrain', 'dream', 'reset-key', '--list', '--json'] } } });
+ fix: { argv: ['gbrain', 'dream', 'reset-key', 'dream:patterns:source:default'], consent: ['paid'], verify: { argv: ['gbrain', 'doctor', '--only', 'dream_paid_loop', '--json'] } } });
});
test('a paid timeout-cancel counts; a cancel before any work does not', async () => {
diff --git a/test/managed-maintenance.test.ts b/test/managed-maintenance.test.ts
index a7285559ba..b997ae2b2f 100644
--- a/test/managed-maintenance.test.ts
+++ b/test/managed-maintenance.test.ts
@@ -607,7 +607,7 @@ test('managed patterns scopes evidence and publishes through the real admitted s
}, 90_000);
test('#6236: a held claim-source rewrite of an existing pattern page submits no patterns child (0 model calls)', async () => {
- await fixture(async (engine, sourceId) => {
+ await fixture(async (engine, sourceId, root) => {
for (let i = 0; i < 3; i++) await seed(engine, sourceId, `wiki/personal/reflections/example-${i}`);
const list = Array.from({ length: 50 }, (_, i) => ` - wiki/personal/reflections/old-${i}`).join('\n');
const ctx = { engine, sourceId, remote: false as const, config: { engine: engine.kind, embedding_disabled: true },
@@ -628,7 +628,7 @@ test('#6236: a held claim-source rewrite of an existing pattern page submits no
expect(lock).not.toBeNull();
try {
await withEnv({ ANTHROPIC_API_KEY: 'sk-test-maintenance' }, async () => {
- const result = await pendingWait(() => runPhasePatterns(engine, { brainDir: null, sourceId, dryRun: false, once: true, cycleDate: '2026-02-03' }));
+ const result = await pendingWait(() => runPhasePatterns(engine, { brainDir: root, sourceId, dryRun: false, once: true, cycleDate: '2026-02-03' }));
expect(result.status).toBe('skipped');
expect(result.details).toMatchObject({ reason: 'pattern_claims_pending', held: ['wiki/personal/patterns/legacy'] });
expect(calls).toBe(0);