# CommitterWorker

**Kind:** Class

**Source:** [`atloria-monorepo/apps/api/src/docs-repo/committer.worker.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/apps/api/src/docs-repo/committer.worker.ts#L21)

CommitterWorker — the single, gated consumer of the 'docs-repo' queue.

Only spins up where DOCS_REPO_WORKER==='true' (a dedicated 1-replica deployment); api pods
enqueue-only. Concurrency 1 per project is enforced by the FAIL-CLOSED commit lock, not by
BullMQ groups: a job takes the per-project lock, drains that project's outbox, writes a
single coalesced commit (DB-wins rebuild), then marks the drained rows processed. If the
lock is held (another commit in flight) or Redis is down (fail-closed), the job is re-delayed
rather than committing.

**Implements:** `OnModuleInit`, `OnModuleDestroy`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `onModuleInit` | `onModuleInit()` | `void` |
| `commitUnderLock` | `commitUnderLock(projectId: string)` | `Promise<string | null>` |
| `commitProject` | `commitProject(projectId: string)` | `Promise<string | null>` |
| `onModuleDestroy` | `onModuleDestroy()` | `Promise<void>` |

## Where it refuses work

- `CommitterWorker` stops the work with an early return when `pending.length === 0`.
- `CommitterWorker` stops the work with an early return when `humanIds.length === 0`.
- `CommitterWorker` stops the work with an early return when `humans.length === 0`.
- `CommitterWorker` stops the work with an early return when `humanIds.length === 1`.

## When something fails

- `CommitterWorker` handles failure in 4 places: it lets it reach the caller in 3, and turns it into a return value in 1.

## Referenced By

- `DocsRepoModule` (MODULE_PROVIDES)
