CodeGraph/docs
Section 6.1

Health Index & Scoring Formula

A continuous, multi-metric structural scoring framework that distills 6 independent graph measurements into a unified 0–100 health index.

Source: server/src/analytics/health/CalculateHealthIndex.ts

The Weighted Aggregation Formula

The Health Index ($H$) combines 6 normalized structural scores ($0 \dots 100$) using calibrated weights that sum to exactly $1.00$:

H = (0.28 · C) + (0.23 · Co) + (0.18 · Fo) + (0.14 · Fi) + (0.10 · D) + (0.07 · M)
MetricSymbolWhat It MeasuresWeightKey Driver
Cycle HealthCCircular file imports & mutual recursion28%Constrains build order & introduces undefined runtime imports.
Coupling HealthCoAverage total structural degree (in + out)23%Broadest measure of repository interconnectedness.
Fan-Out HealthFoRMS outgoing relationship concentration18%Penalizes hotspot files/symbols with excessive outgoing coupling.
Fan-In HealthFiRMS incoming relationship concentration14%Identifies fragile high-blast-radius hub symbols.
Dependency HealthDExternal npm dependency density per file10%External package exposure and supply-chain blast radius.
Module HealthMProportion of unresolved module entities7%Measures external imports that CodeGraph failed to resolve to local files or declared dependencies (Node.js built-ins or unlisted imports).

The 3-Phase Pipeline: Measure → Normalize → Aggregate

  1. Phase 1: Raw Measurement: Extracts raw graph quantities (for example, RMS fan-out = 1.45, cycle count = 0).
  2. Phase 2: Normalization: Converts unbounded raw values into a standardized 0–100 scale using continuous reciprocal decay:
    score = 100 / (1 + k · x)
    or bounded linear ratios:
    score = 100 · (1 - risk)
  3. Phase 3: Weighted Aggregation: Sums the weighted individual metric scores into the final unified repository index.

Score Interpretation Bands

Score RangeClassificationArchitectural Assessment
90 – 100Very HealthyClean modular structure with minimal architectural risk and zero/few cycles.
75 – 89Generally HealthyStandard structural complexity typical of actively growing repositories.
50 – 74Moderate ComplexityNoticeable coupling or hotspot outliers that warrant refactoring.
25 – 49Elevated RiskHigh circularity, heavy God-node concentration, or extreme fan-out.
0 – 24Severe DegradationPervasive structural tangling across both file and symbol layers.