Skip to content

Make Every Code execution lease-safe#1722

Merged
shiny-code-bot merged 13 commits into
mainfrom
feat/1693-work-request-leases
Jul 13, 2026
Merged

Make Every Code execution lease-safe#1722
shiny-code-bot merged 13 commits into
mainfrom
feat/1693-work-request-leases

Conversation

@shiny-code-bot

Copy link
Copy Markdown
Collaborator

Summary

  • add atomic Every Code claims, bounded leases, heartbeats, fencing tokens, and compare-and-write stale recovery
  • make filesystem and PostgreSQL transitions race-safe, with atomic replay evidence on database-backed claims/reruns
  • bind detached tmux sessions and terminal status to the claim attempt so stale workers cannot finish or terminate newer work
  • recover stale work through both local and service-backed worker loops, while migrating legacy active rows to manual review

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 tests
  • changed-file Ruff lint and format checks
  • pnpm --dir frontend validate
  • multiple independent race/correctness reviews, including filesystem concurrency, stale recovery, heartbeat loss, service recovery, legacy migration, and split-brain tmux attempts

Closes #1693

cbusillo and others added 13 commits July 13, 2026 05:23
…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
@shiny-code-bot
shiny-code-bot merged commit 243721b into main Jul 13, 2026
31 checks passed
@shiny-code-bot
shiny-code-bot deleted the feat/1693-work-request-leases branch July 13, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Every Code work-request leases, replay, and stale recovery

2 participants