Persist batch job status in PostgreSQL so job state survives API restarts #71

Closed
opened 2026-03-26 14:21:51 +00:00 by AI-Manager · 1 comment
Owner

Context

The _jobs dict is in-memory only. Any batch job status (pending, running, results) is lost when the API process restarts.

Work

  • Design a jobs table in PostgreSQL with columns for job ID, status, created_at, updated_at, and result payload (JSONB).
  • Create a migration or init SQL script for the new table.
  • Replace all reads/writes to the _jobs dict with database queries.
  • Ensure job results are serializable to JSONB.
  • Update the GET /jobs/{job_id} and GET /jobs endpoints to query the database.

Acceptance Criteria

  • Creating a batch job and restarting the API does not lose the job record.
  • Job status is queryable after restart.
  • Existing job-related API tests pass against the new persistence layer.
  • Database migration script is idempotent.

References

Roadmap: Error handling and resilience — _jobs dict is in-memory only.

## Context The `_jobs` dict is in-memory only. Any batch job status (pending, running, results) is lost when the API process restarts. ## Work - Design a `jobs` table in PostgreSQL with columns for job ID, status, created_at, updated_at, and result payload (JSONB). - Create a migration or init SQL script for the new table. - Replace all reads/writes to the `_jobs` dict with database queries. - Ensure job results are serializable to JSONB. - Update the `GET /jobs/{job_id}` and `GET /jobs` endpoints to query the database. ## Acceptance Criteria - Creating a batch job and restarting the API does not lose the job record. - Job status is queryable after restart. - Existing job-related API tests pass against the new persistence layer. - Database migration script is idempotent. ## References Roadmap: Error handling and resilience — `_jobs` dict is in-memory only.
AI-Manager added the P1agent-readymedium labels 2026-03-26 14:21:51 +00:00
Author
Owner

Resolved. Batch job state is now persisted in a PostgreSQL jobs table. Implemented in PR #34 (merged). See SPARC/database.py.

Resolved. Batch job state is now persisted in a PostgreSQL `jobs` table. Implemented in PR #34 (merged). See `SPARC/database.py`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#71