carlos / platform Public

Self-service managed fleets: rent EC2 boxes in carloku’s AWS account for rootfs apps Feature Request open

Claimed by claude~paul@keymail.dev 1 month ago

Request and settled scope

Paul wants a member to be able to say: “give me 3x ec2 boxes at X size and provision them so that I can deploy my Rails apps on to them”. Asked where the boxes should live, Paul explicitly chose carloku’s AWS account, not the customer’s account.

Build a self-service managed fleet: dedicated EC2 capacity owned and operated by carloku, attached to the member’s CARLOS account, and usable for rootfs apps through the console API and CLI. Rails is the first example; the provisioning feature should be language-neutral. The customer must not need AWS credentials, SSH, SSM, Terraform/OpenTofu, manual tokens or operator-written routes to finish the job.

Paul requested this issue as a brief for another agent. The implementation details below are the proposed starting point, not additional settled product rulings.

Existing work to reuse

  • Approved design: platform-infrastructure/platform-design/superpowers/specs/2026-08-12-private-instances-design.md (local checkout: /home/paulca/amadan.net/carlos/platform-infrastructure/). It already describes managed fleets in the operator’s AWS account, a compute provisioner, priced catalog, box-hour rental, cloud-init bootstrap, and retained data after termination.
  • Historical PR: https://github.com/carlosframework/platform/pull/183 (trust-placement). It was still OPEN and unmerged when checked on 2026-10-28. Inspect what is actually reusable; do not assume the old branch is current or ready to merge.
  • Existing fleet ownership, registration and placement: fleets.go, internal/console/fleets.go, internal/registry/fleets.go, internal/fleetapi/, and carlos apps place --target fleet/<name>.
  • Rootfs work: Amadan #366; current specs/plans under docs/superpowers/, especially 2026-10-24-rootfs-apps-design.md and 2026-10-24-rootfs-apps-0-index.md. A Rails 8 app on a dev fleet box was demonstrated on 2026-10-27. Recheck current merge and release status before planning dependencies.
  • Work from a fresh current-main worktree. The checkout used for this investigation was behind origin/main and contained unrelated untracked files; none were changed.

Proposed member experience

Illustrative syntax, taken from the old design; these are not shipped commands:

carlos boxes create --fleet production --region eu-west-1 --type m7g.large --count 3
carlos apps place --app my-rails-app --target fleet/production

Creation should present the applicable rental price, enforce account eligibility and quotas, provision the boxes and fleet storage, enroll the boxes securely, and wait for all requested boxes to be usable. Report per-box progress and actionable failures. A lost CLI connection must not lose the operation; a retry must not buy another three boxes.

Initial scope recommendation: AWS, a curated ARM instance catalog, one region per fleet, and an explicit fixed box count. Include inspection and safe removal from the start. Automatic scaling/replacement policies and other cloud providers can follow separately.

Three boxes provide capacity. This feature does not by itself promise three replicas of each app, load balancing across those replicas, or high availability. Coordinate with the rootfs replica work without silently expanding this issue into it.

Design and implementation requirements

  1. Extend account-owned fleets with managed resource ownership. Enforce that only the owning account can place apps or manage rented capacity; keep BYO and managed resource authority distinct.
  2. Put provisioning behind an API and a testable provider interface. Use durable operation state, stable retry identities and cloud resource tracking so timeouts, process restarts and partial failures cannot cause duplicate spend or abandoned resources. Revisit the old design’s synchronous-handler/re-run-only recovery assumption explicitly.
  3. Restrict provisioning permissions to the approved resources, regions, instance profiles and catalog. Enroll each box securely; never expose fleet enrollment secrets through progress output or logs. Boxes must not gain broad access to the platform’s deployment bucket or other accounts’ data.
  4. Readiness must cover the expected platform version, rootfs capability, fleet ownership, data access and working routing. An EC2 instance in “running” state or a generic heartbeat is insufficient.
  5. Charge whole-box rental while provisioned, including idle time. Keep storage/traffic pricing explicit and do not additionally bill that same capacity as metered app compute. Define billing start/stop and partial-failure behavior before shipping; reconcile the historical design with the current billing system.
  6. Removal must drain or safely refuse active workloads, terminate the intended cloud resources, and retain fleet data under an explicit retention policy. Preserve the bucket while surviving boxes still use it. Reconcile this with the old design’s immediate-termination wording.
  7. Complete all user operations and diagnostics through the console API/CLI. Even bootstrap failures must be inspectable without requiring the customer to run an AWS or box-local command.

Known integration gaps to investigate

The latest Rails demo report on #366 said public routing still required a manual row on a platform box because platform boxes did not materialize fleet-placed records. Close that gap before calling provisioning self-service; check whether another agent has since fixed it.

Amadan #451 reports approximately 15 minutes of downtime after a rootfs box reboot because shutdown could not prove the instance stopped and its lease remained held. Coordinate the fix and verify reboot recovery before treating this as ready for paying Rails users.

Acceptance checks

  • From an eligible member account, request three catalog-sized boxes and see all three become rootfs-ready through the CLI/API.
  • Deploy/place a Rails rootfs app and verify its public URL and deployed version without any manual infrastructure or route repair.
  • Exercise interrupted creation, ambiguous provider responses, retries, partial capacity failure and quota races; verify no duplicate or untracked billable resources.
  • Verify cross-account refusals, credential isolation and quota enforcement with fake-provider tests.
  • Verify reboot recovery, safe removal with active workloads, continued service on surviving capacity, and retained data according to the chosen policy.
  • Verify rental accounting, including failures and termination, without double charging compute.
  • Document the commands in docs/site/cli.md; follow the repository’s copy review, review, PR and Amadan CI requirements.

Suggested first step and authority boundary

Refresh the existing private-instances design against current main and #366, identify the smallest complete implementation, and obtain the required Opus/Fable review of provisioning authority and production paths. An Opus review of the preliminary proposal was attempted on 2026-10-28 but could not run because the Claude weekly usage limit was reached; no independent review has happened yet.

This issue authorizes local design/implementation work, not live infrastructure changes. Before a live test or rollout, prepare the scoped account/region/domain/resources/permissions/cost/duration/cleanup plan required by AGENTS.md and obtain Paul’s explicit approval. No production resources were created or changed during this investigation.

Coordination from the rootfs Task 11 session (2d812478): fleet boxes cannot receive secrets today. The deployment has one secrets key and a customer box must never hold it, so any fleet app with a secret or a carlos store credential is refused by the box's config guard (no_key). Paul ruled 2026-10-29 that each fleet gets its own key. Spec on design-fleet-secrets-key: docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md.

What it means for managed fleets: the owner registers the fleet's public key with carlos fleets secrets-key <fleet> <pubkey>, and sealKeyFor(acct, app) picks it for every seal of a fleet-placed app. A managed-fleet provisioner could mint the key on the box and call the same door (§8). Please don't build a parallel key path; say here if your enrollment design needs something different from that door.

Coordination (platform-39, 2026-10-29 ~23:55Z): Paul wants fleet apps reachable at their public URL now, so Phase 1a (public routes for fleet-placed apps) is being pulled out of this draft as its own spec on branch design-fleet-public-routes (docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md), witness: shop.bab.dev.oncarlos.com on dev fleet r10r. The rest of #457 (managed provisioning, 1b, 1c, billing) is untouched. If you are working on 1a, reply here before building.

Phase 1a spec APPROVED by Paul 2026-10-30 ("Seems fine"): docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md rev 4 on design-fleet-public-routes (06b4d79e), Astra R1 NOT READY, R2 NOT READY, R3 READY AFTER FIXES (P2s applied). Next: plan, Astra plan review, build, dev roll; witness shop.bab.dev.oncarlos.com on r10r. (platform-39)

Managed fleets design APPROVED by Paul 2026-10-30 ("Approved. Go ahead."): docs/superpowers/specs/2026-10-28-managed-fleets-design.md on design-managed-fleets-457 (e873987f). Phases: (1) 1a routes, which is its own approved spec owned by platform-39 and not repeated here; 1b box choice within a fleet; 1c #451 reboot recovery. (2) Managed fleets with no billing, first on a self-hosted deployment. (3) carloku monthly box billing and per-fleet VPC peering. Astra builder check: four questions, all settled as calls listed in the spec. Next from this session: the phase 1 plan for 1b and 1c. If anyone is already on #451, reply here.

Fleet public routes (Phase 1a) Task 14 step 1: read-only inventory of fleet-placed rows that are not forward rows (platform-39, via the carlos CLI; spec §4.7: such rows keep their host; a row whose raw account is not the fleet's owner stops being served at the roll).

Fleet public routes, Task 14 step 1: legacy fleet-placed rows

Read-only, 2026-10-30 ~16:56Z, through the carlos CLI only (signed in as paul@keymail.dev; no SSM, no box access, no write). carlos fleets ls per account, carlos apps list per account, carlos routes --app for the apps, carlos instances list for the fleet-placed apps.

What is recorded: every registry row whose REGION names a fleet and whose KIND is not forward (a hand row or a legacy placed row). At the roll (spec §4.4, Tasks 4 and 10): such a row of the fleet owner keeps its host; a row with an empty raw account is served and logged; a row of a non-owner account, of an invalid (non-empty) account, or naming a fleet not in the hub's fleets table stops being served.

Limits of this read path:

  • carlos routes lists the console box's own registry ("routes on this deployment's own box; other boxes in a fleet are not listed"); rows on other platform boxes are not seen.
  • The console filters rows by release.RouteAccount(rt), not the raw Account column, and does not return the raw value. A row listed under bab (the ops account, release.OpsAccount) has raw account bab, empty, or an invalid value that resolves to bab; the CLI cannot tell these apart. Only the last would go dark.
  • Only the accounts paul@keymail.dev belongs to are visible; a fleet or a fleet-region row of another account is not.

Dev (https://platform.dev.carlosframework.com)

Accounts: ops (bab), paul (bac).

Fleets:

| fleet | owner | box | status | |---|---|---|---| | r10r | bab | box-1 | active | | r10w | bab | box-1 | detached |

bac: no fleets, no apps.

Apps of bab placed on a fleet (carlos apps list): railsdemo (fleet r10r), shop (fleet r10r), witness (fleet r10w, trashed, purged in 25d; carlos routes answers not found). Routes were listed for every live bab app (assetcheck, claimtrial, hacheck, hapair, helloworld, moverehearsal, railsdemo, shop, wakecheck); only one row names a fleet:

| host | app | REGION | KIND | channel | status | listed under (resolved account) | fleet owner | at the roll | |---|---|---|---|---|---|---|---|---| | railsdemo.bab.dev.oncarlos.com | railsdemo | fleet r10r | instance | r10-proxy | ready | bab | bab | keeps its host if raw account is bab or empty (raw not visible; see limits) |

Other observations:

  • shop (fleet r10r) has no row on the console box's registry (no routes for shop on this deployment's box); its instance record is shop.bab.dev.oncarlos.com, fleet r10r, held (build v3 failed on the box, serving v1). After the roll the hub mints a forward row for it (owner bab).
  • railsdemo's instance record is railsdemo.bab.dev.oncarlos.com, fleet r10r, held (build r4 failed, serving r3b), runtime rootfs. Its legacy row holds the host, so the forward phase leaves the host to it (same app, same fleet: served by the fleet arm, no FPR-C08).

Count: 1 legacy fleet-placed row, 0 rows of a non-owner account, 0 known to go dark.

Flagship (https://console.carloku.com)

Accounts (26): bab, bad, bae, bag, bah, bde, bdf, bdj, bdk, bdm, bdn, bdr, bds, bdw, bdx, bdy, beh, bem, ben, bep, beq, bes, bew, bey, bfb, bfj.

Fleets: none in any of the 26 accounts (no fleets for each).

Apps: 139 listed, none placed on a fleet (regions: Dublin 126, London 10, Sydney 2, N. Virginia 1). Routes listed for all 126 live apps: 186 rows, REGION Dublin (IE) or every region; 20 apps with no route on the console box; no row names a fleet.

Count: 0 legacy fleet-placed rows, 0 known to go dark.

Removal

Removing any row later needs Paul's approval per row (plan Task 14 step 1). Nothing here asks for one.

Removing any row later needs Paul's approval per row.

Phase 1c DONE: #451 merged 4029ac56, in v0.31.2 (dev only, 2026-10-30), reboot drill passed on box-1 (back 15 s after the edge started, was ~15 min); follow-up #475 (edge loses systemd's bus at shutdown). 1b addendum is on design-managed-fleets-457 (97f79b8a) awaiting Paul; the 1b plan waits for 1a to merge.

1b addendum APPROVED by Paul 2026-10-30 (design-managed-fleets-457, bdfa25ae): records name their box (least-loaded ready box at create), only that box mints and runs it, the 1a forward row carries it as FleetBox from the start, relabel on detach/removal or heartbeat absent longer than the lease, removal drains, keep the local DB only when this box was the last holder (#470), rootfs admission follows the chosen box. The 1b plan waits for 1a (design-fleet-public-routes) to merge.

Fleet public routes (#457 Phase 1a) LIVE ON DEV in v0.32.0 (main 65fd8060; tag 00ff9945; dev boxes + dev console 18:21-18:29Z; flagship untouched on v0.31.1). Live check (platform-60): curl -sI https://shop.bab.dev.oncarlos.com/up from outside -> HTTP/2 200 with one x-carlos-version: v1 (the rootfs Rails sample on dev fleet r10r/box-1, no hand-written route; sophie minted its forward row at 18:21:33Z); the same through leo -> 200 v1; railsdemo's hand row keeps serving (200, r3b), held-host line logged once per pass as designed. Known limit: WebSockets do not cross the fleet tunnel (#471), so Action Cable live updates do not work through the public URL yet. Flagship roll needs Paul's go.

1b status (stopping rules 2 and 8), 2026-10-31. All plan tasks 1-7 are built on managed-fleets-1b, each with an Astra task review passed. The whole-branch Astra review R1 is NOT READY: 3 P1 (a pending wake can boot the old assignment's copy after a move; a drain heartbeat can combine lease counts and routes read at different moments; a failed Litestream initialisation can be read as a successful final upload and clear the drain blocker) and 2 P2 (unheard box shows not paused; rollback alert lost once a labelled fleet shrinks to one box). Census approved by Astra. The restore and drain families recur from plan review rounds 2-3, so Paul chooses: fix all three centrally; fix the pending-wake case and replace drain evidence with terminate-confirmed detach (recommended); or cut moves from 1b. Findings: docs/superpowers/plans/CODEX-FINDINGS-MANAGED-FLEETS-1B-BRANCH-R1.md.

Phase 1b MERGED to main as 8294a52 (2026-10-31, Paul's go), not released. On a fleet with two or more boxes each instance runs on one console-chosen box (spread at create), the router goes straight to it, lost boxes' instances move to survivors, carlos fleets drain moves a box's instances off, and a box that has run instances detaches only with --terminated (Paul's option 2). The start rule sets stale copies aside and never boots a moved instance empty; a wake re-checks its route and record under the lease; an invalid fleet identity refuses labelled wakes. Dormant until every box and the console run v0.33.0 or later. Reviews: every task Astra-reviewed; whole-branch Astra R3 READY; census approved (#280). Follow-ups: #481, #483, #485, #494. Next: the dev drill (Task 9) with a temporary second box on r10r, after a v0.33.0 dev release.

Phase 1b dev drill PASSED (2026-10-31, v0.33.0 on all of dev). r10r gained a temporary box-2 (i-0acbbc51a4a2b135f, about 20 min) through the hostname-history window (dev console down about 58 s; history active again, floor now v0.33.0). shop, railsdemo and cable were labelled box-1 from their bindings, and nothing moved. A new app drillcheck was labelled box-2 at create and served from it; the drain relabelled it to box-1, which restored it from the fleet bucket and served the same value. detach-box without --terminated was refused with the new message; after terminating box-2, detach --terminated succeeded. shop/railsdemo 0 non-200 in 155 probes. Finding: the drain left drillcheck dark about 4.6 min (box-2 sees the relabel only on its 5-minute pass; hub 404 before 503), filed as #496. #470 closed. Phase 1 (1a, 1b, 1c) is done; next is phase 2 (managed provisioning).

Bug in 1b's start rule (v0.33.0+), found on dev fleet box box-1 after the v0.33.1 dev roll: every set-aside fails with EXDEV, because /data/instances is a nosymfollow bind of /data/.instances and rename(2) won't cross mount points. shop and railsdemo have answered 503 since 08:14Z ('refusing to start: setting aside the local copy ... renameat2 ...: invalid cross-device link'). Each wake also leaves an empty <nanos>.partial under /data/.superseded/<host>/ (about 19 per host so far, all empty). Fix on branch fix-set-aside-exdev (606b37f7): move through /data/.instances/<id> when it's the same directory, with a namespace-bind regression test that fails without the fix. Paul approved v0.33.2 to dev once it's reviewed and green. Every nested fleet box would hit this, so hold v0.33.0/v0.33.1 off flagship fleets until v0.33.2. (platform-cf)

Phase 2a (managed fleet core) is merged to main as a1f0ae4 (squash of managed-fleets-2a at bb1f4f48). It runs against the fake provider only and is switched off. Paul's copy review (2026-11-02, 45 strings, no edits) is applied verbatim. The census is approved on #280. CI passed at the tip. Not released or rolled; both need Paul's go.