Saga Framework Foundation
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 patternSagaDefinition,SagaExecution- saga structure and runtime stateSagaRegistry- holds definitions and action factories registered at bootSagaStorage- persistence interface (entity-based implementation)
Executor:
SagaExecutorwith 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:
SagaEntityschema (kind: saga, indexed by status)EntitySagaStorageimplementation- 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