Module: utils/pipelineState

Shared pipeline state helpers used by crawler.js and pipelineOrchestrator.js.

Previously both modules defined an identical setStep() function inline — a DRY violation that meant any change to the step-update contract had to be made in two places. This module is the single source of truth.

Exports

  • setStep — Update run.currentStep, persist to DB, broadcast SSE snapshot.
Source:

Methods

(static) setStep(run, step)

Update the pipeline's current step counter on a run object.

  • Mutates run.currentStep in memory (so SSE snapshot reflects the new step).
  • Persists the new step to SQLite (so the frontend polling fallback stays in sync).
  • Emits a "snapshot" SSE event so connected clients update their progress bar.
Parameters:
Name Type Description
run Object

The mutable run record (created in routes/runs.js).

step number

Pipeline step number (1–8).

Source: