Description
Harden the background worker so jobs interrupted by a process crash or deployment can be resumed or safely marked for retry instead of remaining stuck indefinitely. This improves settlement and anchor processing reliability without creating duplicate ledger actions.
Context & Requirements
The repository exposes a worker entry point at src/worker/index.ts and uses Prisma-backed application state. Stellar submissions and SEP-24 polling can outlive a single process. A worker must distinguish an in-progress lease from a completed operation and must not blindly replay a transaction after losing its local state. Recovery should use a lease timeout, bounded attempts, and the existing settlement or anchor state machine rather than adding a second job store.
State updates need to be conditional so two worker instances cannot process the same job simultaneously. Recovery should preserve auditability and record when a job is retried or moved to a terminal failure state.
Acceptance Criteria
Implementation Guidance
Start with src/worker/index.ts and inspect the Prisma schema and service modules used by settlement and SEP-24 processing. Reuse existing status fields and audit patterns where possible. Keep external Stellar and anchor calls in src/services/*, and design the lease duration around the longest supported polling or submission operation rather than a fixed arbitrary sleep.
Testing & Validation
Add tests for lease acquisition, concurrent workers, expired lease recovery, attempt exhaustion, graceful shutdown, and the case where a transaction was submitted before the process stopped. Use a fake clock or controlled timestamps. Run npm run build, npm test, and npm run lint; manually stop and restart the worker against a local test database if the project setup permits it.
Submission Guidelines
Assignment is required before starting. Open one PR that includes Closes #<issue-number>, includes any Prisma migration, and explains how the recovery path avoids duplicate Stellar or anchor actions.
Wave complexity: Medium
Description
Harden the background worker so jobs interrupted by a process crash or deployment can be resumed or safely marked for retry instead of remaining stuck indefinitely. This improves settlement and anchor processing reliability without creating duplicate ledger actions.
Context & Requirements
The repository exposes a worker entry point at
src/worker/index.tsand uses Prisma-backed application state. Stellar submissions and SEP-24 polling can outlive a single process. A worker must distinguish an in-progress lease from a completed operation and must not blindly replay a transaction after losing its local state. Recovery should use a lease timeout, bounded attempts, and the existing settlement or anchor state machine rather than adding a second job store.State updates need to be conditional so two worker instances cannot process the same job simultaneously. Recovery should preserve auditability and record when a job is retried or moved to a terminal failure state.
Acceptance Criteria
Implementation Guidance
Start with
src/worker/index.tsand inspect the Prisma schema and service modules used by settlement and SEP-24 processing. Reuse existing status fields and audit patterns where possible. Keep external Stellar and anchor calls insrc/services/*, and design the lease duration around the longest supported polling or submission operation rather than a fixed arbitrary sleep.Testing & Validation
Add tests for lease acquisition, concurrent workers, expired lease recovery, attempt exhaustion, graceful shutdown, and the case where a transaction was submitted before the process stopped. Use a fake clock or controlled timestamps. Run
npm run build,npm test, andnpm run lint; manually stop and restart the worker against a local test database if the project setup permits it.Submission Guidelines
Assignment is required before starting. Open one PR that includes
Closes #<issue-number>, includes any Prisma migration, and explains how the recovery path avoids duplicate Stellar or anchor actions.Wave complexity: Medium