Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

doctor: shared_skills_sources lists opted-out and parked sources

garrytan79f165e86aa0
diff --git a/src/commands/doctor/checks/shared-skills.ts b/src/commands/doctor/checks/shared-skills.ts
new file mode 100644
index 0000000000..b213059313
--- /dev/null
+++ b/src/commands/doctor/checks/shared-skills.ts
@@ -0,0 +1,35 @@
+import type { BrainEngine } from '../../../core/engine.ts';
+import { readSharedSkillsSourceView } from '../../../core/shared-skills/source-opt-out.ts';
+import { SHARED_SKILLS_OPT_OUT_DOCS } from '../../../core/shared-skills/setup-source-policy.ts';
+import type { Check } from '../../doctor.ts';
+import { agentFix } from '../check-fix.ts';
+
+/**
+ * Sources opted out of shared-skills adoption (`config.shared_skills=false`)
+ * and sources the 0.53.0 migration parked because their pack exceeds an
+ * inventory bound. Null when neither exists. Opting out is a choice (ok);
+ * a parked source waits for the operator (warn).
+ */
+export async function checkSharedSkillsSources(engine: BrainEngine): Promise<Check | null> {
+ try {
+ const ids = (await engine.executeRaw<{ id: string }>('SELECT id FROM sources WHERE NOT archived ORDER BY id')).map(row => row.id);
+ const views = await Promise.all(ids.map(id => readSharedSkillsSourceView(engine, id)));
+ const optedOut = views.filter(view => view.configured === false).map(view => view.source_id);
+ const parked = views.filter(view => view.parked);
+ if (!optedOut.length && !parked.length) return null;
+ const details = { opted_out: optedOut, parked: parked.map(view => ({ source_id: view.source_id, limit: view.parked!.limit, parked_at: view.parked!.parked_at })), docs: SHARED_SKILLS_OPT_OUT_DOCS };
+ const off = optedOut.length ? `Opted out of shared-skills adoption (config.shared_skills=false): ${optedOut.join(', ')}; turn one back on with gbrain sources shared-skills <id> on.` : '';
+ if (!parked.length) return { name: 'shared_skills_sources', status: 'ok', message: off, details };
+ return {
+ name: 'shared_skills_sources', status: 'warn', details,
+ message: `${parked.length} source(s) parked by the shared-skills migration because the pack exceeds an inventory bound: `
+ + `${parked.map(view => `${view.source_id} (${view.parked!.limit})`).join(', ')}. The migration completes and skips them until the bound is raised, the source opts out, or it is released. ${off}`.trim(),
+ fix: agentFix(['gbrain', 'sources', 'shared-skills', parked[0]!.source_id, 'status', '--json'],
+ 'Shows the parked bound and the three ways to resume (raise the bound, opt out, or shrink and release); it changes nothing.', 'shared_skills_sources', { docs: SHARED_SKILLS_OPT_OUT_DOCS }),
+ };
+ } catch (error) {
+ if (/does not exist|no such table/i.test(String(error))) return null;
+ return { name: 'shared_skills_sources', status: 'warn', fix_unavailable_reason: 'check_errored',
+ message: `Shared-skills source settings could not be read: ${error instanceof Error ? error.message : String(error)}. Health is unknown.` };
+ }
+}
diff --git a/src/commands/doctor/checks/sync-search.ts b/src/commands/doctor/checks/sync-search.ts
index 7a11b1b775..d224778999 100644
--- a/src/commands/doctor/checks/sync-search.ts
+++ b/src/commands/doctor/checks/sync-search.ts
@@ -63,6 +63,8 @@ async function runSyncFreshness(ctx: DoctorContext): Promise<Check[]> {
checks.push(await checkSyncFreshness(engine, { localOnly: true }));
const contentWrites = await (await import('./canonical-content.ts')).checkCanonicalContentWrites(engine);
if (contentWrites) checks.push(contentWrites);
+ const sharedSkills = await (await import('./shared-skills.ts')).checkSharedSkillsSources(engine);
+ if (sharedSkills) checks.push(sharedSkills);
// Monthly backup-coverage check (same D4 trust stance as sync_freshness:
// localOnly:true probes git; the remote path stays a cache-only reader).
progress.heartbeat('backup_coverage');
@@ -103,6 +105,7 @@ export const syncFreshnessEntry: DoctorEntry = {
emits: [
'sync_freshness',
'canonical_content_writes',
+ 'shared_skills_sources',
'backup_coverage',
'sync_consolidation',
'links_extraction_lag',
diff --git a/src/core/doctor-categories.ts b/src/core/doctor-categories.ts
index 8fee9e5d4c..23ad85f595 100644
--- a/src/core/doctor-categories.ts
+++ b/src/core/doctor-categories.ts
@@ -212,6 +212,8 @@ export const OPS_CHECK_NAMES: ReadonlySet<string> = new Set([
'bootstrap_serve_lock',
'batch_retry_health',
'canonical_content_writes',
+ // Sources opted out of, or parked by, the shared-skills migration (checks/shared-skills.ts).
+ 'shared_skills_sources',
'brainstorm_health',
'connectors',
'dream_paid_loop',
diff --git a/test/fixtures/goldens/doctor/registry-build-checks.json b/test/fixtures/goldens/doctor/registry-build-checks.json
index 1168f97e33..b04a1d240e 100644
--- a/test/fixtures/goldens/doctor/registry-build-checks.json
+++ b/test/fixtures/goldens/doctor/registry-build-checks.json
@@ -577,6 +577,10 @@
"category": "ops",
"name": "canonical_content_writes"
},
+ {
+ "category": "ops",
+ "name": "shared_skills_sources"
+ },
{
"category": "ops",
"name": "backup_coverage"