Commit 24b3185
committed
dd3ab12 docs: [#298] update epic and spec to reflect PR split strategy (Jose Celano)
943a274 refactor: [#298] add PortBinding domain type and cross-service port validation (Jose Celano)
Pull request description:
## Summary
This PR implements the domain layer foundation for Phase 3 of the Docker Compose Topology refactoring (Epic #287). It creates type-safe port binding types and cross-service port conflict validation, following the same pattern established for networks in Phase 1-2.
## Changes
### P3.1: Create Port Domain Types ✅
- **Reused `Protocol` enum** from `domain/tracker/protocol.rs` (no duplication)
- **Created `PortBinding` struct** with:
- Private fields: `host_port`, `container_port`, `protocol`, `host_ip`, `description`
- Convenience constructors: `tcp()`, `udp()`, `localhost_tcp()`
- `docker_compose_binding()` method for YAML rendering (e.g., `"6969:6969/udp"`)
- Description support for inline YAML comments
- **10 unit tests** covering all constructors and binding formats
### P3.2: Extend ServiceTopology with Ports ✅
- Added `ports: Vec<PortBinding>` field to `ServiceTopology`
- Added `new()` constructor with ports parameter
- Added `with_networks()` for backward compatibility
- Made all fields private with getters (DDD compliance)
- **4 new tests** for port functionality
### P3.3: Add Cross-Service Port Validation ✅
- Created `PortConflict` error type with full context (both services, both bindings)
- Created `TopologyError` enum with `help()` method (DDD error conventions)
- Implemented `validate_port_uniqueness()` on `DockerComposeTopology`
- **6 tests** covering conflict scenarios
## DDD Compliance
All code follows the project's DDD practices ([docs/contributing/ddd-practices.md](docs/contributing/ddd-practices.md)):
| Requirement | Status |
|-------------|--------|
| Private fields with getters | ✅ All domain types |
| `#[must_use]` on getters | ✅ Applied |
| Expressive errors with `help()` | ✅ `TopologyError::help()` |
| Single point of validation | ✅ Aggregate method |
## What's NOT in this PR
**P3.4 (Template Integration)** will be a follow-up PR:
- Update `DockerComposeContext` to use derived ports
- Simplify `docker-compose.yml.tera` port sections
- Remove conditional port logic from template
This split allows the domain foundation to be reviewed and merged independently.
## Testing
- ✅ 20 new unit tests for port topology
- ✅ All 2021 existing tests pass
- ✅ All 393 doc tests pass
- ✅ E2E infrastructure lifecycle tests pass
- ✅ E2E deployment workflow tests pass
- ✅ All linters pass (clippy, rustfmt, markdown, yaml, toml, cspell, shellcheck)
## Files Changed
| File | Change |
|------|--------|
| `src/domain/topology/port.rs` | NEW - `PortBinding` struct |
| `src/domain/topology/error.rs` | NEW - `PortConflict`, `TopologyError` |
| `src/domain/topology/aggregate.rs` | Extended `ServiceTopology` with ports |
| `src/domain/topology/mod.rs` | Added module exports |
| `docs/issues/287-*.md` | Updated epic with PR split |
| `docs/issues/298-*.md` | Updated spec with completed tasks |
## Related
- Epic: #287
- Issue: #298
- Spec: [docs/issues/298-phase-3-port-topology-domain-model.md](docs/issues/298-phase-3-port-topology-domain-model.md)
ACKs for top commit:
josecelano:
ACK dd3ab12
Tree-SHA512: 408a7610a75fcf7ab82128c693f57b6cadc79ad6dbfc7de4073aca790c7719c6c62c4459a8093a0a9cab8a46e3b96e46be0caacd25169ea7079705961dd60cff
File tree
6 files changed
+879
-81
lines changed- docs/issues
- src/domain/topology
6 files changed
+879
-81
lines changedLines changed: 14 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| |||
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
63 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
| |||
71 | 77 | | |
72 | 78 | | |
73 | 79 | | |
| 80 | + | |
| 81 | + | |
74 | 82 | | |
75 | 83 | | |
76 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
6 | 15 | | |
7 | 16 | | |
8 | 17 | | |
| |||
177 | 186 | | |
178 | 187 | | |
179 | 188 | | |
180 | | - | |
| 189 | + | |
181 | 190 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
186 | 196 | | |
187 | | - | |
| 197 | + | |
188 | 198 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
197 | 205 | | |
198 | | - | |
| 206 | + | |
199 | 207 | | |
200 | | - | |
201 | | - | |
202 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
203 | 212 | | |
204 | | - | |
| 213 | + | |
205 | 214 | | |
206 | 215 | | |
207 | 216 | | |
208 | 217 | | |
209 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
210 | 225 | | |
211 | 226 | | |
212 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
213 | 240 | | |
214 | 241 | | |
215 | | - | |
216 | 242 | | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | 243 | | |
221 | 244 | | |
222 | 245 | | |
| |||
0 commit comments