﻿# ADR 0005 — Domain Services Belong in Domain Modules, Not Common (T-F06)

Date: 2026-09-11
Status: Accepted
Refs: T-F06, EXECUTION_ROADMAP.md §9

## Context

`src/Common/Service/` had accumulated domain-specific services that were not
truly "common" cross-cutting infrastructure:
- `BrandRateService` / `BrandRateRepository` (pricing logic)
- `LedgerService` (accounting/ledger logic)
- `CheckService` / `CheckRepository` (cheque payment logic)
- `InventoryRepository` (stock management)
- `AuditLogService`, `AuditIntegrityService`, `AuditMetricsService`,
  `AuditQueryService`, `AuditEventRepository`, `AuditMetricsRepository`,
  `AuditQueryRepository` (audit trail)
- `BrandPricingService` (bulk pricing recalculation)
- `PartnerAmpereService` (partner ampere credit/debit)

## Decision

Each domain service was migrated to its proper bounded context:

| Service | New Location |
|---|---|
| BrandRateService, BrandRateRepository, BrandPricingService | `src/Pricing/` |
| LedgerService | `src/Ledger/` |
| CheckService, CheckRepository | `src/Check/` |
| InventoryRepository | `src/Inventory/Repository/` |
| Audit* | `src/Audit/` |
| PartnerAmpereService | `src/Partner/Service/` |

`src/Common/` now contains only genuine cross-cutting infrastructure:
`UuidService`, `Cache`, `FileRateLimiter`, `RedisRateLimiter`,
`RedisJobQueue`, `DatabaseJobQueue`, `InMemoryJobQueue`, `PartyResolver`.

## Consequences

- The import graph becomes more honest: cross-module dependencies that were
  hidden inside `Common` are now explicit namespace references.
- The number of `use App\Common\...` imports may appear to increase, but this
  reflects real coupling made visible — not new coupling introduced.
- Architecture tests enforce that `Common` does not import from domain modules.
- All `ContainerFactory` bindings were updated to the new namespaces.
