How-To: Drain Backlog Queues with Concurrent Workers
This guide explains how to configure and execute persistent autonomous worker pools to continuously drain ready tasks from the refined buffer.
Persistent Single-Worker Queue Drain
To run a single persistent worker process that continuously claims and executes unblocked tasks until the refined queue is exhausted:
uv run spec-ops worker --drain
To limit the total number of tasks drained in a single run:
uv run spec-ops worker --drain --max-tasks 5
Concurrent Multi-Worker Batch Cycle
To process the backlog with parallel autonomous agents, run spec-ops cycle with concurrency enabled (defaults to 3 concurrent workers):
uv run spec-ops cycle --max-concurrency 3 --drain
Or execute a bounded concurrent batch:
uv run spec-ops cycle --max-concurrency 3 --max-tasks 6
Concurrency & Conflict Protection
During concurrent execution:
- Isolated Worktrees: Each worker stream executes in an isolated git worktree (
.worktrees/task-) on a dedicated task branch (feat/). - Dynamic Unblocking: When a task completes and squash-merges into
main, dependent downstream tasks are immediately recognized as unblocked and dispatched to free worker slots. - Auto-Rebase under MERGE_LOCK: When a worker finishes, it acquires
MERGE_LOCK. Ifmainadvanced due to another worker completing earlier, the worker automatically rebases ontomainand re-verifies preflight before squash-merging. - Signal-Safe Checkpointing: Sending
SIGINT(Ctrl+C) triggers a graceful shutdown trap that allows in-flight steps to checkpoint safely, ensuresMERGE_LOCKis released cleanly, and outputs a batch summary report.
Worktree Rescue and Stalled Task Recovery
When a worker process fails, times out, or encounters a gate failure, SpecOps preserves its worktree under .worktrees/task- for diagnosis or human takeover.
Listing Active / Stalled Worktrees
To view all in-flight or preserved worktrees:
uv run spec-ops rescue --list
Rescuing and Completing a Task
To verify, rebase, and squash-merge a rescued task with guardrails:
uv run spec-ops rescue TASK-0040 --complete
This workflow:
- Cleans temporary prompt files (
.task-prompt.md). - Stages legitimate modifications via guardrails (reverting accidental backlog changes and unauthorized dependency edits).
- Automatically rebases onto latest
main. - Runs full preflight verification (
uv lock --check,uv run pytest,uv run spec-ops health). - Under
MERGE_LOCK, squash-merges intomainand moves the task fromrefined/tocomplete/. - Prunes the worktree and deletes the feature branch.
Discarding or Pruning Worktrees
To discard an interrupted or unneeded worktree and delete its branch:
uv run spec-ops rescue TASK-0036 --discard
To remove all stalled worktrees at once:
uv run spec-ops rescue --prune