Resumable job runner with progress in SQLite #15

Closed
opened 2026-11-06 01:19:26 +00:00 by chris-kreidl · 1 comment
chris-kreidl commented 2026-11-06 01:19:26 +00:00 (Migrated from github.com)

Jobs record progress; an interrupted refresh or enrichment resumes instead of restarting.

Acceptance criteria

Agreed in backlog refinement (see comments).

  • Each run of a step records a row in a jobs table: step, status (running, succeeded, failed, interrupted), started/finished time, done/total, latest message, and error. Progress is written at least every 2 seconds while the step runs. All history is kept.
  • Interrupted runs are detected: after a crash or Ctrl-C, the next start finds the running row with no live process and marks it interrupted.
  • Resume: re-running an interrupted step continues where it stopped:
    • an incremental refresh skips filings it already fetched;
    • enrich skips companies already priced in that job;
    • the bulk download resumes with an HTTP Range request if SEC supports it, and otherwise restarts, saying so.
    • analyze (about a minute) is not resumed; an interrupted run starts over.
  • Start over: an interrupted step can be started from the beginning instead of resumed (a command-line option, and a choice in the interactive menu).
  • One at a time: starting a step that's already running says which run is active and exits non-zero.
  • The CLI menu's hints show each step's last run (status and when), from jobs.
  • Demonstrated on real data: kill enrich halfway, re-run it, and it finishes the rest without re-pricing what was already done.

Definition of Done

  • Acceptance criteria met and demonstrated
  • bun test passes; new logic has tests
  • bun check is clean and bun fmt --check passes
  • Runs end to end on real data (not just fixtures)
  • Committed with Closes #<this issue>
Jobs record progress; an interrupted refresh or enrichment resumes instead of restarting. ### Acceptance criteria *Agreed in backlog refinement (see comments).* - [ ] Each run of a step records a row in a `jobs` table: step, status (`running`, `succeeded`, `failed`, `interrupted`), started/finished time, done/total, latest message, and error. Progress is written at least every 2 seconds while the step runs. All history is kept. - [ ] **Interrupted runs are detected:** after a crash or Ctrl-C, the next start finds the `running` row with no live process and marks it `interrupted`. - [ ] **Resume:** re-running an interrupted step continues where it stopped: - an incremental refresh skips filings it already fetched; - enrich skips companies already priced in that job; - the bulk download resumes with an HTTP Range request if SEC supports it, and otherwise restarts, saying so. - `analyze` (about a minute) is not resumed; an interrupted run starts over. - [ ] **Start over:** an interrupted step can be started from the beginning instead of resumed (a command-line option, and a choice in the interactive menu). - [ ] **One at a time:** starting a step that's already running says which run is active and exits non-zero. - [ ] The CLI menu's hints show each step's last run (status and when), from `jobs`. - [ ] Demonstrated on real data: kill enrich halfway, re-run it, and it finishes the rest without re-pricing what was already done. ### Definition of Done - [ ] Acceptance criteria met and demonstrated - [ ] `bun test` passes; new logic has tests - [ ] `bun check` is clean and `bun fmt --check` passes - [ ] Runs end to end on real data (not just fixtures) - [ ] Committed with `Closes #<this issue>`
chris-kreidl commented 2026-11-11 20:24:50 +00:00 (Migrated from github.com)

🤖 Claude: Proposed acceptance criteria (backlog refinement)

Context: after #12 and #13, the daily jobs take minutes, so resuming matters less for speed. What still matters:

  • the ~1 GB bulk download (first run, --full, or after a long gap);
  • progress another process can read, which M3's "Start jobs from the UI with live progress" (#18) needs;
  • not running the same step twice at once.

The steps already report progress through Reporter (src/report.ts), so a SQLite-backed reporter fits.

Acceptance criteria

  • Each run of a step records a row in a jobs table: step, status (running, succeeded, failed, interrupted), started/finished time, done/total, latest message, and error. Progress is written at least every 2 seconds while the step runs.
  • Interrupted runs are detected: after a crash or Ctrl-C, the next start finds the running row with no live process and marks it interrupted.
  • Resume: re-running an interrupted step continues where it stopped:
    • an incremental refresh skips filings it already fetched;
    • enrich skips companies already priced in that job;
    • the bulk download resumes with an HTTP Range request if SEC supports it, and otherwise restarts, saying so.
  • One at a time: starting a step that's already running says which run is active and exits non-zero.
  • The CLI menu's hints show each step's last run (status and when), from jobs.
  • Demonstrated on real data: kill enrich halfway, re-run it, and it finishes the rest without re-pricing what was already done.

Questions

  1. Keep all job history, or prune old rows? It's tiny either way; I'd keep it all, since it's useful for #20 (rank history).
  2. Should resume apply to analyze too? It takes ~1 minute, so I'd leave it out.

Dependencies

Best done last in M2, after #12 and #13 settle the steps it has to resume.

🤖 **Claude:** **Proposed acceptance criteria** (backlog refinement) **Context:** after #12 and #13, the daily jobs take minutes, so resuming matters less for speed. What still matters: - the ~1 GB bulk download (first run, `--full`, or after a long gap); - progress another process can read, which M3's "Start jobs from the UI with live progress" (#18) needs; - not running the same step twice at once. The steps already report progress through `Reporter` (`src/report.ts`), so a SQLite-backed reporter fits. ### Acceptance criteria - [ ] Each run of a step records a row in a `jobs` table: step, status (`running`, `succeeded`, `failed`, `interrupted`), started/finished time, done/total, latest message, and error. Progress is written at least every 2 seconds while the step runs. - [ ] **Interrupted runs are detected:** after a crash or Ctrl-C, the next start finds the `running` row with no live process and marks it `interrupted`. - [ ] **Resume:** re-running an interrupted step continues where it stopped: - an incremental refresh skips filings it already fetched; - enrich skips companies already priced in that job; - the bulk download resumes with an HTTP Range request if SEC supports it, and otherwise restarts, saying so. - [ ] **One at a time:** starting a step that's already running says which run is active and exits non-zero. - [ ] The CLI menu's hints show each step's last run (status and when), from `jobs`. - [ ] Demonstrated on real data: kill enrich halfway, re-run it, and it finishes the rest without re-pricing what was already done. ### Questions 1. Keep all job history, or prune old rows? It's tiny either way; I'd keep it all, since it's useful for #20 (rank history). 2. Should resume apply to `analyze` too? It takes ~1 minute, so I'd leave it out. ### Dependencies Best done last in M2, after #12 and #13 settle the steps it has to resume.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ckreidl/screener#15
No description provided.