The rack — six pieces of gear, each with the symbol that proves it
Open the file. That is the whole argument.
Each item below names an exported symbol or a module path. Nothing here rests on a description: the citation is the evidence, and every entry also states what that piece of gear refuses to do, because a capability described without its limit is half a sentence.
The retry policy
apps/worker/src/backoff.ts — backoffDelayMs, isExhausted, nextAttemptAt
A failed job does not vanish and does not hammer. The delay for attempt N is computed by backoffDelayMs against a declared BackoffPolicy; nextAttemptAt turns that delay into a concrete timestamp the runner can sleep against; isExhausted is the boolean that ends the retry chain instead of letting it run forever. Three functions, one policy object, and the policy is a value you can read — not a magic number buried in a catch block.
What it refuses: It does not decide, on its own, that a job is unimportant. Exhaustion is a boolean the caller branches on; it is not a silent drop.
Idempotency, scoped to one school
apps/worker/src/asset-gen-idempotency.ts — GenerationResultCache, toCachedGeneration; apps/worker/src/job-idempotency-school-scope.test.ts
A job that runs twice must not produce two of a thing. The generation cache stores a completed result against its key and hands the same result back on a repeat. The key is scoped to a school, and there is a test file whose entire subject is that scoping — job-idempotency-school-scope.test.ts exists because a key that is not tenant-scoped is a cross-tenant leak wearing the costume of a cache hit.
What it refuses: The cache does not span schools. A hit for one school is not a hit for another, and the test that pins that is a sibling of the module, not a distant integration suite.
The budget guard
apps/worker/src/max-pages-guard.ts — assertBookPageBudget, isOverPageBudget, BookPageBudgetExceededError, WORKER_MAX_BOOK_PAGES_DEFAULT
Unattended work is exactly where a runaway costs the most, because nobody is watching it cost anything. The page budget is a declared default (600) with a declared floor (1), and assertBookPageBudget throws a NAMED error class rather than returning a soft flag. A typed throw is a stop; a boolean somebody forgets to check is a wish.
What it refuses: It does not raise its own ceiling to make a red go away. The ceiling is configuration read through resolveWorkerMaxBookPages, and lowering the alarm is not the same repair as fixing the job.
Tracing and the job span
apps/worker/src/observability.ts — createObservability, withJobContext, withJobSpan, createWorkerMetrics; apps/worker/src/observability.tracing.test.ts
Every job runs inside withJobSpan, so a run has a span with typed attributes (JobSpanAttrs) rather than a log line somebody has to grep for. withJobContext carries the job identity through the call, and createWorkerMetrics registers the counters against a MetricsRegistry. There is a dedicated tracing test file: the instrumentation itself is under test, which is the only way an instrument earns the right to be believed.
What it refuses: It does not treat an absent metric as a healthy one. A registry with no handles is an unmeasured runtime, not a quiet one.
The run loop and the database runner
apps/worker/src/loop.ts — startPollLoop, PollLoop; apps/worker/src/db-runner.ts; apps/worker/src/failure-detail.ts
startPollLoop is the whole heartbeat: a poll interval, a handle you can stop, and a runner underneath it that claims work from the database. When a run fails, failure-detail.ts is the module that keeps WHY — there is a db-runner.failure-detail.test.ts pinning that the detail survives to the row instead of being flattened to a status word.
What it refuses: It does not hold work in process memory as its source of truth. The queue is the database, so a restarted runtime does not lose the queue with it.
Demo mode, as a first-class state
apps/worker/src/demo-mode.test.ts; apps/worker/src/config.ts
The runtime has a demo posture with its own test file, because the dangerous version of a demo is one that is only a comment in a config. A named mode with a named test is a mode you can prove you are in.
What it refuses: It does not decide the posture from the shape of the data in front of it. The mode is configuration, read once, not inferred per job.