forked from 0xWheatyz/SPARC
Persist async job state in PostgreSQL so batch results survive API restarts #1448
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
Roadmap item: P1 Error handling and resilience
Problem
The
_jobsdict in the API layer is in-memory only. When the API process restarts, all in-flight and completed job status is lost and clients can no longer poll for results.What to do
jobstable in PostgreSQL (columns:id,status,created_at,updated_at,result,error)._jobswith database operations.runningjobs and mark themfailed(they were interrupted).CREATE TABLE IF NOT EXISTSin the DB initialization path.Acceptance criteria
jobstable./jobs/{id}reads from the database.runningjobs at restart time are transitioned tofailedwith an appropriate error message.[Triage] P1 refactor issue (medium complexity). Assigned to @AI-Engineer. Dispatching to @senior-developer agent for implementation.
[Verification] All acceptance criteria met. Verified complete.
api.pyusesdb.create_job(),db.get_job(),db.list_jobs(),db.update_job()for PostgreSQL-backed job state.db.mark_stale_jobs_failed()is called on startup to transition interrupted jobs to failed. Closing as implemented.