Retries, Circuit Breakers & Lease Guard
Retries temporary blips with backoff and stops zombie workers whose lease expired.
A slow worker that lost its lease wakes up 5 minutes later and overwrites a newer worker’s progress.
The stale worker immediately sees HALT_LEASE_LOST and steps aside cleanly without corrupting state.
What It Does (In Plain English)
Resilience protects long-running tasks from flaky APIs and multi-process race conditions. It retries transient failures with exponential backoff, temporarily quarantines broken endpoints, and verifies before every model call that this worker still owns the task’s active lease.
Real-World Example
- 1Worker A freezes during a garbage-collection pause and its 60-second queue lease expires.
- 2Worker B safely picks up the task with a newer epoch number.
- 3Worker A unfreezes and tries to take its next step.
- 4Resilience checks the lease, catches the mismatch, and stops Worker A cleanly.
When Should You Turn It On?
Add in any multi-worker or production deployment alongside worker-pool.
Safety level note: Level 1 · Review — Read-only. Can inspect and answer, never changes outside systems.
How to Add It (workspace.yaml)
kits:
- "@neusym/kit-resilience@0.1.0"
kitConfigs:
resilience:
maxRetries: 3
baseBackoffMs: 1000Kits It Works With
Technical Details & Configuration Options (5 settings)
| Package | @neusym/kit-resilience |
|---|---|
| Provides Ports | None |
| Requires Ports | tasks@1queue@1 |
| Optional Ports | identity@1secrets@1 |
| Publishes Events | resilience.breaker_openedresilience.breaker_closed |
| Owned DB Collections | quarantine_records |
Configuration Options (kitConfigs.resilience)
| Setting | Type | Default | Description |
|---|---|---|---|
maxRetries | integer | 3 | — |
baseBackoffMs | integer | 250 | — |
failureThreshold | integer | 3 | — |
quarantineMs | integer | 30000 | — |
taskQueue | string | "tasks" | — |