docs(aws): phase 7

Spec: phase 7 done, rulings (E1-E11 as built, R1-R4, cold-start rerun),
data model, feature table. CLAUDE.md: EC2 rules and the docker-socket
step; sandbox is off on all AWS. aws/README.md: triple-c-user admin
setup and caveats, measured sizes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-16 18:19:39 -08:00
1 parent 6e24977cf0
commit 719a75b46d
3 files changed
+213 -22

No files matched your search

+56 -3
View File
@@ -292,7 +292,7 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li
when it drops, so an `AgentEndpoint` stays valid. The `StartSession` token goes to the plugin
through its environment, never argv, and the plugin's environment is stripped of every
inherited `AWS_*` variable before the session's own credentials are added.
`aws_host.rs` is `ProjectHost::Aws` (an ECS Fargate task per project; a running task is
`aws_host.rs` is `ProjectHost::Aws` (an ECS task per project, Fargate or, on the user's own instance, EC2; a running task is
attached to with the token read back from its secret, never rotated; a task a failed start ran
is stopped again) and `tunnels.rs` the registry of open tunnels by project — an AWS project's
`ContainerTarget::for_project` is its tunnel's endpoint, its stored `container_id` is that
@@ -367,8 +367,11 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li
push's snapshot), may push first (under an in-container `timeout`, since the agent does not kill an
exec the client gave up on), then writes `pushed` or `discard` to `/run/triple-c/stop-reason`
(root-owned; the entrypoint's TERM hook reads it, and the idle watcher writes `idle` or `lifetime`) so the hook
doesn't push twice; the marker is cleared if StopTask fails. Claude Code's sandbox is forced off in
the generated settings (bubblewrap can't create namespaces on Fargate, verified live).
doesn't push twice; the marker is cleared if StopTask fails. **Claude Code's sandbox is forced off
on every AWS project, Fargate and EC2** in the generated settings (`sandbox_allowed` is false; the
Runtime toggle is locked off, `sandboxEffective` in `awsWorkspace.ts`): bubblewrap fails on Fargate
and under Docker's default seccomp profile on EC2 too ("No permissions to create new namespace",
verified live), so a `sandbox_allowed` that said yes would only break every command.
**LLM gateway sidecar** (`gateway_sidecar`, Q7): a second, `essential: false` container `gateway`
(`docker::gateway::registry_image_ref`, digest-pinned, amd64+arm64; `memoryReservation` 512; no
`environment`, no `dependsOn`) whose `secrets` are exactly `TRIPLEC_GATEWAY_{CONFIG,API_KEY,MASTER_KEY}`
@@ -387,6 +390,52 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li
EC2 projects (E10) pass `instance_type` (the user's, from `aws_ec2_capacity`): the `AmazonEC2`
on-demand Linux/shared-tenancy hourly price (`EC2_FILTERS`), cached as `<region>--ec2-<type>.json`
with the same rules — the instance's price, not the reservations.
**ECS on EC2 (phase 7; `aws/terraform/user-onboard/ec2.tf`, `workspace.rs` `ec2_plan`, `aws_host.rs`).**
Opt-in per onboarding (`ec2_instance_type`); a project's `launch_type` is `Fargate | Ec2`. Why the
rules are what they are:
- **Per-user cluster `triple-c-<env>--u-<tag>`**, named by the principal tag `triple-c-user`
(`user_ec2_stem` in `tofu_modules.rs`, the only place). One capacity provider per cluster,
because `PutClusterCapacityProviders` replaces the list and two modules would undo each other on
a shared cluster. Environment names and tags never contain `--`, so `triple-c-*--u-*` matches
exactly the per-user clusters. **Two Denies in `workspace-user-tasks.json`** (`RunTask`/`StartTask`
on a `--u-*` cluster other than the caller's own, and on any when the caller has **no**
`triple-c-user` principal tag) are the whole isolation between EC2 users: don't loosen them, and
keep the missing-tag Deny (a variable that resolves to nothing must not fall through). A denial
maps to `EC2_TAG_MISMATCH` ("different triple-c-user value").
- **The instance role is scoped by its own cluster tag.** `triple-c-<env>-<owner_key>-instance`
(owner key, not user tag: role names are account-global) has only the ECS agent's calls, and the
**boundary** allows them on `cluster/${aws:PrincipalTag/triple-c:cluster}` (must match `--u-*`).
A Docker-access project is root on its instance and holds that role, so the tag is what stops it
registering the instance into someone else's cluster. No SSM core on the instance. The boundary
is versioned (2): an account admin re-applies it once before anyone onboards with EC2.
- **Launch templates and groups are pinned to a numeric template version, and the admin policy
denies `$Latest`/`$Default`**: the admin's `iam:PassRole` and `ec2:RunInstances` checks look at the
template when it is created, and a version edited afterwards would carry any instance type or
role (a PassRole bypass). The type list (`ec2_instance_spec` in `models/project.rs`) lives in the
model table, the HCL variable and the policy (`ec2:InstanceType` in the compute file,
`autoscaling:InstanceTypes` twice in the scaling file); change all together. A template-only group
create sends no `autoscaling:InstanceTypes`, so don't add a `Null` condition on it (live-verified).
- **Bridge networking, not awsvpc (R2):** the instance is the user's alone, awsvpc tasks on EC2 get
no public IP, and bridge keeps IMDS out of reach with hop limit 1 (the agent on the host network
still reaches it). The ECS agent's introspection port (172.17.0.1:51678) stays reachable;
accepted. The gateway sidecar is refused on EC2 (no shared loopback).
- **Cold-start rerun + orphan rule.** ECS turns ECS Exec **off** for a task that has to wait for an
instance (the agent tunnel needs it), so the first RunTask only brings the instance up; once
placed, the app stops it, waits for STOPPED and runs again via `find_or_run` (so a concurrent
start never doubles a task: `START_RACE`), requiring exec on (`EXEC_OFF`). A found exec-off task
that is still waiting for an instance is another start's (`INSTANCE_RACE`) while younger than
`ec2_wait + ORPHAN_MARGIN`; older is an orphan, stopped (`REPLACED_REASON`) and replaced. Keep
both launches going through `find_or_run`.
- **Docker access = the instance's own socket**, mounted at `/var/run/docker.sock` (root on the
user's own instance, acceptable only because nobody else's task can land there); VPN =
`NET_ADMIN` + `/dev/net/tun` + `src_valid_mark`. A Fargate project can't keep either: switching
to Fargate clears both flags (`launchTypePatch`, R1).
- **Collision check before an apply** (`ec2_collision_refusal`, `prepare_onboarding`): the module
would adopt another user's cluster of the same name, so the app refuses a name owned by someone
else (resources' `triple-c:owner` tag, the user record `/triple-c/users/<env>/<owner_key>` as
fallback). Admin bundles carry the same check in `README.txt`.
- Scale to zero (min 0): the first start after ~17 min idle is cold (~3.5-4 min), warm ~20-30 s.
Re-applying onboarding without EC2 drains and deletes the group even with an instance running.
**Environments are OpenTofu modules** (`aws/terraform/{environment,user-onboard,permissions-boundary}`;
spec D2–D10). `tofu_modules.rs` embeds them and is the **only** place the shared names are built
(environment, `/triple-c/environments/<env>` record, owner key — `sha256("<region>:<aws:userid>")`,
@@ -508,6 +557,10 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li
The re-clone closes the apply lock's fd (a later connect never waits for it); `--prepare` takes it.
The functions both scripts use live in `container/entrypoint-lib.sh`
(`/usr/local/lib/triple-c/`), sourced by the entrypoint first; it only defines things.
**The Docker-socket group step** (`# >>> docker_socket`) runs in aws mode as well as Docker mode: an
EC2 project with Docker access mounts the instance's `/var/run/docker.sock`, and the step adds
`claude` to a group with the socket's gid (`docker-host` if none exists). Fargate never has the
socket, so it is inert there.
**The `TRIPLEC_` env prefix is reserved** on both hosts (`RESERVED_ENV_PREFIXES`; `workspace.rs`
drops custom variables in it): the entrypoint's settings live there.
- **Browser runtime libraries are baked in; browser *binaries* are not.** A layer runs
+38 -7
View File
@@ -37,6 +37,36 @@ The same value goes into the user's onboarding (`ec2_user_tag`), which names the
A user without the tag can't run anything on a per-user EC2 cluster (Fargate is unaffected), and
a user whose tag differs from their onboarding's can't run on the cluster it created.
**Setting up EC2 capacity (admin, once per user).** Phase 7 is opt-in per onboarding. In order:
1. Re-apply the **boundary** (version 2; see "One-time setup: the boundary policy"). Without it
the instance role's ECS agent calls are denied and no instance registers.
2. Attach all four admin files to whoever onboards (`environment-admin-compute.json` and
`-scaling.json` are the phase 7 ones; measured sizes under "Attaching the tier policies").
3. Give the user the `triple-c-user` principal tag (above). Before an admin-bundle apply, check
that **no cluster or Auto Scaling group named `triple-c-<env>--u-<tag>` exists**: the app's own
pre-apply check refuses a name that belongs to another onboarding (by the resources'
`triple-c:owner` tag, with the user record as fallback). A bundle run by hand has no such check
in the module (it would take over a cluster of that name), so the bundle's `README.txt` has an
"EC2 capacity" step with the three commands; run them right before `tofu apply`.
4. Onboard with `ec2_instance_type` (supported types below), `ec2_max_instances` (1 to 4) and
`ec2_user_tag` (the same value as the tag). Idle capacity scales to zero (min 0), so the
first start after about 17 minutes of idleness takes 3.5 to 4 minutes.
**Caveats of `triple-c-user`.** It is the isolation boundary between EC2 users, so treat it as one.
- **Session tags override role tags.** If a role's trust policy lets the caller pass session tags
(`sts:TagSession`), the caller can set `triple-c-user` to another user's value and run tasks on
that user's cluster. Trust policies of roles that carry the tag must not allow `sts:TagSession`
(or must restrict it with `aws:TagKeys` so `triple-c-user` can't be passed).
- **The identity-source attribute must not be user-editable.** For IAM Identity Center the
attribute behind `triple-c-user` must be one only an admin can change (not a self-service
profile field); otherwise a user can claim another's value. Likewise no workspace user may be
able to `iam:TagUser`/`iam:TagRole` the tagged principal.
- **A role shared by several people is one EC2 identity.** The tag belongs to the role, so
everyone who assumes it has the same cluster and can use each other's instance (and, with
Docker access, its root). Give each person their own tagged role or permission set.
Every per-user resource is tagged `triple-c:owner = ${aws:userid}`. That value is the `UserId`
printed by `aws sts get-caller-identity`. The policy uses this tag so that a user can only do the
following:
@@ -374,7 +404,7 @@ it is unpacked), and an admin can run the very same files by hand from a bundle.
|---|---|---|
| `terraform/permissions-boundary` | the account's `triple-c-permissions-boundary` policy (an account administrator applies it; the admin tier cannot) | `boundary/terraform.tfstate` |
| `terraform/environment` | what every user shares: ECS cluster (Fargate, Fargate Spot), the tasks security group (no inbound rules), KMS key and alias, log group `/triple-c/<env>`, the network (`network_mode`: `public`, `private-nat`, `existing`) and, last, the record `/triple-c/environments/<env>` (which carries the advisory `max_workspace_hours` lifetime cap, 0 = none, at most 168) | `environments/<env>/terraform.tfstate` |
| `terraform/user-onboard` | one user's task and execution roles (with the boundary) and their own EFS file system, its `-efs` security group, two mount targets and a file-system policy that admits only their task role | `users/<env>/<owner key>/terraform.tfstate` |
| `terraform/user-onboard` | one user's task and execution roles (with the boundary) and their own EFS file system, its `-efs` security group, two mount targets and a file-system policy that admits only their task role. With `ec2_instance_type` set (phase 7) also their own EC2 capacity: cluster `triple-c-<env>--u-<user tag>`, one capacity provider, an Auto Scaling group (min 0), a launch template, the instance role and profile, and the record `/triple-c/users/<env>/<owner key>` | `users/<env>/<owner key>/terraform.tfstate` |
**Workspace lifetime cap (advisory).** `max_workspace_hours` (module variable, 0 to 168, default 0 =
no cap) is stored in the environment record and passed to every workspace as
@@ -499,13 +529,12 @@ module creates the same policy, applied by an account administrator; the admin t
Create each file as a **customer managed policy** and attach it. In the console, go to
**IAM → Policies → Create policy → JSON**, paste the file, and attach the policy to a user, group
or role. Inline policies do not fit: a role's inline policies share 10,240 characters and an
environment admin needs every tier file (about 23,300), and a user's share 2,048. A managed policy
environment admin needs every tier file (23,304 characters in all), and a user's share 2,048. A managed policy
may hold 6,144 characters, not counting whitespace. Measured 2026-11-16 without whitespace, `workspace-user.json` is
6,036 (108 characters of headroom), `workspace-user-tasks.json` 1,827 (including `ReadFargatePrices` and the EC2 cluster Denies),
`environment-admin.json` 5,805 (339), `environment-admin-network.json` 3,340,
`environment-admin-compute.json` 3,326, `environment-admin-scaling.json` 3,006 and
`permissions-boundary.json` 2,661 (`workspace-user-tasks.json` is 1,827 with the per-user cluster
Denies); a unit test (`every_policy_fits_a_managed_policy`)
`environment-admin-compute.json` 3,326, `environment-admin-scaling.json` 2,970 and
`permissions-boundary.json` 2,661; a unit test (`every_policy_fits_a_managed_policy`)
fails before any file outgrows the limit. A tier that outgrows its files gains another file, which
the app then lists with the others. For IAM Identity Center, add the files as inline policies on the permission set
(the "up to 32,768 characters" limit is unverified) or reference the managed policies.
@@ -556,8 +585,10 @@ aws iam attach-user-policy --user-name <user> \
**Phase 7 (per-user EC2 capacity): the live run's answers (Task 7, 2026-11-16)**
The unit tests' evaluator is not IAM. What the live run (see "Phase 7: ECS on EC2" below) settled,
and what is still open:
The unit tests' evaluator is not IAM. What the live run (see "Phase 7: ECS on EC2" below) settled.
Still open for phase 7: an Identity Center attribute as the `triple-c-user` source and a user
without the tag (only a role tag was used live), and creating the Auto Scaling and ECS
service-linked roles as the admin (the test account had both). Everything else below is ✓:
- ✓ **Creating an Auto Scaling group checks the caller's launch permissions.** The onboarding's
group create as the environment admin (only the four admin files) passed with no denial. A group
@@ -492,13 +492,14 @@ fails because of a quota, the app says so and doesn't retry.
|---|---|---|
| Start time | About 30–90 s (image pull every time; SOCI lazy-loading **to evaluate**) | Fast when the image is cached on a warm instance |
| Docker access / privileged / VPN | No | Yes, on dedicated capacity |
| GPU | No | Yes |
| Ops | None | ASG + capacity provider, defined in the environment module. The app only picks a capacity provider |
| Cost when idle | 0 (task stopped) | Instances keep running unless the ASG scales in |
| GPU | No | Not in phase 7 (no GPU, accelerator or metal types) |
| Ops | None | A per-user cluster, capacity provider, ASG and launch template, created by the user's onboarding module (phase 7). The app only picks the launch type |
| Cost when idle | 0 (task stopped) | The ASG has min 0 and managed scaling removes the instance about 17 minutes after the last task stops; a start after that is cold (3.5-4 min) |
| Max size | 16 vCPU / 120 GB | Instance type |
ECS on EC2 uses `awsvpc` network mode too, so security groups and the no-inbound rule work the same
way.
ECS on EC2 uses `bridge` network mode (phase 7, R2), not `awsvpc`: the instance is the user's alone,
so per-task ENIs buy nothing. The task egresses through the instance (the environment's tasks
security group, which has no inbound rules, is on the instance), and the no-inbound rule holds.
### Lifecycle and status
@@ -556,11 +557,11 @@ way.
| Speech-to-text | Yes (local STT, audio over the agent) | Yes | Yes |
| Scheduler, Mission Control | Yes, and they keep running with the app closed | Yes | Yes |
| Marketplace installs | Yes (files copied through the agent) | Yes | Yes |
| LLM gateway (LiteLLM) | Sidecar container in the task definition | Sidecar | Sidecar |
| LLM gateway (LiteLLM) | Sidecar container in the task definition | Sidecar | **No** (refused: bridge containers share no loopback) |
| Ollama / llama.cpp on the user's machine | **No**, unless the URL is reachable from AWS | No | No |
| Claude Code sandbox (bubblewrap) | Off (bubblewrap fails on Fargate, P9) | Weaker nested mode | Full |
| Docker access | No | No | Yes |
| VPN support | No | No | Yes |
| Claude Code sandbox (bubblewrap) | Off (bubblewrap fails on Fargate, P9) | Weaker nested mode | **Off** (bubblewrap fails under Docker's seccomp profile on EC2 too, measured) |
| Docker access | No | No | Yes (the instance's own socket; root on the user's instance) |
| VPN support | No | No | Yes (`NET_ADMIN`, `/dev/net/tun`, `src_valid_mark`; WireGuard device created live) |
| Snapshots | Setup script instead | Setup script | Setup script |
## Fit with existing conventions (CLAUDE.md)
@@ -611,7 +612,10 @@ pub host_id: Option<String>, // None = Local (all existing project
pub aws_placement: Option<AwsPlacement>, // { region, environment } — set when host_id is an AWS connection
pub aws: Option<AwsWorkspaceConfig>,
pub enum LaunchType { Fargate /* default */, Ec2 } // serde snake_case; absent in old JSON = Fargate
pub struct AwsWorkspaceConfig {
pub launch_type: LaunchType, // Ec2 = the user's own instance (see user record below)
pub cpu: u32, pub memory_mib: u32, pub arch: Arch, // X86_64 | Arm64 (Fargate's valid pairs)
pub storage: StorageMode, // Ephemeral | Hybrid (default) | Efs (Hybrid + /workspace on EFS)
pub ephemeral_gib: u32, // 21-200
@@ -628,7 +632,12 @@ pub struct AwsWorkspaceConfig {
pub workspace_access_point_id: Option<String>, // the EFS-mode /workspace access point
}
// EnvironmentInfo (the SSM record, parsed): max_workspace_hours: u32 (0 = no cap).
// Not built: launch_type (Fargate only; EC2 is phase 7).
// UserCompute (the user's EC2 record, SSM `/triple-c/users/<env>/<owner_key>`, written by their
// onboarding module only while it has EC2 capacity; workspace users can read it): schema,
// instance_type, cluster_arn (`triple-c-<env>--u-<tag>`), capacity_provider (same name),
// user_tag, max_instances. Absent = no EC2 capacity. On EC2, cpu/memory are reservations that
// must fit the instance type (10% memory margin; ECS registers less than nominal); no ephemeral
// size, no spot, no gateway sidecar. Switching the launch type back to Fargate clears Docker/VPN (R1).
```
Existing `projects.json` files deserialize unchanged (`host_id` missing → Local).
@@ -678,6 +687,99 @@ Execution rulings:
- **R7** Switching to copy-at-connect recreates the project secret (force delete, then create), because a new secret version would keep the old credentials as AWSPREVIOUS. Cost: a short delay on the first start after the switch.
- **R8** The sidecar's master key is random per start, so the local Docker gateway's keychain key never goes to AWS.
### Phase 7: rulings (2026-11-16)
**Done 2026-11-16.** Verified live (`aws/README.md` "Phase 7: ECS on EC2"): cold start about
3.5-4 minutes including the instance launch, a warm start 20-30 s, scale to zero about 17 minutes
after the last task stops, Docker access and VPN work, IMDS is blocked for the container, another
user's cluster is refused (RunTask denied), and the sandbox stays off on EC2 too.
User decisions:
- **Idle capacity scales to zero.** The group has min 0 and managed scaling removes the instance
when no task needs it; the next start waits for an instance (boot, ECS registration, image pull).
- **The instance type is chosen at onboarding** (`ec2_instance_type`, default `m7i.large` for x86 or
`m7g.large` for ARM, from a built-in table of supported families); a project only chooses
Fargate or EC2. Compute is opt-in per onboarding (`ec2_instance_type` empty = none).
- **No GPU** (and no accelerator or metal types).
- **Isolation by the `triple-c-user` principal tag.** An admin gives each EC2 user a tag value
(an Identity Center attribute for access control, or a tag on the IAM user or role); the user's
cluster is named after it, and the workspace policy denies `RunTask`/`StartTask` on every
per-user cluster except `cluster/triple-c-*--u-${aws:PrincipalTag/triple-c-user}`, and on all of
them when the tag is missing. Users without the tag can't use EC2. This amended E1.
Plan decisions, as built (E1-E11):
- **E1** A **per-user cluster**, not a capacity provider on the environment cluster:
`PutClusterCapacityProviders` replaces a cluster's whole list, so two modules writing the shared
cluster would undo each other. The cluster is `triple-c-<env>--u-<tag>` (environment names and
tags never hold `--`, so the pattern matches exactly the per-user clusters) with exactly one
capacity provider; the Auto Scaling group and launch template share the name.
- **E2** Opt-in per onboarding: `ec2_instance_type`, `ec2_max_instances` (1-4), `ec2_user_tag`.
`ONBOARD_MODULE_VERSION` 1 -> 2; existing users keep working on Fargate.
- **E3** The ECS-optimized AL2023 AMI (public SSM parameter, by architecture), IMDSv2 required,
**hop limit 1 and bridge networking (R2) instead of awsvpc**, gp3 50 GiB encrypted root, the
environment's subnets and tasks security group, no ENI trunking.
- **E4** The instance role `triple-c-<env>-<owner_key>-instance` (named by owner key: role names
are account-global) carries only the ECS agent's calls, which the **boundary scopes to the
cluster named by the role's `triple-c:cluster` tag** (`aws:PrincipalTag/triple-c:cluster`; the tag
must match `triple-c-*--u-*`, never the shared cluster). **The SSM core is dropped**: nobody gets
host sessions, and ECS Exec uses the task role. The boundary changed (version 2); an account
administrator re-applies it once.
- **E5** The admin tier grows to **four files**: `environment-admin-compute.json` (capacity
providers, launch templates, `RunInstances` rules, the instance role's PassRole to EC2, the AMI
parameter) and `environment-admin-scaling.json` (Auto Scaling groups, instance profiles, the
service-linked roles). Every launch template and group is **pinned to a numeric template
version** and checked on create: `$Latest`/`$Default` would let a template edited after the check
carry any instance type or role (a PassRole bypass), so they are denied. A capacity provider over
someone else's group is refused (ECS checks `CreateOrUpdateTags` on the group).
- **E6** Docker access on EC2 is the instance's own socket (host volume), the entrypoint's
docker-socket group step running in aws mode. That is root on the user's own instance, and the
UI says so.
- **E7** VPN on EC2 is `NET_ADMIN`, the `/dev/net/tun` device and `src_valid_mark=1`, as locally.
- **E8** **The sandbox is off on EC2 as on Fargate.** Bubblewrap fails ("No permissions to create
new namespace") because Docker's default seccomp profile refuses `unshare` without
`CAP_SYS_ADMIN`, although the kernel allows user namespaces; the toggle is locked off for every
AWS project.
- **E9** EC2 CPU/memory are reservations that must fit the instance type (ECS registers less
memory than nominal, so a 10% margin), no ephemeral size, no Spot.
- **E10** The cost estimate is the instance type's on-demand hourly price while it runs.
- **E11** **The user record** `/triple-c/users/<env>/<owner_key>` (schema, instance_type,
cluster_arn, capacity_provider, user_tag, max_instances) is written by the onboarding module only
while it has EC2 capacity. Workspace users may read it (they can't read the state bucket), and it
lives outside `/triple-c/environments/` so environment detection doesn't list it.
Execution rulings:
- **R1** A Fargate AWS project can't keep Docker access or VPN: no grandfathering. Switching the
launch type to Fargate clears both flags (the user re-enables them after switching back).
- **R2** EC2 tasks use **bridge** networking. The instance is single-tenant, so per-task ENIs buy
nothing, awsvpc tasks on EC2 get no public IP (no internet in public-mode environments without
a NAT), and bridge keeps IMDS out of reach through the hop limit. Cost: the ECS agent's
introspection port (`172.17.0.1:51678`: cluster, tasks, no credentials) is reachable from the
container; accepted, since the instance runs only its user's tasks.
- **R3/R4** A pre-apply **collision check**: onboarding refuses a `triple-c-<env>--u-<tag>` cluster
or group that belongs to someone else, because the module would adopt it (R3). Ownership is the
resources' `triple-c:owner` tag, with the user record as fallback; only other-owned or
unowned names are refused, so an onboarding's own half-built cluster doesn't block its re-apply
(R4, amending R3). Admin bundles carry the same check as commands in their `README.txt`.
- **The gateway sidecar is refused on EC2.** In bridge mode a task's containers don't share a
loopback, so the sidecar on 127.0.0.1:4000 wouldn't be reachable; a host port would expose it on
the instance's network. Saves and starts of an EC2 project with it are refused.
- **The cold-start rerun.** ECS turns `enableExecuteCommand` **off** for a RunTask that has to
wait for an instance (measured in CloudTrail: true in the request, false in the answer, and the
task keeps it off), so the agent tunnel can't open. On a cold start the first task only brings
the instance up; once it is placed on an instance and desired RUNNING, the app stops it, waits
for STOPPED and runs the task again, requiring exec on (else it stops that task and fails with
`EXEC_OFF`). A live task found with exec off is stopped and replaced. Cost: about 30-60 s on a
cold start.
- **Race rules for the rerun.** Both launches go through `find_or_run`, so a concurrent start's
live task is never doubled (`START_RACE`, with one RunTask only). A first task that stops by
itself ends the start with its stop reason, with no second RunTask. A task still waiting for an
instance with exec off is another start's (`INSTANCE_RACE`) while it is younger than the
instance wait plus 2 minutes; an older one is an orphan and is replaced. A first task stopped
with `REPLACED_REASON` says another start replaced it. A stop gets its own 3-minute wait.
## Shipped AWS artefacts
```
@@ -723,8 +825,13 @@ TLS only, tagged `triple-c:component=state`), one object per deployment (D9).
"Phase 6: one workspace with every option"): EFS persistence, the setup script, port mapping,
the sidecar, copy-at-connect and the cost estimate. Not exercised live: the lifetime cap firing
(unit-tested), a v1 → v2 environment update, a private clone retried after connect.
7. **ECS on EC2.** Per-user capacity providers in the onboarding module, privileged/Docker/VPN on
dedicated capacity.
7. **ECS on EC2.** Per-user capacity (cluster, capacity provider, Auto Scaling group at min 0,
launch template) in the onboarding module, Docker and VPN on that dedicated capacity.
**Done 2026-11-16** (rulings: "Phase 7: rulings"). Verified live (`aws/README.md` "Phase 7:
ECS on EC2"): cold start about 3.5-4 min including the instance launch, warm 20-30 s, scale to
zero about 17 min after the last task, Docker and VPN work, IMDS blocked, cross-user RunTask
denied, sandbox off on EC2 too. Not exercised live: an Identity Center attribute as the
`triple-c-user` source, an untagged user, creating the service-linked roles.
8. **Standard tenancy** (opt-in), only if demand appears.
## To verify before or during implementation