Packages
@argus/queue
Implementations of the Queue contract from @argus/shared. The contract
encodes the one ordering rule the product depends on: jobs for the same PR
run strictly in order, one at a time; different PRs run in parallel.
Without it, a push arriving mid-review could interleave two reviews of one
PR — duplicate threads, races on last_reviewed_sha.
Place in the system
The ingress enqueues; the worker consumes. Both depend only on the contract
— bin/ wiring picks the implementation via QUEUE_MODE.
The session ordering model
The session key is sessionKeyForJob(job) = org/project/repoId/prId:
flowchart LR
subgraph q["queue argus-jobs"]
direction TB
subgraph s1["session …/PR 41"]
direction LR
a1["review.full"] --> a2["review.incremental"] --> a3["thread.reply"]
end
subgraph s2["session …/PR 42"]
b1["review.full"]
end
end
s1 -- "strict FIFO,<br/>one consumer at a time" --> c1["worker replica"]
s2 -- "in parallel with PR 41" --> c2["worker replica"]
Figure 1 · Sessions in the argus-jobs queue — strict FIFO within a PR,
parallelism across PRs.
A handler failure redelivers the job up to 3 times (code default), then dead-letters it without blocking later jobs in the same session — a poison message never wedges its PR.
The two implementations
| Implementation | Notes |
|---|---|
MemoryQueue (QUEUE_MODE=memory) |
In-process; same FIFO-per-key, bounded-concurrency, dead-letter semantics as production. This is what dev:ingress and the tests run on. |
ServiceBusQueue (QUEUE_MODE=servicebus) |
Azure Service Bus with sessions. Sends set sessionId; consumption is acceptNextSession with session-lock auto-renewal for long reviews. Auth: SERVICEBUS_NAMESPACE + DefaultAzureCredential (primary) or SERVICEBUS_CONNECTION (SAS fallback). Dead-letter reasons: invalid-job (schema-invalid body) and max-deliveries-exhausted. |
The Service Bus queue entity must have sessions enabled — the checkbox is immutable after queue creation, and a session-less queue silently breaks consumption.
How it's tested
memoryQueue.test.ts proves the ordering contract (FIFO per key, cross-key
parallelism, dead-letter without session blockage); serviceBusQueue.test.ts
exercises ServiceBusQueue against a scripted fake of the Service Bus SDK —
no Azure needed.
