Make Every Code execution lease-safe#1722
Merged
Merged
Conversation
…overy (#1693) Implements atomic claim leases with `lease_expires_at`, monotonic `fencing_token` (= `attempt` counter), and heartbeat/stale-recovery endpoints so process death and multi-worker races no longer leave requests permanently stuck in claimed/running. - Contract: lease/fencing/attempt fields, heartbeat model, stale recovery policy (safe_requeue ≤3 attempts, manual_review >3), fencing-token guard on status updates, idempotent requeue for active states - Migration be91f3a5c7d2: idempotent ADD COLUMN + index on (state, lease_expires_at) - Postgres/filesystem stores: new columns, heartbeat record method, list_stale query - HTTP app: POST /v1/every-code/work-requests/heartbeat (409 on wrong owner), POST /v1/every-code/work-requests/recover-stale (safe_requeue or manual_review per policy) - Worker: background heartbeat thread, fencing token threaded through status updates, stale recovery maintenance step - Tests: 10 new PostgreSQL concurrency/lease tests covering two-worker exclusion, heartbeat accept/reject, stale listing, safe-requeue, process-death attempt increment, lost-response fencing rejection Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> # Conflicts: # control_plane/http_app.py
…t-leases # Conflicts: # control_plane/storage/schema_invariants.py
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.
Summary
Validation
uv run --extra dev launchplane ci unittest-shard local(12/12 shards, 1,925 targets)LAUNCHPLANE_TEST_POSTGRES_URL=... uv run --extra dev launchplane ci postgres-integration(24 tests)uv run --extra dev mypy control_plane testspnpm --dir frontend validateCloses #1693