Skip to main content

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

LibraryUse
tokioasync runtime
async-natsJetStream consumer/producer
mongodbstate reads/writes via nexus-db
serdeserialization
tracinglogs / spans
cronscheduled jobs
backoffretry with backoff
futuresstream 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

  1. Find ready_for_agent tasks whose depends_on are satisfied.
  2. Lease the task (atomic update; lease expires) to prevent double-dispatch.
  3. Ask Core/runtime to start a run.
  4. On failure, apply retry/backoff or quarantine the agent per policy.