fix(deploy): stop stale pending deployments from blocking agent self-update #142

Merged
gmackie merged 1 commit from fix/stale-deploy-selfupdate into main 2026-07-27 17:04:40 +00:00
Owner

Closes the recurring zombie-deployment problem (testgame → labnuc, offline since Jun 7; blocked the 0.1.36 rollout on master).

Server — reapStaleDeployments now also expires pending deployments whose target node has not heartbeated for 10+ minutes (row must also have waited 10+ min), journal: node offline, re-create when it returns. 10 min > CF_CLAIM_TTL_MS (5 min), so re-claimable CF Workers rows migrate to an online node before expiry.

Agent — runCycle set deploying whenever the poll returned any deployment, including rows it skips every cycle (unhandleable CF Workers, empty flake ref), so the end-of-cycle self-update check deferred indefinitely. The flag is now set lazily via willExecuteDeployment, which mirrors the dispatch loop skip conditions (unit-tested).

TDD: red-first tests for both sides (deployment-reaper.test.ts, deploy_gate_test.go). Full agent go test ./..., go vet, and apps/web typecheck green.

Note: the current live zombie (6d363980, testgame development → labnuc, pending since Jul 25) should be reaped automatically by the next poll after this deploys — will verify post-merge.

🤖 Generated with Claude Code

Closes the recurring zombie-deployment problem (testgame → labnuc, offline since Jun 7; blocked the 0.1.36 rollout on master). **Server** — `reapStaleDeployments` now also expires `pending` deployments whose target node has not heartbeated for 10+ minutes (row must also have waited 10+ min), journal: node offline, re-create when it returns. 10 min > CF_CLAIM_TTL_MS (5 min), so re-claimable CF Workers rows migrate to an online node before expiry. **Agent** — `runCycle` set `deploying` whenever the poll returned *any* deployment, including rows it skips every cycle (unhandleable CF Workers, empty flake ref), so the end-of-cycle self-update check deferred indefinitely. The flag is now set lazily via `willExecuteDeployment`, which mirrors the dispatch loop skip conditions (unit-tested). TDD: red-first tests for both sides (`deployment-reaper.test.ts`, `deploy_gate_test.go`). Full agent `go test ./...`, `go vet`, and `apps/web` typecheck green. Note: the current live zombie (`6d363980`, testgame development → labnuc, pending since Jul 25) should be reaped automatically by the next poll after this deploys — will verify post-merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(deploy): stop stale pending deployments from blocking agent self-update
All checks were successful
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 8m6s
574e920017
Two-sided fix for the recurring zombie-deployment problem (task: deployments
targeting offline nodes sit pending forever and defer agent self-updates):

Server: reapStaleDeployments now also expires pending deployments whose
target node has not heartbeated for 10+ minutes (and the row itself has
waited 10+ minutes), with a journal explaining the node is offline. The
10-minute window stays above CF_CLAIM_TTL_MS (5 min) so re-claimable CF
Workers rows migrate to an online node before expiry.

Agent: runCycle marked 'deploying' whenever the poll returned ANY
deployment — including rows it skips every cycle (unhandleable CF Workers,
empty flake ref) — so the self-update check at the end of the same cycle
deferred forever. The flag is now set lazily via willExecuteDeployment,
which mirrors the dispatch loop's skip conditions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.