Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Make doctor --alert --only report unknown for the page checks it skipped, never none

garrytana84e6d582f05
diff --git a/src/commands/doctor.ts b/src/commands/doctor.ts
index 8eb765d22c..d6c28775d8 100644
--- a/src/commands/doctor.ts
+++ b/src/commands/doctor.ts
@@ -532,7 +532,7 @@ export async function runDoctor(
if (args.includes('--probe') && !(await (await import('./doctor/probe-consent.ts')).authorizeProviderProbe(engine, args, jsonOutput))) return;
const checks = await buildChecks(engine, args, dbSource, connectError, deadline, { lastKnown: 'cli' });
const run = doctorRunSummary(args, deadline);
- const extras = { engine: engine?.kind, db_url_source: dbSource ?? null, run, alertRan: alertRanChecks(checks, parseDoctorTier(args)) };
+ const extras = { engine: engine?.kind, db_url_source: dbSource ?? null, run, alertRan: alertRanChecks(checks, parseDoctorTier(args), parseOnlyChecks(args)) };
if (args.includes('--alert')) return setCliExitVerdict(printAlertReport(computeDoctorReport(checks, extras), jsonOutput));
const hasFail = outputResults(checks, jsonOutput, extras);
diff --git a/src/commands/doctor/alert.ts b/src/commands/doctor/alert.ts
index 6a06539eb5..12256b90d3 100644
--- a/src/commands/doctor/alert.ts
+++ b/src/commands/doctor/alert.ts
@@ -88,11 +88,12 @@ export function alertRunArgs(args: readonly string[]): string[] {
/**
* The page-class checks this run executed: none when the database checks did not run (no connection check that is
- * ok), else every page-class check whose entry runs at tier. A page-class check missing from such a run did not apply.
+ * ok), else every page-class check whose entry runs at tier and that `only` (--only) names, when given. A page-class
+ * check missing from such a run did not apply.
*/
-export function alertRanChecks(checks: readonly Pick<Check, 'name' | 'status'>[], tier: DoctorTier): Set<string> {
+export function alertRanChecks(checks: readonly Pick<Check, 'name' | 'status'>[], tier: DoctorTier, only?: ReadonlySet<string> | null): Set<string> {
if (!checks.some((c) => c.name === 'connection' && c.status === 'ok')) return new Set();
- return new Set([...PAGE_CHECK_NAMES].filter((name) => DOCTOR_CHECK_REGISTRY.some((e) => e.emits.includes(name) && entryRunsAt(e.tier, tier))));
+ return new Set([...PAGE_CHECK_NAMES].filter((name) => (!only || only.has(name)) && DOCTOR_CHECK_REGISTRY.some((e) => e.emits.includes(name) && entryRunsAt(e.tier, tier))));
}
function unknownReason(c: Check): AlertUnknownReason | null {
diff --git a/src/commands/doctor/remote-tier.ts b/src/commands/doctor/remote-tier.ts
index add11a55fe..828c996009 100644
--- a/src/commands/doctor/remote-tier.ts
+++ b/src/commands/doctor/remote-tier.ts
@@ -44,7 +44,7 @@ export async function runRemoteDoctorTier(ctx: OperationContext, p: Record<strin
const deadline = startDoctorDeadline(args);
const raw = await buildChecks(ctx.engine, args, undefined, undefined, deadline, { sourceIds, remote: ctx.remote !== false });
const checks = transport === 'cli' ? raw : redactForTransport(raw, 'http');
- return computeDoctorReport(checks, { engine: ctx.engine.kind, render, alertRan: alertRanChecks(checks, 'standard') });
+ return computeDoctorReport(checks, { engine: ctx.engine.kind, render, alertRan: alertRanChecks(checks, 'standard', new Set(only)) });
}
const report = await doctorReportRemote(ctx.engine, { sourceIds, remote: ctx.remote, render });
const kept = report.checks.filter((c) => only!.includes(c.name));
diff --git a/test/doctor-alert-w4.test.ts b/test/doctor-alert-w4.test.ts
index d703786b87..b0f93eaa51 100644
--- a/test/doctor-alert-w4.test.ts
+++ b/test/doctor-alert-w4.test.ts
@@ -146,6 +146,15 @@ describe('alert verdict per page-class check', () => {
expect(ran.has('jsonb_integrity')).toBe(false);
expect(alertRanChecks([ok('connection')], 'standard')).toEqual(ALL);
});
+
+ test('--alert --only <subset>: page checks outside the subset did not run, so a healthy subset is unknown, never none', () => {
+ const ran = alertRanChecks([ok('connection')], 'standard', new Set(['connection']));
+ expect([...ran]).toEqual(['connection']);
+ const alert = computeDoctorReport([ok('connection')], { alertRan: ran }).alert!;
+ expect(alert.level).toBe('unknown');
+ expect(alert.unknown.map((u) => u.check)).toContain('rls');
+ expect(alertRanChecks([ok('connection')], 'standard', new Set(PAGE_CHECK_NAMES))).toEqual(ALL);
+ });
});
describe('remote alert items', () => {