Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test: register loop-facts / loop_facts_drift in the explicit-kind pins, valid_until allow-list, e2e map and doctor goldens (#5869)
garrytan0d6531bcc4ec
diff --git a/scripts/e2e-test-map.ts b/scripts/e2e-test-map.tsindex 05a80d399d..c2cd1abd4f 100644--- a/scripts/e2e-test-map.ts+++ b/scripts/e2e-test-map.ts@@ -27,7 +27,12 @@ export const E2E_TEST_MAP: Record<string, string[]> = {// GBRA-35 E10: the managed connector-source job contract drives these writers on an unbound connector source."test/helpers/managed-connector-job-contract.ts": ["test/e2e/managed-connector-job-contract.test.ts"],"src/core/persistence/atom-maintenance.ts": ["test/e2e/managed-connector-job-contract.test.ts"],- "src/core/ops/loops.ts": ["test/e2e/managed-connector-job-contract.test.ts"],+ "src/core/ops/loops.ts": ["test/e2e/managed-connector-job-contract.test.ts", "test/e2e/loops-close-fact-postgres.test.ts"],+ "src/core/persistence/loop-fact-retirement.ts": ["test/e2e/loops-close-fact-postgres.test.ts", "test/e2e/managed-connector-job-contract.test.ts"],+ "src/core/repair/loop-facts.ts": ["test/e2e/loops-close-fact-postgres.test.ts"],+ "src/core/google/loop-catchup.ts": ["test/e2e/google-loops-recovery-postgres.test.ts"],+ "src/core/google/loop-detect.ts": ["test/e2e/google-loops-recovery-postgres.test.ts"],+ "src/core/cycle/connector-extract.ts": ["test/e2e/connector-cycle-extract-postgres.test.ts", "test/e2e/managed-connector-job-contract.test.ts"],"src/core/minions/handlers/autopilot-cycle.ts": ["test/e2e/managed-connector-job-contract.test.ts"],// Fix wave 4, Lane D: the apply-migrations orchestration lease (#5693), source deletes and// orphan bindings (#5732), and deactivate racing admission (#5455).@@ -155,7 +160,7 @@ export const E2E_TEST_MAP: Record<string, string[]> = {"test/e2e/openclaw-plugin-load-real.test.ts",],// dream.ts is a thin alias over runCycle in cycle.ts.- "src/core/cycle.ts": ["test/e2e/cycle.test.ts", "test/e2e/dream.test.ts", "test/e2e/managed-phase-matrix.test.ts", "test/e2e/managed-connector-job-contract.test.ts"],+ "src/core/cycle.ts": ["test/e2e/cycle.test.ts", "test/e2e/dream.test.ts", "test/e2e/managed-phase-matrix.test.ts", "test/e2e/managed-connector-job-contract.test.ts", "test/e2e/connector-cycle-extract-postgres.test.ts"],"src/core/cycle/phase-*.ts": ["test/e2e/managed-phase-matrix.test.ts"],// Multi-source sync writes share the per-source bookmark anchor."src/core/sync.ts": ["test/e2e/sync.test.ts", "test/e2e/multi-source.test.ts", "test/e2e/sync-reconcile-postgres.test.ts", "test/e2e/sync-lock-overlap-postgres.test.ts"],@@ -569,7 +574,7 @@ export const E2E_TEST_MAP: Record<string, string[]> = {"src/core/facts/backstop.ts": ["test/e2e/managed-facts-backstop.test.ts", "test/e2e/facts-worker-config.test.ts", "test/e2e/managed-facts-embedding.test.ts", "test/e2e/managed-facts-compaction.test.ts", "test/e2e/legacy-fact-extraction-dedup-postgres.test.ts"],"src/core/facts/extract.ts": ["test/e2e/managed-facts-embedding.test.ts"],"src/core/github-source.ts": ["test/e2e/managed-connector-routing.test.ts", "test/e2e/managed-connector-retry.test.ts", "test/e2e/managed-connector-fencing.test.ts", "test/e2e/managed-connector-recovery.test.ts", "test/e2e/connector-holds.test.ts"],- "src/core/google/google-source.ts": ["test/e2e/managed-connector-routing.test.ts", "test/e2e/managed-connector-retry.test.ts", "test/e2e/managed-connector-fencing.test.ts", "test/e2e/managed-connector-recovery.test.ts", "test/e2e/google-attachments-postgres.test.ts", "test/e2e/connector-holds.test.ts", "test/e2e/managed-connector-job-contract.test.ts"],+ "src/core/google/google-source.ts": ["test/e2e/managed-connector-routing.test.ts", "test/e2e/managed-connector-retry.test.ts", "test/e2e/managed-connector-fencing.test.ts", "test/e2e/managed-connector-recovery.test.ts", "test/e2e/google-attachments-postgres.test.ts", "test/e2e/connector-holds.test.ts", "test/e2e/managed-connector-job-contract.test.ts", "test/e2e/google-loops-recovery-postgres.test.ts"],"src/core/google/attachment-receipts.ts": ["test/e2e/google-attachments-postgres.test.ts"],"src/core/google/attachment-backfill.ts": ["test/e2e/google-attachments-postgres.test.ts"],"src/core/persistence/connector-google-receipts.ts": ["test/e2e/google-attachments-postgres.test.ts"],diff --git a/test/eval-contradictions/no-valid-until-write.test.ts b/test/eval-contradictions/no-valid-until-write.test.tsindex 14fe589cb6..636f0c1a7b 100644--- a/test/eval-contradictions/no-valid-until-write.test.ts+++ b/test/eval-contradictions/no-valid-until-write.test.ts@@ -58,6 +58,10 @@ import { join } from 'node:path';// contradiction PROPOSAL only when the user runs `gbrain decide proposals// accept|undo <id>` (local CLI); the sweep and the inline fact write path// never call it, so a probe still never mutates (auto-supersession.ts:4).+// - persistence/loop-fact-retirement.ts (#5869) — retires a commitment fact+// only when its loop is closed through `loops_close` or `gbrain repair+// loop-facts` (expired_at + valid_until with the struck fence row); the+// contradiction sweep and probes never call it.const VALID_UNTIL_WRITE_ALLOWLIST: ReadonlySet<string> = new Set(['src/core/cycle/extract-facts.ts','src/core/cycle/phases/consolidate.ts',@@ -66,6 +70,7 @@ const VALID_UNTIL_WRITE_ALLOWLIST: ReadonlySet<string> = new Set(['src/core/facts/withdrawal.ts','src/core/facts/withdrawal-schema.ts','src/core/persistence/canonical-projections.ts',+ 'src/core/persistence/loop-fact-retirement.ts','src/core/persistence/prepared-maintenance.ts','src/core/postgres-engine.ts','src/core/pglite-engine.ts',diff --git a/test/fix-wave-5-integration.test.ts b/test/fix-wave-5-integration.test.tsindex 6552fe9a2b..5032355a13 100644--- a/test/fix-wave-5-integration.test.ts+++ b/test/fix-wave-5-integration.test.ts@@ -191,7 +191,7 @@ for (const backend of testBackends()) {const liveAtoms = async () => (await engine.executeRaw<{ n: number }>("SELECT count(*)::int AS n FROM pages WHERE type='atom' AND deleted_at IS NULL"))[0].n;const activeFacts = async () => (await engine.executeRaw<{ n: number }>("SELECT count(*)::int AS n FROM facts WHERE source_markdown_slug='conversations/expired' AND expired_at IS NULL"))[0].n;const untouched = async () => { expect(await liveAtoms()).toBe(30); expect(await activeFacts()).toBe(0); };- const previews = { 'google-file-modes': 'gbrain repair google-file-modes', 'stale-atoms': 'gbrain repair stale-atoms', 'extractor-facts': 'gbrain repair extractor-facts' };+ const previews = { 'google-file-modes': 'gbrain repair google-file-modes', 'stale-atoms': 'gbrain repair stale-atoms', 'extractor-facts': 'gbrain repair extractor-facts', 'loop-facts': 'gbrain repair loop-facts' };// The post-upgrade banner names both findings with the kind's read-only preview.const banner = await postUpgradeRecoveryBanner(engine, 'host');diff --git a/test/fixtures/goldens/doctor/json-pglite-degraded.json b/test/fixtures/goldens/doctor/json-pglite-degraded.jsonindex 060c614c93..430c97ca6a 100644--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json@@ -720,6 +720,17 @@"name": "extractor_facts_expired","status": "ok"},+ {+ "category": "brain",+ "details": {+ "docs": "docs/guides/repair.md#explicit-only-repair-kinds",+ "drifted": 0,+ "repair": "loop-facts"+ },+ "message": "Every closed commitment loop has its fact retired.",+ "name": "loop_facts_drift",+ "status": "ok"+ },{"category": "brain","message": "Sampled 0 pages; no bare-tweet phrases or external links.",diff --git a/test/fixtures/goldens/doctor/json-pglite-fresh.json b/test/fixtures/goldens/doctor/json-pglite-fresh.jsonindex 43c6ad0cad..cb5629fff1 100644--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json@@ -720,6 +720,17 @@"name": "extractor_facts_expired","status": "ok"},+ {+ "category": "brain",+ "details": {+ "docs": "docs/guides/repair.md#explicit-only-repair-kinds",+ "drifted": 0,+ "repair": "loop-facts"+ },+ "message": "Every closed commitment loop has its fact retired.",+ "name": "loop_facts_drift",+ "status": "ok"+ },{"category": "brain","message": "Sampled 0 pages; no bare-tweet phrases or external links.",diff --git a/test/fixtures/goldens/doctor/json-postgres-fresh.json b/test/fixtures/goldens/doctor/json-postgres-fresh.jsonindex 59337fde0d..0223ece8f4 100644--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json@@ -730,6 +730,17 @@"name": "extractor_facts_expired","status": "ok"},+ {+ "category": "brain",+ "details": {+ "docs": "docs/guides/repair.md#explicit-only-repair-kinds",+ "drifted": 0,+ "repair": "loop-facts"+ },+ "message": "Every closed commitment loop has its fact retired.",+ "name": "loop_facts_drift",+ "status": "ok"+ },{"category": "brain","message": "Sampled 0 pages; no bare-tweet phrases or external links.",diff --git a/test/fixtures/goldens/doctor/registry-build-checks.json b/test/fixtures/goldens/doctor/registry-build-checks.jsonindex b40fae8128..36e7970e0b 100644--- a/test/fixtures/goldens/doctor/registry-build-checks.json+++ b/test/fixtures/goldens/doctor/registry-build-checks.json@@ -389,6 +389,10 @@"category": "brain","name": "extractor_facts_expired"},+ {+ "category": "brain",+ "name": "loop_facts_drift"+ },{"category": "brain","name": "integrity"diff --git a/test/repair-explicit-only.test.ts b/test/repair-explicit-only.test.tsindex a42e5f6229..e26c36c54a 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[] = ['google-file-modes', 'stale-atoms', 'extractor-facts'];+const EXPLICIT: RepairKind[] = ['google-file-modes', 'stale-atoms', 'extractor-facts', 'loop-facts'];let engine: PGLiteEngine;const home = mkdtempSync(join(tmpdir(), 'gbrain-repair-explicit-'));@@ -62,7 +62,7 @@ function withExplicitCheck<T>(run: (spec: WaveCheckSpec) => T): T {}describe('registry', () => {- test('google-file-modes, stale-atoms and extractor-facts are registered explicit-only and excluded from the --all set', () => {+ test('google-file-modes, stale-atoms, extractor-facts and loop-facts are registered explicit-only and excluded from the --all set', () => {expect(EXPLICIT_REPAIR_REGISTRY.map(spec => spec.kind)).toEqual(EXPLICIT);for (const kind of EXPLICIT) expect(REPAIR_REGISTRY.map(spec => spec.kind)).toContain(kind);expect(AUTO_REPAIR_REGISTRY.some(spec => spec.explicit_only)).toBe(false);@@ -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 google-file-modes; gbrain repair stale-atoms; gbrain repair extractor-facts');+ expect(await captured(['--all'])).toContain('Explicit-only kinds (not run without their name; preview each): gbrain repair google-file-modes; gbrain repair stale-atoms; gbrain repair extractor-facts; gbrain repair loop-facts');});test('gbrain repair --all --apply exits 0 when explicit kinds are the only ones left', async () => {