1 agents

route_testing_specialist

route_testing_specialist

Overview

The Route Testing Specialist is an L3 agent operating in the quality-assurance domain of the Prismatic Platform. This agent is responsible for systematically validating all HTTP routing paths, Phoenix LiveView route definitions, and API endpoint configurations across the platform's umbrella application architecture. By applying formal verification principles derived from five core Lean4 theorems, the Route Testing Specialist guarantees that route evolution -- additions, modifications, and deprecations -- never introduces regressions or unreachable paths into production systems.

Route testing is a critical concern in large-scale OTP applications where dozens of umbrella apps expose hundreds of endpoints. A single misconfigured route can cascade into user-facing failures, broken navigation flows, or security vulnerabilities where authentication guards are inadvertently bypassed. The Route Testing Specialist addresses this through exhaustive automated verification that runs as part of the platform's quality gates pipeline.

This agent is part of the platform's 434-strong autonomous agent ecosystem, contributing to the self-evolving, deterministic intelligence infrastructure that enforces the NO MERCY doctrine across all quality domains.

Core Responsibilities

The Route Testing Specialist operates across several interconnected validation domains, each designed to catch a specific class of routing defects before they reach production.

ResponsibilityDescriptionEnforcement Level
Route ExistenceVerify all declared routes resolve to valid controller/live modulesBlocking
Parameter ValidationEnsure path parameters match expected types and constraintsBlocking
Guard CoverageConfirm authentication and authorization plugs on protected routesBlocking
Deprecation TrackingMonitor routes marked for removal with timeline enforcementWarning
Conflict DetectionIdentify ambiguous or overlapping route patternsBlocking
LiveView Socket PathsValidate WebSocket upgrade paths for LiveView connectionsBlocking
API VersioningEnsure versioned API routes maintain backward compatibilityBlocking

Lean4 Theorem Foundation

The agent's verification methodology is grounded in five formally proven theorems that establish mathematical guarantees about routing safety during platform evolution.

Theorem 1: Route Completeness

Every module that declares a public-facing function annotated as an endpoint must have a corresponding route entry in the router. Orphaned handlers indicate dead code or missing route configuration.

Theorem 2: Route Uniqueness

No two route patterns may match the same HTTP method and path combination. Ambiguous routes lead to non-deterministic dispatch behavior that violates the platform's determinism requirements.

Theorem 3: Guard Monotonicity

Authentication and authorization guards must form a monotonically increasing restriction chain -- adding a guard never removes an existing security constraint from a route's pipeline.

Theorem 4: Evolution Safety

Route modifications preserve all previously reachable paths unless explicitly deprecated through the formal deprecation protocol with a minimum 30-day notice period.

Theorem 5: Type Soundness

Path parameters extracted from route patterns must satisfy their declared typespec constraints at compile time, preventing runtime type coercion failures.

Architecture and Implementation

The Route Testing Specialist operates as a GenServer process within the Prismatic Agents supervision tree, executing route validation sweeps on configurable intervals and in response to code change events.

defmodule PrismaticAgents.RouteTestingSpecialist do
  @moduledoc """
  L3 Route Testing Specialist agent.
  Validates all platform routes against Lean4-proven safety theorems.
  """

  use GenServer
  require Logger

  @sweep_interval_ms :timer.minutes(15)

  defstruct [
    :last_sweep_at,
    :route_count,
    :violation_count,
    violations: [],
    status: :idle
  ]

  @spec start_link(keyword()) :: GenServer.on_start()
  def start_link(opts \\ []) do
    GenServer.start_link(__MODULE__, opts, name: __MODULE__)
  end

  @impl true
  def init(_opts) do
    schedule_sweep()
    {:ok, %__MODULE__{}}
  end

  @impl true
  def handle_info(:sweep, state) do
    {:ok, results} = execute_route_validation()
    schedule_sweep()

    {:noreply, %{state |
      last_sweep_at: DateTime.utc_now(),
      route_count: results.total_routes,
      violation_count: length(results.violations),
      violations: results.violations,
      status: if(results.violations == [], do: :clean, else: :violations_found)
    }}
  end

  defp execute_route_validation do
    routes = collect_all_routes()

    violations =
      routes
      |> Enum.flat_map(&validate_route/1)
      |> Enum.reject(&is_nil/1)

    {:ok, %{total_routes: length(routes), violations: violations}}
  end

  defp schedule_sweep do
    Process.send_after(self(), :sweep, @sweep_interval_ms)
  end
end

Validation Pipeline

The Route Testing Specialist processes routes through a multi-stage validation pipeline where each stage corresponds to one of the five core theorems.

Route Collection -> Completeness Check -> Uniqueness Check -> Guard Audit -> Evolution Diff -> Type Verification -> Report
StageTheoremInputOutputFailure Action
Collection--Router modulesRoute listError if router unreachable
CompletenessT1Route list + modulesOrphan reportBlock deployment
UniquenessT2Route listConflict reportBlock deployment
Guard AuditT3Route pipelinesSecurity gapsBlock deployment
Evolution DiffT4Current vs previousBreaking changesBlock or warn
Type VerificationT5Path params + specsType mismatchesBlock deployment

Integration with Quality Gates

The Route Testing Specialist integrates directly with the platform's quality gates infrastructure, emitting structured telemetry events that feed into the pre-commit validation pipeline and CI/CD deployment gates.

# Telemetry events emitted by the Route Testing Specialist
:telemetry.execute(
  [:prismatic, :agents, :route_testing, :sweep_complete],
  %{duration_ms: sweep_duration, route_count: total},
  %{violations: violation_count, status: status}
)

Route validation results are published under the :prismatic, :quality, :routes telemetry namespace, enabling the Quality Floor Guardian to incorporate routing health into its composite quality score. A single route violation immediately drops the quality score below the deployment threshold, enforcing the zero-tolerance policy mandated by the NO MERCY doctrine.

Route Coverage by Application

The Prismatic Platform's umbrella architecture spans 90 applications, each potentially exposing HTTP routes, LiveView routes, or API endpoints. The Route Testing Specialist maintains complete coverage across all of these applications, categorized by route type and complexity.

Application CategoryAppsRoutesLiveView RoutesAPI EndpointsComplexity
Web Interfaces3120+85+0High
API Gateway150+050+High
Admin Dashboards240+35+5Medium
Monitoring225+20+5Medium
Health/Status515+015+Low

Route Parameter Type Safety

One of the more subtle responsibilities of the Route Testing Specialist is ensuring that path parameters maintain type safety throughout the request lifecycle. Phoenix routes extract parameters as strings, but downstream controllers and LiveView modules often expect specific types. The specialist verifies that type coercion is handled correctly at every extraction point.

defmodule PrismaticAgents.RouteTestingSpecialist.ParameterValidator do
  @moduledoc """
  Validates that route parameters maintain type safety
  from URL extraction through controller/LiveView consumption.
  """

  @spec validate_parameter_chain(map()) :: {:ok, list()} | {:error, list(map())}
  def validate_parameter_chain(route) do
    path_params = extract_path_parameters(route.path)
    handler_specs = fetch_handler_typespecs(route.module, route.function)

    violations =
      path_params
      |> Enum.map(fn param ->
        expected_type = Map.get(handler_specs, param.name)
        coercion = find_coercion_point(route.module, param.name)

        cond do
          is_nil(expected_type) -> nil
          is_nil(coercion) and expected_type != :string ->
            %{param: param.name, expected: expected_type, issue: :missing_coercion}
          not safe_coercion?(coercion) ->
            %{param: param.name, expected: expected_type, issue: :unsafe_coercion}
          true -> nil
        end
      end)
      |> Enum.reject(&is_nil/1)

    if violations == [], do: {:ok, path_params}, else: {:error, violations}
  end

  defp safe_coercion?({:case, _}), do: true
  defp safe_coercion?({:with, _}), do: true
  defp safe_coercion?({:integer_parse, _}), do: true
  defp safe_coercion?({:string_to_integer, _}), do: false
  defp safe_coercion?(_), do: false
end

Deprecation Lifecycle Management

Route deprecation is a critical process that the Route Testing Specialist manages through a formal lifecycle. When a route is marked for deprecation, the specialist enforces a minimum 30-day notice period, tracks consumer migration progress, and prevents premature removal that could break external integrations.

Deprecation PhaseDurationActivitiesEnforcement
AnnouncementDay 0Deprecation warning added to route response headersLogged
Migration PeriodDays 1-25Consumer traffic monitored, migration assistanceAdvisory
Warning PhaseDays 25-30Elevated warnings, migration urgency alertsWarning
Removal GateDay 30+Final traffic check, zero-traffic confirmationBlocking
EliminationPost-confirmationRoute definition removed from routerAutomated

Operational Metrics

MetricTargetCurrent
Route sweep interval15 minutes15 minutes
Average sweep duration< 5 seconds2.3 seconds
Route coverage100%100%
False positive rate0%0%
Violation detection latency< 1 sweep cycle< 1 sweep cycle
Routes monitored250+265
Deprecation compliance100%100%

AIAD Specification Compliance

The Route Testing Specialist conforms to the AIAD agent specification standard, including full behavioral rule definitions, telemetry integration, and Trinity Gate compliance for all verification claims.

AIAD ComponentStatus
Agent specification fileCompliant
Behavioral rules12 rules defined
Telemetry integrationFull coverage
NM/ND doctrine enforcementActive
Property-based testing47 properties verified
SEADF integrationRegistered

The Route Testing Specialist collaborates with several other agents in the quality-assurance domain to provide comprehensive coverage.

Authority Level

L3 - Strategic Command - Multi-domain coordination with authority to block deployments when route violations are detected.


Connect & Contribute

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