Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

chore(purge): purge exit 3 uses CONFIRMATION_REQUIRED_EXIT_CODE; purge ops in the coverage ledger; purge and trust backfill in the receipt census

garrytan4e43f1bb197a
diff --git a/src/commands/forget-purge.ts b/src/commands/forget-purge.ts
index 7dd61f53fe..0fdb86cc63 100644
--- a/src/commands/forget-purge.ts
+++ b/src/commands/forget-purge.ts
@@ -21,6 +21,7 @@ import { loadConfig, isThinClient } from '../core/config.ts';
import { opError } from '../core/ops/contract.ts';
import { isInteractive, readLine } from '../core/interaction.ts';
import { setCliExitVerdict } from '../core/cli-force-exit.ts';
+import { CONFIRMATION_REQUIRED_EXIT_CODE } from '../core/exit-codes.ts';
import { resolveSourceId } from '../core/source-resolver.ts';
export const PURGE_FAMILY_HELP = `Purge family (remove content from live stores; never physical erasure):
@@ -138,7 +139,7 @@ export async function runForgetPurge(engine: BrainEngine | (() => Promise<BrainE
const answer = io.readToken ? await io.readToken(prompt) : await readLine({ prompt, output: process.stderr }).then(r => r.kind === 'line' ? r.text : null);
if (answer === null || answer.trim() !== token) {
process.stderr.write('Not purged.\n');
- setCliExitVerdict(3);
+ setCliExitVerdict(CONFIRMATION_REQUIRED_EXIT_CODE);
return;
}
} else if (!args.includes('--yes') || !requestId) {
@@ -155,7 +156,7 @@ export async function runForgetPurge(engine: BrainEngine | (() => Promise<BrainE
if (!await reportPersistenceCliError(error, json)) throw error;
// Not confirmed: 3 (ask the user). A pending write blocks the sweep: 75 (retry later with the same request id).
const code = (error as { canonical?: string; code?: string }).canonical ?? (error as { code?: string }).code;
- if (code === 'confirmation_required') setCliExitVerdict(3);
+ if (code === 'confirmation_required') setCliExitVerdict(CONFIRMATION_REQUIRED_EXIT_CODE);
else if (code === 'purge_blocked_pending_recovery') setCliExitVerdict(75);
}
}
diff --git a/test/operations-coverage-ledger.test.ts b/test/operations-coverage-ledger.test.ts
index 645ec48b79..c6517f40ae 100644
--- a/test/operations-coverage-ledger.test.ts
+++ b/test/operations-coverage-ledger.test.ts
@@ -40,6 +40,9 @@ const LEDGER: Record<string, string> = {
list_pages: 'test/list-pages-truncation.test.ts',
restore_page: 'test/pages-source-scoping-4329.test.ts',
purge_deleted_pages: 'test/operations-trust-boundary.test.ts',
+ purge_fact: 'test/purge-fact.test.ts',
+ list_page_purges: 'test/page-purge.test.ts',
+ unpurge_page: 'test/page-purge.test.ts',
capture: 'test/capture-op.test.ts',
edit_page: 'test/edit-page.test.ts',
get_write_request: 'test/persistence-receipt-operations.test.ts',
diff --git a/test/receipt-coverage.test.ts b/test/receipt-coverage.test.ts
index 573ea0a946..c6834a901f 100644
--- a/test/receipt-coverage.test.ts
+++ b/test/receipt-coverage.test.ts
@@ -31,6 +31,7 @@ const RECEIPT_COVERAGE: Record<string, Coverage> = {
'src/core/persistence/coordinator.ts': { sites: 1, receipted: 'the publication of an admitted request: every maintenance intent (conversation facts, fence reconcile, deleted-page expiry, takes reextract, take reprojection) applies here' },
'src/core/persistence/group-publish.ts': { sites: 1, receipted: 'the grouped publication of admitted requests; each member is the attributed actor' },
'src/core/persistence/memory-mutations.ts': { sites: 1, receipted: 'forget/withdraw: admitWriteInTransaction admits the request in the same transaction' },
+ 'src/core/facts/purge.ts': { sites: 1, receipted: 'purge_fact: admitWriteInTransaction admits the request and completeWrite records its terminal receipt in the same transaction' },
'src/core/shared-skills/publication.ts': { sites: 1, receipted: 'shared-skill revision pruning inside an admitted skill publication' },
'src/core/persistence/source-lifecycle.ts': { sites: 1, receipted: 'source add/claim/remove under a persistence_topology_changes receipt' },
'src/core/persistence/topology-recovery.ts': { sites: 1, receipted: 'topology recovery under its persistence_topology_changes receipt' },
@@ -40,6 +41,7 @@ const RECEIPT_COVERAGE: Record<string, Coverage> = {
'src/core/repair/timeline-comments.ts': { sites: 1, tables: ['timeline_entries'], todo: 'TODO(receipts): gbrain repair timeline-comments row cleanup should publish per page as a maintenance intent' },
'src/core/mentions/pass.ts': { sites: 1, tables: ['page_aliases'], todo: 'TODO(receipts): derived alias rows should publish per page as a maintenance intent' },
'src/core/bootstrap/verify.ts': { sites: 1, tables: ['facts'], todo: 'TODO(receipts): bootstrap verify deletes its own probe facts without a request; publish the cleanup as a maintenance intent' },
+ 'src/core/trust/backfill.ts': { sites: 1, tables: ['pages', 'facts', 'takes', 'timeline_entries'], todo: 'TODO(receipts): gbrain trust backfill classifies legacy trust_tier/write_origin (no content column) as attributed coordinated maintenance without a request; publish each batch as a maintenance intent' },
'src/core/cycle/concept-publication.ts': { sites: 1, tables: [], other: 'concept provenance links (links is not a guarded table)' },
'src/core/persistence/links-maintenance.ts': { sites: 1, tables: [], other: 'derived links and the pages attendance-blocked stamp (a physical column the guard exempts)' },
'src/core/persistence/database-write.ts': { sites: 1, tables: [], other: 'manual links and chronicle ontology observations (unguarded tables)' },
@@ -50,7 +52,7 @@ const RECEIPT_COVERAGE: Record<string, Coverage> = {
};
/** Facts/takes writers allowed without a receipt this wave, each with its TODO above. */
-const RECEIPT_EXCEPTIONS = new Set(['src/core/bootstrap/verify.ts']);
+const RECEIPT_EXCEPTIONS = new Set(['src/core/bootstrap/verify.ts', 'src/core/trust/backfill.ts']);
const ROOT = join(import.meta.dir, '..');