Durable, lease-based task queue (crash-recovery + exactly-once)#38
Merged
Conversation
Closes the two gaps the harness research flagged: crash loses work, and a shared backlog double-runs. TaskQueue on SQLite: - claim() hands one worker exactly one task under a write-locked transaction, so concurrent workers never grab the same one. - an expired lease makes an abandoned task claimable again (a dead worker does not strand it); complete() is idempotent by id, so a re-run cannot overwrite a recorded result. - results + backlog survive a restart; outstanding() lets a resuming orchestrator see what is still in flight. A coordination/durability primitive; the auth boundary stays on the tools a worker calls with its scoped token. 286 tests (+7), mypy --strict, ruff (whole repo), catalog freshness all green. v1.5.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the two gaps the harness research flagged as the biggest: a crash loses in-flight work, and a shared backlog double-runs.
TaskQueueis crash-recovery + exactly-once on SQLite.enqueue(do, args=...)writes a pending task to disk.claim(worker)hands one worker exactly one task under a write-locked transaction, so concurrent workers never grab the same one, and leases it.complete(id)is idempotent by id, so a re-run cannot overwrite a recorded result.result/outstandingsurvive a restart, so a resuming orchestrator sees what is still in flight.A coordination/durability primitive; the auth boundary stays on the tools a worker calls with its scoped token. Complements the A2A orchestrator (broadcast/addressed coordination) with a claimed, durable work queue.
7 new tests: enqueue/claim/complete/result, one-task-per-worker (no double hand-out), empty-queue claim, expired-lease reclaim, idempotent complete ignoring a stale re-run, outstanding/pending counts, and survives-across-instances (restart). 286 tests, mypy --strict, ruff (whole repo), catalog-freshness green. Backward compatible; v1.5.0.