Repository navigation
feat: worker-kit 0.1.0, background jobs on BullMQ or in-process - #1
Merged
Merged
Conversation
Typed job definitions, one queue API over BullMQ on Redis, in-process, or worker-when-available-else-standalone, and the worker runner. Extracted from the api's src/jobs so the api and mail-kit share one job layer. The same scenario runs on the in-process backend and on BullMQ against a real Redis and must match. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ksSjXhGjrz5w5b9THeNDT
6 of 9 tasks
BackStacked
added a commit
to mgpl-diagnostics/.github
that referenced
this pull request
Oct 15, 2026
<!-- claude-projects-attribution: {"github_login":"BackStacked"} -->
_Requested by **Himanshu** · [project
thread](https://claude.ai/code/project/chan_016JXeBZ2UxSi4N5VU2C26fQ?thread=cmsg_016JXeBZ2UxSi4N5VU2C26fQD1q5wdig6xLugjBA7ckTBv)_
## What and why
Before: `scripts/protect-repos.mjs` had no entry for the new worker-kit
repo, so protecting it would not require the `ci` check, and the org
profile did not list it.
After: `"worker-kit": ["ci"]` is in `CHECKS`, and the profile has a
worker-kit card after mail-kit. The kit itself is
mgpl-diagnostics/worker-kit#1. Once this is merged, the owner's local
agent runs `node scripts/protect-repos.mjs worker-kit`.
## Type
- [ ] Bug fix
- [ ] Feature
- [ ] Test data (ranges, units, prices) — source linked below
- [x] Docs
- [x] Refactor / tooling
## Checklist
- [x] Opened on a branch (not `main`)
- [x] `node --check scripts/protect-repos.mjs` passes (this repo has no
typecheck or tests)
- [x] Docs updated (profile README)
- [x] **No real patient data, contact details or signatures**
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_019ksSjXhGjrz5w5b9THeNDT
---
_Generated by [Claude
Code](https://claude.ai/code/session_019ksSjXhGjrz5w5b9THeNDT)_
Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Himanshu · project thread
Before: the Redis + BullMQ worker lived inside the api (
src/jobs/), hard-wired to its two queues, and mail-kit had its own BullMQ-shaped adapter. Nothing else could reuse it.After:
@mgpl-diagnostics/worker-kitis its own kit. You define a job once (defineJob) and start it through one queue API (createJobQueue) on any of three backends: BullMQ on Redis (/bullmqentry, withstartWorkerfor the worker process), in-process (inlineBackend), or the worker when Redis is up and standalone otherwise (fallbackBackend).jobs.enqueuer(job)has mail-kit'sMailQueueshape.The three backends behave the same: data and results cross JSON, retries and exponential backoff match BullMQ, and only a
JobFailure's message is shown (anything else reads "Job failed" and goes toonError). Job data is checked in the caller: JSON only, a size limit, and no secret-looking keys (token,password,secret, …).How: the behaviour is lifted from the api's
src/jobs/bullmq.tsandinline.ts(UUID job ids,UnrecoverableErrorfor non-retryable failures, retention viaremoveOnComplete/removeOnFail, the state mapping) and generalised to any job set.scripts/test.tsruns one scenario (success with Dates, a job that succeeds on attempt 3, a non-retryable failure, an internal crash) on the in-process backend and on BullMQ against a real Redis and asserts identical results. CI runs a Redis service withREQUIRE_REDIS=1, and checks thatdist/index.jsdoes not import bullmq or ioredis. Same layout as the other kits (tsup, tsx tests,cijob id,publish.ymlonv*tags, dependabot, CODEOWNERS, llms files).Locally:
npm run typecheck && npm test && npm run build→ 30 passed, 0 failed.Follow-ups (not in this PR): switch the api's
src/jobsonto worker-kit once 0.1.0 is published, and add worker-kit toCHECKSin.github/scripts/protect-repos.mjs.🤖 Generated with Claude Code
https://claude.ai/code/session_019ksSjXhGjrz5w5b9THeNDT
Generated by Claude Code