Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

doctor: atom_retirements_restorable joins the wave lane; regenerate doctor and pages SQL-text goldens (#7013)

garrytanc9efbbfc1272
diff --git a/src/commands/doctor/checks/graph-health.ts b/src/commands/doctor/checks/graph-health.ts
index 4e95f7d7e5..4258ba2dbb 100644
--- a/src/commands/doctor/checks/graph-health.ts
+++ b/src/commands/doctor/checks/graph-health.ts
@@ -345,6 +345,7 @@ export const timelineHistoryEntry: DoctorEntry = {
'stale_embedding_effects',
'google_file_modes',
'google_calendar_readable',
+ 'atom_retirements_restorable',
'extractor_facts_expired',
'conversation_label_facts',
'conversation_outcomes_stale',
diff --git a/test/fixtures/goldens/doctor/json-pglite-degraded.json b/test/fixtures/goldens/doctor/json-pglite-degraded.json
index 5c778dea82..9a821f3a29 100644
--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json
+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json
@@ -1512,6 +1512,24 @@
"name": "google_calendar_readable",
"status": "ok"
},
+ {
+ "category": "brain",
+ "details": {
+ "by_source": [],
+ "count": 0,
+ "docs": "docs/guides/repair.md#atoms-restore",
+ "hold_until": null,
+ "newest_retired_at": null,
+ "oldest_retired_at": null,
+ "origins": 0,
+ "repair": "atoms-restore",
+ "source_ids": []
+ },
+ "elapsed_ms": "<volatile>",
+ "message": "No atom retired by an empty re-extraction is waiting to be restored.",
+ "name": "atom_retirements_restorable",
+ "status": "ok"
+ },
{
"category": "brain",
"details": {
diff --git a/test/fixtures/goldens/doctor/json-pglite-fresh.json b/test/fixtures/goldens/doctor/json-pglite-fresh.json
index d9eaafa642..852583fe18 100644
--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json
+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json
@@ -1568,6 +1568,24 @@
"name": "google_calendar_readable",
"status": "ok"
},
+ {
+ "category": "brain",
+ "details": {
+ "by_source": [],
+ "count": 0,
+ "docs": "docs/guides/repair.md#atoms-restore",
+ "hold_until": null,
+ "newest_retired_at": null,
+ "oldest_retired_at": null,
+ "origins": 0,
+ "repair": "atoms-restore",
+ "source_ids": []
+ },
+ "elapsed_ms": "<volatile>",
+ "message": "No atom retired by an empty re-extraction is waiting to be restored.",
+ "name": "atom_retirements_restorable",
+ "status": "ok"
+ },
{
"category": "brain",
"details": {
diff --git a/test/fixtures/goldens/doctor/registry-build-checks.json b/test/fixtures/goldens/doctor/registry-build-checks.json
index 617d31a4cb..359c8ec8bb 100644
--- a/test/fixtures/goldens/doctor/registry-build-checks.json
+++ b/test/fixtures/goldens/doctor/registry-build-checks.json
@@ -529,6 +529,10 @@
"category": "ops",
"name": "google_calendar_readable"
},
+ {
+ "category": "brain",
+ "name": "atom_retirements_restorable"
+ },
{
"category": "brain",
"name": "extractor_facts_expired"
diff --git a/test/fixtures/goldens/sql-text/pages.json b/test/fixtures/goldens/sql-text/pages.json
index 1a28f40fe5..58b5ab6767 100644
--- a/test/fixtures/goldens/sql-text/pages.json
+++ b/test/fixtures/goldens/sql-text/pages.json
@@ -789,8 +789,8 @@
"params": [
"number"
],
- "sql": "DELETE FROM pages WHERE deleted_at IS NOT NULL AND deleted_at < now() - ($1 || ' hours')::interval -- #6729: the old page of an open rename-identity downgrade waits for its disposition (identityDowngradePurgeHold). AND NOT EXISTS (SELECT 1 FROM op_checkpoints dg WHERE dg.op = 'sync-identity-downgrade' AND dg.fingerprint = pages.id::text AND dg.completed_keys->0->>'disposition' IS NULL AND pages.deleted_at = (dg.completed_keys->0->>'old_deleted_at')::timestamptz) RETURNING slug, source_id",
- "textSha256": "3c28a0ea4ebbe757ed585c56f918dd4f3f98afbda412a509c1bdd9cb5d34c8c5"
+ "sql": "DELETE FROM pages WHERE deleted_at IS NOT NULL AND deleted_at < now() - ($1 || ' hours')::interval -- #6729: the old page of an open rename-identity downgrade waits for its disposition (identityDowngradePurgeHold). AND NOT EXISTS (SELECT 1 FROM op_checkpoints dg WHERE dg.op = 'sync-identity-downgrade' AND dg.fingerprint = pages.id::text AND dg.completed_keys->0->>'disposition' IS NULL AND pages.deleted_at = (dg.completed_keys->0->>'old_deleted_at')::timestamptz) -- #7013: a restorable re-extraction retirement waits out its hold (atomRetirementPurgeHold). AND NOT (pages.deleted_at > now() - interval '30 days' AND ((pages.type='atom' AND pages.deleted_at IS NOT NULL AND pages.frontmatter->>'retired_by'='managed-reextract' AND NULLIF(pages.frontmatter->>'imported_from','') IS NULL) AND ((NULLIF(pages.frontmatter->>'source_slug','') IS NOT NULL AND EXISTS (SELECT 1 FROM pages ao WHERE ao.source_id=pages.source_id AND ao.slug=pages.frontmatter->>'source_slug' AND ao.deleted_at IS NULL)) OR (NULLIF(pages.frontmatter->>'source_slug','') IS NULL AND NULLIF(pages.frontmatter->>'source_path','') IS NOT NULL)) AND NOT EXISTS (SELECT 1 FROM pages ar WHERE ar.source_id=pages.source_id AND ar.type='atom' AND ar.deleted_at IS NULL AND NULLIF(ar.frontmatter->>'imported_from','') IS NULL AND ((NULLIF(pages.frontmatter->>'source_slug','') IS NOT NULL AND ar.frontmatter @> jsonb_build_object('source_slug',pages.frontmatter->'source_slug')) OR (NULLIF(pages.frontmatter->>'source_slug','') IS NULL AND ar.frontmatter @> jsonb_build_object('source_path',pages.frontmatter->'source_path'))) AND regexp_replace(COALESCE(ar.frontmatter->>'source_hash',''),'^pending:','')<>regexp_replace(COALESCE(pages.frontmatter->>'source_hash',''),'^pending:','')) AND regexp_replace(COALESCE(pages.frontmatter->>'source_hash',''),'^pending:','')=(SELECT regexp_replace(COALESCE(ag.frontmatter->>'source_hash',''),'^pending:','') FROM pages ag WHERE ag.source_id=pages.source_id AND ag.type='atom' AND ag.deleted_at IS NOT NULL AND ag.frontmatter @> jsonb_build_object('retired_by','managed-reextract') AND NULLIF(ag.frontmatter->>'imported_from','') IS NULL AND ((NULLIF(pages.frontmatter->>'source_slug','') IS NOT NULL AND ag.frontmatter @> jsonb_build_object('source_slug',pages.frontmatter->'source_slug')) OR (NULLIF(pages.frontmatter->>'source_slug','') IS NULL AND ag.frontmatter @> jsonb_build_object('source_path',pages.frontmatter->'source_path'))) ORDER BY ag.frontmatter->>'retired_at' DESC NULLS LAST, ag.id DESC LIMIT 1))) RETURNING slug, source_id",
+ "textSha256": "0d8c2215c423232c2e41fa9ef0e32071bf140e85591d43f6a824de834ec9c504"
},
{
"event": "commit",
@@ -803,8 +803,8 @@
"params": [
"number"
],
- "sql": "SELECT slug, deleted_at FROM pages WHERE deleted_at IS NOT NULL AND deleted_at < now() - ($1 || ' hours')::interval AND NOT EXISTS (SELECT 1 FROM op_checkpoints dg WHERE dg.op = 'sync-identity-downgrade' AND dg.fingerprint = pages.id::text AND dg.completed_keys->0->>'disposition' IS NULL AND pages.deleted_at = (dg.completed_keys->0->>'old_deleted_at')::timestamptz) ORDER BY deleted_at ASC, slug ASC",
- "textSha256": "6d9afbd5ee5480399ddcd577977b106ccf5005eee1be7b84044daebff995d3e2"
+ "sql": "SELECT slug, deleted_at FROM pages WHERE deleted_at IS NOT NULL AND deleted_at < now() - ($1 || ' hours')::interval AND NOT EXISTS (SELECT 1 FROM op_checkpoints dg WHERE dg.op = 'sync-identity-downgrade' AND dg.fingerprint = pages.id::text AND dg.completed_keys->0->>'disposition' IS NULL AND pages.deleted_at = (dg.completed_keys->0->>'old_deleted_at')::timestamptz) AND NOT (pages.deleted_at > now() - interval '30 days' AND ((pages.type='atom' AND pages.deleted_at IS NOT NULL AND pages.frontmatter->>'retired_by'='managed-reextract' AND NULLIF(pages.frontmatter->>'imported_from','') IS NULL) AND ((NULLIF(pages.frontmatter->>'source_slug','') IS NOT NULL AND EXISTS (SELECT 1 FROM pages ao WHERE ao.source_id=pages.source_id AND ao.slug=pages.frontmatter->>'source_slug' AND ao.deleted_at IS NULL)) OR (NULLIF(pages.frontmatter->>'source_slug','') IS NULL AND NULLIF(pages.frontmatter->>'source_path','') IS NOT NULL)) AND NOT EXISTS (SELECT 1 FROM pages ar WHERE ar.source_id=pages.source_id AND ar.type='atom' AND ar.deleted_at IS NULL AND NULLIF(ar.frontmatter->>'imported_from','') IS NULL AND ((NULLIF(pages.frontmatter->>'source_slug','') IS NOT NULL AND ar.frontmatter @> jsonb_build_object('source_slug',pages.frontmatter->'source_slug')) OR (NULLIF(pages.frontmatter->>'source_slug','') IS NULL AND ar.frontmatter @> jsonb_build_object('source_path',pages.frontmatter->'source_path'))) AND regexp_replace(COALESCE(ar.frontmatter->>'source_hash',''),'^pending:','')<>regexp_replace(COALESCE(pages.frontmatter->>'source_hash',''),'^pending:','')) AND regexp_replace(COALESCE(pages.frontmatter->>'source_hash',''),'^pending:','')=(SELECT regexp_replace(COALESCE(ag.frontmatter->>'source_hash',''),'^pending:','') FROM pages ag WHERE ag.source_id=pages.source_id AND ag.type='atom' AND ag.deleted_at IS NOT NULL AND ag.frontmatter @> jsonb_build_object('retired_by','managed-reextract') AND NULLIF(ag.frontmatter->>'imported_from','') IS NULL AND ((NULLIF(pages.frontmatter->>'source_slug','') IS NOT NULL AND ag.frontmatter @> jsonb_build_object('source_slug',pages.frontmatter->'source_slug')) OR (NULLIF(pages.frontmatter->>'source_slug','') IS NULL AND ag.frontmatter @> jsonb_build_object('source_path',pages.frontmatter->'source_path'))) ORDER BY ag.frontmatter->>'retired_at' DESC NULLS LAST, ag.id DESC LIMIT 1))) ORDER BY deleted_at ASC, slug ASC",
+ "textSha256": "cc27694a76f120933c3771d45f1d6b506bdc58a9a1644db9c560fc27d4cdc55b"
}
]
},
diff --git a/test/repair-explicit-only.test.ts b/test/repair-explicit-only.test.ts
index fc38ae5d68..09bf51035e 100644
--- a/test/repair-explicit-only.test.ts
+++ b/test/repair-explicit-only.test.ts
@@ -24,7 +24,7 @@ import { REPAIR_HELP, parseRepairArgs, runRepairCommand } from '../src/commands/
import { _resetCliExitVerdictForTests, currentExitCode } from '../src/core/cli-force-exit.ts';
import { withEnv } from './helpers/with-env.ts';
-const EXPLICIT: RepairKind[] = ['accepted-takes', 'google-file-modes', 'stale-atoms', 'extractor-facts', 'conversation-labels', 'captured-facts', 'loop-facts', 'ontology-facts', 'facts-rehome', 'orphan-children', 'failed-writes', 'split-facts', 'frontmatter', 'timeline-comments', 'managed-sync-orphans', 'content-receipt-root', 'frontmatter-keys', 'file-drift', 'stuck-recovery', 'ghost-pages', 'origin-twins', 'receipt-compaction', 'aliases', 'rename-identity', 'overwritten-edits', 'missing-tables', 'url-clone-fences'];
+const EXPLICIT: RepairKind[] = ['accepted-takes', 'google-file-modes', 'stale-atoms', 'atoms-restore', 'extractor-facts', 'conversation-labels', 'captured-facts', 'loop-facts', 'ontology-facts', 'facts-rehome', 'orphan-children', 'failed-writes', 'split-facts', 'frontmatter', 'timeline-comments', 'managed-sync-orphans', 'content-receipt-root', 'frontmatter-keys', 'file-drift', 'stuck-recovery', 'ghost-pages', 'origin-twins', 'receipt-compaction', 'aliases', 'rename-identity', 'overwritten-edits', 'missing-tables', 'url-clone-fences'];
let engine: PGLiteEngine;
const home = mkdtempSync(join(tmpdir(), 'gbrain-repair-explicit-'));
@@ -109,7 +109,7 @@ describe('surfaces that list instead of run', () => {
expect(out.explicit_kinds).toEqual(EXPLICIT.map(kind => ({ kind, code: 'explicit_kind_required', preview_command: `gbrain repair ${kind}`,
docs: 'docs/guides/repair.md#explicit-only-repair-kinds' })));
}
- expect(await captured(['--all'])).toContain('Explicit-only kinds (not run without their name; preview each): gbrain repair accepted-takes; gbrain repair google-file-modes; gbrain repair stale-atoms; gbrain repair extractor-facts; gbrain repair conversation-labels; gbrain repair captured-facts; gbrain repair loop-facts');
+ expect(await captured(['--all'])).toContain('Explicit-only kinds (not run without their name; preview each): gbrain repair accepted-takes; gbrain repair google-file-modes; gbrain repair stale-atoms; gbrain repair atoms-restore; gbrain repair extractor-facts; gbrain repair conversation-labels; gbrain repair captured-facts; gbrain repair loop-facts');
});
test('gbrain repair --all --apply exits 0 when explicit kinds are the only ones left', async () => {