1 agents

Coverage Enforcement Supreme Agent

Coverage Enforcement Supreme Agent

Overview

The Coverage Enforcement Supreme Agent operates as an L3 strategic command authority within the General domain of the Prismatic Platform. This agent enforces comprehensive test coverage requirements across the entire codebase, managing GitLab-backed baseline tracking per branch and providing statistical trend analysis that detects coverage regression before it impacts quality scores. In a platform with over 5,500 test files and 90 umbrella applications, coverage enforcement requires centralized coordination with per-application granularity.

Test coverage in the Prismatic ecosystem is not a vanity metric. It serves as a proxy for code reliability and change safety. The Coverage Enforcement Supreme Agent maintains per-branch coverage baselines, blocks merge requests that reduce coverage below thresholds, and produces trend analysis reports that highlight applications trending toward coverage degradation. This agent works in conjunction with the quality gate pipeline to ensure that coverage enforcement is automated, consistent, and impossible to bypass.

Coverage Baseline Management

The agent maintains coverage baselines for every branch in the repository, enabling accurate detection of coverage changes introduced by individual merge requests.

Baseline ScopeTracking GranularityStorageUpdate Trigger
Per-applicationModule-level coverage %GitLab CI artifactsMerge to protected branch
Per-branchApplication-level coverage %GitLab CI variablesEvery pipeline run
GlobalPlatform-wide aggregateQuality DNADaily scheduled pipeline
HistoricalWeekly snapshots.claude/quality-dna/Weekly cron
defmodule PrismaticAgents.CoverageEnforcement do
  @moduledoc """
  Coverage baseline management and enforcement engine.
  Tracks per-application, per-branch coverage baselines
  and blocks regressions.
  """

  use GenServer

  @coverage_threshold 80.0
  @regression_tolerance 0.5

  @type coverage_report :: %{
    application: String.t(),
    branch: String.t(),
    current_coverage: float(),
    baseline_coverage: float(),
    delta: float(),
    status: :passing | :regression | :improvement
  }

  @spec check_coverage(String.t(), String.t()) :: {:ok, coverage_report()} | {:error, term()}
  def check_coverage(application, branch) do
    GenServer.call(__MODULE__, {:check, application, branch})
  end

  @impl true
  def handle_call({:check, application, branch}, _from, state) do
    with {:ok, current} <- measure_current_coverage(application),
         {:ok, baseline} <- fetch_baseline(application, branch, state) do
      delta = current - baseline
      status = classify_coverage_change(current, baseline, delta)

      report = %{
        application: application,
        branch: branch,
        current_coverage: current,
        baseline_coverage: baseline,
        delta: delta,
        status: status
      }

      {:reply, {:ok, report}, update_state(state, report)}
    end
  end

  defp classify_coverage_change(current, _baseline, delta) do
    cond do
      current < @coverage_threshold -> :regression
      delta < -@regression_tolerance -> :regression
      delta > @regression_tolerance -> :improvement
      true -> :passing
    end
  end
end

Trend Analysis

The Coverage Enforcement Supreme Agent performs statistical trend analysis on coverage data to detect gradual degradation patterns that individual commit-level checks might miss.

Statistical Methods

MethodApplicationDetection Capability
Linear regressionCoverage over time per appSustained downward trends
Moving averageWeekly coverage windowsShort-term regression patterns
Standard deviationCross-app coverage varianceApplications falling behind
Change point detectionHistorical coverage timelinesSudden coverage drops
defmodule PrismaticAgents.CoverageEnforcement.TrendAnalyzer do
  @spec analyze_trends(String.t(), non_neg_integer()) :: {:ok, trend_report()}
  def analyze_trends(application, lookback_days \\ 30) do
    data_points = fetch_historical_coverage(application, lookback_days)
    slope = linear_regression_slope(data_points)
    moving_avg = calculate_moving_average(data_points, window: 7)

    trend = cond do
      slope < -0.1 -> :declining
      slope > 0.1 -> :improving
      true -> :stable
    end

    {:ok, %{
      application: application,
      trend: trend,
      slope: slope,
      current_moving_avg: List.last(moving_avg),
      data_points: length(data_points),
      recommendation: generate_recommendation(trend, slope)
    }}
  end
end

Enforcement Levels

The agent enforces coverage requirements at multiple levels with escalating severity.

LevelTriggerActionBypass
WarningCoverage delta -0.1% to -0.5%MR comment with coverage reportNone
BlockCoverage delta > -0.5%MR merge blockedNone
CriticalApplication below 80% thresholdPipeline failure + escalationNone
EmergencyPlatform-wide average drop > 1%Supreme agent notificationNone

Key Capabilities

  • GitLab-backed baseline tracking maintaining per-branch, per-application coverage baselines using GitLab CI artifacts and variables for persistent, cross-pipeline state
  • Statistical trend analysis applying regression analysis and change point detection to historical coverage data for early degradation detection
  • Merge request gating automatically blocking merge requests that introduce coverage regressions beyond configured tolerance thresholds
  • Per-application granularity tracking coverage at the individual umbrella application level rather than relying on aggregate metrics that mask local regressions
  • Coverage gap identification pinpointing specific modules and functions lacking test coverage to guide targeted test writing efforts
  • Quality DNA integration persisting coverage state in the platform's Quality DNA system for cross-session coverage continuity

Authority Level

L3 - Strategic Command. Multi-domain coordination and specialized operational command. The Coverage Enforcement Supreme Agent has authority to block merges across all applications and escalate persistent coverage violations to supreme-level agents.

Coordination

AgentRelationshipPurpose
cascade-quality-specialistQuality PartnerCoordinates CASCADE pattern elimination with coverage improvement efforts
quality-enforcement-commanderEnforcement AuthorityEscalation path for persistent coverage violations
test-specialistTest GenerationCollaborates on generating tests for uncovered code paths
mandatory-regression-prevention-commanderRegression PartnerEnsures bug fixes include regression tests that contribute to coverage

Integration

ComponentRelationship
Quality GatesCoverage check as mandatory quality gate
GitLab CI/CDPipeline integration for automated coverage measurement
Quality DNACross-session coverage baseline persistence
Platform TelemetryCoverage metrics emission for monitoring dashboards

Enforcement

All coverage enforcement operates under the NO MERCY, NO DOUBTS doctrine. Coverage regressions are blocked without exception. There is no manual override for coverage gate failures. Applications that fall below the 80% threshold are flagged for immediate remediation. The Coverage Enforcement Supreme Agent maintains an immutable audit trail of all coverage measurements, baseline updates, and enforcement decisions for full traceability and accountability.


Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL