Skip to main content

Aggregate design canvas

Synced from warehouse-ops-agent

This page is a copy of docs/docs/ddd/aggregate-design-canvas.md on develop, derived from that repository's code. Edit it there, then re-sync.

Following the ddd-crew Aggregate Design Canvas v1.1.

No aggregate root​

warehouse-ops-agent has no aggregate root, so this page carries no per-aggregate H2 sections. That is a design decision, not a gap:

  • internal/domain/policy/doc.go states it outright: the package "is deliberately NOT a domain in the DDD sense: warehouse-ops-agent owns no aggregate, enforces no invariant over persisted state, and persists nothing of its own."
  • There is no internal/domain/<aggregate> package, no repository port in internal/ports (every port is an outbound read client, a telemetry / log reader, the Reasoner, or ArbitrationMetrics), no migrations/ directory and no database driver in go.mod.
  • No type in the policy package has an identity that survives a request, a status enum with transition methods, or a version field. Every value is built from upstream reads, returned, and forgotten.
  • ADR 0001: if a slice ever needs an aggregate, an invariant or persisted state, that slice belongs in a bounded-context repo, not here.

The canvas sections map to this repo as follows:

Canvas sectionWhat applies here
1. Namenone — no aggregate
2. Descriptionnone
3. State transitionsnone — no status enum with transition methods exists in internal/domain/policy
4. Enforced invariantsnone over persisted state. The rejections that do exist are input validation at an untrusted boundary (see below)
5. Corrective policiesthe degrade-to-hold rules below play this role for recommendations, not for state
6. Handled commandsnone — every inbound message is a query (GET routes, read-only MCP tools)
7. Created eventsnone — no Kafka I/O, no CloudEvents type (see Domain events)
8. Throughputn/a for an aggregate; request-rate estimates for the use cases are below
9. Sizen/a — nothing is stored

Boundary validation (not invariants)​

These reject untrusted input; none guards a stored state.

RuleEnforced byRejects
wes RebalanceAction is one of NoActionNeeded, ThrottleUpstream, ReassignLaborpolicy.ParseRebalanceActionan unknown action from get_rebalance_recommendation (the use case returns an error, HTTP 400)
TaskType is one of PICK, PACK, SLAMpolicy.TaskType.Valid, checked by policy.Evaluatean unknown taskType on detect_stranded_reservation
severity filter is info, warning or criticalseverityRank + invalidSeverityErr (inbound/mcp)an unknown list_open_exceptions filter
LLM_MODE is off, shadow or onpolicy.ParseLLMModean unknown mode — a startup error in cmd/agent/reasoner.go
An LLM plan uses the closed action vocabulary, 0 ≤ proposedHeads ≤ 50, heads only with assign_labor, non-empty rationalepolicy.ValidatePlan (wraps policy.ErrInvalidPlan)an out-of-vocabulary or out-of-bounds plan; Arbitrate falls back to the deterministic decision
A capacity reading is in ORDER units and non-negativepolicy.SummarizeCapacityOutlookany other unit or a negative rate, turned into an OmittedReason
Both location codes are suppliedusecases.ExplainTravelFactor.Executea missing fromLocationCode / toLocationCode, or facility-layout rejecting the codes with a validation slug (error wrapping usecases.ErrInvalidInput, HTTP 400; decided 2026-10-06, ADR 0018); any other upstream facility-layout failure (not-found, internal-error, slug-less legacy text, outage) is not input validation and is HTTP 502

Decision objects and read models (listed separately)​

These are built per request and are not aggregates. Each row names the pure function that builds it and the degrade rule that plays the "corrective policy" role.

Type (internal/domain/policy)Built byDegrade / corrective rule
Decision (the E1 FlowBalanceException)Decide, then Arbitratemissing wes signal, or missing wfm / fe on the branch in play, yields Partial: true, MissingSignals, hold
UtilizationCorrelation (ADR 0008 overlay on Decision)CorrelateUtilizationnil when labor-performance is unavailable or UtilizationPct is null — never 0%
StrandedReservationException (E2)Evaluateany missing signal, no reservationId, or no bin occupancy yields hold; revoke_reservation only with a BlastRadius
DailyBrief / SiteBrief / PathBrief / OpenException (E3)SynthesizePathBrief, deriveExceptionsan unavailable upstream leaves that fact nil and adds an Unavailable entry; exceptions only from ≥ 2 signals
CapacityOutlook (ADR 0013)SummarizeCapacityOutlook, OmittedCapacityOutlookfail-open: any failure becomes OmittedReason; never feeds deriveExceptions
TravelFactorCorrelation (ADR 0009)CorrelateTravelFactornil when no reading
RuntimeSignalsReport / ServiceSignalClassifyErrorRate, ClassifyLatencyP99, ServiceSignal.Severityfailing source listed in UnavailableSources
Arbitration (ADR 0004)Arbitrateon mode falls back to the deterministic decision with Source = fallback

Application-layer read models with no policy at all: usecases.OrderLifecycleResult (order lifecycle) and usecases.DashboardResult / ReportSection (WMS / WES dashboards).

Throughput and size (estimates)​

Estimate, not measured. Request rate is driven by humans and agentic hosts: a console screen or an LLM host polling the daily brief every few seconds to minutes, flow-balance and stranded-reservation checks on demand. Each request fans out to between 1 (travel factor) and roughly 5 × N upstream calls (daily brief, N = configured path targets), plus up to 6 Anthropic turns when LLM_MODE is not off (defaultMaxTurns = 6).

Estimate. Size per "instance" is zero at rest: every decision object lives for one request. The only process-lifetime state is listed on the Entity relationship page.