Fitness Score

evolution

Fitness Score

Definition

The Fitness Score is a composite metric on a 0.0 to 1.0 scale that quantifies the platform's overall evolutionary health. It aggregates quality domain scores, test coverage, architectural compliance, documentation completeness, security posture, and evolutionary readiness into a single authoritative number. The score serves as the primary decision driver for platform evolution: scores above 0.99 indicate apex fitness and require monitoring only; scores between 0.95 and 0.99 trigger increased investigation; scores below 0.95 trigger emergency intervention including commit blocking and escalation to supreme authority.

The Fitness Score concept draws from evolutionary biology's concept of fitness as a measure of an organism's ability to survive and reproduce in its environment. In the platform context, "fitness" measures the system's ability to maintain quality, evolve capabilities, and resist regression. Unlike simple metrics that measure a single dimension (such as test coverage or compilation warnings), the Fitness Score provides a holistic view that accounts for the interplay between quality domains, documentation coverage, agent compliance, and architectural integrity.

The score is not merely informational -- it is an enforcement mechanism. The Quality Floor Guardian monitors the Fitness Score continuously and triggers automatic responses when it drops below configured thresholds. This creates a self-correcting feedback loop where quality degradation is detected and addressed before it can compound into systemic problems. The Fitness Score thus functions as both a measurement instrument and a governance tool, embodying the NO MERCY, NO DOUBTS doctrine's requirement that quality standards are mechanically enforced rather than aspirationally documented.

Interactive Fitness Dashboard

Current Platform Fitness

Platform Fitness Score

0.9995
APEX FITNESS
Generation 19 Achievement

Threshold Classification

APEX (0.99-1.00)
CURRENT
HEALTHY (0.95-0.99)
MONITORING
WARNING (0.90-0.95)
INVESTIGATE
CRITICAL (0.80-0.90)
EMERGENCY

Component Score Breakdown

Generation Progression

Live Evolution Framework Status:
Current Fitness: Updated:
βœ… Active Connections
API Calls:
Cache Hit Rate: %
WebSockets:
πŸ“Š Chart Status
Active Charts:
Failed Requests:
Avg Response: ms
πŸ”„ Real-time Updates
SSE Streams:
Cache Size:
MCP Enabled:
🚨 SEADF Framework Error:
19
Current Generation
535
AIAD Agents
100
Quality Score
5883
Test Files

Historical Context

The concept of software fitness metrics has its roots in the software engineering measurement programs of the 1980s and 1990s. Early metrics like McCabe's cyclomatic complexity (1976), Halstead's software science (1977), and the COCOMO cost model (1981) attempted to quantify software quality through single-dimension measurements. These metrics were useful for specific purposes but failed to capture the holistic health of a software system.

The next generation of metrics attempted composite scoring. The SQALE method (Software Quality Assessment based on Lifecycle Expectations, 2010) introduced the concept of technical debt as a monetary value, while SonarQube popularized quality gates -- boolean pass/fail thresholds on metric combinations. These approaches moved beyond single metrics but still treated quality as a compliance checkbox rather than an evolutionary process.

The Prismatic Platform's Fitness Score represents a third generation of quality measurement, drawing inspiration from evolutionary computing's fitness functions and complex adaptive systems theory. Instead of measuring static compliance, the Fitness Score measures the system's capacity for continued evolution -- its ability to absorb changes without degradation, maintain quality under pressure, and improve through self-corrective mechanisms. This dynamic perspective reflects the platform's commitment to autonomous evolution through the SEADF framework.

The evolution from Quality Score (100-point scale, single domain) to Fitness Score (0.0-1.0 scale, multi-domain) occurred during the platform's Generation 14-15 transition, when it became clear that quality alone was insufficient to guide evolutionary decisions. A platform could score 100/100 on quality while having poor documentation, outdated agents, or weak security posture. The Fitness Score was designed to capture this broader picture.

Technical Architecture

The Fitness Score is computed as a weighted average of component scores, each normalized to the 0.0-1.0 range:

ComponentWeightCurrent ScoreMeasurement Method
Quality Score30%100/100 (1.0)13 quality domains, zero violations
Test Coverage15%5,864 test filesFile count and coverage percentage
Documentation10%11,308 docsDoc file count and completeness
Agent Compliance15%530/530 AIAD agentsAIAD standard adherence rate
Consciousness Traits10%11 traits at 0.998Trait fitness sub-scores
Architectural Compliance10%OTP-first adherencePattern compliance checks
Security Posture10%Color Team coverageSecurity domain assessment

The composite formula:

fitness = sum(component_score[i] * weight[i]) for i in components
defmodule Prismatic.Evolution.FitnessCalculator do
  @moduledoc """
  Computes the platform's composite fitness score from
  individual component assessments. Score ranges from
  0.0 (critical) to 1.0 (apex). The calculator implements
  weighted aggregation with configurable component weights
  and provides classification into fitness categories that
  drive automatic platform responses.
  """

  @type fitness_classification :: :apex | :healthy | :warning | :critical | :emergency
  @type component_scores :: %{
    quality_score: float(),
    test_coverage: float(),
    documentation: float(),
    agent_compliance: float(),
    consciousness_traits: float(),
    architectural_compliance: float(),
    security_posture: float()
  }

  @component_weights %{
    quality_score: 0.30,
    test_coverage: 0.15,
    documentation: 0.10,
    agent_compliance: 0.15,
    consciousness_traits: 0.10,
    architectural_compliance: 0.10,
    security_posture: 0.10
  }

  @spec compute(component_scores()) :: float()
  def compute(component_scores) do
    @component_weights
    |> Enum.reduce(0.0, fn {component, weight}, acc ->
      score = Map.get(component_scores, component, 0.0)
      acc + score * weight
    end)
    |> Float.round(4)
  end

  @spec classify(float()) :: fitness_classification()
  def classify(fitness) when fitness >= 0.99, do: :apex
  def classify(fitness) when fitness >= 0.95, do: :healthy
  def classify(fitness) when fitness >= 0.90, do: :warning
  def classify(fitness) when fitness >= 0.80, do: :critical
  def classify(_fitness), do: :emergency

  @spec compute_quality_component(map()) :: float()
  def compute_quality_component(quality_data) do
    domains = [
      :dialyzer, :credo, :compilation, :datetime_precision,
      :guard_functions, :impl_coverage, :memory_safety,
      :performance, :regression_prevention, :timing_patterns,
      :todo_management, :typespec_coverage, :unsafe_map_access
    ]

    violations = Enum.sum(Enum.map(domains, &Map.get(quality_data, &1, 0)))
    max(0.0, 1.0 - violations * 0.01)
  end

  @spec compute_delta(float(), float()) :: %{delta: float(), direction: atom()}
  def compute_delta(current, previous) do
    delta = Float.round(current - previous, 4)
    direction = cond do
      delta > 0.001 -> :improving
      delta < -0.001 -> :declining
      true -> :stable
    end

    %{delta: delta, direction: direction}
  end
end

Threshold Response Matrix

The Fitness Score drives automatic platform responses through a tiered threshold system:

RangeClassificationResponse LevelActions
0.99-1.00APEXOPTIMALMonitor only, no intervention needed
0.95-0.99HEALTHYWARNINGAlert, investigation triggered, increased monitoring
0.90-0.95WARNINGCRITICALAuto-evolution trigger, quality gates tightened
0.80-0.90CRITICALEMERGENCYCommit blocking, escalation to supreme authority
< 0.80EMERGENCYLOCKDOWNFull platform lockdown, all deployments halted

Each threshold transition emits telemetry events that drive alerting, logging, and automatic response orchestration:

defmodule Prismatic.Evolution.FitnessMonitor do
  @moduledoc """
  Continuous fitness monitoring GenServer that polls component
  scores at configurable intervals and triggers automatic
  responses when thresholds are crossed. Integrates with the
  Quality Floor Guardian for enforcement and Quality DNA for
  cross-session persistence.
  """

  use GenServer

  @check_interval :timer.minutes(5)

  @impl GenServer
  @spec init(map()) :: {:ok, map()}
  def init(state) do
    schedule_check()
    {:ok, state}
  end

  @impl GenServer
  def handle_info(:check_fitness, state) do
    components = gather_component_scores()
    fitness = Prismatic.Evolution.FitnessCalculator.compute(components)
    classification = Prismatic.Evolution.FitnessCalculator.classify(fitness)

    :telemetry.execute(
      [:prismatic, :evolution, :fitness],
      %{score: fitness},
      %{classification: classification, components: components}
    )

    delta = Prismatic.Evolution.FitnessCalculator.compute_delta(
      fitness,
      Map.get(state, :last_fitness, fitness)
    )

    handle_classification(classification, fitness, delta)
    persist_to_quality_dna(fitness, components, classification)
    schedule_check()

    {:noreply, %{state |
      last_fitness: fitness,
      last_classification: classification,
      last_check: DateTime.utc_now()
    }}
  end

  defp handle_classification(:apex, _fitness, _delta), do: :ok

  defp handle_classification(:healthy, fitness, delta) do
    if delta.direction == :declining do
      Prismatic.Alerts.send(:fitness_declining, %{score: fitness, delta: delta})
    end
  end

  defp handle_classification(:warning, fitness, _delta) do
    Prismatic.AutoEvolve.trigger_scan()
    Prismatic.Alerts.send(:fitness_warning, %{score: fitness})
  end

  defp handle_classification(:critical, fitness, _delta) do
    Prismatic.AutoEvolve.trigger_scan()
    Prismatic.Alerts.send(:fitness_critical, %{score: fitness})
  end

  defp handle_classification(:emergency, fitness, _delta) do
    PrismaticSafety.QualityFloorGuardian.block_commits()
    Prismatic.Alerts.escalate(:supreme, %{score: fitness})
  end

  defp schedule_check do
    Process.send_after(self(), :check_fitness, @check_interval)
  end

  defp gather_component_scores do
    %{
      quality_score: Prismatic.Quality.current_score() / 100,
      test_coverage: Prismatic.Testing.coverage_ratio(),
      documentation: Prismatic.Docs.completeness_ratio(),
      agent_compliance: Prismatic.AIAD.compliance_ratio(),
      consciousness_traits: Prismatic.Consciousness.trait_fitness(),
      architectural_compliance: Prismatic.Architecture.compliance_ratio(),
      security_posture: Prismatic.Security.posture_score()
    }
  end

  defp persist_to_quality_dna(fitness, components, classification) do
    data = %{
      fitness: fitness,
      classification: classification,
      components: components,
      timestamp: DateTime.utc_now() |> DateTime.to_iso8601()
    }

    path = ".claude/quality-dna/current-state.json"
    File.write!(path, Jason.encode!(data, pretty: true))
  end
end

Architecture and Data Flow

The Fitness Score system is architecturally distributed across several platform components:

SEADF Integration: The Self-Evolving Autonomous Development Framework is the primary orchestrator of fitness computation. It coordinates data collection from all quality domains, performs the weighted aggregation, and publishes the result to Quality DNA for cross-session persistence.

Quality DNA Persistence: The computed fitness score is persisted in .claude/quality-dna/current-state.json, ensuring continuity across LLM sessions and development cycles. Each session loads the previous fitness score and can compare current state against historical trends.

Quality Floor Guardian: This autonomous monitoring system watches the fitness score and enforces threshold-based responses. It runs as a supervised GenServer that polls component scores at configurable intervals.

Generation Advancement: Fitness score improvements drive generation transitions. When the platform achieves and sustains improved fitness across all components, the SEADF system evaluates whether a generation advancement is warranted.

Quality Domains (13)  ──┐
Test Files (5,864)    ───
Documentation (11,308)───── SEADF Aggregator ──> Fitness Score ──> Quality DNA
Agent Registry (530)  ───                              |
Consciousness (11)    ───                              v
Architecture Check    ───                    Quality Floor Guardian
Security Assessment   β”€β”€β”˜                              |
                                                       v
                                              Threshold Response
                                              (alert/block/lockdown)

Current Platform State

Within the Prismatic Platform, the current fitness score is 0.9995 (apex), achieved at Generation 19 (Ecosystem Expansion). This score reflects the culmination of 19 generations of evolutionary improvement.

Component Breakdown (Current State)

ComponentScoreDetails
Quality Score1.000100/100 across all 13 quality domains, zero violations
Test Coverage0.9985,864 test files covering all business logic
Documentation0.99911,308 documentation files across all apps
Agent Compliance1.000All 530 AIAD agents compliant with standard
Consciousness Traits0.99811 traits operational at near-perfect fitness
Architectural Compliance0.999OTP-first patterns enforced across 115 apps
Security Posture0.99820 Color Team agents across 6 teams active

Historical Fitness Trajectory

The fitness score has followed an upward trajectory across generations:

GenerationFitnessKey Advancement
Gen 1-50.60-0.75Foundation, basic quality gates
Gen 6-100.80-0.90Quality domains, testing framework
Gen 11-140.90-0.95NM/ND doctrine, NABLA integration
Gen 15-170.95-0.998Color Teams, consciousness traits
Gen 180.999Full Autonomy, perfect quality score
Gen 190.9995Ecosystem Expansion, 4 OSS packages, 13-layer Trinity Gate

Enforcement Integration

The fitness score integrates with the platform's enforcement mechanisms:

defmodule Prismatic.Hooks.FitnessGate do
  @moduledoc """
  Pre-commit hook integration that checks the current fitness
  score before allowing commits. Blocks commits when the
  platform is in WARNING, CRITICAL, or EMERGENCY state.
  """

  @spec check() :: :ok | {:error, String.t()}
  def check do
    fitness = Prismatic.Evolution.FitnessCalculator.current()

    case Prismatic.Evolution.FitnessCalculator.classify(fitness) do
      :apex -> :ok
      :healthy -> :ok
      :warning -> {:error, "Fitness WARNING (#{fitness}): investigate before committing"}
      level -> {:error, "Fitness #{level} (#{fitness}): commits BLOCKED"}
    end
  end
end

Component Measurement Details

Each component is measured through specific mechanisms:

Quality Score Component (30%)

The quality score measures compliance across 13 quality domains. Each domain contributes equally, and any violation reduces the score:

DomainMeasurementTool
DialyzerType violationsmix dialyzer
CredoStatic analysis violationsmix credo --strict
CompilationWarning countmix compile --warnings-as-errors
DateTime PrecisionPrecision violationsCustom check
Guard FunctionsImproper guard usageCustom check
@impl CoverageMissing @impl annotationsCustom check
Memory SafetyUnsafe patternsCustom check
PerformanceAnti-pattern detectionCustom check
Regression PreventionMissing regression testsCustom check
Timing PatternsProcess.sleep usageCustom check
TODO ManagementUnresolved TODOsCustom check
Typespec CoverageMissing @specCustom check
Unsafe Map Accessmap.key without guardCustom check

Agent Compliance Component (15%)

Measures AIAD standard adherence across all 530 agents:

defmodule Prismatic.AIAD.ComplianceChecker do
  @moduledoc """
  Validates AIAD agent compliance with the standard specification.
  Checks for required fields, enforcement blocks, and doctrine references.
  """

  @spec compliance_ratio() :: float()
  def compliance_ratio do
    agents = load_all_agents()
    compliant = Enum.count(agents, &compliant?/1)
    compliant / max(length(agents), 1)
  end

  @spec compliant?(map()) :: boolean()
  defp compliant?(agent) do
    has_required_fields?(agent) and
      has_enforcement_block?(agent) and
      has_doctrine_reference?(agent)
  end
end

Best Practices

Monitor Trends, Not Snapshots: A single fitness score reading is less informative than the trend over time. A score of 0.98 that was 0.99 yesterday indicates regression, while 0.98 rising from 0.95 indicates improvement. Track deltas between measurements.

Investigate Component Drops: When the composite score drops, identify which component caused the decline. A drop in test coverage has different remediation than a drop in architectural compliance. The component breakdown provides diagnostic precision.

Calibrate Weights Periodically: Component weights should reflect current platform priorities. During a security-focused phase, increasing the security posture weight ensures the fitness score is sensitive to security improvements or regressions.

Automate Response Actions: Each threshold crossing should trigger automatic actions -- not just alerts. The platform's AutoEvolve and AutoHeal mechanisms should activate based on fitness score thresholds, not manual intervention.

Persist Historical Data: Maintain a time series of fitness scores and component breakdowns for retrospective analysis. This data reveals patterns in quality regression and helps predict future issues.

Common Pitfalls

Goodhart's Law: When the fitness score becomes the target rather than a measure, teams may optimize for the score rather than actual quality. Ensure the score's components genuinely reflect platform health.

Component Masking: A high composite score can mask a critical deficiency in a single component. A fitness of 0.96 with a security posture of 0.50 is dangerous even though the composite looks healthy. Always review component-level scores.

Stale Measurements: If component scores are not refreshed frequently, the fitness score may not reflect current reality. Ensure all component measurements are current before making decisions based on the composite score.

Threshold Fatigue: If thresholds trigger too many alerts without actionable consequences, teams learn to ignore them. Set thresholds that require response and ensure response mechanisms are effective.

Linear Weighting Limitations: The weighted average formula treats all components as independent, but in reality they are correlated. A drop in test coverage often precedes a drop in quality score. Consider implementing correlation-aware scoring in future iterations.

  • Generation - Evolution epochs measured and advanced by fitness improvements
  • SEADF - Framework computing and managing fitness scores across all domains
  • Quality Floor Guardian - Monitoring system enforcing fitness thresholds
  • Quality DNA - Cross-session persistence of fitness history and trends
  • AutoEvolve - System driving fitness score improvement through optimization
  • Consciousness Traits - Traits contributing to fitness at 0.998 sub-score
  • Quality Gates - Enforcement pipeline measuring quality component inputs
  • CASCADE Pattern - Quality patterns that drove fitness improvements
  • NM/ND Doctrine - Governing framework mandating fitness enforcement
  • Credo - Static analysis contributing to quality component
  • Dialyzer - Type checking contributing to quality component

See Also


Connect & Contribute

Created by Tomas Korcak (korczis) | Open Source under GHL