Multi-Step Rollback (Saga)
Automatically undoes earlier completed steps in reverse order if a later step fails.
Step 3 fails and leaves orphaned cloud previews, locked inventory, or mismatched Jira tickets behind.
Saga automatically calls ticket.revert_status and deploy.destroy_preview in reverse order through the journal.
What It Does (In Plain English)
When one workflow touches multiple external systems (e.g., reserve inventory → charge card → create shipment), a failure on step 3 leaves the first two steps half-done. Saga records each forward step paired with its undo tool and runs all undo actions in strict reverse order (3 → 2 → 1) on failure.
Real-World Example
- 1Step 1 creates a staging preview (
deploy.create_preview) paired with undodeploy.destroy_preview. - 2Step 2 updates a ticket (
ticket.update_status) paired with undoticket.revert_status. - 3Step 3 fails a final release check.
- 4Saga automatically reverts the ticket first, then destroys the preview — leaving zero mess.
When Should You Turn It On?
Enterprise Edition. Add at Level 3 (execute) when workflows mutate 2+ external systems that must stay in sync.
Safety level note: Level 3 · Execute — Can run routine live actions with grants, receipts, and audit logs.
How to Add It (workspace.yaml)
# Enterprise Edition (@neusym/kit-saga)
kits:
- "@neusym/kit-saga@0.1.0"
kitConfigs:
saga:
autoCompensateOnTaskFailure: trueKits It Works With
Technical Details & Configuration Options (4 settings)
| Package | @neusym/kit-saga |
|---|---|
| Provides Ports | saga@1 |
| Requires Ports | tasks@1tools@1operations@1 |
| Optional Ports | delegation@1budget@1secrets@1notifier@1scheduler@1 |
| Publishes Events | saga.changedsaga.compensation_failed |
| Owned DB Collections | sagassaga_steps |
Configuration Options (kitConfigs.saga)
| Setting | Type | Default | Description |
|---|---|---|---|
maxStepsPerSaga | integer | 64 | — |
autoCompensateOnTaskFailure | boolean | true | — |
compensationLeaseMs | integer | 30000 | — |
maxCompensationAttempts | integer | 3 | — |