Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

persistence: the group recovery route fires recovery_interruption_charged between its charge and recovering mark; lp-c pins one publication per claim

garrytan6c8dc3b14aa5
diff --git a/src/core/persistence/group-publish.ts b/src/core/persistence/group-publish.ts
index a2efaf453a..1324d77e41 100644
--- a/src/core/persistence/group-publish.ts
+++ b/src/core/persistence/group-publish.ts
@@ -412,6 +412,7 @@ export async function publishGroup(engine: BrainEngine, rows: WriteRequest[], pr
for (const { row } of recorded.values()) {
try {
const charged = await chargedInterruption(engine, row, error);
+ if (charged) await faultPoint('persistence:recovery_interruption_charged', { requestId: row.request_id, writeId: row.id, sourceId: row.source_id, operation: row.operation });
const failure = charged?.failure ? withAttempt(charged.failure, 'publication') : undefined;
await markRecovering(engine, row, failure ? 'publication_failed' : 'publication_not_started', failure);
const recovered = await recoverPublication(engine, row.id, hostId, true, failure, true);
diff --git a/test/pathological/lp-c-publication-ceiling-retry.test.ts b/test/pathological/lp-c-publication-ceiling-retry.test.ts
index 27012d03de..823bd9501e 100644
--- a/test/pathological/lp-c-publication-ceiling-retry.test.ts
+++ b/test/pathological/lp-c-publication-ceiling-retry.test.ts
@@ -69,7 +69,7 @@ for (const { backend, databaseUrl } of pathologicalArms()) describe(`[${backend}
/** Every publication of claims `overruns(k)` parks past the ceiling and then fails as a discarded connection. */
function overrun(requestId: string, overruns: (claim: number) => boolean) {
- const seen = { claims: 0, transient: [] as number[], preparation: [] as number[] };
+ const seen = { claims: 0, publications: 0, transient: [] as number[], preparation: [] as number[] };
installFaultHook(async (point, detail) => {
if (detail.requestId !== requestId) return;
if (point === 'consumer:preparing') {
@@ -80,10 +80,13 @@ for (const { backend, databaseUrl } of pathologicalArms()) describe(`[${backend}
return;
}
if (point === 'persistence:interruption_charged' || point === 'persistence:recovery_interruption_charged') {
- await engine.executeRaw('UPDATE persistence_requests SET next_attempt_at=now() WHERE request_id=$1::uuid', [requestId]).catch(() => undefined);
+ // Only a released row: one still held (the recovery route charges before it requeues) keeps its backoff, which the
+ // owner's reclaim of a row it released itself must honour.
+ await engine.executeRaw("UPDATE persistence_requests SET next_attempt_at=now() WHERE request_id=$1::uuid AND state='queued'", [requestId]).catch(() => undefined);
return;
}
if (point === 'publication:before_commit' && seen.claims <= GUARD && overruns(seen.claims)) {
+ seen.publications++;
await new Promise(resolve => setTimeout(resolve, PARK_MS));
throw discarded();
}
@@ -115,6 +118,8 @@ for (const { backend, databaseUrl } of pathologicalArms()) describe(`[${backend}
const outcome = await call({ slug, content: page(`Overrun ${n}`), request_id: requestId }).catch(error => error as { code?: string });
installFaultHook(undefined);
expect(seen.claims).toBe(6);
+ // One publication per claim: on Postgres a cancelled group of one is never published again under the same claim.
+ expect(seen.publications).toBe(6);
expect((outcome as { code?: string }).code).toBe('write_interrupted');
expect(seen.transient).toEqual([0, 1, 2, 3, 4, 5]);
expect(seen.preparation).toEqual([0, 0, 0, 0, 0, 0]);