DESIGNING HARNESSES

TaskPool

Competitive task-queue pattern — read-only workers claim exclusive timed leases to unlock workspace writes and merge verified revisions.

TaskPool is the exclusive-lease queue pattern. Use it when multiple workers should discover and execute tasks in parallel while strictly preventing two Agents from editing the same target at the same time.

How it is designed

1. Services

Three local host Services enforce coordination without external infrastructure:

  • task: shared task queue with exclusive, timed leases (propose, claim, complete, release). Only one Agent holds a lease at a time; expired leases return cleanly to the pool.
  • context: durable shared notes/materials so workers do not repeat dead ends.
  • workspace: versioned host workspace that accepts verified submissions and advances the canonical revision (with an optional judge verifier before merge).

2. Profiles & Permissions

  • Workers start with writable: false while exploring and proposing tasks.
  • Only when a worker wins an exclusive task.claim lease does the Harness grant write access via runtime.files.replace({ writable: true }) against the latest workspace revision.
  • When the lease finishes or expires, the Harness revokes writes and rotates the worker back to the pool.

3. Orchestration & Events

  • The Harness tracks active leases and watches runtime.onEvent() for completions, errors, or lease timeouts.
  • If a worker stalls or exceeds its lease window, the host interrupts it, reclaims the task, and lets another worker pick it up without corrupting the canonical workspace.

Try or eject it

anyswarm eject taskpool --dir ./my-taskpool
cd ./my-taskpool
npm install
anyswarm --harness taskpool --cwd /path/to/project \
  --prompt 'Break the work into discrete tasks, claim them exclusively, and merge verified updates.' \
  --output-dir ./runs
anyswarm trace --root ./runs --port 8787

Good starting point for: parallel bug-fixing queues, multi-step refactoring pipelines, formalization/proof subgoals, and any workload requiring single-writer safety.