Parallel Background Workers
Picks up queued tasks and runs them in parallel across role-specific worker queues.
Tasks only run one at a time when someone manually calls runTask.
Events, sub-tasks, and approvals automatically run in parallel across dedicated worker pools.
What It Does (In Plain English)
Worker Pool turns Neusym from a one-at-a-time script into a multi-worker system. It watches the task queue, leases jobs fairly across workers, supports role-separated queues (like builder, reviewer, committer), and automatically retries crashed jobs.
Real-World Example
- 1Ten customer tickets arrive via webhook at the same second.
- 2Intake queues all 10 tasks onto the
triagerole queue. - 3Worker Pool leases 4 tasks in parallel and runs them safely with separate tenant contexts.
- 4If one worker process crashes mid-job, another worker resumes from its last checkpoint.
When Should You Turn It On?
Add whenever you run background agents, event triggers, delegation, or @neusym/server --watch.
Safety level note: Level 1 · Review — Read-only. Can inspect and answer, never changes outside systems.
How to Add It (workspace.yaml)
kits:
- "@neusym/kit-worker-pool@0.1.0"
grants:
contextIssuer: [worker-pool]
kitConfigs:
worker-pool:
concurrency: 4
allowedRoles: ["triage", "builder"]Kits It Works With
Technical Details & Configuration Options (10 settings)
| Package | @neusym/kit-worker-pool |
|---|---|
| Provides Ports | workers@1 |
| Requires Ports | tasks@1queue@1 |
| Optional Ports | secrets@1 |
| Publishes Events | None |
| Owned DB Collections | worker_wake_origins |
Configuration Options (kitConfigs.worker-pool)
| Setting | Type | Default | Description |
|---|---|---|---|
concurrency | integer | 2 | Jobs one runPending call takes and runs at once. |
perTenantMaxConcurrency | integer | — | Optional ceiling on active leases held concurrently for a single tenant. |
fairness | string | "fifo" | Cross-tenant leasing fairness mode. |
priorityByUrgency | object | — | Maps TaskRecord.urgency tiers to numeric queue priorities (0..100). |
leaseMs | integer | 60000 | How long a worker holds a job before another may take it over; renewed while the run goes on. |
maxAttempts | integer | 3 | Runs that throw before the task is marked failed (RETRIES_EXHAUSTED). |
retryAfterMs | integer | 5000 | Wait before a run that threw is tried again (it resumes from its checkpoint). |
maxRetryAfterMs | integer | 300000 | Ceiling on the wait before a task requeued on a transient refusal (TOKENS_RESERVED) is leased again; the wait starts at retryAfterMs and doubles with each requeue in a row, with jitter. |
allowedRoles | array | [] | Worker roles whose per-role queues this pool leases. When empty, serves the default tasks queue only. |
serveDefaultQueue | boolean | — | Whether this pool leases unroled tasks from the default queue (defaults to true only when allowedRoles is empty). |