Stage 4.1: BullMQ publish worker + Redis/Postgres integration

- apps/scheduler/src/queue.ts: PUBLISH_QUEUE, BullMQ-compatible Redis connection
  factory, queue factory, default retry/backoff job opts.
- apps/scheduler/src/worker.ts: makePublishWorker factory drives the publish-loop
  state machine (queued -> dispatching -> published | failed/dlq) and persists
  each transition to publications. Dispatcher is injected (fake in tests; the
  LinkedIn client swaps in once Gate 0.9 / CMA lands).
- apps/scheduler/src/main.ts: runnable entry; boots the worker; LinkedIn dispatch
  is fail-closed until CMA is approved.
- apps/scheduler/src/worker.integration.test.ts: gated behind INTEGRATION=1;
  verifies enqueue -> consume -> row published within 5s, and failure -> dlq with
  error recorded. Run against real Redis + Postgres.

Closes the Stage 4.1 DoD (enqueue -> worker-consume -> DB row updated within 5s).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Angelo B. J. Luidens
2026-06-03 15:12:44 -04:00
parent 7543366a15
commit c0dad39d55
6 changed files with 319 additions and 3 deletions
+1
View File
@@ -56,6 +56,7 @@
"@stargue/observability": "workspace:*",
"@stargue/schema": "workspace:*",
"bullmq": "^5.30.0",
"drizzle-orm": "^0.36.0",
"ioredis": "^5.4.0",
},
"devDependencies": {