You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tower start-up: readiness loop and ownership check still probe heavy routes (/api/status, /health) instead of /health/live #2003
Two start-up probes still ask one of Tower's heavy routes when all they need to know is "is a Tower alive on this port". Both run when the machine is busiest (a Tower starting or restarting), which is when a heavy route is slowest and most likely to miss its budget.
afx tower start's readiness loop (packages/codev/src/agent-farm/commands/tower.ts, around line 141) polls GET /api/status. That handler calls getInstances() on every poll.
The start-up ownership check (packages/codev/src/agent-farm/db/tower-owner.ts, the probe around line 151) asks GET /health. That handler calls getInstances() and the fleet census (ps -A, or a PowerShell CIM query on Windows), which the file's own comments name as the reason its budget is generous.
Root cause
Both were written before Tower had a cheap liveness route. The liveness route for the CLI probe (issue #1977, PR #2001, GET /health/live) moves the SDK's probeHealth, afx send's older-Tower check and the VS Code reconnect probe; these two sites were left out of that PR on purpose because they sit in Tower's start-up path.
Fix
Depends on PR #2001 (the /health/live route) being merged.
Point both probes at GET /health/live.
Keep the fallback to the old route when the answer shows an older Tower (a 404 or 401 from the route), never on a timeout. The ownership check must keep its three distinguishable states and stay fail-closed: an inconclusive answer is never read as "no Tower".
The readiness loop today uses a keyed route; /health/live is public, so the loop no longer needs the key for this question. Check that nothing else in the loop relied on the key being accepted (it is also an implicit check that the new Tower reads the same key file).
With the cheaper route, revisit the ownership check's generous budget only if measurement supports it; do not shorten it by assumption.
Out of scope: codev doctor's read of insideCodevSession on Windows, which needs a field only /health reports and is not on a busy path.
Testing
Unit tests for each probe: a current Tower (200 from /health/live), an older Tower (404 and 401 fall back to the old route), a timeout (no fallback; ownership stays inconclusive), a non-Tower process on the port.
This touches Tower's lifecycle, so the PR dispatches the Windows workflow on its branch.
Exercise the real path once: afx tower start against a stopped Tower and against a running one. That restarts Tower, which needs the owner's word; no load test is needed or wanted.
Activity