Relocate the ~6k-file docs tree from the repo root into plugins/document-navigator/docs/ so the plugin is self-contained and portable. docs/superpowers/ (specs and plans) stays at the repo root. Moved via cp+rm rather than git mv because directory rename() fails with EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the identical-content files at commit time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@suaveplan/queue-distribution - Worker-pool distribution layer: load-balancing strategies (round-robin / least-busy / weighted), worker pool, manager with retry + health checks, in-process LocalWorker. Transport-agnostic — HTTP and worker-thread plugins ship as separate packages.
Summary
Worker-pool distribution layer: load-balancing strategies, worker pool management, manager with retry and health checks, in-process LocalWorker. Transport-agnostic — HTTP and worker-thread transports ship as separate plugin packages (@suaveplan/queue-distribution-http, @suaveplan/queue-distribution-worker-thread).
The package is decoupled from @suaveplan/queue's Job model: distribution operates on a minimal DistributedTask<I, O> contract so it can serve any consumer that produces typed work units (queue, batch, RPC, agent dispatch).
Documentation tree
- errors — (no submodules)
- queue-distribution-error — (no submodules)
- health-checker — (no submodules)
- health-checker — (no submodules)
- internal — (no submodules)
- noop-logger — (no submodules)
- base — (no submodules)
- base — (no submodules)
- least-busy — (no submodules)
- least-busy — (no submodules)
- round-robin — (no submodules)
- round-robin — (no submodules)
- weighted — (no submodules)
- weighted — (no submodules)
- manager — (no submodules)
- manager-dispatch —
dispatchWithRetryis the core retry loop ofWorkerManager. It picks a worker via the configured `LoadBalancingStrat… - manager-supervisor — The supervisor module owns the worker-health side of
WorkerManager: periodic health checks across the pool, restart o… - manager — (no submodules)
- manager-dispatch —
- observability — (no submodules)
- instruments — (no submodules)
- pool — (no submodules)
- pool — (no submodules)
- task — (no submodules)
- task — (no submodules)
- worker — (no submodules) - abstract-metrics —
abstract-metrics.tscarries the…- abstract — (no submodules)
- abstract-metrics —
abstract-metrics.tscarries the pure functions and the small accumulator used byAbstractWorkerto track success/fa… - abstract — (no submodules)
- abstract-metrics —
- local — (no submodules)
- local — (no submodules)
- worker — (no submodules) - abstract-metrics —
abstract-metrics.tscarries the…
- abstract — (no submodules)
- manager-supervisor — The supervisor module owns the worker-health side of
WorkerManager: periodic health checks across the pool, restart o… - manager — (no submodules)- observability — (no submodules)- instruments — (no submodules)- pool — (no submodules)- pool — (no submodules)- task — (no submodules)- task — (no submodules)- worker — (no submodules)- abstract — (no submodules)- abstract-metrics —
abstract-metrics.tscarries the pure functions and the small accumulator used byAbstractWorkerto track success/fa…- abstract — (no submodules)- local — (no submodules)- local — (no submodules)- worker — (no submodules)- queue-distribution-error — (no submodules)- health-checker — (no submodules)- health-checker — (no submodules)- internal — (no submodules)- noop-logger — (no submodules)- base — (no submodules)- base — (no submodules)- least-busy — (no submodules)- least-busy — (no submodules)- round-robin — (no submodules)- round-robin — (no submodules)- weighted — (no submodules)- weighted — (no submodules)- manager — (no submodules)- manager-dispatch —
dispatchWithRetryis the core retry loop ofWorkerManager. It picks a worker via the configured `LoadBalancingStrat…
- abstract — (no submodules)- local — (no submodules)- local — (no submodules)- worker — (no submodules)- queue-distribution-error — (no submodules)- health-checker — (no submodules)- health-checker — (no submodules)- internal — (no submodules)- noop-logger — (no submodules)- base — (no submodules)- base — (no submodules)- least-busy — (no submodules)- least-busy — (no submodules)- round-robin — (no submodules)- round-robin — (no submodules)- weighted — (no submodules)- weighted — (no submodules)- manager — (no submodules)- manager-dispatch —
- manager-supervisor — The supervisor module owns the worker-health side of
WorkerManager: periodic health checks across the pool, restart o… - manager — (no submodules)- observability — (no submodules)- instruments — (no submodules)- pool — (no submodules)- pool — (no submodules)- task — (no submodules)- task — (no submodules)- worker — (no submodules)- abstract-metrics — `abstract…
- abstract — (no submodules)- abstract-metrics —
abstract-metrics.tscarries the pure functions and the small accumulator used byAbstractWorkerto track success/fa… - queue-distribution-error — (no submodules)- health-checker — (no submodules)- health-checker — (no submodules)- internal — (no submodules)- noop-logger — (no submodules)- base — (no submodules)- base — (no submodules)- least-busy — (no submodules)- least-busy — (no submodules)- round-robin — (no submodules)- round-robin — (no submodules)- weighted — (no submodules)- weighted — (no submodules)- manager — (no submodules)- manager-dispatch —
dispatchWithRetryis the core retry loop ofWorkerManager. It picks a worker via the configured `LoadBalancingStrat…- manager-supervisor — The supervisor module owns the worker-health side of
WorkerManager: periodic health checks across the pool, restart o… - manager — (no submodules)- observability — (no submodules)- instruments — (no submodules)- pool — (no submodules)- pool — (no submodules)- task — (no submodules)- task — (no submodules)- worker — (no submodules)- abstract-metrics —
abstract-metrics.tscarries th… - abstract — (no submodules)- abstract-metrics —
abstract-metrics.tscarries the pure functions and the small accumulator used byAbstractWorkerto track success/fa…
- manager-supervisor — The supervisor module owns the worker-health side of
- queue-distribution-error — (no submodules)- health-checker — (no submodules) - health-checker — (no submodules)- internal — (no submodules) - noop-logger — (no submodules)- base — (no submodules) - base — (no submodules)- least-busy — (no submodules) - least-busy — (no submodules)- round-robin — (no submodules) - round-robin — (no submodules)- weighted — (no submodules) - weighted — (no submodules)- manager — (no submodules) - manager-dispatch —
dispatchWithRetryis the core retry loop ofWorkerManager. It picks a worker via the configured `LoadBalancingStrat…- manager-supervisor — The supervisor module owns the worker-health side of
WorkerManager: periodic health checks across the pool, restart o… - manager — (no submodules)- observability — (no submodules) - instruments — (no submodules)- pool — (no submodules) - pool — (no submodules)- task — (no submodules) - task — (no submodules)- worker — (no submodules) - abstract — (no submodules) - abstract-metrics —
abstract-metrics.tscarries the pure functions and the small accumulator used byAbstractWorkerto track success/fa…
- manager-supervisor — The supervisor module owns the worker-health side of
Install
bun add @suaveplan/queue-distribution
Quick start
import {
LocalWorker,
WorkerManager,
WorkerPool,
} from "@suaveplan/queue-distribution";
const pool = new WorkerPool();
pool.addWorker(new LocalWorker({}, { id: "a", capacity: 4 }));
pool.addWorker(new LocalWorker({}, { id: "b", capacity: 4 }));
await pool.startAllWorkers();
const manager = new WorkerManager(pool, {
autoHealthCheck: false,
maxTaskRetries: 2,
});
const task = {
id: "double",
execute: async (n: number) => n * 2,
getStatus: () => "PENDING" as const,
setStatus: () => {},
getMetadata: () => ({ createdAt: new Date(), attempts: 0 }),
};
console.log(await manager.assignTask(task, 21)); // 42
Modules
- Task contract —
DistributedTask<I, O>,TaskStatus,TaskMetadata. - Worker contract —
Worker,WorkerStatus,WorkerHealth,WorkerInfo+ Zod schemas. - AbstractWorker — base class with lifecycle FSM, metrics, OTel emission.
AbstractWorkermetrics helpers —WorkerMetricsStateaccumulator.- LocalWorker — in-process executor.
- Strategy base —
LoadBalancingStrategy,AbstractLoadBalancingStrategy. - RoundRobinStrategy.
- LeastBusyStrategy — optional EWMA performance bias.
- WeightedStrategy — injectable
Rng. - PeriodicHealthChecker — thresholds + cache + timeout.
- WorkerPool — CRUD + criteria-based search.
- WorkerManager — public dispatch surface.
- WorkerManager dispatch — bounded retry loop with @suaveplan/retry.
- WorkerManager supervisor — health-loop and restart logic.
- Errors —
QueueDistributionError+ 12 stable codes. - Observability — every counter, histogram, span the package emits.
- Internal: NOOP_LOGGER.
Design highlights
- 100% test coverage (statements + branches + functions + lines) under
provider: "istanbul". - Injectable
Clock,IdGenerator,Rng,LoggerLikeeverywhere — noMath.random/Date.now/uuidat module scope. AbortSignalthreaded through every async public method.- Retry routed through
@suaveplan/retry; bounded loop, no recursion. - Zod schemas at every public boundary (
WorkerHealthSchema,WorkerInfoSchema,TaskMetadataSchema, …). - Structured
SuaveplanErrorsubclasses with a frozen stable-code registry. - Tree-shakeable via 15 per-feature subpath exports.
Status
This package is part of the rebuild — version 0.1.0 while it stabilises. Graduation to 1.0.0 follows the criteria in CLAUDE.md.