# Saga Pattern

> A design pattern that runs a cross-service transaction as a sequence of local steps, each paired with a compensating step.

Record: `architecture:saga-pattern`
Kind: pattern
Layer: [Execution Core](https://banes-lab.com/records/layer/execution-core.md)
Severity: contextual
Scope: service workflow, distributed system
Canonical: https://banes-lab.com/ontology#architecture-saga-pattern

Listed in [Architecture principles](https://banes-lab.com/api/records/architecture.md), after [Eventual Consistency](https://banes-lab.com/records/architecture/eventual-consistency.md) and before [Outbox Pattern](https://banes-lab.com/records/architecture/outbox-pattern.md).

## Repair

- Refactored by: Introduce Saga, Add Compensation
- Detected by: distributed transaction attempts
- Violated by: cross-service transaction requiring atomic database commit
- Measured by: compensation coverage
- Enforced by: workflow tests

## Requires

- [Compensating Transactions](https://banes-lab.com/records/lexicon/compensating-transactions.md)
- [Idempotency](https://banes-lab.com/records/architecture/idempotency.md)

## Reinforces

- [Eventual Consistency](https://banes-lab.com/records/architecture/eventual-consistency.md)

## Enables

- [Long-Running Transactions](https://banes-lab.com/records/lexicon/long-running-transactions.md)

## Conflicts with

- [Global ACID Transaction](https://banes-lab.com/records/lexicon/global-acid-transaction.md)

## In tension with

- [Workflow Complexity](https://banes-lab.com/records/lexicon/workflow-complexity.md)

## Tensions

- [Saga Pattern / Workflow Complexity](https://banes-lab.com/records/tension/saga-pattern-workflow-complexity.md)

## Severity

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

## Category

- [Event / Messaging / Asynchronous Architecture](https://banes-lab.com/records/architecture-category/event-messaging-asynchronous-architecture.md)

## Reinforced by

- [Compensating Transaction](https://banes-lab.com/records/architecture/compensating-transaction.md)

## Linked from

- [Event / Messaging / Asynchronous Architecture](https://banes-lab.com/ontology/principles/architecture-category-event-messaging-asynchronous-architecture.md)
- [Transactions / State / Concurrency](https://banes-lab.com/ontology/principles/architecture-category-transactions-state-concurrency.md)
- [Event Messaging Async](https://banes-lab.com/ontology/lexicon/lexicon-category-event-messaging-async.md)
- [Severity levels](https://banes-lab.com/ontology/schema/the-vocabulary-severity.md)
- [The resolutions](https://banes-lab.com/ontology/schema/the-resolutions.md)
