Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Deactivate and migrate name the command that finishes a stopped expired-archive purge now

garrytan9f246206869c
diff --git a/src/core/persistence/deactivation.ts b/src/core/persistence/deactivation.ts
index 83ab2bc41b..8b4e7f4fc9 100644
--- a/src/core/persistence/deactivation.ts
+++ b/src/core/persistence/deactivation.ts
@@ -119,7 +119,7 @@ export async function deactivationBlockers(engine: BrainEngine): Promise<Deactiv
for (const t of topology) blockers.push({ kind: 'topology_recovery', id: t.id, source_id: t.source_id,
detail: !t.admission ? `${t.operation} for ${t.source_id} is recovering`
: `${t.automatic ? 'automatic expired-archive purge' : t.operation} of ${t.source_id} (request ${t.request_id}) stopped before it finished`,
- exit: t.admission && t.automatic ? `the next automatic expired-archive purge finishes it (gbrain sources writer status --source ${t.source_id} --json lists the request), then rerun deactivate`
+ exit: t.admission && t.automatic ? `the next automatic expired-archive purge finishes it, or gbrain sources purge with no source id finishes it now (gbrain sources writer status --source ${t.source_id} --json lists the request), then rerun deactivate`
: t.admission ? `ask the user whether to finish it, because finishing deletes the rest of ${t.source_id}'s pages: to finish, rerun the same gbrain sources ${t.operation} command with all its original flags and --request-id ${t.request_id} (an automatic expired-archive purge finishes on its next run); to keep what is left, any other lifecycle change to the source (gbrain sources restore of an archived source, or archive then restore) abandons the request; then rerun deactivate`
: `gbrain sources writer status ${t.source_id} --json, then let the owner finish recovery` });
// GBRA-130 A-15: only work that can still change blocks, as activation checks; terminal failures are failedEffectHistory's.
diff --git a/src/core/persistence/graduation-drain.ts b/src/core/persistence/graduation-drain.ts
index 9a77a2d6f0..33fba12cfe 100644
--- a/src/core/persistence/graduation-drain.ts
+++ b/src/core/persistence/graduation-drain.ts
@@ -62,7 +62,7 @@ export async function graduationBlockers(source: BrainEngine, hostId: string): P
"SELECT id::text AS id, operation, source_id, request_id::text AS request_id, (state = 'recovering' AND recovery IS NULL) AS admission, COALESCE(outcome->>'expired_only', 'false') = 'true' AS automatic FROM persistence_topology_changes WHERE state = 'recovering' OR recovery IS NOT NULL ORDER BY created_at");
for (const t of topology) {
blockers.push({ kind: 'topology_recovery', id: t.id, detail: t.admission && t.automatic
- ? `automatic expired-archive purge of ${t.source_id} (request ${t.request_id}) stopped before it finished; the next automatic expired-archive purge finishes it`
+ ? `automatic expired-archive purge of ${t.source_id} (request ${t.request_id}) stopped before it finished; the next automatic expired-archive purge finishes it, or gbrain sources purge with no source id finishes it now`
: t.admission
? `${t.operation} of ${t.source_id} (request ${t.request_id}) stopped before it finished; ask the user whether to finish it (rerun the same command with all its original flags and --request-id ${t.request_id}, which deletes the rest of its pages) or keep what is left (any other lifecycle change to the source, such as a restore, abandons the request)`
: `${t.operation} for ${t.source_id} is recovering`,
diff --git a/test/source-retire-incarnation.test.ts b/test/source-retire-incarnation.test.ts
index 64790779a6..b73bae62a8 100644
--- a/test/source-retire-incarnation.test.ts
+++ b/test/source-retire-incarnation.test.ts
@@ -186,10 +186,11 @@ test('a stopped automatic expired-archive purge is left to the next automatic ru
const deactivate = (await deactivationBlockers(engine)).find(b => b.kind === 'topology_recovery');
expect(deactivate?.detail).toContain(`automatic expired-archive purge of ${source} (request ${requestId})`);
expect(deactivate?.exit).toMatch(/^the next automatic expired-archive purge finishes it/);
+ expect(deactivate?.exit).toContain('or gbrain sources purge with no source id finishes it now');
expect(deactivate?.exit).not.toContain('ask the user');
const graduation = (await graduationBlockers(engine, localHostId())).find(b => b.kind === 'topology_recovery');
expect(graduation).toMatchObject({ needsUser: false, argv: ['gbrain', 'sources', 'writer', 'status', source, '--json'] });
- expect(graduation?.detail).toContain('the next automatic expired-archive purge finishes it');
+ expect(graduation?.detail).toContain('the next automatic expired-archive purge finishes it, or gbrain sources purge with no source id finishes it now');
expect(await runManagedSourceLifecycle(engine, { operation: 'purge', sourceId: source, confirmDestructive: true, expiredOnly: true, expectedIncarnation: first })).toMatchObject({ state: 'committed' });
expect(await change(requestId)).toMatchObject({ state: 'failed' });
expect((await deactivationBlockers(engine)).filter(b => b.kind === 'topology_recovery')).toEqual([]);