Skip to main content

Bounded Context Canvas

Following the ddd-crew Bounded Context Canvas v5. Every message row below maps to a real REST route (internal/adapters/inbound/http/server.go, internal/adapters/inbound/http/reports_handler.go), MCP tool (internal/adapters/inbound/mcp/tools.go) or Kafka topic + CloudEvents type (internal/adapters/kafka/cloudevents/cloudevents.go).

Canvas at a glance​

Two pictures of the sections below, laid out like the ddd-crew canvas: first the inbound collaborators feeding this context (purpose, domain roles and the business decisions it enforces), then the outbound collaborators it calls or notifies. Arrows follow the message type: solid blue commands (cmd), dotted green queries (qry), thick orange events (evt); each arrow names its channel and the messages it carries. Box shapes mark the collaborator kind: rounded = people, UI or any client; blue = sibling bounded context; double border = external system or platform; grey = this context's own projector, reports or dead-letter path; dashed = published today with no consumer. Channel names on the arrows are abbreviated (REST, MCP, Kafka, HTTP, port); the Inbound and Outbound Communication tables carry the exact route, tool, topic and CloudEvents type for every message.

Inbound​

Outbound​

Source: the Inbound Communication and Outbound Communication tables of this page, which map to internal/adapters/inbound/{http,kafka,mcp} and internal/adapters/outbound/. The diagram omits assumptions, verification metrics, open questions and the ubiquitous language (sections below), the relationship pattern per message (OHS, ACL, Conformist, Customer/Supplier - see the tables) and anything the tables mark as deprecated or platform-only (health probes).

Name​

Labor Performance (labor-performance, CloudEvents subdomain wes, source = /warehouse/labor-performance).

Purpose​

Tell a warehouse how long each kind of task should take and how long it actually took. The context holds the engineered labor standard per TaskType ("a PICK should take 45 s"), scores every completed task against the standard that was in force when it finished, measures the idle gap before each task, and turns those facts into per-associate scorecards, fleet-wide task-type performance, utilization and an hourly analytical report — without ever influencing how the work is executed.

Strategic Classification​

DimensionValueEvidence
DomainSupportingADR 0002, Subdomain classification, Core Domain Chart
Business ModelCompliance / cost reduction — makes labor productivity visible so staffing (in workforce-management) and coaching (by a human) can act on it; it earns no revenue and enforces nothing itselfADR 0005 ("visibility, not enforcement"), ADR 0013
EvolutionProduct — engineered labor standards are an off-the-shelf WMS/LMS moduleDomain vision

Domain Roles​

  • Analysis context (primary) — it observes another context's facts and derives scores, trends and utilization from them.
  • Specification context (secondary) — it owns one piece of reference data the rest of the fleet can rely on: the engineered labor standard per TaskType.
  • Downstream observer / gateway of none — it has no command path back into execution and calls no sibling (ADR 0003).

Inbound Communication​

CollaboratorMessageTypeChannelRelationship
fulfillment-executionTaskCompletedEventKafka warehouse.fulfillment.events, CE type com.warehouse.wes.fulfillment-execution.task.TaskCompleted (group labor-performance) → RecordTaskPerformanceConformist to upstream OHS/PL
Operator via warehouse-console (labor_mfe)DefineStandardCommandREST POST /standards (requires Idempotency-Key when Postgres is configured)OHS
Operator via warehouse-console (labor_mfe)GetAssociateScorecardQueryREST GET /associates/{associateId}/scorecardOHS
Operator via warehouse-console (labor_mfe); workforce-management (http mode)GetTaskTypePerformanceQueryREST GET /task-types/{taskType}/performanceOHS
Any REST clientGetStandardQueryREST GET /standards/{taskType}OHS
Any REST clientGetUtilization.ForTaskTypeQueryREST GET /task-types/{taskType}/utilization?window=OHS
Any REST clientGetUtilization.ForAssociateQueryREST GET /associates/{associateId}/utilization?window=OHS
warehouse-ops-agentGetAssociateScorecardQueryMCP tool get_associate_scorecard; resource template scorecard://labor/{associateId}OHS
warehouse-ops-agentGetTaskTypePerformanceQueryMCP tool get_task_type_performanceOHS
warehouse-ops-agentGetStandardQueryMCP tool get_labor_standardOHS
warehouse-ops-agentGetUtilization.ForTaskTypeQueryMCP tool get_task_type_utilizationOHS
warehouse-console (reports page), warehouse-ops-agentLabor Performance ReportQueryREST (reports, cmd/labor-reports :8092) GET /reports/performance?from=&to=&taskType=&granularity=OHS
warehouse-console (reports page), warehouse-ops-agentReport freshnessQueryREST (reports) GET /reports/performance/freshnessOHS
this context (cmd/labor) → cmd/labor-projectorLaborStandardDefined, LaborStandardRevised, TaskPerformanceRecordedEventKafka warehouse.labor-performance.analytics (group labor-performance-analytics, earliest offset)internal — same context

Outbound Communication​

CollaboratorMessageTypeChannelRelationship
workforce-managementTaskPerformanceRecordedEventKafka warehouse.labor-performance.events, CE type com.warehouse.wes.labor-performance.performance.TaskPerformanceRecorded, key associate_idOHS + Published Language; WFM is Conformist
warehouse-planningLaborStandardDefinedEventKafka warehouse.labor-performance.events, CE type com.warehouse.wes.labor-performance.standard.LaborStandardDefined, key task_type (ADR 0038)OHS + Published Language; warehouse-planning is Conformist
warehouse-planningLaborStandardRevisedEventKafka warehouse.labor-performance.events, CE type com.warehouse.wes.labor-performance.standard.LaborStandardRevised, key task_type (ADR 0038)OHS + Published Language; warehouse-planning is Conformist
own cmd/labor-projectorLaborStandardDefinedEventKafka warehouse.labor-performance.analytics, CE type com.warehouse.wes.labor-performance.standard.LaborStandardDefined, key task_typeinternal
own cmd/labor-projectorLaborStandardRevisedEventKafka warehouse.labor-performance.analytics, CE type com.warehouse.wes.labor-performance.standard.LaborStandardRevised, key task_typeinternal
own cmd/labor-projectorTaskPerformanceRecordedEventKafka warehouse.labor-performance.analytics, CE type com.warehouse.wes.labor-performance.performance.TaskPerformanceRecorded, key task_typeinternal
operations (no consumer)undecodable or repeatedly failing TaskCompletedEvent (dead letter)Kafka warehouse.fulfillment.events.dlq (original bytes + x-dlq-* headers)—

There is no outbound command or query: no REST or MCP client to any sibling exists (ADR 0003).

Ubiquitous Language​

Full glossary with code identifiers: Ubiquitous language. Top terms:

  • LaborStandard — the expected seconds for one TaskType, with an append-only effective range.
  • TaskPerformance — one completed task, scored and frozen.
  • StandardSecondsAtCompletion — the standard in force as of the completion instant, copied onto the row.
  • EfficiencyPct — 100 × standard ÷ actual; null when either is not positive.
  • Idle Gap (IdlePeriod) — previous completion → next claim.
  • Utilization — task time ÷ (task time + idle time), as a percent.
  • Scorecard, Trend, CoachingFlag — per-associate read model and its two signals.

Business Decisions​

  • A standard revision closes the prior standard and opens a new one; it never overwrites (ADR 0004). At most one open standard per TaskType (partial unique index, ADR 0022).
  • A task is scored against the standard active as of its completion time, not the one active at ingestion; the value is frozen (ADR 0004).
  • No number is ever fabricated: unscorable/unmeasurable rows yield null efficiency/means, never 0 (ADR 0006, CLAUDE.md non-negotiable 3).
  • Unknown or absent task_type and empty associate_id are recorded, not rejected (ParseTaskTypeLenient).
  • Idle gaps are capped at IDLE_GAP_CAP_SECONDS (default 3600) and flagged capped; out-of-order gaps are skipped, not failed (ADR 0014).
  • Trend needs at least 3 scored recent tasks and a 5-point move; the coaching flag needs the last 3 scored tasks under 85 % (ADR 0005). The flag is a signal for a human, never an action.
  • TaskPerformance is written only by the Kafka consumer; there is no REST write for it (CLAUDE.md non-negotiable 4).
  • Decided 2026-10-06: the open gap stays per associate (ADR 0014). GetUtilization.ForTaskType reports openGapSeconds: 0 by design and says so in the OpenAPI description. An idle gap belongs to an Associate; until that associate's next claim ends it, it has no task type, so attributing it to one would invent semantics. No code or contract change.

Assumptions​

  • fulfillment-execution keeps publishing TaskCompleted with a meaningful time (completion instant) and duration_seconds (claim → completion); the idle-gap derivation depends on both.
  • TaskType stays the closed set PICK, PACK, SLAM mirrored from fulfillment-execution's task.Type; any other value is "unclassified".
  • One associate does one task at a time, so previous completion → next claim is a meaningful idle gap.
  • Shifts are not modelled here; the cap stands in for shift boundaries.

Verification Metrics​

  • Business counter labor_performance.standards.defined, split by outcome accepted/rejected (internal/adapters/outbound/telemetry/metrics.go, ADR 0008).
  • Outbox lag gauge labor_performance.outbox.lag_seconds, registered by postgres.RegisterOutboxLagGauge (internal/adapters/outbound/postgres/outbox_metrics.go).
  • Report freshness lag from GET /reports/performance/freshness (lagSeconds).
  • HTTP RED metrics (http.server.request.duration) and Kafka consume/publish spans exported over OTLP.

Open Questions​

  • Who sets standards in practice? Today any unauthenticated REST client can POST /standards (ADR 0012 removed auth).
  • The integration topic is keyed by associate_id; robot-station completions all share the empty key and therefore one partition.
  • warehouse.fulfillment.events.dlq has no consumer or replay tooling.
  • Utilization for robot stations is out of scope (no associate, no idle gap) — is that a gap someone needs filled?
  • Resolved, decided 2026-10-06: the open gap stays per associate (ADR 0014); at task-type scope openGapSeconds is always 0 by design, so this is no longer an open question.