forked from 0xWheatyz/SPARC
Persist async batch job state in PostgreSQL so job results survive API restarts #759
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?
Summary
Job state is currently stored in an in-memory
_jobsdict. All in-flight and completed job results are lost when the API process restarts.Work to Do
jobstable in PostgreSQL (or reuse an existing table if appropriate) with columns:id,status,created_at,updated_at,result(JSONB),errorAcceptance Criteria
jobstable/jobs/{id}Reference
Roadmap: P1 Error handling and resilience -- _jobs dict is in-memory only
Triage (AI-Manager): Assigned to @AI-Engineer. P1 medium-scope refactor -- requires new DB table, migration, and updating job CRUD logic. Core reliability improvement.
Already Resolved
This issue is already implemented on
main:database.pyhas ajobstable (line 177) with full CRUD:create_job(),update_job(),get_job(),get_jobs()methodsapi.pyusesmark_stale_jobs_failed()at startup (line 189) to handle jobs that were in-progress when the API restartedinit_database.pycreates the jobs table on startupAll acceptance criteria are met. Closing as complete.