SmartMemory
Concepts

Graph Health

SmartMemory measures the structural health of your knowledge graph through metrics like orphan ratio, provenance coverage, and type distribution.

Health Metrics

GraphHealthChecker

Collects health metrics via Cypher queries:

MetricDescriptionHealthy Threshold
total_nodesNumber of nodes in the graph—
total_edgesNumber of edges in the graph—
orphan_countNodes with zero edges—
orphan_ratioorphan_count / total_nodes< 0.2 (20%)
provenance_coverageFraction of decisions with provenance edges> 0.5 (50%)
type_distributionCount of nodes by memory type—
edge_distributionCount of edges by edge type—

HealthReport

The HealthReport dataclass provides an is_healthy property that checks:

  • Orphan ratio is below 20%
  • Provenance coverage is above 50%

Usage

from smartmemory.metrics import GraphHealthChecker

checker = GraphHealthChecker(smart_memory)
report = checker.collect_health()

print(f"Healthy: {report.is_healthy}")
print(f"Orphan ratio: {report.orphan_ratio:.1%}")
print(f"Provenance coverage: {report.provenance_coverage:.1%}")

REST API

MethodEndpointDescription
GET/memory/graph/healthCollect health metrics

On this page