MCPcopy Create free account
hub / github.com/SethGammon/Citadel / readHealth

Function readHealth

scripts/dashboard.js:681–707  ·  view source on GitHub ↗
(projectRoot)

Source from the content-addressed store, hash-verified

679 return total;
680}
681
682function readHealth(projectRoot) {
683 const today = new Date().toISOString().slice(0, 10);
684 const auditPath = path.join(projectRoot, '.planning', 'telemetry', 'audit.jsonl');
685 const audit = tailJsonl(auditPath, 500);
686 const hookConfig = readJson(path.join(projectRoot, 'hooks', 'hooks.json')) ||
687 readJson(path.join(projectRoot, '.claude', 'hooks.json')) ||
688 readJson(path.join(projectRoot, '.claude', 'settings.json'));
689 const runtime = configControl.detectRuntimeContract(projectRoot);
690 const effective = configControl.loadActivationContext(projectRoot, { runtime });
691 const loaded = configControl.readConfigFile(projectRoot);
692 const harness = effective.usable
693 && effective.receipt?.authority.valid
694 && loaded.raw
695 && typeof loaded.raw === 'object'
696 ? loaded.raw
697 : {};
698 const trust = harness.trust || {};
699 const sessions = Number(trust.sessionsCompleted ?? trust.sessions_completed ?? 0);
700 const campaigns = Number(trust.campaignsCompleted ?? trust.campaigns_completed ?? 0);
701
702 let level = 'novice';
703 if (sessions >= 20 && campaigns >= 2) level = 'trusted';
704 else if (sessions >= 5) level = 'familiar';
705 if (trust.override) level = `${trust.override} (override)`;
706
707 return {
708 auditEntriesToday: audit.filter((entry) => String(eventTimestamp(entry) || '').startsWith(today)).length,
709 hooksInstalled: countHooksInConfig(hookConfig),
710 trustLevel: level,

Callers 1

collectDashboardFunction · 0.85

Calls 4

tailJsonlFunction · 0.85
eventTimestampFunction · 0.85
countHooksInConfigFunction · 0.85
readJsonFunction · 0.70

Tested by

no test coverage detected