Skip to content

[Refactor] Phase 2: Create DockerComposeTopology Aggregate (P2.1, P2.2) #296

Description

@josecelano

Overview

This task creates the DockerComposeTopology aggregate and derives required networks from service configurations. This is PR 5 in the 5-PR refactoring strategy and completes Epic #287.

Parent Epic: #287
Depends On: #294 (Phase 1 - completed)
Specification: docs/issues/phase-2-topology-aggregate.md

Goals

  • Create DockerComposeTopology aggregate with service topology collection
  • Create Service enum for type-safe service identification
  • Derive required networks from service configurations (single source of truth)
  • Remove conditional network logic from docker-compose template
  • Enforce invariant: "if a service uses a network, that network must be defined"

Tasks

P2.1: Create DockerComposeTopology Aggregate

  • Create Service enum in src/domain/topology/service.rs
  • Create DockerComposeTopology aggregate in src/domain/topology/aggregate.rs
  • Create ServiceTopology struct
  • Implement required_networks() method with deduplication and sorting
  • Write unit tests for Service enum and aggregate invariants

P2.2: Derive Required Networks in Context

  • Add NetworkDefinition type to context module
  • Add required_networks: Vec<NetworkDefinition> to DockerComposeContext
  • Implement derive_required_networks() in builder
  • Update template to iterate over required_networks
  • Remove all conditional network logic from networks section
  • Write unit tests for network derivation

Acceptance Criteria

  1. Service enum exists with all 5 services (Tracker, MySQL, Prometheus, Grafana, Caddy)
  2. DockerComposeTopology aggregate derives required networks from services
  3. required_networks field added to DockerComposeContext
  4. Template uses required_networks loop instead of conditionals
  5. No conditional network logic remains in template
  6. All invariants enforced (no orphan networks, deterministic order)
  7. All existing tests pass
  8. E2E tests verify behavioral equivalence

Related

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions