Skip to content

SI-4: Migrate stats context to contract-first architecture #1942

Closed

Description

@josecelano

Subissue of EPIC #1938 — REST API Contract-First Migration

Problem

The stats context is the most complex in the REST API. It has two endpoints (GET /stats, GET /metrics) aggregating data from 6+ tracker internal repositories across tracker-core, http-core, udp-core, udp-server, swarm-coordination-registry, and rest-api-core. The Stats DTO has ~28 fields. The Axum server injects all dependencies as multi-element state tuples.

Scope

  • Define Stats and LabeledStats DTOs (~28 fields) in rest-api-protocol
  • Define StatsQueryPort trait in rest-api-application
  • Implement StatsApiService use-case
  • Implement TrackerStatsAdapter consuming SI-30 traits (BanningStats, UdpCoreStatsRepository, UdpServerStatsRepository)
  • Handle Prometheus serialization (keep as Axum transport concern — Option A)
  • Rewire Axum handlers to use StatsApiService
  • Remove direct internal crate deps from axum-rest-api-server stats wiring

Checklist

  • Stats and LabeledStats DTOs defined in rest-api-protocol
  • StatsQueryPort trait defined
  • StatsApiService use-case implemented
  • TrackerStatsAdapter implemented consuming SI-30 traits
  • Prometheus serialization handled (Option A)
  • Axum handlers dispatch through use-case
  • Direct internal crate deps removed from Axum server
  • Pre-commit checks pass
  • Pre-push checks pass

Activity

  1. self-assigned this
    on Jun 24, 2026
  2. added
    Code Cleanup / Refactoring
    - Developer -
    API
    on Jun 24, 2026
  3. added 2 commits that reference this issue on Jun 24, 2026
  4. added a commit that references this issue on Jun 29, 2026
  5. added 8 commits that reference this issue on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

- Developer -APICode Cleanup / Refactoringtask

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions