Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(facts): facts_drain doctor check pushes its literal name; goldens and phase count include facts_drain

garrytan42258427f7af
diff --git a/src/commands/doctor/checks/facts-drain.ts b/src/commands/doctor/checks/facts-drain.ts
index f104f95ce9..04665c7722 100644
--- a/src/commands/doctor/checks/facts-drain.ts
+++ b/src/commands/doctor/checks/facts-drain.ts
@@ -6,7 +6,6 @@
*/
import { FACTS_DRAIN_DOCS, readFactsDrainStatus } from '../../../core/facts/drain.ts';
import type { Check } from '../../doctor.ts';
-import { infoCheck } from '../check-fix.ts';
import { connectedEngine, type DoctorContext, type DoctorEntry } from '../context.ts';
async function runFactsDrainCheck(ctx: DoctorContext): Promise<Check[]> {
@@ -16,15 +15,17 @@ async function runFactsDrainCheck(ctx: DoctorContext): Promise<Check[]> {
...(status.settings ? { enabled: status.settings.enabled, budget_usd: status.settings.budgetUsd, daily_budget_usd: status.settings.dailyBudgetUsd, max_jobs: status.settings.maxJobs } : {}),
docs: FACTS_DRAIN_DOCS,
};
- switch (status.health) {
- case 'not_applicable': return [infoCheck('facts_drain', status.message, 'not_applicable', undefined, details)];
- case 'disabled': return [infoCheck('facts_drain', status.message, 'disabled_by_choice', status.fix, details)];
- case 'deferred':
- case 'no_owner':
- return [{ name: 'facts_drain', status: 'warn', message: status.message, ...(status.fix ? { fix: status.fix } : {}), readiness_state: 'degraded', details }];
- default:
- return [{ name: 'facts_drain', status: 'ok', message: status.message, details }];
+ const fix = status.fix ? { fix: status.fix } : {};
+ const checks: Check[] = [];
+ if (status.health === 'not_applicable' || status.health === 'disabled') {
+ checks.push({ name: 'facts_drain', status: 'ok', message: status.message, severity: 'info',
+ readiness_state: status.health === 'disabled' ? 'disabled_by_choice' : 'not_applicable', ...fix, details });
+ } else if (status.health === 'deferred' || status.health === 'no_owner') {
+ checks.push({ name: 'facts_drain', status: 'warn', message: status.message, readiness_state: 'degraded', ...fix, details });
+ } else {
+ checks.push({ name: 'facts_drain', status: 'ok', message: status.message, details });
}
+ return checks;
}
export const factsDrainEntry: DoctorEntry = { name: 'facts_drain', emits: ['facts_drain'], run: runFactsDrainCheck };
diff --git a/test/fixtures/goldens/doctor/json-pglite-degraded.json b/test/fixtures/goldens/doctor/json-pglite-degraded.json
index 22c4a12451..7eda06d330 100644
--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json
+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json
@@ -1478,6 +1478,27 @@
"severity": "info",
"status": "ok"
},
+ {
+ "category": "brain",
+ "details": {
+ "backlog": {
+ "active": 0,
+ "delayed": 0,
+ "waiting": 0
+ },
+ "budget_usd": 1,
+ "daily_budget_usd": 5,
+ "daily_spent_usd": 0,
+ "docs": "docs/guides/facts-drain.md",
+ "enabled": true,
+ "health": "idle",
+ "last_run": null,
+ "max_jobs": 50
+ },
+ "message": "No facts-absorb jobs are queued (no run recorded yet).",
+ "name": "facts_drain",
+ "status": "ok"
+ },
{
"category": "brain",
"details": {
@@ -1653,7 +1674,7 @@
"category": "meta",
"details": {
"counts": {
- "global": 10,
+ "global": 11,
"mixed": 2,
"source": 12
},
@@ -1669,6 +1690,7 @@
"extract": "source",
"extract_atoms": "source",
"extract_facts": "source",
+ "facts_drain": "global",
"grade_takes": "global",
"lint": "source",
"orphans": "global",
@@ -1684,7 +1706,7 @@
"synthesize_concepts": "global"
}
},
- "message": "Phase taxonomy: 12 source-scoped, 10 brain-global, 2 mixed. Source-safe: [lint, backlinks, sync, extract, extract_facts, extract_atoms, recompute_emotional_weight, consolidate, propose_takes, conversation_facts_backfill, enrich_thin, schema-suggest]. Brain-global: [resolve_symbol_edges, synthesize_concepts, grade_takes, calibration_profile, drift, chronicle, skillopt, embed, orphans, purge]. Mixed: [synthesize, patterns].",
+ "message": "Phase taxonomy: 12 source-scoped, 11 brain-global, 2 mixed. Source-safe: [lint, backlinks, sync, extract, extract_facts, extract_atoms, recompute_emotional_weight, consolidate, propose_takes, conversation_facts_backfill, enrich_thin, schema-suggest]. Brain-global: [resolve_symbol_edges, synthesize_concepts, grade_takes, calibration_profile, drift, chronicle, facts_drain, skillopt, embed, orphans, purge]. Mixed: [synthesize, patterns].",
"name": "cycle_phase_scope",
"status": "ok"
},
diff --git a/test/fixtures/goldens/doctor/json-pglite-fresh.json b/test/fixtures/goldens/doctor/json-pglite-fresh.json
index 153d996111..cf50c1c43f 100644
--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json
+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json
@@ -1566,6 +1566,27 @@
"severity": "info",
"status": "ok"
},
+ {
+ "category": "brain",
+ "details": {
+ "backlog": {
+ "active": 0,
+ "delayed": 0,
+ "waiting": 0
+ },
+ "budget_usd": 1,
+ "daily_budget_usd": 5,
+ "daily_spent_usd": 0,
+ "docs": "docs/guides/facts-drain.md",
+ "enabled": true,
+ "health": "idle",
+ "last_run": null,
+ "max_jobs": 50
+ },
+ "message": "No facts-absorb jobs are queued (no run recorded yet).",
+ "name": "facts_drain",
+ "status": "ok"
+ },
{
"category": "brain",
"details": {
@@ -1729,7 +1750,7 @@
"category": "meta",
"details": {
"counts": {
- "global": 10,
+ "global": 11,
"mixed": 2,
"source": 12
},
@@ -1745,6 +1766,7 @@
"extract": "source",
"extract_atoms": "source",
"extract_facts": "source",
+ "facts_drain": "global",
"grade_takes": "global",
"lint": "source",
"orphans": "global",
@@ -1760,7 +1782,7 @@
"synthesize_concepts": "global"
}
},
- "message": "Phase taxonomy: 12 source-scoped, 10 brain-global, 2 mixed. Source-safe: [lint, backlinks, sync, extract, extract_facts, extract_atoms, recompute_emotional_weight, consolidate, propose_takes, conversation_facts_backfill, enrich_thin, schema-suggest]. Brain-global: [resolve_symbol_edges, synthesize_concepts, grade_takes, calibration_profile, drift, chronicle, skillopt, embed, orphans, purge]. Mixed: [synthesize, patterns].",
+ "message": "Phase taxonomy: 12 source-scoped, 11 brain-global, 2 mixed. Source-safe: [lint, backlinks, sync, extract, extract_facts, extract_atoms, recompute_emotional_weight, consolidate, propose_takes, conversation_facts_backfill, enrich_thin, schema-suggest]. Brain-global: [resolve_symbol_edges, synthesize_concepts, grade_takes, calibration_profile, drift, chronicle, facts_drain, skillopt, embed, orphans, purge]. Mixed: [synthesize, patterns].",
"name": "cycle_phase_scope",
"status": "ok"
},
diff --git a/test/fixtures/goldens/doctor/registry-build-checks.json b/test/fixtures/goldens/doctor/registry-build-checks.json
index ff1428fea1..560d566cef 100644
--- a/test/fixtures/goldens/doctor/registry-build-checks.json
+++ b/test/fixtures/goldens/doctor/registry-build-checks.json
@@ -621,6 +621,10 @@
"category": "brain",
"name": "auto_chronicle_default_on"
},
+ {
+ "category": "brain",
+ "name": "facts_drain"
+ },
{
"category": "brain",
"name": "fact_take_vectors"
diff --git a/test/phase-scope-coverage.test.ts b/test/phase-scope-coverage.test.ts
index 791502d6f1..7a77b8aa73 100644
--- a/test/phase-scope-coverage.test.ts
+++ b/test/phase-scope-coverage.test.ts
@@ -41,16 +41,17 @@ describe('PHASE_SCOPE coverage', () => {
expect(invalid).toEqual([]);
});
- test('all 24 phases covered (regression on accidental omission)', () => {
+ test('all 25 phases covered (regression on accidental omission)', () => {
// Pin the count so a future PR that adds a phase to ALL_PHASES
// without updating PHASE_SCOPE notices here too. The v0.39.1.0
// master merge brought in the 17th phase (`schema-suggest`); v0.41
// adds 'extract_atoms' + 'synthesize_concepts' (T9 lens packs) +
// 'conversation_facts_backfill' (v0.41.11.0) for 20; v0.41.39 (#1700)
// adds 'enrich_thin' and v0.42.0.0 adds 'skillopt' for a total of 22;
- // #2653 adds 'drift' for 23; #5876 adds 'chronicle' for 24.
- expect(ALL_PHASES.length).toBe(24);
- expect(Object.keys(PHASE_SCOPE).length).toBe(24);
+ // #2653 adds 'drift' for 23; #5876 adds 'chronicle' for 24; GBRA-40 Lane D
+ // adds 'facts_drain' for 25.
+ expect(ALL_PHASES.length).toBe(25);
+ expect(Object.keys(PHASE_SCOPE).length).toBe(25);
});
test('embed remains global (the headline brain-wide phase)', () => {