Skip to content

feat(execution): run the fleet on ECS - #439

Merged
allisonmahmood merged 4 commits into
mainfrom
tier2/406-fleet-ecs
Oct 1, 2026
Merged

allisonmahmood merged 4 commits into
mainfrom
tier2/406-fleet-ecs

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

The fleet controller only had a local task provider, so production servers could not admit tier 2 patches.

This adds the ECS provider, private management and callback listeners, and rollout fencing with deployment-secret overlap and retirement. A reproducible host/exec image and guarded spike deploy script cover deployment and teardown. Documentation records the measured behavior rather than promising unchanged sibling latency on half a vCPU.

Stacked on tier2/405-fleet-controller. This PR targets that branch, not main.

Closes #406.

Verification

  • All nine checks passed on latest documentation-only commit c48dbe5: Node 22/24 tests, lint, CLI smoke, Clerk live, Postgres concurrency, dependency review, image and label. CI, image.
  • pnpm typecheck and pnpm lint passed. Focused execution suites: 5 files and 66 tests passed, including 20 new ECS provider/controller regressions.
  • Two independent local image builds using the exact pinned CI crane release produced byte-identical archives and metadata.
  • Role-only live Fargate acceptance passed every feat(execution): the fleet on ECS: the image with two entrypoints, the spike deploy and the Fargate acceptance #406 Done-when case: spare binding, idle stop, guest network isolation, adjacent deployment interoperability, 90-second drain, same-document keyed retry across replacement, and two spinning processes on half a vCPU. Private callbacks and management-secret retirement also passed. No runtime fix was needed.

Role-only deployment and cleanup

The operator granted the existing host role its documented fleet policy and rotated the deployer's key, deleting the old key. The acceptance reloaded those credentials. Host and control tasks verified temporary credentials for patchy-tier2-spike-host-task, without static AWS keys. Exec tasks had no task role. The earlier IAM authorization blocker is resolved.

The two loaded CPU windows returned 50/50 healthy replies each, but p95 increased from 999 to 1189 ms and from 768 to 938 ms. Four distinct process reports recorded stall. These are client-observed measurements, not an unchanged-sibling-speed guarantee. The original acceptance record retains the earlier unexplained non-200 response rather than retroactively classifying it.

The run was torn down. Independent checks found zero tasks, services, targets and run image tags; both run databases and all ten published objects are absent. ALB, target-group and security-group settings match their pre-run snapshots. Run task definitions are deregistered and pending deletion. Pre-existing spike infrastructure, the operator-installed role policy and CloudWatch evidence remain.

The old credential-bearing revisions remain deregistered. Git history was not rewritten. The agent made no IAM policy/key changes and did not touch production.

Implemented with openai-codex/gpt-6-astra through the omp harness.

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area size:xl Over 1,000 changed lines; review in multiple passes labels Sep 29, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Astra review

Reviewed 8fb1e2a against origin/tier2/405-fleet-controller with git diff origin/tier2/405-fleet-controller...HEAD, using #406 and #384. One pass, no subagents. Two merge blockers.

Standards

No merge-blocking method or YAGNI findings.

Spec

1. [P1] Intent: an incomplete ECS listing permanently loses a live task

ecsTaskProvider.ts:606–618 returns the latest inventory as authoritative and deletes cached ARNs absent from it. But ECS explicitly uses eventual consistency.

One omitted running task makes fleet.ts:450–451 mark it durably stopped. When it reappears, the orphan check at lines 461–474 refuses to stop it because its database row still exists. It remains running outside reconciliation and the fleet budget.

Local reproduction with the actual ECS provider, controller and Postgres: omit one task from one listing, then restore normal responses. After three further housekeeping passes, Postgres counted 2 active tasks, ECS returned 3 RUNNING tasks, and 0 StopTask calls had occurred. The forgotten row remained stopped.

#406 requires: "The controller owns every exec task." Preserve and reconcile known ARNs; an omitted listing or transient MISSING response must not certify physical exit.

2. [P2] Intent: spare sizing excludes most of Fargate's cold start

ecsTaskProvider.ts:340–353 prefers ECS startedAt, which means the transition to RUNNING. FleetStore.target computes cold start as ready_at - started_at, excluding provisioning and image pull.

The local reproduction supplied a task created 30 seconds before readiness and RUNNING for 1 second. The stored cold-start average was 1,008 ms, versus 30,009 ms pending-to-ready. At one company wake per second, that sizes the pool at 2 spares rather than about 30, causing avoidable cold waits under sustained arrivals despite available fleet budget.

#384 §5 requires max(2, wake rate over 15 min × measured cold start). Base sizing on the durable controller-request-to-ready interval, including provisioning and image pull.

Verification

  • pnpm exec vitest run packages/execution/src/Fleet.test.ts packages/execution/src/Supervisor.test.ts --maxWorkers=1: 37 tests passed.
  • Both reproductions ran against the real provider/controller with scripted local ECS responses and disposable Postgres. No AWS, Neon or running development instance was touched.

Standards: 0 blockers. Spec: 2 blockers, worst P1: a live task permanently escapes reconciliation and the fleet budget.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Opus review

Reviewed origin/tier2/405-fleet-controller...8fb1e2a against #406 (with the #426 stickiness and #428 exec handoff comments), spec #384 §5 and §18, and the effect-service conventions. All six "Done when" items have recorded evidence on #406, and docs/product.md claims only what the half-vCPU numbers support. Six findings block the merge, most severe first.

1. The new Image CI job fails on this head, so the build has not been shown to reproduce in CI

scripts/build-server-image.mjs:169 requires crane version to print exactly v0.22.1. The release binary installed by .github/workflows/server-image.yml prints something else, and the job exits in 35 s before either build runs (run 36640865847). The issue asks for the image to be "built reproducibly in CI", and the #406 evidence says "CI repeats this comparison", but that comparison has never passed in CI. Fix the version check (for example, strip a leading v before comparing) and get the double-build cmp green on this PR.

2. Distinct workerd uids fail open, even though the docs state them as fact

The image ends with USER node (apps/server/Dockerfile:44). packages/execution/src/process.ts:285 drops a child to its own uid only when process.getuid() === 0. Otherwise it quietly runs every workerd as the supervisor's uid. Root comes only from the spike's task definition (scripts/tier2-spike.mjs:721, user: "0"). The provider's task-definition check (packages/execution/src/ecsTaskProvider.ts:213-233) doesn't look at user, and apps/server/src/exec.ts never checks it either. If any other exec definition leaves out user: "0" (#415's CDK is the next one), guests share a uid with the process whose environment holds EXECUTION_MANAGEMENT_SECRET and the previous secret. No check fires. ADR-0012:287 and docs/DEVELOPMENT.md:234 still say each child has a distinct uid. #428 handed this privilege decision to this ticket, so it should be enforced here. Have exec.ts refuse to start on a private interface unless getuid() === 0, or have the provider reject a definition whose container user isn't "0".

3. The AWS account id and Neon project id are now in a public repo

scripts/tier2-spike.mjs:10,12,82 and docs/DEVELOPMENT.md:212-213 commit account 614817375332, the IAM user name and Neon project fancy-mode-72369071 to a public repository. Neither id appears on main. The hard-coded account also doesn't keep the script off production: the patchy:spike=tier2 tag checks, the caller-ARN check and the Neon API checks do that. Read the expected account and project from aws-spike.env and neon-spike.env, keep those checks, and describe the guard in DEVELOPMENT.md without the ids.

4. The spike writes a long-lived IAM user key into a task definition, so the task-role path was never tested

scripts/tier2-spike.mjs:780-781 puts AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY into hostEnv, and line 801 registers them as plaintext container environment. Anyone with ecs:DescribeTaskDefinition can read them. The RegisterTaskDefinition request also records them in CloudTrail, and deregistering or deleting the definition doesn't scrub that record. The user key also takes precedence over the host task role, so acceptance never ran the credential path the provider documents (ecsTaskProvider.ts:78, "SDK credentials come from the host task role"). The IAM policy described in DEVELOPMENT.md is therefore unverified. repeatable makes this worse: every up, rollout and seal copies the key again. Put the fleet policy on the disposable patchy-tier2-spike-host-task role, drop the keys from hostEnv, and rotate the key that has already been registered.

5. The ECS provider has no offline test and no seam for one

packages/execution/src/ecsTaskProvider.ts is 688 new lines, and no test file references it. It holds the only code enforcement of the credential-free promise: it rejects a task role, secrets, environmentFiles and AWS_*/ECS_CONTAINER_CREDENTIALS variables. It also holds the ownership filter, idempotent start (client token, conflict on an existing task's revision) and the per-revision secret choice in post (revision?.secret ?? options.current.secret), which rollout interop depends on. All of it is checked only by the live spike, so a regression passes CI. new ECSClient(...) inside make (line 161) leaves nothing to substitute. The repo's convention is to inject faults with an alternate layer. Take ECS send from a small service in the environment and add focused it.effect cases for definition rejection and secret selection across adjacent revisions.

6. CONTEXT-MAP.md still says hosted tier 2 is refused

CONTEXT-MAP.md:12 says "Hosted tier 2 publication remains refused until its host and fleet tickets land." This PR admits production tier 2 under EXECUTION_PROVIDER=ecs (packages/patches/src/PatchesConfig.ts:14). It belongs to the vocabulary and product-shape surface in "Hit every surface".

Checked without finding a blocker: task per spare, stop by ARN and stop-time reconciliation (list, stop, observation, the housekeeping task_lost path); quiesce, persist, acknowledge, then stop; the housekeeping lease gated on the staged revision; accepting the previous secret in both directions during a rollout, and the seal step retiring it; per-bind callback URL registration, where every invocation binds first; private-interface binding; the 90 s deregistration and application-cookie stickiness in the spike; and teardown restoring only the attributes the script changed.

@allisonmahmood

allisonmahmood commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner Author

Review dispositions and role-only acceptance

Read the conversation comments, review bodies and inline review comments. Astra and Opus posted the findings below; no additional Grok finding appeared in the inspected feedback.

Fixed

Finding Change and reason
Astra: a missing inventory entry loses a live task Known ARNs survive listing gaps; MISSING is uncertainty, not physical exit. Durable rows stay budgeted across host replacement. A running task that reappears beside a stopped row is durably fenced before replenishment and stopped.
Astra: cold-start sizing omits provisioning and image pull Spare sizing uses durable requested_at through ready_at. ECS started_at remains available for usage accounting.
Opus: image CI rejects the pinned release binary Normalize the optional leading v in crane version. The checksum-verified release binary prints 0.22.1; two local builds using that exact binary produced identical archives and metadata.
Opus: exec uid isolation fails open Current and previous exec definitions must explicitly declare a supported root user. Unsafe default or non-root users are rejected before launch.
Opus: committed account/project identifiers Removed the literals from the current tree. Expected identities come only from the named private env files; identity, region, resource-tag and Neon endpoint/storage guards remain. Ambient values cannot supply missing allowlist fields.
Opus: host definitions contain IAM-user credentials Removed AWS credential overrides and require the existing host task role, including stored promotion definitions. The role-only live acceptance now passed after the operator granted its fleet policy. No static-key fallback.
Opus: ECS provider has no offline seam or coverage Added a scoped, typed ECS transport service and 20 provider/controller regressions for inventory uncertainty, host replacement, budget retention, ambiguous starts, ownership, unsafe definitions, revision authentication and cold-start sizing. The provider layer exposes this dependency rather than hiding the live client.
Opus: stale context map Updated Patches, Serving and Runtime descriptions for tier 2 admission under the ECS provider.

Security and conservative behavior

  • The operator has now rotated the deployer's access key and deleted the old key. This run reloaded the private credentials. The agent made no IAM policy/key changes and did not rewrite Git history.
  • The credential audit enumerates the old credential-bearing host revisions :1, :2, :3. They are deregistered; deletion does not erase CloudTrail history.
  • A task that ECS has forgotten without positive stop evidence remains reserved in the durable budget. Operator reconciliation is safer than declaring a potentially live task stopped.
  • The CPU documentation makes no unchanged-latency guarantee. The original unretained non-200 response remains unexplained; the new role-only measurements retained every response and showed increased healthy p95 in both contention windows.

Verification

  • Code fixes are in 509849a; 66eb974 gives the existing four-process CLI scenario its established 30-second multi-process test budget. Assertions and production timeouts remain unchanged.
  • pnpm typecheck: 38/38 tasks passed. pnpm lint passed. Focused ECS, fleet, supervisor, local-provider and server-execution suites: 5 files, 66 tests passed, including 20 new regressions. Follow-up Standards and Spec reviews found no remaining code findings.
  • All nine checks passed on latest commit c48dbe55099c34cab8356eabfd2aa1f7853cbe48: Node 22/24 tests, lint, CLI smoke, Clerk live, Postgres concurrency, dependency review, image and label. CI run, image run. The PR is clean and remains unmerged.

IAM blocker resolved by live acceptance

Full role-only acceptance and teardown on #406 records every Done-when case. The image ran runtime commit 66eb974; no runtime fix was needed. Commit c48dbe5 updates DEVELOPMENT and ADR-0012 with the results.

  • Host and control tasks verified patchy-tier2-spike-host-task credentials from ECS, with no static AWS keys. Hosts launched warm spares, served real browser calls and stopped idle execution tasks.
  • First-open ready: 481.3 ms, using an existing spare. Closing the last actual document reached physical ECS stop in 49.244 s. All five guest network probes were refused.
  • Both adjacent deployment directions passed. Binding epochs 5, 6 and 7 recorded replacement; the 90-second drain completed. The same browser document's explicit keyed retry returned its original committed nonce after replacement, sealing and contention.
  • During overlap both management secrets returned 200. After sealing, the retired secret returned 401, and the current secret 200, on the active bound task.
  • Two action spinners shared a half-vCPU task with a healthy third version. Both loaded windows returned 50/50 healthy replies. Client-observed p95 rose from 999 to 1189 ms and from 768 to 938 ms. Four process reports recorded stall; the ticket contains CPU, RSS, percentiles and the preliminary query-deadline control.

The run is torn down. Independent checks found zero tasks, services, targets and run image tags; both run databases and all ten published object keys are absent. ALB, target-group and security-group settings match the pre-run snapshots. Host/exec definitions :4, :5, :6 are deregistered and pending deletion. The pre-existing spike infrastructure, operator-installed role policy and CloudWatch evidence remain. Production was not touched. PR not merged.

@allisonmahmood
allisonmahmood merged commit b8dd79d into main Oct 1, 2026
9 checks passed
@allisonmahmood
allisonmahmood deleted the tier2/406-fleet-ecs branch October 1, 2026 05:02
allisonmahmood added a commit that referenced this pull request Oct 1, 2026
Patches can share tables, but could not read another patch's file store.
This adds read-only access to shared stores on tiers 1 and 2, with live
source authorization and recovery after reshare or restore.

Includes shared-store discovery and declarations, CLI add/remove,
generated SDK support, local fixtures, and documentation. Query
subscriptions track source files and lifecycle changes; fixture reloads
invalidate subscriptions even when the last file is removed.

Stacked on `tier2/406-fleet-ecs` in #439. This PR intentionally targets
that branch and contains only the shared-store change.

Closes #407. Implements the shared-store requirements in #384, using the
agreed UI from #385.

## Verification

- `pnpm test`: 134 files and 1,500 tests passed.
- `pnpm typecheck` and `pnpm lint` passed.
- Chromium verified both tiers, downloads, fresh URL authorization,
rollback, served-tier gating, lifecycle recovery, and subscription
invalidation/recovery.
- Real CLI and dev flows verified add/remove and empty-fixture reloads.
- Standards and spec reviews completed with no unresolved findings.

Implemented with GPT-6 Astra using the omp harness.
allisonmahmood added a commit that referenced this pull request Oct 2, 2026
The docs pass was written while #406's role-only acceptance waited on the IAM
grant. That run passed on 2026-09-30 and #439 merged, so the "pending" claims
contradicted ADR-0012's own measurements section.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
allisonmahmood added a commit that referenced this pull request Oct 2, 2026
The docs pass was written while #406's role-only acceptance waited on the IAM
grant. That run passed on 2026-09-30 and #439 merged, so the "pending" claims
contradicted ADR-0012's own measurements section.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:server Touches the server area size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(execution): the fleet on ECS: the image with two entrypoints, the spike deploy and the Fargate acceptance

1 participant