Repository navigation
feat(execution): manage company task fleets - #438
Conversation
Astra reviewReviewed StandardsNo separate merge-blocking method or YAGNI findings. Spec1. Intent: the local fleet cannot work across independently constructed hostsEach host creates its own provider, whose task inventory is an instance-local Map. The database bindings and housekeeping lease are shared, but task discovery and management routing are not. A second host selects the first host's active binding, then fails to load its bundle because that task is absent from its provider. Once the second host takes the housekeeping lease, the missing-task branch records the still-running task as stopped. It can then launch a replacement without stopping the original, exceeding the fleet budget and recording a false stop time. #405 requires the controller to run against a local task provider so "every state transition is testable offline", with the housekeeping lease "held by one replica" for replenishment and orphan reconciliation. #384 §5 specifies a "global pool of spares". The current two-replica tests share one provider object, hiding the host composition failure. Reproduced with disposable real Postgres and two independently constructed local providers/controllers: Make local task discovery and management routing shared across host instances, and cover this through independently constructed hosts/providers rather than sharing one in-memory provider. A host-local inventory cannot authoritatively reconcile the global fleet. This is an offline-controller blocker, not a request to bring the ECS ticket into scope. Verification used an isolated smoke script, not a suite rerun. Its task processes and temporary database were cleaned up; repository files were unchanged. Summary: Standards 0; Spec 1 blocker, cross-host task discovery breaks routing, reconciliation and the fleet budget. |
Opus reviewScope: 1. The 15 s housekeeping lease can't outlast a real cold start, so an empty-pool first open always hits
|
|
Addressed the five blocking findings in 9b6741f; retained the T-1 UI commit
Kept: production refuses the local provider; ECS remains outside this ticket. The local provider requires a shared Linux filesystem/process/network namespace and stable callback ports. The supervisor still reports invocation failure promptly: the CI breaker test now waits for the actual terminal report before collection, retaining the assertion of exactly six durable kill reports rather than weakening it. Additional review: Standards and Spec reviewers independently found the same owner startup-record race. Child identity is now persisted before the initialize handshake. A deterministic real-process smoke with a delayed identity read reproduced lost readiness before the fix and preserved readiness afterward. Both axes then reported no remaining findings. Verification: 26 targeted tests passed; the full offline suite passed (133 files, 1,455 tests). After the startup ordering fix, typecheck, lint, server/dependency build, all four provider tests and all five Chromium starting/fleet scenarios passed. Documentation, the dev-loop skill, runtime glossary and disposable host fixtures match the new lifecycle/configuration. No public CLI or wire contract changed; migration 0014 remains wired through all three migrators. Read conversation comments, review bodies and inline comments again after the push; no Grok feedback was present. Latest-commit CI confirmation is pending below; this PR has not been merged. |
|
CI exposed a TestClock/Postgres synchronization race in the new active-housekeeping regressions: simulated time could advance past lease expiry while real SQL or its continuation was still pending. SQL observation barriers did not fully solve that scheduling mismatch. Commit 52c21c3 removes those barriers and runs the cold-start and failure-isolation scenarios with a live clock, real Postgres and actual supervisors. The 25-second cold start, 15-second lease, competing-host refusal, same lease epoch, concurrent starts, 40-second admission bound and completion despite wedged stats remain asserted. Idle and breaker windows still use TestClock. Production code is unchanged. All 15 fleet tests passed on Node 24.20.0 (including the actual 25-second startup and 40-second wedged-call bound); lint passed. Waiting for CI on 52c21c3. |
|
Address round complete at 9dcfcc5. This supersedes the earlier CI-pending updates and the live-clock approach in 52c21c3. Fixed
Kept, with reasons
Verification
Addressed with OpenAI GPT-6 Astra in omp. |
Opus re-reviewI re-reviewed
Not blocking, for the record:
All eight checks are green on 9dcfcc5. |
cc98e88 to
92dafe3
Compare
Implement #405 with a real-process local provider, durable fleet lifecycle and metering, breaker admission, and the T-1 starting flow. Production remains closed pending the ECS provider.
The T-1 cover now matches the picked mock: a static dim over the frame with
one centred note-float. Starting is blue with the elapsed time ("12 s so far")
rewritten once a second, no spinner. start_failed turns the same note amber
with Try again and holds through automatic bind retries until ready, Try again
or a resume. The dialog keeps the name "Starting your tools" and the elapsed
line stays outside the live region.
supporting-text moves into core's shell subset so the served wrapper has it.
ui-consistency, API.md and ADR-0010/0012 follow the new copy.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
9dcfcc5 to
6923ee5
Compare
…uns 24 boxes (#984) ## What changed Company boxes and hosts ran on half a vCPU, and production capped the fleet at 15 boxes with 2 warm spares. Both now get a full vCPU (memory stays 2 GiB), and the fleet can run 24 boxes with 3 warm spares. Patches should feel quicker, and more companies can be open at once before anyone waits for a box. 24 is what the account's current 30-vCPU Fargate quota allows at a full vCPU each; the budget goes to 30 once the quota is raised. ## Look at 1. **The sizes and the fleet limits** in `apps/infra/src/AppStack.ts`: exec and host task definitions go `512` → `1024` CPU units, and the hosts' `PATCHY_LIMITS_JSON` goes `{"execution.fleet.budget":15}` → `{"execution.fleet.budget":24,"execution.pool.spares":3}`. A new infra case pins them. It fails against main's stack and passes on this branch: ``` # main's AppStack.ts with this branch's test × gives hosts and company boxes a full vCPU, and the fleet 24 boxes with three spares AssertionError: Template has 2 resources with type AWS::ECS::TaskDefinition, but none match as expected. Tests 1 failed | 6 passed (7) # this branch Test Files 1 passed (1) Tests 7 passed (7) ``` 2. **`execution.task.cpu` and `execution.task.memory` stay, but inert and truthful.** Nothing reads them: the ECS provider sends no size override, so the exec task definition sets every box's size. Their defaults now match it (1 vCPU, 2 GiB), and their measure says they aren't read and are kept so existing configuration still loads. `docs/limits.md` says where the size comes from. A `PATCHY_LIMITS_JSON` naming either id still loads, and stored override rows can still be read and removed. Removing the ids is a separate change that needs a deprecation path. The limits docs and skill snapshots are regenerated. 3. **The Fargate vCPU quota** in `docs/OPERATIONS.md` › Production. The account's Fargate On-Demand vCPU quota must cover 24 boxes + 4 hosts mid-deploy + the promote task, which is **29 vCPUs** (it was 10), inside the current 30. Fargate refuses launches past the quota, so raising the budget to 30 needs the quota raised first. 4. **Freeing budget for a promotion**, a new runbook in OPERATIONS.md › Rolling back. Housekeeping never trims the current revision's surplus spares. So a rollback to an older release (budget 15, floor 2) can stall forever with **no company bound** once this release holds 14 or more spares. Waiting and re-running don't help. The runbook has two statements for the platform database: - **A count query** that diagnoses the stall and gives `stops`: `max(0, live + max(0, floor − staged spares and starting) − budget)`. `live` is every `starting`, `spare` and `bound` task of either revision, so a fleet already over the staged budget is covered; `stopping` tasks are already leaving, so recounting right after a fence is correct. - **The fence** the controller itself puts on a spare before stopping it (`fleet.ts`, `drainTask`). It sets the current revision's newest `spare` rows to `stopping` with `FOR UPDATE SKIP LOCKED`, so it never takes a row a claim holds, and a claim never takes a row it holds. Housekeeping's reconcile stops every `stopping` task through ECS on its next pass, so the operator never calls ECS. That path has existed since the fleet landed (#438), so every release production could roll back to has it. If `stops` is more than the eligible spares, the runbook says the rest must come from bound companies going idle, and to count again each round. A throwaway probe on this head ran both statements verbatim (placeholders filled) with the real controller and store, disposable Postgres and the memory provider: ``` race A: fence in open transaction [race-spare-00] race A: claim while fence uncommitted no spare race A: claim after commit no spare # row is stopping race B: claim in open transaction race-spare-01 race B: fence while claim uncommitted [] race B: fence after commit [] # row stays bound stalled [larger spare 16] promoted false count {live 16, stopping 0, current_spares 16, staged_spares 0, stops 3} fenced [larger-spare-13, larger-spare-14, larger-spare-15] count after fence {live 13, stopping 3, stops 0} pass 1 [larger spare 13] promoted false # the controller stopped the three pass 2 [larger spare 13, older spare 2] promoted true after promotion [older spare 2] # the surplus drains on its own ``` This PR adds no controller test for it, because `packages/execution` belongs to another lane this round. The probe is the reproduction. Docs that followed: OPERATIONS.md (promotion now needs **three** ready spares within **24**), ADR-0012's production topology and hosting decisions 1–2, product.md's box size and cost promise (about $36 a month for an always-on box instead of $21, with the per-call figures scaled the same way), and a `packages/serving` comment that said "half a vCPU". ADR-0012's spike measurements still say half a vCPU on purpose: they record what was measured. The spike script keeps its own 512. ## How it was verified - `pnpm --filter @patchy/infra exec vitest run`: red on main's stack, green here (above). The security-group snapshot doesn't cover task sizes, so it is unchanged. - `packages/limits` and `apps/infra` tests: 6 files, 32 tests pass. A probe loads `{"execution.task.cpu":0.5}` and `{"execution.task.memory":2147483648}` on this head without error, as on main. - `pnpm check`: format, lint, typecheck and synth pass. The offline tests fail locally in the `packages/patchy` CLI suites and `LocalTaskProvider`. That's stray `GET /` requests from another process on the shared machine reaching the tests' fake servers on random localhost ports (`expected { method: 'GET', url: '/' } to match object { url: '/api/me' }`). A different set fails on every run, and `SdkApi.test.ts`'s two 5-second timeouts pass when run alone (21/21). CI is the clean run. - Not checked: the deploy and a real ECS rollback. The runbook's statements ran against Postgres with the real controller, not against production. ## Release impact - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Infrastructure sizing and production's fleet limits, which fit the account's current Fargate vCPU quota, so nothing is needed before deploying. No API, CLI, schema or configuration-format change: every limit id that loaded before still loads, and stored overrides stay readable. The deployment configuration's revision hash changes because `execution.task.cpu`'s default moved from 0.5 to 1. It changes whenever a resolved value does, and nothing reads that value. - **What does a revert leave behind?** Nothing stored: no schema, no rows. Exec task definitions are retained on replacement, so the 1-vCPU revision stays registered, and the previous release's hosts can still launch and manage its spares until promotion. - **Does the release before it still work with that?** Yes. An older release's stacks carry their own sizes (0.5 vCPU), budget (15) and spare floor (2), and the deploy record hands its hosts this release's exec task definition as "previous". Its promotion needs two ready spares inside 15 live tasks, counting this release's bound boxes and spares. Once this release holds 14 or more spares, that never happens on its own, even with no company bound. Rollback line for the deploy: if this release misbehaves, roll back to the live commit. If the rollback's promote step times out short of two older spares, follow OPERATIONS.md › Freeing budget for a promotion: count, fence `stops` of this release's newest spares with the controller's own fence, recount until the older revision has its two spares, then re-run the run. If there aren't enough spares to fence, the rest of the room comes from bound companies going idle. Made by Claude Opus 5.5 via Claude Code; reviewed with GPT-6.1-Sol. Co-authored-by: Claude Opus 5.5 <[email protected]>
Tier 2 documents need a company task before server calls can run. Hosts need to bind, drain and replace those tasks without replaying held calls or losing metering.
Adds a database-backed fleet controller exercised against real local task processes. It manages spare capacity, atomic binding, stopping and rollout, housekeeping, bound/process metering, and the cross-host breaker. The shell uses the T-1 starting cover picked in #385, with bounded held calls, focus handling and retry without replay.
Stacked on
tier2/404-dev-engine. This PR targets that branch and contains only the fleet work and its starting-cover refinement. Production admission remains closed until the ECS provider lands.Closes #405.
Verification
Fleet implementation and PR preparation used GPT-6 Astra in omp. The starting-cover follow-up credits Claude Opus 5.5.