Reprocessing Engine
When auto-verification rules change — a new reference range, an updated delta threshold, a corrected LOINC mapping — Vorian Connect can re-run verification on historical messages in bulk. The reprocessing engine handles this asynchronously with per-job versioning, one-click rollback, and configurable worker concurrency.
How It Works
- A reprocess job is submitted from the dashboard Inspector (Reprocess button on the message detail page) or via the
cmd/reprocessCLI, specifying which messages to re-run — by status, date range, or message count - The job is tracked authoritatively in the
reprocess_jobsPostgreSQL table with a unique job ID, status, and progress counters — Redis is used only as a low-latency wake signal, so a job is never lost if Redis is momentarily unavailable - A worker pool (
cmd/reprocessor) claims jobs from thereprocess_jobstable, re-runs each message through the current auto-verification pipeline, and writes the new verification status and notes - Before overwriting any message's status, the worker snapshots the current state to
reprocess_history— storing the old status and notes alongside the new ones - If the new rules produce unexpected results, the rollback function restores the previous verification state from the most recent history snapshot for any message
- Worker concurrency is controlled by a buffered channel semaphore — configurable via
WORKER_CONCURRENCY(default 5). Jobs are claimed atomically with a lease, and interrupted jobs are reclaimed and resumed rather than lost, so reprocessing is safe across worker restarts or scale-to-zero events
What's Included
- Durable job queue: Jobs are tracked in PostgreSQL with atomic lease-based claiming. Interrupted jobs persist their progress and resume where they left off — no lost work on worker restart. Redis serves only as a low-latency wake hint
- Versioning and one-click rollback: Every reprocess run snapshots the old verification state before writing the new one. The
Rollback()function restores from the most recent snapshot — no data loss, no manual SQL - Configurable concurrency:
WORKER_CONCURRENCYenvironment variable controls how many messages are processed in parallel. The channel-based semaphore ensures predictable resource usage - Duplicate prevention: Atomic lease-based claiming ensures no two workers process the same message, even when running multiple worker instances
- Dashboard integration: The Inspector page's Reprocess button submits a single-message job. The message detail page shows reprocess history — every previous verification status and the rule version that produced it
Where It Fits
The reprocessing engine is separate from the live message pipeline. Reprocess jobs never block new message ingestion — they use their own durable job table and worker pool. This means a lab can reprocess 100,000 historical messages while the edge agent continues to receive and auto-verify new results from analyzers without any impact on throughput.
Reprocessing is typically triggered after significant rule changes: deploying a new auto-verification rule, updating LOINC mappings, adjusting delta thresholds, or recovering from an incorrect rule that auto-verified results that should have been flagged.
Technical Details (for evaluators)
The reprocess CLI accepts -statuses (comma-separated verification statuses to target), -from and -to (date range in YYYY-MM-DD format), and -limit (maximum messages to process). Jobs are tracked in reprocess_jobs with status transitions: pending → running → completed (or failed).
Each history entry in reprocess_history records the old verification status, old notes, new status, new notes, and the job ID that produced the change. This creates a full audit trail of every verification decision change — useful for compliance reviews and debugging rule behaviour.
The worker pool uses a buffered Go channel as a semaphore to limit concurrent processing. When the channel is full, new jobs wait — no unbounded goroutine creation, no resource exhaustion under load.