Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

#6643: keep the pinned not-fully-committed checkpoint failure; retry-failed wait names the request it waits on

garrytan986a04fe6acf
diff --git a/src/core/persistence/sync-run.ts b/src/core/persistence/sync-run.ts
index f94475e02c..8564b9a56c 100644
--- a/src/core/persistence/sync-run.ts
+++ b/src/core/persistence/sync-run.ts
@@ -788,13 +788,10 @@ async function recoverKnockOn(engine: BrainEngine, input: SettleInput): Promise<
/** #6643: checkpoint revivals per sync invocation (keyed by its run options object), so a refusal loop ends the invocation, never the cursor. */
const checkpointRevivalsByRun = new WeakMap<object, number>();
-const NOT_FULLY_COMMITTED_MESSAGE = 'The sync cursor is not fully committed.';
-const revivableCheckpointRefusal = (done: Pick<WriteRequest, 'state' | 'error_code' | 'error_message' | 'recovery'>) => !done.recovery
- && ((done.state === 'failed' && done.error_code === 'recovery_required')
- || (['failed', 'conflict'].includes(done.state) && done.error_code === 'revision_conflict' && done.error_message === NOT_FULLY_COMMITTED_MESSAGE));
+/** A same-run index lag ("The sync cursor is not fully committed.") stays a recorded failure (managed-sync-checkpoint-replaced.test.ts pins it). */
+const revivableCheckpointRefusal = (done: Pick<WriteRequest, 'state' | 'error_code' | 'recovery'>) => !done.recovery && done.state === 'failed' && done.error_code === 'recovery_required';
/**
- * #6643: a checkpoint refused because a receipt blocked it (`recovery_required`) or because the cursor had not reached
- * its end yet ("not fully committed") is re-assessed whenever the run resumes: when nothing blocks it any more (a
+ * #6643: a checkpoint refused because a receipt blocked it (`recovery_required`) is re-assessed whenever the run resumes: when nothing blocks it any more (a
* knock-on, a receipt at an index the cursor settled), a fresh checkpoint request replaces it by cursor swap, and its
* publication validates everything again. The completed manifest and the old receipt stay as they are. Null when it
* still blocks, or after `CHECKPOINT_REVIVAL_LIMIT` revivals in this invocation (the next invocation re-assesses).
diff --git a/test/persistence-sync-failures.serial.test.ts b/test/persistence-sync-failures.serial.test.ts
index b12482aaf4..1f835cff3f 100644
--- a/test/persistence-sync-failures.serial.test.ts
+++ b/test/persistence-sync-failures.serial.test.ts
@@ -346,12 +346,16 @@ test('explicit retry leaves a frozen terminal cursor untouched while queued work
topologyGeneration: row.topology_generation, principal: row.authority.principal, authority: row.authority,
callerIntent: { ...row.intent, runId: 'another-active-run' }, intent: { ...row.intent, runId: 'another-active-run' } });
writeFileSync(join(f.root, 'bad.md'), 'Repaired useful source content.\n'); commit(f.root);
- expect(await performManagedSync(engine, { ...options, retryFailed: true })).toEqual(blocked);
+ // #6643: the retry no longer returns the old blocked result silently; it waits, naming the request it waits for.
+ const waiting = (state: string, recovery: boolean) => ({ status: 'partial', reason: 'writer_pending', runId: blocked.runId,
+ retryWait: { request_id: active.request_id, slug: row.slug, state, recovery } });
+ expect(await performManagedSync(engine, { ...options, retryFailed: true })).toMatchObject(waiting('queued', false));
expect((await engine.executeRaw<{ run: string }>("SELECT completed_keys->0->>'runId' AS run FROM op_checkpoints WHERE op='managed-sync' AND completed_keys->0->>'sourceId'=$1", [f.id]))[0].run).toBe(blocked.runId!);
const claimed = await claimNextWrite(engine, localHostId()); expect(claimed?.id).toBe(active.id);
- expect(await performManagedSync(engine, { ...options, retryFailed: true })).toEqual(blocked);
+ expect(await performManagedSync(engine, { ...options, retryFailed: true })).toMatchObject(waiting('running', false));
await markRecovering(engine, claimed!, 'Synthetic recovering fixture');
- expect(await performManagedSync(engine, { ...options, retryFailed: true })).toEqual(blocked);
+ expect(await performManagedSync(engine, { ...options, retryFailed: true })).toMatchObject(waiting('recovering', false));
+ expect((await engine.executeRaw<{ run: string }>("SELECT completed_keys->0->>'runId' AS run FROM op_checkpoints WHERE op='managed-sync' AND completed_keys->0->>'sourceId'=$1", [f.id]))[0].run).toBe(blocked.runId!);
await engine.transaction(tx => completeWrite(tx, claimed!, 'cancelled', {}, { code: 'storage_error', message: 'Fixture cleanup' }));
expect((await performManagedSync(engine, { ...options, retryFailed: true })).status).toBe('first_sync');
}