Audit
localnest_auditAudit LocalNest health: get memory coverage, knowledge graph metrics, unpopulated nests, broken bridges, stale memories, and a 0-100 health score with actionable suggestions.
Instructions
Run a comprehensive self-audit of LocalNest health. Returns memory coverage by project, KG density metrics (entities, triples, orphans, duplicates, connected components), unpopulated nests, broken bridges, stale memories, a 0-100 health score, and actionable suggestions. Call once to get a full integrity dashboard.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| response_format | No | json |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | ||
| meta | Yes |
Implementation Reference
- Main handler function that runs the comprehensive self-audit by querying project coverage, KG density, nest health, and stale memories, then computes a health score and suggestions.
export async function runAudit(adapter: Adapter): Promise<AuditResult> { const [coverage, density, nestHealth, stale] = await Promise.all([ auditProjectCoverage(adapter), auditKgDensity(adapter), auditNestHealth(adapter), auditStaleMemories(adapter) ]); const suggestions = generateSuggestions(coverage, density, nestHealth, stale); const healthScore = computeHealthScore(coverage, density, nestHealth, stale); return { audited_at: new Date().toISOString(), health_score: healthScore, project_coverage: coverage, kg_density: density, nest_health: nestHealth, stale_memories: stale, suggestions, summary: buildSummary(healthScore, coverage, density, stale) }; } function buildSummary( score: number, coverage: AuditProjectCoverage, density: AuditKgDensity, stale: AuditStaleMemories ): string { const parts: string[] = [ `Health: ${score}/100`, `${coverage.total_memories} memories across ${coverage.total_projects} project(s)`, `${density.total_entities} KG entities, ${density.active_triples} active triples` ]; if (density.orphaned_entities > 0) { parts.push(`${density.orphaned_entities} orphaned entities`); } if (stale.stale_count > 0) { parts.push(`${stale.stale_count} stale memories`); } return parts.join('. ') + '.'; } - AuditResult type definition — the output schema for localnest_audit, specifying all returned fields including health score, coverage, density, nest health, stale memories, and suggestions.
export interface AuditResult { audited_at: string; health_score: number; project_coverage: AuditProjectCoverage; kg_density: AuditKgDensity; nest_health: AuditNestHealth; stale_memories: AuditStaleMemories; suggestions: AuditSuggestion[]; summary: string; } - src/mcp/tools/audit-tools.ts:18-33 (handler)MCP tool registration for localnest_audit — defines the tool with title, description, empty input schema, read-only annotation, and delegates to memory.audit().
registerJsonTool( 'localnest_audit', { title: 'Audit', description: 'Run a comprehensive self-audit of LocalNest health. Returns memory coverage by project, ' + 'KG density metrics (entities, triples, orphans, duplicates, connected components), ' + 'unpopulated nests, broken bridges, stale memories, a 0-100 health score, and actionable suggestions. ' + 'Call once to get a full integrity dashboard.', inputSchema: {}, annotations: READ_ONLY_ANNOTATIONS, outputSchema: BUNDLE_RESULT_SCHEMA }, async () => memory.audit() ); } - src/app/register-tools.ts:133-136 (registration)Where registerAuditTools is called during app initialization, wiring the memory service as the provider.
registerAuditTools({ registerJsonTool, memory: services.memory }); - src/services/memory/store.ts:509-512 (helper)Memory store's audit() method — delegates to the runAudit function from dashboard.ts, bridging the tool registration to the core audit logic.
async audit(): Promise<AuditResult> { await this.init(); return runAuditFn(this.adapter!); }