Submit an issue View all issues Source
MIR-439

Saga Framework Foundation

Done public
phinze phinze Opened Oct 2, 2025 Updated Jun 4, 2026

Implement the core saga framework that enables crash-recoverable multi-step operations with guaranteed compensation.

Scope

Build pkg/saga package with:

Core Interfaces:

  • Action, ActionInputs, ActionFactory - stateless action pattern
  • SagaDefinition, SagaExecution - saga structure and runtime state
  • SagaRegistry - holds definitions and action factories registered at boot
  • SagaStorage - persistence interface (entity-based implementation)

Executor:

  • SagaExecutor with Execute/Compensate/Resume logic
  • Durable logging after each action
  • Reverse-order compensation on failure
  • Recovery mechanism (query incomplete sagas, resume or compensate)

Progress Infrastructure:

  • Framework-level progress callbacks via ActionInputs.Progress()
  • Gracefully noop during recovery
  • Route to application-provided callbacks during execution

Storage:

  • SagaEntity schema (kind: saga, indexed by status)
  • EntitySagaStorage implementation
  • Support for querying incomplete sagas (status IN running, compensating)

Testing:

  • Unit tests for executor logic (success, failure, compensation)
  • Recovery scenario tests (crash simulation)
  • Mock storage for fast testing

Why Foundation First

This is the framework that Issues #2 and #3 will build on. Can't meaningfully split it without creating circular dependencies.

Reference

RFD 0035: Saga Pattern for Distributed Operations Phase 1 from Migration Strategy