Resumable job runner with progress in SQLite (#15) #55
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
epic:E1-foundation
epic:E2-correct-metrics
epic:E3-fast-jobs
epic:E4-cli
epic:E5-web-ui
epic:E6-history
good first issue
help wanted
invalid
question
sprint-tracking
story
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ckreidl/screener!55
Loading…
Reference in a new issue
No description provided.
Delete branch "15-resumable-jobs"
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?
🤖 Claude: Closes #15
Each run of a step is now a row in a
jobstable. A run that's interrupted resumes where it stopped, and only one run of a step can be active at a time.What changed
src/jobs.ts(new):startJobrecords arunningrow (pid, start time) and writes progress (done/total/latest message) every second. That write also serves as a heartbeat. At the next start, arunningrow is markedinterruptedif its process is gone or it hasn't written for 60 s. The check and the insert run in oneBEGIN IMMEDIATEtransaction, so two processes can't both start the same step. Steps save finished work tojob_checkpoint. A run that resumes an interrupted run gets that work back. Any other run clears it, and a success clears it too.Range+If-Range(ETag). If SEC sends the whole file instead, the download starts over and says so. If the run died after the download finished, during extraction, the zip isn't fetched again.SecFetchnow takes extra request headers.--restartstarts an interrupted refresh or enrich over. In the menu you choose "Resume it" or "Start over". Each hint shows the step's last run. Before anything runs, any step that's already active is named, with job id and pid, and the CLI exits 1. Analyze and rank record jobs but always start over (your decision on #15).jobsandjob_checkpointare inensureSchema. All history is kept. CLAUDE.md is updated.Demonstrated on real data
running, with 900 quotes saved. The re-run printedResuming the interrupted run (job 2)and priced only the remaining 693 tickers (7 batches, 7 s). The totals were identical to an uninterrupted run:1591 priced · 2 no quote · 900 quotes from the interrupted run. Job 2 becameinterrupted, job 3 succeeded withresumes = 2, and the checkpoint was cleared.Downloaded 1358 MB (resumed at 290 MB)and extracted 20,571 files from the appended zip.bun cli.ts enrichwhile one was running printedenrich is already running (job 4, pid 83181, started …)and exited 1.--restartafter an interruption fetched all 16 batches again and resumed nothing.Enrich with prices (1679 companies · about 2 min · last run succeeded Nov 12, 2026 at 11:36 AM).bun run pipeline: all four steps ran and recordedsucceededjobs.For your review
failedtoo would be a one-line change. Your call; I can open an issue.--restartgives fresh prices. Prices that are days old could warrant a limit; that's also your call.Definition of Done
bun testpasses; new logic has tests: 263 pass, 0 fail. New:test/jobs.test.ts(16), resume tests for enrich (3), refresh incremental (1) and bulk (4), and CLI (3)bun checkis clean andbun fmt --checkpassesbun run pipeline, plus the kill/resume runs above🤖 Generated with Claude Code
Code review
No issues found. Checked for bugs and CLAUDE.md compliance.