nexus-worker
The background worker. It reacts to events and reconciles state — it does not serve the public API.
Responsibilities
- Task scheduling · Agent dispatch · Retry handling
- Plane sync · Memory indexing · Webhook processing
- CI polling · Board reconciliation
Stack
| Library | Use |
|---|---|
tokio | async runtime |
async-nats | JetStream consumer/producer |
mongodb | state reads/writes via nexus-db |
serde | serialization |
tracing | logs / spans |
cron | scheduled jobs |
backoff | retry with backoff |
futures | stream combinators |
Events
The worker subscribes to durable JetStream subjects:
nexus.task.created
nexus.task.updated
nexus.agent.run.started
nexus.agent.run.completed
nexus.board.sync.requested
nexus.memory.proposed
nexus.approval.requested
Because JetStream is durable and replayable, a worker restart resumes from the last acknowledged message — no lost dispatches.
Scheduling and leasing
- Find
ready_for_agenttasks whosedepends_onare satisfied. - Lease the task (atomic update; lease expires) to prevent double-dispatch.
- Ask Core/runtime to start a run.
- On failure, apply retry/backoff or quarantine the agent per policy.