Command
A command is the interpretation of an event by a given observer as an attempted transition of a target subject.
Relative to the interpreting observer, the event is an exogenous input event. Relative to the emitter, the carried event is an endogenous output event. These are boundary-relative roles. The carried value and interaction contract may explicitly express command intent, but the emitter does not compel another observer's semantic interpretation.
All inputs to an operation are modeled as input events subject to interpretation. They become commands only when an observer interprets them as attempted transitions for a target subject.
Command interpretation proceeds as follows:
Endogenous output event at an emitter boundary
-> exogenous input event at an interpreting observer boundary
-> attempted transition, relative to the observer and target subject
-> validation against current entity state, required observations, invariants, policies, authority, and expected version
-> typed applied, no-change, alternate, conflict, or rejection outcomeCommands are not mere messages. They are interpretations made relative to:
- The specific observer, its boundary and its current view of state.
- Authority, invariants, and policies.
- The intended transition.
- An optional expected version or ETag.
A command's expected version is a claim carried by the input event, ordinarily based on the emitter's observation of entity state when it formed its request. The receiving observer decides whether that claim is relevant and validates it before accepting the transition and advancing the entity version.
An emitter may express command intent through a target identity, operation name, schema, expected version, or other protocol data. When a message contract carries singular intent toward an understood observer, command interpretation is the expected interpretation and may be operationally unambiguous. The semantic command nevertheless remains observer-relative: the receiver admits and interprets the input as a requested transition for a subject in a specific context and may reject, ignore, or classify an invalid input without accepting the transition.
When the emitter expects a later response, the emission may be modeled as a request effect. The request obligation belongs to the emitter's intent and continuation; command interpretation belongs to the receiving observer. Neither relation requires synchronous interaction, and the request is not an event subtype.
A query is the corresponding observer-relative interpretation of input as a request to observe, compute, or return information without requesting a modeled semantic state transition.
In CQRS, commands belong to the write side: they are interpreted against the authoritative model and may commit transitions that later become visible to queries through projections, read models, or other reconstitution paths.
External References
- Gregor Hohpe and Bobby Woolf, Command Message, Enterprise Integration Patterns, 2003.
Related concepts: enterprise integration patterns, value, shape, observation, query, CQRS, observer, authority, boundaries, entity, transition, version, effect, Effect Models, messages and envelopes, interaction, concurrency control, monads monoids and duals, adjunctions.