ADR-0006 — Project ShiftPlanCommitted into LaborPlanObserved, not into our ShiftPlan
Status
Amended by ADR-0049 (2026-11-18): the
ShiftPlanhalf moves to warehouse-planning; theLaborPlanObservedprojection described here stays.
Accepted.
Context
workforce-management publishes ShiftPlanCommitted when a human commits a
split of headcount across process paths, one message per path line:
{"building_id": "BLD1", "shift_id": "S1", "path_id": "pick-a",
"planned_heads": 7, "planned_rate": 95.5, "planned_hours": 8}
This service has an aggregate called ShiftPlan, containing PathPlan lines
with plannedHeads, rate and hours.
Same name. Nearly the same fields. The obvious implementation is to feed the
event into CommitShiftPlan and be done.
That would be the classic DDD mistake. The strategic reference names it directly:
Same word, different model is allowed — and expected.
Taskin WMS andTaskin WES are deliberately different classes with different lifecycles. Don't force a shared DTO/entity across the boundary; translate at the ACL.
The two models genuinely differ:
Workforce's ShiftPlan | Our ShiftPlan | |
|---|---|---|
| What it is | A labour commitment: which associates, which paths, direct vs indirect hours, one per building per shift | This context's own throughput decision: rate × heads × hours on a path |
| Owns | associates, certifications, breaks, assignments | the plannedHeads ≤ installedStations invariant |
| Concept of "installed stations" | none — it does not model physical station counts | central; it is the invariant's right-hand side |
| Who may change it | a human in Workforce | this service's CommitShiftPlan use case |
| Lifecycle | committed at shift start, revised intra-shift | committed by us, then read by release and rebalance |
Three concrete failures follow from merging them.
- An external system could violate our invariant. Workforce has no
installedStationsand no reason to respect it. Aplanned_heads: 12event for a path with 8 stations would either be rejected — meaning we drop a fact Workforce has already committed and is entitled to commit — or accepted, destroying the invariant. Neither is acceptable. - Our commit logic would be coupled to their publish cadence. Every Workforce revision would silently overwrite a decision this context made.
- The failure would be invisible. No compiler and no test catches "these
two
ShiftPlans are the same thing", because from a distance they look identical. The only defence is a deliberate boundary.
Decision
We will project ShiftPlanCommitted into a new, separate, read-only type
called LaborPlanObserved, and it will never touch the ShiftPlan aggregate or
the CommitShiftPlan use case.
-
A new package,
internal/domain/laborview, holding a plain value:type LaborPlanObserved struct {PathId shared.PathIdPlannedHeads intPlannedRate float64PlannedHours float64ObservedAt time.Time}Exported fields, no constructor, no validation, no behaviour. That shape is the decision made visible: this type protects nothing, because the facts in it are owned by another bounded context and we are not entitled to reject them. Compare
PathPlan, which has private fields and a validating constructor because its rule is ours. -
Deliberately different names. Not
ShiftPlanVieworExternalShiftPlan—LaborPlanObserved. A reader who sees it besideShiftPlanshould have to ask why, and get this answer. -
Its own port, table and endpoint.
LaborPlanViewRepowith memory and Postgres adapters, alabor_plan_viewtable joined to nothing, andGET /paths/{pathId}/labor-plan-view— returning404when nothing has been observed, so "no observation" is distinguishable from "observed zero". -
Idempotent projection. The
event_idis checked againstprocessed_eventsbefore writing, so redelivery does not re-write the row. -
Additive context only in
RebalanceDecision. The response may carry the projection as an extra field. The decision logic does not consult it, and the existing rebalance tests were unchanged by adding it.
The same reasoning produced UsableInventoryObserved for Inventory's events —
keyed by SKU, not by path, because Inventory reservations are SKU-scoped and
a SKU-to-path mapping does not exist in the domain. Forcing one for the sake of
consistency with our other endpoints would have produced a projection wrong in a
way no test could catch.
Consequences
Easier
- Our invariant is inviolable from outside. No external event can reach
PathPlan's constructor. - Both facts are available side by side. "We planned 6 heads; Workforce
committed 7" is answerable, and it is genuinely useful next to a
ReassignLaborrecommendation — which is exactly why the projection appears as context on that response. - Workforce's schema can change freely. Its payload struct is unexported inside our inbound Kafka adapter; nothing downstream of the ACL knows its shape.
- The read model is trivial. No invariants means no invariant tests, no migration risk from a rule change, and a table with no foreign keys.
Harder
- Two similar types in one codebase.
ShiftPlan,PathPlan,LaborPlanObserved— a newcomer will ask whether the third is redundant. This ADR is the answer, and it needs to keep being given. - Nothing enforces the separation. No test fails if someone wires the
consumer into
CommitShiftPlan. It is a convention, defended by naming, package boundaries and this record. (The arch-go fitness tests enforce layering, not semantic boundaries.) - Duplication is now permanent. Both models carry planned heads and rate. They will drift, and drift is the correct outcome — but it will look like a bug to someone.
- Reconciliation is out of scope. Nothing detects that we planned 6 while Workforce committed 7. The data is exposed; noticing is a human's job today.
- The name is longer.
LaborPlanObservedreads awkwardly next toShiftPlan. Accepted: awkwardness that prompts a question is cheaper than familiarity that hides one.