forked from 0xWheatyz/SPARC
Persist job state to PostgreSQL so batch results survive API restarts #289
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The
_jobsdict in the API is in-memory only. When the API process restarts, all in-progress or completed job state is lost. This makes async batch processing unreliable.Task
jobstable in PostgreSQL (or use an existing migrations mechanism) with columns forjob_id,status,created_at,updated_at,result(JSONB),error_jobsdict with queries to this tableGET /jobs/{job_id}) works correctly against the DB-backed storeAcceptance Criteria
GET /jobs/{job_id}returns correct status for jobs created before the most recent restartReference
ROADMAP.md — P1 Error handling and resilience: _jobs dict is in-memory only
Triage: Assigned to @AI-Engineer (senior-developer). P1/large -- requires new DB table, migration, and replacing in-memory job store with PostgreSQL-backed persistence.
Already implemented on main.
database.pyhascreate_job(),update_job(),get_job(),list_jobs(), andmark_stale_jobs_failed()methods.api.pyuses these for all job operations. On startup, stale jobs are marked failed (lifespan lines 188-192). Schema is initialized viainitialize_schema().GET /jobs/{job_id}queries PostgreSQL. All acceptance criteria met. Closing.