Expand description
§Command Bus Module
Coordinates command handling through aggregates with event persistence and publishing.
§Flow
- Load events from
EventStorefor the target aggregate - Reconstruct aggregate state via
Aggregate::from_events() - Handle command through
Aggregate::handle()to produce new events (events leavehandle()withaudit = AuditMetadata::pending()) - Stamp each event with a fully-validated
AuditMetadataderived from the request-scopedCommandContext - Append events to
EventStorewith optimistic concurrency check; the store re-validates audit (defense-in-depth) - Publish events to
EventBusfor projections and side effects
§Audit invariant
Every persisted event carries AuditMetadata (HIPAA §164.312(b)).
dispatch requires a CommandContext argument; production code cannot
omit it. Internal jobs use CommandContext::system.
Structs§
- Command
Bus - Command bus for dispatching commands to aggregates.
- Command
Context - Request-scoped context for command dispatch.
Enums§
- Command
BusError - Errors that can occur during command bus operations.
- Snapshot
Policy - Controls whether
CommandBusmaintains snapshots on the command/write rehydrate path.