mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 06:40:50 +00:00
The five hand-written registrars (about 5,500 lines, one 997-line function) are replaced by `jobs/registry/`: one `defineJob` entry per queue with its cron, schedule send options, policy, work options, lock, lane and a handler loader. `registerJobGroup` creates, schedules, retires and binds each group in the order the registrars used; the worker boot walks the groups and runs their boot discovery. Handlers load on their queue's first job. The facts a declaration needs at boot (names, crons, concurrency, send options) moved out of the heavy job modules into light `*-queue.ts` siblings, and their importers point there, so loading the registry evaluates 288 modules instead of the 1,164 the registrars pulled in. The formerly inline handlers moved verbatim into handler modules under `jobs/reminder/`. Fitbit's queues live in `fitbit/jobs/definitions.ts` and enter the registry through one spread, so removing the integration later is that folder and that line. `tests/integration/queue-registration-parity.test.ts` proves pg-boss holds exactly what the registrars left (queues, schedules, bindings, byte for byte) and loads every handler once. The queue tests and the runtime guard assert on the registry objects instead of reading registrar source.
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
/**
|
|
* Queue-registration guard for the combined Coach memory-refresh job
|
|
* (rolling conversation summary + durable fact extraction).
|
|
*
|
|
* Reads the worker registry: the queue is declared in the status group and
|
|
* its loader resolves to the handler that runs the refresh pipeline. An
|
|
* unregistered queue silently never runs (the dead-queue class).
|
|
*/
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { COACH_MEMORY_REFRESH_QUEUE } from "@/lib/ai/coach/coach-memory-shared";
|
|
import { handleCoachMemoryRefresh } from "@/lib/jobs/reminder/status-handlers";
|
|
import {
|
|
groupOf,
|
|
jobOf,
|
|
loadedHandler,
|
|
} from "@/lib/jobs/registry/__tests__/registry-helpers";
|
|
|
|
describe("coach-memory-refresh registration", () => {
|
|
it("declares the coach-memory-refresh queue in the status group", () => {
|
|
expect(groupOf(COACH_MEMORY_REFRESH_QUEUE).name).toBe("status");
|
|
});
|
|
|
|
it("runs one refresh at a time and has no cron", () => {
|
|
const job = jobOf(COACH_MEMORY_REFRESH_QUEUE);
|
|
expect(job.work).toEqual({ localConcurrency: 1 });
|
|
expect(job.cron).toBeUndefined();
|
|
});
|
|
|
|
it("binds the handler that runs the refresh pipeline", async () => {
|
|
expect(await loadedHandler(COACH_MEMORY_REFRESH_QUEUE)).toBe(
|
|
handleCoachMemoryRefresh,
|
|
);
|
|
});
|
|
});
|