# Event Ordering

> A rule or precondition that a stateful consumer processes the events of one key in their sequence order.

Record: `architecture:event-ordering`
Kind: constraint
Layer: [Causality Core](https://banes-lab.com/records/layer/causality-core.md)
Severity: contextual
Scope: stream, queue, consumer
Canonical: https://banes-lab.com/ontology#architecture-event-ordering

Listed in [Architecture principles](https://banes-lab.com/api/records/architecture.md), after [Happens-Before Relationship](https://banes-lab.com/records/architecture/happens-before-relationship.md) and before [Causal Dependency](https://banes-lab.com/records/architecture/causal-dependency.md).

## Repair

- Refactored by: Add Partition Key, Sequence Number, Reorder Buffer
- Detected by: missing ordering key/sequence checks
- Violated by: stateful consumers processing out of order
- Measured by: out-of-order rate
- Enforced by: stream config, consumer tests

## Requires

- [Ordering Key or Sequence](https://banes-lab.com/records/lexicon/ordering-key-or-sequence.md)

## Reinforces

- [Causality](https://banes-lab.com/records/architecture/causality.md)

## Enables

- [Correct Stateful Processing](https://banes-lab.com/records/lexicon/correct-stateful-processing.md)

## Conflicts with

- [Unordered Parallel Consumption](https://banes-lab.com/records/lexicon/unordered-parallel-consumption.md)

## In tension with

- [Throughput](https://banes-lab.com/records/architecture/throughput.md)

## Tensions

- [Event Ordering / Throughput](https://banes-lab.com/records/tension/event-ordering-throughput.md)

## Severity

- [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)

## Category

- [Causality / Ordering / Distributed Time](https://banes-lab.com/records/architecture-category/causality-ordering-distributed-time.md)

## Reinforced by

- [Hybrid Logical Clocks](https://banes-lab.com/records/architecture/hybrid-logical-clocks.md)
- [Total-Order Broadcast](https://banes-lab.com/records/architecture/total-order-broadcast.md)

## Linked from

- [Orchestration as declared structure](https://banes-lab.com/pag/orchestration/declared-structure.md)
- [The board and the venue](https://banes-lab.com/disciplined-methodology/collaborate/the-board-and-the-venue.md)
- [One chain](https://banes-lab.com/disciplined-methodology/ship/one-chain.md)
- [Execution joins the halves](https://banes-lab.com/software-architecture/principles/execution-joins-the-halves.md)
- [Causality / Ordering / Distributed Time](https://banes-lab.com/ontology/principles/architecture-category-causality-ordering-distributed-time.md)
- [Scalability / Performance / Optimization](https://banes-lab.com/ontology/principles/architecture-category-scalability-performance-optimization.md)
- [Causality / Ordering / Distributed Time](https://banes-lab.com/ontology/lexicon/lexicon-category-causality-ordering-distributed-time.md)
- [Severity levels](https://banes-lab.com/ontology/schema/the-vocabulary-severity.md)
- [The resolutions](https://banes-lab.com/ontology/schema/the-resolutions.md)
