From edef77feed77c69710fd9c3b464b5123f23b2c40 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 12:46:40 -0800 Subject: [PATCH 01/29] =?UTF-8?q?docs(aws):=20phase=207=20plan=20=E2=80=94?= =?UTF-8?q?=20ECS=20on=20EC2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../plans/2026-11-16-aws-phase7-ec2.md | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 docs/superpowers/plans/2026-11-16-aws-phase7-ec2.md diff --git a/docs/superpowers/plans/2026-11-16-aws-phase7-ec2.md b/docs/superpowers/plans/2026-11-16-aws-phase7-ec2.md new file mode 100644 index 0000000..c51bf8c --- /dev/null +++ b/docs/superpowers/plans/2026-11-16-aws-phase7-ec2.md @@ -0,0 +1,95 @@ +# AWS Host Phase 7 (ECS on EC2) Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** A project can run on its owner's dedicated EC2 capacity instead of Fargate, which makes Docker access, VPN support and the full Claude Code sandbox available on AWS; the capacity scales to zero when unused. + +**Architecture:** The onboarding module gains an optional per-user compute block: the user's own ECS cluster, an instance role and profile, a launch template on the ECS-optimized AMI, an Auto Scaling group (min 0) and a capacity provider with managed scaling, so instances exist only while a task needs one. An EC2 project registers an EC2-compatible task definition (awsvpc, the host's Docker socket and/or VPN device when enabled) and runs on that cluster through the capacity provider. Everything else (secret, EFS, agent tunnel, stop guard, idle stop, follower, port mappings) is phase 5–6 unchanged. + +**Tech Stack:** OpenTofu (user-onboard module, hashicorp/aws 6.73.0 pinned), Rust (aws-sdk-ecs/-ec2 read, pricing), bash entrypoint, React/TS. + +**Spec:** `docs/superpowers/specs/2026-11-13-aws-ecs-host-design.md` (Multi-user accounts → strict tenancy "Privileged and Docker allowed only on a per-user capacity provider"; ECS on EC2 vs Fargate; Feature compatibility "EC2 (dedicated)" column; Phase 7). Phase 5 and 6 rulings still bind. + +## User decisions (2026-11-16) + +- **Idle capacity scales to zero.** The Auto Scaling group has min 0; the capacity provider's managed scaling removes instances when no task needs them. Starts after idle take about 2–3 minutes longer (instance boot + image pull). +- **The instance type is set at onboarding** (default `m7i.large` for x86, `m7g.large` for ARM). Projects only choose Fargate or EC2. +- **No GPU in phase 7.** + +## Decisions this plan makes (rulings) + +- **E1. A per-user ECS cluster, not a capacity provider on the environment cluster.** `PutClusterCapacityProviders` replaces a cluster's whole list, and the environment module owns the shared cluster's list; two modules writing it would race and undo each other. The user's onboarding module creates `triple-c--` (the workspace-user policy's `ecs:cluster` condition `cluster/triple-c-*` already matches) with exactly one capacity provider. Strict isolation follows for free: nobody else's task can be placed on the user's instances. +- **E2. Compute is opt-in per onboarding.** New onboarding variables `ec2_instance_type` (empty = no EC2 compute, the default; the module creates nothing for EC2) and `ec2_max_instances` (1–4, default 1). Adding or removing it is an onboarding re-apply. `ONBOARD_MODULE_VERSION` 1 → 2 (re-apply shows "Update available"; existing users keep working on Fargate without it). +- **E3. Instance specifics:** ECS-optimized Amazon Linux 2023 AMI resolved at apply time from the public SSM parameter (`/aws/service/ecs/optimized-ami/amazon-linux-2023/recommended/image_id`, or `…/arm64/…` by the type's architecture); IMDSv2 required, hop limit 2 (tasks can't reach the instance role at hop 1 with awsvpc anyway — awsvpc tasks get no IMDS route; set `ECS_AWSVPC_BLOCK_IMDS=true` in the agent config); root volume gp3 50 GiB encrypted; instances in the environment's two subnets with the environment's tasks security group; `ECS_ENABLE_TASK_ENI` trunking is **not** enabled (one workspace per instance is the expected use; `ec2_max_instances` bounds concurrency). +- **E4. The instance role** `triple-c---instance` carries the managed-policy-equivalent inline rights for the ECS agent (register/poll/submit, ECR pull, logs) and SSM core (for ECS Exec on EC2), under the permissions boundary — which therefore grows: the boundary module gains those actions (boundary version bump; an account admin re-applies it once). Instance profile of the same name. +- **E5. Admin tier grows a third file** `aws/policies/environment-admin-compute.json` (the two existing files are at 5,805 and 3,340 of 6,144): `autoscaling:*` on `autoScalingGroup:*:autoScalingGroupName/triple-c-*` with tag conditions, EC2 launch templates tag-scoped (`triple-c:component`), `ecs:CreateCapacityProvider`/`DeleteCapacityProvider`/`UpdateCapacityProvider`/`PutClusterCapacityProviders` on `capacity-provider/triple-c-*` and `cluster/triple-c-*`, `iam:*InstanceProfile*` on `instance-profile/triple-c-*`, `iam:PassRole` to `ec2.amazonaws.com` for `role/triple-c-*`, `ssm:GetParameter` on the public AMI parameters, `ec2:RunInstances` (with launch-template + tag conditions), `iam:CreateServiceLinkedRole` for `autoscaling.amazonaws.com`. Destruction tag-scoped as in phase 3. MODULE_CALLS gains every new provider call (drift test). +- **E6. Docker access on EC2 = the host's socket.** `allow_docker_access` on an EC2 project mounts `/var/run/docker.sock` from the instance (host volume) at the same path, and the entrypoint's existing Docker-socket group step runs in aws mode when the socket exists. That is root on the user's own instance — acceptable only because the instance is theirs alone (E1); the UI says so. **Privileged mode is not offered** separately (nothing in Triple-C needs it beyond Docker/VPN). +- **E7. VPN on EC2 = the same three pieces as local** (`vpn_host_config` parity): `NET_ADMIN`, the `/dev/net/tun` device, and the `net.ipv4.conf.all.src_valid_mark=1` system control (ECS `systemControls`, allowed for awsvpc). The AMI must have the `tun` module (AL2023 does); the live test checks a `wg` interface can be created. +- **E8. The Claude Code sandbox is allowed on EC2** (bubblewrap's user namespaces work on the ECS-optimized AMI; verify live — if not, keep it off like Fargate, P9). +- **E9. EC2 task sizing:** CPU/memory become reservations that must fit the instance type (the app knows the type's vCPU/memory from a small built-in table for the default families, validated at save; unknown types → only a "must fit" warning), no `ephemeralStorage` (instance disk), no Spot (EC2 Spot is a later item). +- **E10. Cost estimate for EC2** = the instance type's on-demand hourly price (Pricing API `AmazonEC2`, Linux, shared tenancy) while running; shown with "instances scale to zero when no workspace is running". + +## Global Constraints + +- Phase 5/6 constraints hold (sdk_config only; three tag keys on per-user resources; names only in `aws/tofu_modules.rs`; P1; policy + checks + README together, ≤ 6,144 each; three-part command registration; serde defaults + TS mirrors; live AWS only via the scratchpad `awsx`, cleaned up, spend cap $10 overall). +- Module versions and pinning tests move together (HCL `template_version` ↔ Rust consts ↔ default tags). +- Fargate projects behave exactly as before (fingerprints of existing Fargate plans unchanged — pinned tests). +- Every per-user EC2 resource carries `triple-c:component=user-onboarding` via default tags (admin destruction scoping). + +## Review Focus + +1. A user without EC2 compute picks EC2 for a project: refused at save with "Ask an admin to add EC2 capacity to your onboarding" — Task 4/6. +2. First start after idle: the capacity provider has to launch an instance; the start waits (progress "Starting an instance (about 3 minutes)…") instead of timing out at the Fargate wait — Task 5. +3. A task that doesn't fit the instance type: refused at save, not stuck PROVISIONING forever — Task 4/5. +4. Removing EC2 compute from an onboarding while an EC2 project exists: the next start says why — Task 5. +5. Docker access on: `docker ps` in the workspace works and lists only the user's own instance's containers — Task 7 (live). + +--- + +### Task 1: Model and validation + +**Files:** `models/project.rs`, `lib/types.ts`, `lib/awsWorkspace.ts`, `commands/project_commands.rs` (validate_aws_update). +**Produces:** `AwsWorkspaceConfig.launch_type: LaunchType { Fargate (default), Ec2 }`; validation: Ec2 forbids `spot` and `ephemeral_gib` ≠ default is ignored; Docker access and VPN allowed only when `launch_type == Ec2` for AWS projects; `ec2_instance_spec(type) -> Option<(vcpu_units, memory_mib)>` table for m7i/m7g/c7i/c7g/r7i/r7g/t3/t4g common sizes (large…4xlarge); fit check reserve 256 MiB + 128 CPU units for the agent/OS. +- [ ] Tests: old JSON → Fargate; Ec2 + spot refused; Docker/VPN refused on Fargate AWS projects, allowed on Ec2; fit check pass/fail; unknown type → Ok with warning flag. +- [ ] Commit `feat(aws): EC2 launch type setting`. + +### Task 2: Policies — boundary and the admin compute file + +**Files:** `aws/policies/permissions-boundary.json`, new `aws/policies/environment-admin-compute.json`, `aws/terraform/permissions-boundary/*` (version), `aws/policies.rs` (+ checks, `policy_files(EnvironmentAdmin)` three files), `aws/README.md`, `aws/live_tests.rs` (admin role attaches all three). +**Produces:** E4/E5 statements; boundary version bump; checks in lock-step; destruction tag-scoped; sizes recorded. +- [ ] Tests: lock-step + evaluator; another owner's ASG/launch template/capacity provider denied; PassRole to ec2 only for `role/triple-c-*`; all files ≤ 6,144. +- [ ] Commit `feat(aws): admin and boundary permissions for per-user EC2 capacity`. + +### Task 3: Onboarding module — per-user EC2 compute + +**Files:** `aws/terraform/user-onboard/{variables.tf,main.tf,ec2.tf (new),outputs.tf}`, `.terraform.lock.hcl` if providers change (they shouldn't), `aws/tofu_modules.rs` (+ tests: version 2, variables, `MODULE_CALLS`, names `user_cluster_name(env, owner_key)`, `user_capacity_provider_name`, `user_instance_role_name`), `aws/environments.rs` (onboarding outputs: `ec2_cluster_arn`, `ec2_capacity_provider`, `ec2_instance_type` — readable how? see note). +**Produces:** E1–E4 resources gated on `ec2_instance_type != ""` (`count`); outputs; `onboarding_complete` still depends on everything. +**Note (E11):** workspace users can't read the state bucket, so the module also writes a per-user SSM record `/triple-c/users//` (`{schema:1, instance_type, cluster_arn, capacity_provider}`, String, tagged) that the workspace user can read (`ssm:GetParameter*` on `parameter/triple-c/*`). It lives outside `/triple-c/environments/` so environment detection (GetParametersByPath there) never sees it. Task 2 must make sure the admin tier can put/delete parameters under `parameter/triple-c/users/*` (tag-scoped like the environment record). +- [ ] Tests (HCL + Rust): resources present only with the variable set; ASG min 0, max `ec2_max_instances`, `protect_from_scale_in` true with managed termination protection; capacity provider managed scaling target 100; IMDSv2 required; AMI parameter by arch; user record field list pinned. +- [ ] Commit `feat(aws): optional per-user EC2 capacity in the onboarding module`. + +### Task 4: Onboarding UI + commands + +**Files:** `commands/environment_commands.rs` (onboard + admin bundle carry `ec2_instance_type`, `ec2_max_instances`), `components/settings/hosts/*` (onboarding dialog: "EC2 capacity: none | m7i.large | m7g.large | other…", max instances), `aws/environments.rs` (`OnboardingState` gains `ec2: Option` from the user record). +- [ ] Tests: vars passed through; re-apply keeps existing values unless changed; UI shows the user's compute. +- [ ] Commit `feat(aws): choose EC2 capacity when onboarding`. + +### Task 5: EC2 task definition and run + +**Files:** `aws/workspace.rs` (EC2 request: `requiresCompatibilities EC2`, awsvpc, no ephemeralStorage, Docker socket host volume + mount when enabled, VPN linuxParameters/devices/systemControls when enabled, sandbox per E8), `aws/tasks.rs` (run on the user's cluster with `capacityProviderStrategy=[{user CP, weight 1}]`; wait timeout 10 min for EC2 with the "Starting an instance…" progress while the task is PROVISIONING/PENDING without a container instance), `host/aws_host.rs` (cluster per project: environment cluster for Fargate, user cluster for EC2; reconcile/watch/stop use the project's cluster), `aws/runtime.rs` (user record read). +- [ ] Tests: Fargate request bytes unchanged (pinned fingerprints); EC2 request shape for each toggle combination; run request uses the user's cluster + CP; watch groups by cluster; missing user compute → clear error; wait progress strings. +- [ ] Commit `feat(aws): run projects on per-user EC2 capacity`. + +### Task 6: Container + UI for EC2 projects + +**Files:** `container/entrypoint.sh` (aws mode: Docker socket group step when `/var/run/docker.sock` exists; VPN skill install when `VPN_SUPPORT_ENABLED=1` as on Docker), `docker/aws_mode_tests.rs`, `HostSection.tsx` (Launch type: Fargate | EC2 (your instance: m7i.large) — disabled with the reason when the user has no EC2 compute; EC2 notes: scale-to-zero start delay; Docker access = root on your instance), `AccessSection.tsx`/`RuntimeSection.tsx` (Docker access / VPN enabled for EC2 projects), cost estimate (E10) in `aws/pricing.rs` + `AwsCostEstimate`. +- [ ] Tests: entrypoint gating; UI enable/disable per launch type; EC2 estimate arithmetic with a recorded `AmazonEC2` price fixture. +- [ ] Commit `feat(aws): EC2 projects in the UI, Docker access and VPN`. + +### Task 7: Live verification + +Via `scripts/aws-e2e-workspace.sh` (extend or add a test): onboard a workspace user with `ec2_instance_type = m7i.large`, start an EC2 project (Hybrid) with Docker access and VPN on: cold start time (instance launch), `docker ps` works, `ip link add wg0 type wireguard` (or `ip tuntap add`) works, bubblewrap check (E8), stop → capacity scales back to 0 instances within the managed-scaling window (record the time), second start time; remove; destroy; inventory incl. EC2 instances, ASGs, launch templates, capacity providers, instance profiles. Budget < $2. + +### Task 8: Docs + +Spec (phase 7 done, E1–E10 + user decisions + execution rulings, data model), `CLAUDE.md` (aws/, host/, container), `aws/README.md` (third admin file, boundary re-apply, EC2 compute, live results). -- 2.52.0 From 86f253b7da2807e228ad83dee9f7da66ad593458 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 12:54:24 -0800 Subject: [PATCH 02/29] feat(aws): EC2 launch type setting Co-Authored-By: Claude Opus 5.5 --- .../src/commands/project_commands.rs | 32 ++++ app/src-tauri/src/models/project.rs | 180 ++++++++++++++++-- .../home/config/RuntimeSection.test.tsx | 16 ++ .../projects/home/config/RuntimeSection.tsx | 14 +- app/src/lib/awsWorkspace.ts | 1 + app/src/lib/types.ts | 4 + 6 files changed, 225 insertions(+), 22 deletions(-) diff --git a/app/src-tauri/src/commands/project_commands.rs b/app/src-tauri/src/commands/project_commands.rs index 751ee4c..047d259 100644 --- a/app/src-tauri/src/commands/project_commands.rs +++ b/app/src-tauri/src/commands/project_commands.rs @@ -1248,6 +1248,18 @@ fn validate_aws_update( crate::models::validate_region(&place.region)?; crate::aws::tofu_modules::validate_environment_name(&place.environment)?; crate::models::validate_aws_workspace(cfg)?; + // Docker access and VPN need the user's own instance (E6, E7); + // Fargate refuses them. Grandfather a value the stored project + // already had on AWS so an old row can still be saved. + if cfg.launch_type != crate::models::LaunchType::Ec2 { + let was_aws = stored.aws.is_some(); + if project.allow_docker_access && !(was_aws && stored.allow_docker_access) { + return Err("Docker access on AWS needs the EC2 launch type".into()); + } + if project.vpn_support_enabled && !(was_aws && stored.vpn_support_enabled) { + return Err("VPN support on AWS needs the EC2 launch type".into()); + } + } // Q6: forwarded over loopback, TCP only, never a reserved port // (rows the save adds or edits; everything when newly on AWS). crate::host::port_forwards::validate_aws_port_mappings_update( @@ -2896,6 +2908,26 @@ mod tests { assert!(validate_gateway_sidecar_update(&off, &off, &half).is_ok()); } + #[test] + fn docker_and_vpn_on_aws_need_the_ec2_launch_type() { + use crate::models::LaunchType; + let hosts = vec![host("h1")]; + let stored = aws_project(); + for (docker, vpn) in [(true, false), (false, true)] { + let mut p = stored.clone(); + p.allow_docker_access = docker; + p.vpn_support_enabled = vpn; + assert!(validate_aws_update(&stored, &p, &hosts).is_err()); + // A value the AWS project already had is grandfathered. + let mut old = stored.clone(); + old.allow_docker_access = docker; + old.vpn_support_enabled = vpn; + assert!(validate_aws_update(&old, &old, &hosts).is_ok()); + p.aws.as_mut().unwrap().launch_type = LaunchType::Ec2; + assert!(validate_aws_update(&stored, &p, &hosts).is_ok()); + } + } + #[test] fn a_stored_workspace_access_point_blocks_moving_the_host() { let hosts = vec![host("h1"), host("h2")]; diff --git a/app/src-tauri/src/models/project.rs b/app/src-tauri/src/models/project.rs index 7890deb..574035d 100644 --- a/app/src-tauri/src/models/project.rs +++ b/app/src-tauri/src/models/project.rs @@ -521,8 +521,20 @@ fn default_aws_ephemeral_gib() -> u32 { 21 } +/// Where an AWS workspace's task runs. +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum LaunchType { + #[default] + Fargate, + Ec2, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct AwsWorkspaceConfig { + /// Fargate (default; absent in old JSON) or the user's own EC2 instances. + #[serde(default)] + pub launch_type: LaunchType, #[serde(default = "default_aws_cpu")] pub cpu: u32, #[serde(default = "default_aws_memory_mib")] @@ -568,6 +580,7 @@ pub const MAX_SETUP_SCRIPT_BYTES: usize = 32_768; impl Default for AwsWorkspaceConfig { fn default() -> Self { Self { + launch_type: LaunchType::default(), cpu: default_aws_cpu(), memory_mib: default_aws_memory_mib(), arch: Arch::default(), @@ -700,23 +713,101 @@ fn describe_sizes(sizes: &[u32]) -> String { format!("{} to {} MiB in steps of {}", first, last, sizes[1] - sizes[0]) } -pub fn validate_aws_workspace(cfg: &AwsWorkspaceConfig) -> Result<(), String> { - let sizes = fargate_memory_sizes(cfg.cpu).ok_or_else(|| { - format!( - "{} is not a Fargate CPU size (256, 512, 1024, 2048, 4096, 8192 or 16384)", - cfg.cpu - ) - })?; - if !sizes.contains(&cfg.memory_mib) { - return Err(format!( - "{} MiB of memory is not valid with {} CPU units: use {}", - cfg.memory_mib, - cfg.cpu, - describe_sizes(&sizes) - )); +/// CPU units and memory (MiB) held back on an EC2 instance for the ECS agent +/// and the OS. +pub const EC2_RESERVED_CPU_UNITS: u32 = 128; +pub const EC2_RESERVED_MEMORY_MIB: u32 = 256; + +/// `(vcpu * 1024, memory MiB)` of a common EC2 instance type, or None when the +/// type is not in the built-in table (m7i, m7g, c7i, c7g, r7i, r7g, t3, t4g). +pub fn ec2_instance_spec(instance_type: &str) -> Option<(u32, u32)> { + let (family, size) = instance_type.split_once('.')?; + let vcpu: u32 = match size { + "large" => 2, + "xlarge" => 4, + "2xlarge" => 8, + "4xlarge" => 16, + _ => return None, + }; + // GiB per vCPU: general purpose 4, compute 2, memory 8. + let gib_per_vcpu: u32 = match family { + "m7i" | "m7g" => 4, + "c7i" | "c7g" => 2, + "r7i" | "r7g" => 8, + "t3" | "t4g" => { + // Burstable: 2 vCPU with 8 GiB (large), then no 4xlarge exists. + return match size { + "large" => Some((2048, 8192)), + "xlarge" => Some((4096, 16384)), + "2xlarge" => Some((8192, 32768)), + _ => None, + }; + } + _ => return None, + }; + Some((vcpu * 1024, vcpu * gib_per_vcpu * 1024)) +} + +/// Whether an EC2 workspace's reservations fit an instance type. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +#[serde(tag = "kind", rename_all = "snake_case")] +pub enum Fit { + Ok, + /// The reservations exceed what the instance leaves for tasks. + TooBig { available_cpu: u32, available_memory_mib: u32 }, + /// The type is not in the table: the caller shows a "must fit" warning. + UnknownType, +} + +/// Check an EC2 config's reservations against `instance_type`, less the agent +/// and OS reserve. A Fargate config always fits (no instance involved). +pub fn fits_instance(cfg: &AwsWorkspaceConfig, instance_type: &str) -> Fit { + if cfg.launch_type != LaunchType::Ec2 { + return Fit::Ok; } - if !(21..=200).contains(&cfg.ephemeral_gib) { - return Err("Ephemeral storage must be 21 to 200 GiB".into()); + let Some((cpu, mem)) = ec2_instance_spec(instance_type) else { + return Fit::UnknownType; + }; + let available_cpu = cpu - EC2_RESERVED_CPU_UNITS; + let available_memory_mib = mem - EC2_RESERVED_MEMORY_MIB; + if cfg.cpu > available_cpu || cfg.memory_mib > available_memory_mib { + Fit::TooBig { available_cpu, available_memory_mib } + } else { + Fit::Ok + } +} + +pub fn validate_aws_workspace(cfg: &AwsWorkspaceConfig) -> Result<(), String> { + match cfg.launch_type { + LaunchType::Fargate => { + let sizes = fargate_memory_sizes(cfg.cpu).ok_or_else(|| { + format!( + "{} is not a Fargate CPU size (256, 512, 1024, 2048, 4096, 8192 or 16384)", + cfg.cpu + ) + })?; + if !sizes.contains(&cfg.memory_mib) { + return Err(format!( + "{} MiB of memory is not valid with {} CPU units: use {}", + cfg.memory_mib, + cfg.cpu, + describe_sizes(&sizes) + )); + } + if !(21..=200).contains(&cfg.ephemeral_gib) { + return Err("Ephemeral storage must be 21 to 200 GiB".into()); + } + } + LaunchType::Ec2 => { + // Reservations on the user's instance; the instance type is not on + // the project, so `fits_instance` does the fit check later. + if cfg.cpu == 0 || cfg.memory_mib == 0 { + return Err("An EC2 workspace needs a positive CPU and memory reservation".into()); + } + if cfg.spot { + return Err("Spot is not available on EC2 yet".into()); + } + } } if let Some(m) = cfg.idle_stop_minutes { if !(5..=1440).contains(&m) { @@ -1436,6 +1527,63 @@ mod tests { assert!(p.is_aws()); } + fn ec2(cpu: u32, mem: u32) -> AwsWorkspaceConfig { + AwsWorkspaceConfig { launch_type: LaunchType::Ec2, cpu, memory_mib: mem, ..Default::default() } + } + + #[test] + fn old_json_is_fargate_and_ec2_round_trips() { + let c: AwsWorkspaceConfig = serde_json::from_str("{}").unwrap(); + assert_eq!(c.launch_type, LaunchType::Fargate); + let e: AwsWorkspaceConfig = serde_json::from_str(r#"{"launch_type":"ec2"}"#).unwrap(); + assert_eq!(e.launch_type, LaunchType::Ec2); + assert!(serde_json::to_string(&e).unwrap().contains(r#""launch_type":"ec2""#)); + } + + #[test] + fn ec2_validation_shape() { + // Reservations need not be a Fargate pair. + assert!(validate_aws_workspace(&ec2(1500, 3000)).is_ok()); + assert!(validate_aws_workspace(&ec2(0, 3000)).is_err()); + assert!(validate_aws_workspace(&ec2(1024, 0)).is_err()); + let mut s = ec2(1024, 2048); + s.spot = true; + assert!(validate_aws_workspace(&s).unwrap_err().contains("Spot")); + // Ephemeral size is ignored on EC2. + let mut e = ec2(1024, 2048); + e.ephemeral_gib = 5; + assert!(validate_aws_workspace(&e).is_ok()); + // Fargate still rejects the non-pair. + assert!(validate_aws_workspace(&cfg(1500, 3000)).is_err()); + } + + #[test] + fn instance_table_values() { + assert_eq!(ec2_instance_spec("m7i.large"), Some((2048, 8192))); + assert_eq!(ec2_instance_spec("m7g.4xlarge"), Some((16384, 65536))); + assert_eq!(ec2_instance_spec("c7i.xlarge"), Some((4096, 8192))); + assert_eq!(ec2_instance_spec("r7g.2xlarge"), Some((8192, 65536))); + assert_eq!(ec2_instance_spec("t3.large"), Some((2048, 8192))); + assert_eq!(ec2_instance_spec("t4g.2xlarge"), Some((8192, 32768))); + assert_eq!(ec2_instance_spec("t3.4xlarge"), None); + assert_eq!(ec2_instance_spec("p5.48xlarge"), None); + assert_eq!(ec2_instance_spec("m7i"), None); + } + + #[test] + fn fit_checks_reserve_for_the_agent() { + // m7i.large: 2048 / 8192 less 128 / 256. + assert_eq!(fits_instance(&ec2(1920, 7936), "m7i.large"), Fit::Ok); + assert_eq!( + fits_instance(&ec2(1921, 4096), "m7i.large"), + Fit::TooBig { available_cpu: 1920, available_memory_mib: 7936 } + ); + assert!(matches!(fits_instance(&ec2(1024, 7937), "m7i.large"), Fit::TooBig { .. })); + assert_eq!(fits_instance(&ec2(1024, 2048), "z9.huge"), Fit::UnknownType); + // Fargate configs have no instance to fit. + assert_eq!(fits_instance(&cfg(16384, 122880), "m7i.large"), Fit::Ok); + } + #[test] fn cpu_and_memory_must_be_a_fargate_pair() { // Shared with the frontend's copy (`lib/awsWorkspace.test.ts`). diff --git a/app/src/components/projects/home/config/RuntimeSection.test.tsx b/app/src/components/projects/home/config/RuntimeSection.test.tsx index e8e1ea7..700b3cd 100644 --- a/app/src/components/projects/home/config/RuntimeSection.test.tsx +++ b/app/src/components/projects/home/config/RuntimeSection.test.tsx @@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest"; import { render, screen, fireEvent, waitFor } from "@testing-library/react"; import RuntimeSection from "./RuntimeSection"; import type { AuthBridgeStatus, Project } from "../../../../lib/types"; +import { awsProject } from "../../../../test/awsFixtures"; // The auth-bridge row owns its own IPC — see `AuthBridgeRow.tsx` for why it // does not go through `save`. @@ -181,3 +182,18 @@ describe("RuntimeSection — auth bridge toggle", () => { expect(save).not.toHaveBeenCalled(); }); }); + +describe("RuntimeSection — Docker and VPN on AWS follow the launch type", () => { + beforeEach(() => vi.clearAllMocks()); + + it("are off and disabled on Fargate, switchable on EC2", () => { + const fargate = awsProject(); + const { unmount } = renderSection(fargate); + expect(screen.getByRole("switch", { name: VPN })).toBeDisabled(); + expect(screen.getByRole("switch", { name: "Allow container spawning" })).toBeDisabled(); + unmount(); + renderSection({ ...fargate, aws: { ...fargate.aws!, launch_type: "ec2" } }); + expect(screen.getByRole("switch", { name: VPN })).toBeEnabled(); + expect(screen.getByRole("switch", { name: "Allow container spawning" })).toBeEnabled(); + }); +}); diff --git a/app/src/components/projects/home/config/RuntimeSection.tsx b/app/src/components/projects/home/config/RuntimeSection.tsx index 099564b..ed31bf3 100644 --- a/app/src/components/projects/home/config/RuntimeSection.tsx +++ b/app/src/components/projects/home/config/RuntimeSection.tsx @@ -21,6 +21,8 @@ export default function RuntimeSection({ disabledReason, }: Props) { const aws = isAwsProject(project); + // Docker access and VPN need the user's own EC2 instance (not Fargate). + const noPrivileged = aws && project.aws?.launch_type !== "ec2"; return ( <> save({ allow_docker_access: v })} /> } @@ -70,12 +72,12 @@ export default function RuntimeSection({ save({ vpn_support_enabled: v })} /> } diff --git a/app/src/lib/awsWorkspace.ts b/app/src/lib/awsWorkspace.ts index ae18393..16e122f 100644 --- a/app/src/lib/awsWorkspace.ts +++ b/app/src/lib/awsWorkspace.ts @@ -77,6 +77,7 @@ export function formatMemory(mib: number): string { /** Mirrors Rust `AwsWorkspaceConfig::default()`. */ export function defaultAwsWorkspace(): AwsWorkspaceConfig { return { + launch_type: "fargate", cpu: 1024, memory_mib: 4096, arch: "x86_64", diff --git a/app/src/lib/types.ts b/app/src/lib/types.ts index 299c747..091a454 100644 --- a/app/src/lib/types.ts +++ b/app/src/lib/types.ts @@ -92,7 +92,11 @@ export interface RepoSource { folder: string; } +export type LaunchType = "fargate" | "ec2"; + export interface AwsWorkspaceConfig { + /** Absent in old data = fargate. */ + launch_type: LaunchType; cpu: number; memory_mib: number; arch: Arch; -- 2.52.0 From c6b46a7347f65bb17e0bc984bf7baba8b21cd057 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 12:56:18 -0800 Subject: [PATCH 03/29] fix(aws): refuse Docker/VPN on Fargate without grandfathering; launchTypePatch Co-Authored-By: Claude Opus 5.5 --- .../src/commands/project_commands.rs | 35 +++++++++++-------- app/src-tauri/src/models/project.rs | 8 ++++- .../home/config/RuntimeSection.test.tsx | 20 +++++++++++ app/src/lib/awsWorkspace.ts | 13 +++++++ 4 files changed, 60 insertions(+), 16 deletions(-) diff --git a/app/src-tauri/src/commands/project_commands.rs b/app/src-tauri/src/commands/project_commands.rs index 047d259..01236a5 100644 --- a/app/src-tauri/src/commands/project_commands.rs +++ b/app/src-tauri/src/commands/project_commands.rs @@ -1248,16 +1248,13 @@ fn validate_aws_update( crate::models::validate_region(&place.region)?; crate::aws::tofu_modules::validate_environment_name(&place.environment)?; crate::models::validate_aws_workspace(cfg)?; - // Docker access and VPN need the user's own instance (E6, E7); - // Fargate refuses them. Grandfather a value the stored project - // already had on AWS so an old row can still be saved. + // Docker access and VPN need the user's own instance (E6, E7). if cfg.launch_type != crate::models::LaunchType::Ec2 { - let was_aws = stored.aws.is_some(); - if project.allow_docker_access && !(was_aws && stored.allow_docker_access) { - return Err("Docker access on AWS needs the EC2 launch type".into()); + if project.allow_docker_access { + return Err("Docker access on AWS needs the EC2 launch type; turn it off first".into()); } - if project.vpn_support_enabled && !(was_aws && stored.vpn_support_enabled) { - return Err("VPN support on AWS needs the EC2 launch type".into()); + if project.vpn_support_enabled { + return Err("VPN support on AWS needs the EC2 launch type; turn it off first".into()); } } // Q6: forwarded over loopback, TCP only, never a reserved port @@ -2918,13 +2915,21 @@ mod tests { p.allow_docker_access = docker; p.vpn_support_enabled = vpn; assert!(validate_aws_update(&stored, &p, &hosts).is_err()); - // A value the AWS project already had is grandfathered. - let mut old = stored.clone(); - old.allow_docker_access = docker; - old.vpn_support_enabled = vpn; - assert!(validate_aws_update(&old, &old, &hosts).is_ok()); - p.aws.as_mut().unwrap().launch_type = LaunchType::Ec2; - assert!(validate_aws_update(&stored, &p, &hosts).is_ok()); + // Already stored that way on Fargate: still refused (no grandfathering). + assert!(validate_aws_update(&p, &p, &hosts).is_err()); + // Ec2 -> Fargate with the flags still on: refused. + let mut ec2 = p.clone(); + ec2.aws.as_mut().unwrap().launch_type = LaunchType::Ec2; + assert!(validate_aws_update(&ec2, &ec2, &hosts).is_ok()); + assert!(validate_aws_update(&ec2, &p, &hosts).is_err()); + // Local -> AWS(Fargate) with the flags on: refused. + let mut local = stored.clone(); + local.host_id = None; + local.aws_placement = None; + local.aws = None; + local.allow_docker_access = docker; + local.vpn_support_enabled = vpn; + assert!(validate_aws_update(&local, &p, &hosts).is_err()); } } diff --git a/app/src-tauri/src/models/project.rs b/app/src-tauri/src/models/project.rs index 574035d..4af52e8 100644 --- a/app/src-tauri/src/models/project.rs +++ b/app/src-tauri/src/models/project.rs @@ -735,7 +735,8 @@ pub fn ec2_instance_spec(instance_type: &str) -> Option<(u32, u32)> { "c7i" | "c7g" => 2, "r7i" | "r7g" => 8, "t3" | "t4g" => { - // Burstable: 2 vCPU with 8 GiB (large), then no 4xlarge exists. + // Burstable families: memory is 4 GiB per vCPU at xlarge and above, + // 8 GiB at large; AWS offers no 4xlarge in these families. return match size { "large" => Some((2048, 8192)), "xlarge" => Some((4096, 16384)), @@ -761,6 +762,11 @@ pub enum Fit { /// Check an EC2 config's reservations against `instance_type`, less the agent /// and OS reserve. A Fargate config always fits (no instance involved). +/// +/// Nominal sizes only: ECS registers less memory than the instance's nominal +/// (the ECS-optimized AMI reserves some, e.g. ~7.5 GiB on an 8 GiB type), so a +/// later task should leave headroom or use the container instance's +/// registered memory. pub fn fits_instance(cfg: &AwsWorkspaceConfig, instance_type: &str) -> Fit { if cfg.launch_type != LaunchType::Ec2 { return Fit::Ok; diff --git a/app/src/components/projects/home/config/RuntimeSection.test.tsx b/app/src/components/projects/home/config/RuntimeSection.test.tsx index 700b3cd..f44d26d 100644 --- a/app/src/components/projects/home/config/RuntimeSection.test.tsx +++ b/app/src/components/projects/home/config/RuntimeSection.test.tsx @@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest"; import { render, screen, fireEvent, waitFor } from "@testing-library/react"; import RuntimeSection from "./RuntimeSection"; import type { AuthBridgeStatus, Project } from "../../../../lib/types"; +import { launchTypePatch } from "../../../../lib/awsWorkspace"; import { awsProject } from "../../../../test/awsFixtures"; // The auth-bridge row owns its own IPC — see `AuthBridgeRow.tsx` for why it @@ -196,4 +197,23 @@ describe("RuntimeSection — Docker and VPN on AWS follow the launch type", () = expect(screen.getByRole("switch", { name: VPN })).toBeEnabled(); expect(screen.getByRole("switch", { name: "Allow container spawning" })).toBeEnabled(); }); + + it("saves the flags when toggled on EC2", () => { + const p = awsProject({ vpn_support_enabled: false, allow_docker_access: false }); + renderSection({ ...p, aws: { ...p.aws!, launch_type: "ec2" } }); + fireEvent.click(screen.getByRole("switch", { name: VPN })); + expect(save).toHaveBeenCalledWith({ vpn_support_enabled: true }); + fireEvent.click(screen.getByRole("switch", { name: "Allow container spawning" })); + expect(save).toHaveBeenCalledWith({ allow_docker_access: true }); + }); + + it("launchTypePatch clears Docker and VPN when switching to Fargate", () => { + const p = awsProject({ allow_docker_access: true, vpn_support_enabled: true }); + const toFargate = launchTypePatch(p, "fargate"); + expect(toFargate).toMatchObject({ allow_docker_access: false, vpn_support_enabled: false }); + expect(toFargate.aws?.launch_type).toBe("fargate"); + const toEc2 = launchTypePatch(p, "ec2"); + expect(toEc2.allow_docker_access).toBeUndefined(); + expect(toEc2.aws?.launch_type).toBe("ec2"); + }); }); diff --git a/app/src/lib/awsWorkspace.ts b/app/src/lib/awsWorkspace.ts index 16e122f..c07c528 100644 --- a/app/src/lib/awsWorkspace.ts +++ b/app/src/lib/awsWorkspace.ts @@ -2,6 +2,7 @@ import type { AwsWorkspaceConfig, DetectedEnvironment, GatewaySettings, + LaunchType, Project, RepoSource, UnsavedWork, @@ -238,3 +239,15 @@ export function localEndpointProblem(url: string, gatewayPort: number | null): s } return null; } + +/** The save patch for switching an AWS project's launch type. Docker access and + * VPN need EC2 (Rust refuses them on Fargate), so switching to Fargate turns + * them off in the same save. Task 6's launch-type control must use this. */ +export function launchTypePatch(project: Project, launch_type: LaunchType): Partial { + const patch: Partial = { aws: { ...project.aws!, launch_type } }; + if (launch_type !== "ec2") { + patch.allow_docker_access = false; + patch.vpn_support_enabled = false; + } + return patch; +} -- 2.52.0 From 7393143762594420b6d9640efacaab4441880238 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 13:07:37 -0800 Subject: [PATCH 04/29] feat(aws): admin and boundary permissions for per-user EC2 capacity Phase 7 Task 2 (E4, E5, E11): - New third admin file environment-admin-compute.json (3,705 chars): capacity providers (triple-c-*), component-tagged launch templates, triple-c-* Auto Scaling groups (request tag to create, resource tag to change/protect/delete), RunInstances only from a tagged launch template with Amazon images, tags only at create, instance profiles (triple-c-*), PassRole of triple-c-*-instance roles to ec2.amazonaws.com only, service-linked roles for Auto Scaling and ECS only, the public ECS-optimized AMI parameter, autoscaling/capacity-provider reads. - Boundary v2 (2,625 chars): the ECS agent's calls on triple-c-* clusters and container instances, TagResource only at RegisterContainerInstance, DiscoverPollEndpoint and Session Manager core. BOUNDARY_MODULE_VERSION=2 with a template_version local and default tag, pinned by a test. - Checks for every new action; tests for tag/name scoping, launch-only- through-templates, PassRole to EC2 only for instance roles, the workspace tier changing no compute, the boundary's agent fence. - EC2_COMPUTE_CALLS in tofu_modules/tests.rs: the onboarding module's expected calls, evaluated against the admin tier and in the write drift test until Task 3 moves them into MODULE_CALLS. - README: third file, sizes, boundary re-apply, resource table rows, scoping notes and "still open" points for the live run. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/policies.rs | 582 +++++++++++++++++++- app/src-tauri/src/aws/tofu_modules.rs | 5 + app/src-tauri/src/aws/tofu_modules/tests.rs | 253 ++++++++- app/src-tauri/src/commands/host_commands.rs | 9 +- aws/README.md | 105 +++- aws/policies/environment-admin-compute.json | 222 ++++++++ aws/policies/permissions-boundary.json | 48 ++ aws/terraform/permissions-boundary/main.tf | 9 +- 8 files changed, 1204 insertions(+), 29 deletions(-) create mode 100644 aws/policies/environment-admin-compute.json diff --git a/app/src-tauri/src/aws/policies.rs b/app/src-tauri/src/aws/policies.rs index 259be0a..37465e7 100644 --- a/app/src-tauri/src/aws/policies.rs +++ b/app/src-tauri/src/aws/policies.rs @@ -34,6 +34,10 @@ pub fn policy_files(tier: Tier) -> &'static [(&'static str, &'static str)] { "environment-admin-network.json", include_str!("../../../../aws/policies/environment-admin-network.json"), ), + ( + "environment-admin-compute.json", + include_str!("../../../../aws/policies/environment-admin-compute.json"), + ), ], Tier::WorkspaceUser => &[ ( @@ -208,6 +212,45 @@ const PROBE_STATE_BUCKET: &str = "arn:aws:s3:::triple-c-tfstate-{account}-{regio const PROBE_STATE_OBJECT: &str = "arn:aws:s3:::triple-c-tfstate-{account}-{region}/environments/probe/terraform.tfstate"; const PROBE_BOUNDARY: &str = "arn:aws:iam::{account}:policy/triple-c-permissions-boundary"; +// Per-user EC2 capacity (phase 7, `environment-admin-compute.json`). +const PROBE_CAPACITY_PROVIDER: &str = + "arn:aws:ecs:{region}:{account}:capacity-provider/triple-c-probe"; +const PROBE_LAUNCH_TEMPLATE: &str = + "arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"; +const PROBE_INSTANCE: &str = "arn:aws:ec2:{region}:{account}:instance/i-00000000000000000"; +const PROBE_VOLUME: &str = "arn:aws:ec2:{region}:{account}:volume/vol-00000000000000000"; +/// Public images have no account in their ARN. +const PROBE_IMAGE: &str = "arn:aws:ec2:{region}::image/ami-00000000000000000"; +const PROBE_AUTO_SCALING_GROUP: &str = "arn:aws:autoscaling:{region}:{account}:autoScalingGroup:\ + 00000000-0000-0000-0000-000000000000:autoScalingGroupName/triple-c-probe"; +const PROBE_INSTANCE_PROFILE: &str = "arn:aws:iam::{account}:instance-profile/triple-c-probe"; +/// An instance role is `triple-c---instance`. +const PROBE_INSTANCE_ROLE: &str = "arn:aws:iam::{account}:role/triple-c-probe-instance"; +const PROBE_AUTO_SCALING_SERVICE_ROLE: &str = "arn:aws:iam::{account}:role/aws-service-role/\ + autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"; +const PROBE_ECS_SERVICE_ROLE: &str = + "arn:aws:iam::{account}:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS"; +/// The public parameter the onboarding module resolves the ECS-optimized +/// AMI from (no account in its ARN). +const PROBE_AMI_PARAMETER: &str = "arn:aws:ssm:{region}::parameter/aws/service/ecs/\ + optimized-ami/amazon-linux-2023/recommended/image_id"; +/// A user's compute record (`/triple-c/users//`, E11). +const PROBE_USER_RECORD: &str = + "arn:aws:ssm:{region}:{account}:parameter/triple-c/users/probe/0123456789ab"; +/// RunInstances names the launch template the instance comes from. +const FROM_LAUNCH_TEMPLATE: Context = &[( + "ec2:LaunchTemplate", + Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"), +)]; +/// ...and the image is Amazon's. +const AMAZON_IMAGE_FROM_LAUNCH_TEMPLATE: Context = &[ + ("ec2:Owner", Literal("amazon")), + ( + "ec2:LaunchTemplate", + Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"), + ), +]; +const PASSED_TO_EC2: Context = &[("iam:PassedToService", Literal("ec2.amazonaws.com"))]; const fn write(action: &'static str, resource: &'static str, context: Context) -> Check { Check { @@ -784,6 +827,173 @@ const ENVIRONMENT_ADMIN_CHECKS: &[Check] = &[ read("s3:GetObject", PROBE_STATE_OBJECT, IN_MY_ACCOUNT), write("s3:PutObject", PROBE_STATE_OBJECT, IN_MY_ACCOUNT), write("s3:DeleteObject", PROBE_STATE_OBJECT, IN_MY_ACCOUNT), + // Per-user EC2 capacity (environment-admin-compute.json, phase 7): the + // user's cluster is a `triple-c-*` cluster (above); its capacity + // provider is scoped by name, like the cluster. + write( + "ecs:CreateCapacityProvider", + PROBE_CAPACITY_PROVIDER, + COMPONENT_REQUESTED, + ), + write( + "ecs:TagResource", + PROBE_CAPACITY_PROVIDER, + &[("ecs:CreateAction", Literal("CreateCapacityProvider"))], + ), + write("ecs:UpdateCapacityProvider", PROBE_CAPACITY_PROVIDER, &[]), + write("ecs:DeleteCapacityProvider", PROBE_CAPACITY_PROVIDER, &[]), + write( + "ecs:PutClusterCapacityProviders", + PROBE_CAPACITY_PROVIDER, + &[], + ), + write("ecs:UntagResource", PROBE_CAPACITY_PROVIDER, &[]), + read("ecs:ListTagsForResource", PROBE_CAPACITY_PROVIDER, &[]), + read("ecs:DescribeCapacityProviders", "*", &[]), + // Launch templates: created with the component tag, changed, used and + // deleted only when they carry it. + write( + "ec2:CreateLaunchTemplate", + PROBE_LAUNCH_TEMPLATE, + COMPONENT_REQUESTED, + ), + write( + "ec2:CreateTags", + PROBE_LAUNCH_TEMPLATE, + &[("ec2:CreateAction", Literal("CreateLaunchTemplate"))], + ), + write( + "ec2:CreateLaunchTemplateVersion", + PROBE_LAUNCH_TEMPLATE, + COMPONENT_TAGGED, + ), + write( + "ec2:ModifyLaunchTemplate", + PROBE_LAUNCH_TEMPLATE, + COMPONENT_TAGGED, + ), + write( + "ec2:DeleteLaunchTemplate", + PROBE_LAUNCH_TEMPLATE, + COMPONENT_TAGGED, + ), + write("ec2:CreateTags", PROBE_LAUNCH_TEMPLATE, COMPONENT_TAGGED), + write("ec2:DeleteTags", PROBE_LAUNCH_TEMPLATE, COMPONENT_TAGGED), + // Creating an Auto Scaling group checks that the caller could launch + // its template: RunInstances, only from a Triple-C launch template and + // only Amazon's images, and the tags the launch puts on. + write("ec2:RunInstances", PROBE_LAUNCH_TEMPLATE, COMPONENT_TAGGED), + write("ec2:RunInstances", PROBE_INSTANCE, FROM_LAUNCH_TEMPLATE), + write("ec2:RunInstances", PROBE_VOLUME, FROM_LAUNCH_TEMPLATE), + write( + "ec2:RunInstances", + PROBE_NETWORK_INTERFACE, + FROM_LAUNCH_TEMPLATE, + ), + write("ec2:RunInstances", PROBE_SUBNET, FROM_LAUNCH_TEMPLATE), + write( + "ec2:RunInstances", + PROBE_SECURITY_GROUP, + FROM_LAUNCH_TEMPLATE, + ), + write( + "ec2:RunInstances", + PROBE_IMAGE, + AMAZON_IMAGE_FROM_LAUNCH_TEMPLATE, + ), + write( + "ec2:CreateTags", + PROBE_INSTANCE, + &[("ec2:CreateAction", Literal("RunInstances"))], + ), + write( + "ec2:CreateTags", + PROBE_VOLUME, + &[("ec2:CreateAction", Literal("RunInstances"))], + ), + write( + "ec2:CreateTags", + PROBE_NETWORK_INTERFACE, + &[("ec2:CreateAction", Literal("RunInstances"))], + ), + // Auto Scaling groups: `triple-c-*`, created with the component tag, + // changed and deleted only when they carry it. + write( + "autoscaling:CreateAutoScalingGroup", + PROBE_AUTO_SCALING_GROUP, + COMPONENT_REQUESTED, + ), + write( + "autoscaling:CreateOrUpdateTags", + PROBE_AUTO_SCALING_GROUP, + COMPONENT_REQUESTED, + ), + write( + "autoscaling:CreateOrUpdateTags", + PROBE_AUTO_SCALING_GROUP, + COMPONENT_TAGGED, + ), + write( + "autoscaling:UpdateAutoScalingGroup", + PROBE_AUTO_SCALING_GROUP, + COMPONENT_TAGGED, + ), + write( + "autoscaling:SetInstanceProtection", + PROBE_AUTO_SCALING_GROUP, + COMPONENT_TAGGED, + ), + write( + "autoscaling:DeleteTags", + PROBE_AUTO_SCALING_GROUP, + COMPONENT_TAGGED, + ), + write( + "autoscaling:DeleteAutoScalingGroup", + PROBE_AUTO_SCALING_GROUP, + COMPONENT_TAGGED, + ), + read("autoscaling:DescribeAutoScalingGroups", "*", &[]), + read("autoscaling:DescribeScalingActivities", "*", &[]), + // The service-linked roles Auto Scaling and ECS (managed scaling) use, + // created on first use; AWS fixes their policies. + write( + "iam:CreateServiceLinkedRole", + PROBE_AUTO_SCALING_SERVICE_ROLE, + &[("iam:AWSServiceName", Literal("autoscaling.amazonaws.com"))], + ), + write( + "iam:CreateServiceLinkedRole", + PROBE_ECS_SERVICE_ROLE, + &[("iam:AWSServiceName", Literal("ecs.amazonaws.com"))], + ), + // The instance role (a bounded `triple-c-*` role, above) and its + // instance profile, scoped by name. + write("iam:CreateInstanceProfile", PROBE_INSTANCE_PROFILE, &[]), + write("iam:TagInstanceProfile", PROBE_INSTANCE_PROFILE, &[]), + write("iam:UntagInstanceProfile", PROBE_INSTANCE_PROFILE, &[]), + write("iam:AddRoleToInstanceProfile", PROBE_INSTANCE_PROFILE, &[]), + write( + "iam:RemoveRoleFromInstanceProfile", + PROBE_INSTANCE_PROFILE, + &[], + ), + write("iam:DeleteInstanceProfile", PROBE_INSTANCE_PROFILE, &[]), + read("iam:GetInstanceProfile", PROBE_INSTANCE_PROFILE, &[]), + read("iam:ListInstanceProfileTags", PROBE_INSTANCE_PROFILE, &[]), + write("iam:PassRole", PROBE_INSTANCE_ROLE, PASSED_TO_EC2), + // The ECS-optimized AMI's public parameter, and the user's compute + // record (`/triple-c/*`, above). + read("ssm:GetParameter", PROBE_AMI_PARAMETER, &[]), + read("ssm:GetParameters", PROBE_AMI_PARAMETER, &[]), + write("ssm:PutParameter", PROBE_USER_RECORD, COMPONENT_REQUESTED), + write( + "ssm:AddTagsToResource", + PROBE_USER_RECORD, + COMPONENT_REQUESTED, + ), + write("ssm:DeleteParameter", PROBE_USER_RECORD, &[]), + read("ssm:GetParameter", PROBE_USER_RECORD, &[]), ]; #[cfg(test)] @@ -1691,6 +1901,20 @@ mod tests { "sts:GetCallerIdentity", "bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream", + // The ECS agent on a user's instance (E4). + "ecs:RegisterContainerInstance", + "ecs:DeregisterContainerInstance", + "ecs:DiscoverPollEndpoint", + "ecs:Poll", + "ecs:StartTelemetrySession", + "ecs:SubmitTaskStateChange", + "ecs:SubmitContainerStateChange", + "ecs:SubmitAttachmentStateChanges", + "ecs:UpdateContainerInstancesState", + "ecs:TagResource", + // Session Manager on the instance. + "ssm:UpdateInstanceInformation", + "ec2messages:GetMessages", ] { assert!( granted.iter().any(|a| glob(a, need)), @@ -1741,6 +1965,69 @@ mod tests { } } + /// The instance role's ECS agent (E4) reaches only Triple-C clusters and + /// their container instances, and tags only the instance it registers. + #[test] + fn the_boundary_keeps_the_ecs_agent_on_triple_c_clusters() { + let stmts = statements_of(&boundary()); + let within = |action: &'static str, resource: &'static str, context: Context| { + evaluate_in( + &stmts, + Request { + check: &write(action, resource, context), + caller: ME, + owner: ME, + }, + ) + }; + const INSTANCE: &str = "arn:aws:ecs:{region}:{account}:container-instance/\ + triple-c-probe-0123456789ab/0123456789abcdef0123456789abcdef"; + const OTHER_CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/prod"; + const OTHER_INSTANCE: &str = "arn:aws:ecs:{region}:{account}:container-instance/\ + prod/0123456789abcdef0123456789abcdef"; + const AT_REGISTER: Context = &[("ecs:CreateAction", Literal("RegisterContainerInstance"))]; + for action in [ + "ecs:RegisterContainerInstance", + "ecs:DeregisterContainerInstance", + "ecs:SubmitTaskStateChange", + ] { + assert!(within(action, PROBE_CLUSTER, &[]), "{action}"); + assert!(!within(action, OTHER_CLUSTER, &[]), "{action} elsewhere"); + } + for action in [ + "ecs:Poll", + "ecs:StartTelemetrySession", + "ecs:UpdateContainerInstancesState", + ] { + assert!(within(action, INSTANCE, &[]), "{action}"); + assert!(!within(action, OTHER_INSTANCE, &[]), "{action} elsewhere"); + } + assert!(within("ecs:TagResource", INSTANCE, AT_REGISTER)); + assert!(!within("ecs:TagResource", OTHER_INSTANCE, AT_REGISTER)); + for (resource, context) in [ + (INSTANCE, &[][..]), + (PROBE_CLUSTER, AT_REGISTER), + (PROBE_TASK, &[][..]), + ] { + assert!( + !within("ecs:TagResource", resource, context), + "ecs:TagResource on {resource} with {context:?}" + ); + } + // The agent never runs, stops or changes tasks or clusters itself. + for action in [ + "ecs:RunTask", + "ecs:StartTask", + "ecs:StopTask", + "ecs:CreateCluster", + "ecs:DeleteCluster", + "ecs:ExecuteCommand", + ] { + assert!(!within(action, PROBE_CLUSTER, &[]), "{action}"); + assert!(!within(action, PROBE_TASK, &[]), "{action}"); + } + } + #[test] fn writes_are_marked_and_reads_are_not() { const READ_PREFIXES: &[&str] = &["Describe", "List", "Get", "Filter", "Simulate"]; @@ -1855,7 +2142,11 @@ mod tests { let names = |t: Tier| policy_files(t).iter().map(|(n, _)| *n).collect::>(); assert_eq!( names(Tier::EnvironmentAdmin), - ["environment-admin.json", "environment-admin-network.json"] + [ + "environment-admin.json", + "environment-admin-network.json", + "environment-admin-compute.json" + ] ); assert_eq!( names(Tier::WorkspaceUser), @@ -2123,16 +2414,299 @@ mod tests { ME, ME )); - // Triple-C roles are passed only to ECS tasks (Fargate, v1). - let pass_to_ec2: Context = &[("iam:PassedToService", Literal("ec2.amazonaws.com"))]; + // Only an instance role is passed to EC2 (phase 7); task and + // execution roles go to ECS tasks only. assert!(!allowed( tier, - &write("iam:PassRole", PROBE_ROLE, pass_to_ec2), + &write("iam:PassRole", PROBE_ROLE, PASSED_TO_EC2), ME, ME )); } + /// The new compute checks of the admin tier. + fn compute_checks() -> Vec<&'static Check> { + let compute = parse( + "environment-admin-compute.json", + policy_files(Tier::EnvironmentAdmin) + .iter() + .find(|(n, _)| *n == "environment-admin-compute.json") + .expect("the compute file") + .1, + ); + let stmts = statements_of(&compute); + let found: Vec<_> = checks(Tier::EnvironmentAdmin) + .iter() + .filter(|c| { + let req = Request { + check: c, + caller: ME, + owner: ME, + }; + !matching(&stmts, &req).is_empty() + }) + .collect(); + assert!(found.len() >= 30, "only {} compute checks", found.len()); + found + } + + /// Per-user EC2 capacity (E5): what the admin creates carries the + /// component tag, and what it changes, uses or deletes must carry it; + /// another (untagged, or not `triple-c-*`) launch template, Auto Scaling + /// group, capacity provider or instance profile is out of reach. + #[test] + fn per_user_compute_is_tag_and_name_scoped() { + let tier = Tier::EnvironmentAdmin; + for (action, resource) in [ + ("ec2:CreateLaunchTemplate", PROBE_LAUNCH_TEMPLATE), + ( + "autoscaling:CreateAutoScalingGroup", + PROBE_AUTO_SCALING_GROUP, + ), + ] { + assert!(allowed( + tier, + &write(action, resource, COMPONENT_REQUESTED), + ME, + ME + )); + assert!( + !allowed(tier, &write(action, resource, &[]), ME, ME), + "untagged {action}" + ); + } + for (action, resource) in [ + ("ec2:CreateLaunchTemplateVersion", PROBE_LAUNCH_TEMPLATE), + ("ec2:ModifyLaunchTemplate", PROBE_LAUNCH_TEMPLATE), + ("ec2:DeleteLaunchTemplate", PROBE_LAUNCH_TEMPLATE), + ("ec2:CreateTags", PROBE_LAUNCH_TEMPLATE), + ("ec2:DeleteTags", PROBE_LAUNCH_TEMPLATE), + ("ec2:RunInstances", PROBE_LAUNCH_TEMPLATE), + ( + "autoscaling:UpdateAutoScalingGroup", + PROBE_AUTO_SCALING_GROUP, + ), + ( + "autoscaling:SetInstanceProtection", + PROBE_AUTO_SCALING_GROUP, + ), + ("autoscaling:CreateOrUpdateTags", PROBE_AUTO_SCALING_GROUP), + ("autoscaling:DeleteTags", PROBE_AUTO_SCALING_GROUP), + ( + "autoscaling:DeleteAutoScalingGroup", + PROBE_AUTO_SCALING_GROUP, + ), + ] { + assert!( + allowed(tier, &write(action, resource, COMPONENT_TAGGED), ME, ME), + "{action} on a tagged {resource}" + ); + assert!( + !allowed(tier, &write(action, resource, &[]), ME, ME), + "{action} on an untagged {resource}" + ); + } + // Named resources: someone else's names are out of reach, tagged or not. + let others = [ + ( + "autoscaling:DeleteAutoScalingGroup", + "arn:aws:autoscaling:{region}:{account}:autoScalingGroup:\ + 00000000-0000-0000-0000-000000000000:autoScalingGroupName/prod-web", + ), + ( + "ecs:DeleteCapacityProvider", + "arn:aws:ecs:{region}:{account}:capacity-provider/prod-web", + ), + ( + "ecs:UpdateCapacityProvider", + "arn:aws:ecs:{region}:{account}:capacity-provider/prod-web", + ), + ( + "ecs:PutClusterCapacityProviders", + "arn:aws:ecs:{region}:{account}:cluster/prod", + ), + ( + "iam:DeleteInstanceProfile", + "arn:aws:iam::{account}:instance-profile/prod-web", + ), + ( + "iam:AddRoleToInstanceProfile", + "arn:aws:iam::{account}:instance-profile/prod-web", + ), + ( + "iam:RemoveRoleFromInstanceProfile", + "arn:aws:iam::{account}:instance-profile/prod-web", + ), + ]; + for (action, resource) in others { + for context in [&[][..], COMPONENT_TAGGED] { + assert!( + !allowed(tier, &write(action, resource, context), ME, ME), + "{action} on {resource}" + ); + } + } + // Tags go on at create only through the creating call. + for resource in [PROBE_LAUNCH_TEMPLATE, PROBE_INSTANCE, PROBE_VOLUME] { + let other: Context = &[("ec2:CreateAction", Literal("CreateVolume"))]; + assert!( + !allowed(tier, &write("ec2:CreateTags", resource, other), ME, ME), + "CreateTags on {resource} through CreateVolume" + ); + } + // The user's record lives under /triple-c/; nothing else's does. + assert!(!allowed( + tier, + &write( + "ssm:DeleteParameter", + "arn:aws:ssm:{region}:{account}:parameter/prod/users/x", + &[] + ), + ME, + ME + )); + } + + /// RunInstances (which creating an Auto Scaling group checks the caller + /// for) works only from a Triple-C launch template, with Amazon's + /// images: never a bare launch, nor someone else's template or image. + #[test] + fn instances_launch_only_from_triple_c_launch_templates() { + let tier = Tier::EnvironmentAdmin; + for resource in [ + PROBE_INSTANCE, + PROBE_VOLUME, + PROBE_NETWORK_INTERFACE, + PROBE_SUBNET, + PROBE_SECURITY_GROUP, + ] { + assert!(allowed( + tier, + &write("ec2:RunInstances", resource, FROM_LAUNCH_TEMPLATE), + ME, + ME + )); + for context in [&[][..], COMPONENT_REQUESTED, COMPONENT_TAGGED] { + assert!( + !allowed(tier, &write("ec2:RunInstances", resource, context), ME, ME), + "RunInstances on {resource} without a launch template ({context:?})" + ); + } + } + assert!(!allowed( + tier, + &write("ec2:RunInstances", PROBE_LAUNCH_TEMPLATE, &[]), + ME, + ME + )); + let someone_elses_image: Context = &[ + ("ec2:Owner", Literal("999999999999")), + ( + "ec2:LaunchTemplate", + Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"), + ), + ]; + for context in [&[][..], FROM_LAUNCH_TEMPLATE, someone_elses_image] { + assert!( + !allowed( + tier, + &write("ec2:RunInstances", PROBE_IMAGE, context), + ME, + ME + ), + "RunInstances with an image and {context:?}" + ); + } + // Other resource types a launch could name (a key pair, an + // instance-store snapshot, ...) are not granted at all. + for resource in [ + "arn:aws:ec2:{region}:{account}:key-pair/k", + "arn:aws:ec2:{region}::snapshot/snap-00000000000000000", + ] { + assert!(!allowed( + tier, + &write("ec2:RunInstances", resource, FROM_LAUNCH_TEMPLATE), + ME, + ME + )); + } + } + + /// Roles go to EC2 only as an instance role (`triple-c-*-instance`), + /// and never anything else's; service-linked roles only for Auto + /// Scaling and ECS. + #[test] + fn instance_roles_are_the_only_roles_passed_to_ec2() { + let tier = Tier::EnvironmentAdmin; + assert!(allowed( + tier, + &write("iam:PassRole", PROBE_INSTANCE_ROLE, PASSED_TO_EC2), + ME, + ME + )); + for role in [ + PROBE_ROLE, + "arn:aws:iam::{account}:role/triple-c-probe-0123456789ab-task", + "arn:aws:iam::{account}:role/admin-instance", + "arn:aws:iam::{account}:role/OrganizationAccountAccessRole", + ] { + assert!( + !allowed(tier, &write("iam:PassRole", role, PASSED_TO_EC2), ME, ME), + "{role} passed to EC2" + ); + } + for service in ["lambda.amazonaws.com", "ecs-tasks.amazonaws.com"] { + let ctx: Context = + Box::leak(vec![("iam:PassedToService", Literal(service))].into_boxed_slice()); + let instance_to_other = write("iam:PassRole", PROBE_INSTANCE_ROLE, ctx); + // An instance role is still a `triple-c-*` role, which the + // phase-5 statement lets the admin pass to ECS tasks; nothing + // else. + assert_eq!( + allowed(tier, &instance_to_other, ME, ME), + service == "ecs-tasks.amazonaws.com", + "{service}" + ); + } + // (A service's role ARN follows from its name, so one statement + // covers both services.) + for (role, service) in [ + ( + "arn:aws:iam::{account}:role/aws-service-role/\ + elasticbeanstalk.amazonaws.com/AWSServiceRoleForElasticBeanstalk", + "elasticbeanstalk.amazonaws.com", + ), + (PROBE_ROLE, "autoscaling.amazonaws.com"), + ] { + let ctx: Context = + Box::leak(vec![("iam:AWSServiceName", Literal(service))].into_boxed_slice()); + assert!( + !allowed( + tier, + &write("iam:CreateServiceLinkedRole", role, ctx), + ME, + ME + ), + "service-linked {role} for {service}" + ); + } + } + + /// A workspace user changes none of the compute (they may read, as + /// they read all of ECS): their EC2 capacity is the admin's onboarding + /// module's to create. + #[test] + fn the_workspace_tier_cannot_manage_compute() { + for c in compute_checks().into_iter().filter(|c| c.write) { + assert!( + !allowed(Tier::WorkspaceUser, c, ME, ME), + "workspace user: {} on {}", + c.action, + rendered(c) + ); + } + } + const OTHER_BOUNDARY: Context = &[ ( "iam:PermissionsBoundary", diff --git a/app/src-tauri/src/aws/tofu_modules.rs b/app/src-tauri/src/aws/tofu_modules.rs index 09ebece..a529269 100644 --- a/app/src-tauri/src/aws/tofu_modules.rs +++ b/app/src-tauri/src/aws/tofu_modules.rs @@ -19,6 +19,11 @@ pub const ENVIRONMENT_MODULE_VERSION: u32 = 2; /// The same for the user-onboarding module. #[allow(dead_code)] // the onboarding module's version; checked against its HCL by a test pub const ONBOARD_MODULE_VERSION: u32 = 1; +/// The same for the permissions-boundary module. 2: the instance role's ECS +/// agent and Session Manager actions (phase 7, E4); an account admin +/// re-applies the boundary once. +#[allow(dead_code)] // checked against its HCL by a test; nothing reads the tag yet +pub const BOUNDARY_MODULE_VERSION: u32 = 2; /// The permissions boundary every module-created role carries (no path). /// Equal to [`super::policies::PERMISSIONS_BOUNDARY_NAME`]; a test checks it. pub const BOUNDARY_POLICY_NAME: &str = "triple-c-permissions-boundary"; diff --git a/app/src-tauri/src/aws/tofu_modules/tests.rs b/app/src-tauri/src/aws/tofu_modules/tests.rs index 0c7303f..575f6a3 100644 --- a/app/src-tauri/src/aws/tofu_modules/tests.rs +++ b/app/src-tauri/src/aws/tofu_modules/tests.rs @@ -1308,7 +1308,10 @@ fn boundary_vars_carry_the_shipped_boundary() { let tags = default_tags(&body); assert_eq!( object_keys(tags), - BTreeSet::from(["triple-c:component".to_string()]) + BTreeSet::from([ + "triple-c:component".to_string(), + "triple-c:template-version".to_string() + ]) ); assert_eq!( object_get(tags, "triple-c:component"), @@ -1316,6 +1319,21 @@ fn boundary_vars_carry_the_shipped_boundary() { ); } +#[test] +fn the_boundary_module_version_is_pinned() { + assert_eq!(BOUNDARY_MODULE_VERSION, 2); + let body = parsed(ModuleKind::PermissionsBoundary); + let version = local_def(&body, "template_version"); + assert_eq!(version, &Expression::Number(BOUNDARY_MODULE_VERSION.into())); + let tag = object_get(default_tags(&body), "triple-c:template-version") + .expect("template-version default tag"); + assert!( + render(tag).contains("local.template_version"), + "template-version tag is {}", + render(tag) + ); +} + /// EC2 accepts only these characters in a security group's or rule's /// description; the provider checks only the length, so a stray apostrophe /// passes `tofu validate` and fails `CreateSecurityGroup`. @@ -1874,6 +1892,230 @@ const MODULE_CALLS: &[(&str, &[Check])] = &[ ("backend.s3", BACKEND), ]; +// Phase 7 (per-user EC2 capacity, E1–E5, E11): the calls the onboarding +// module's EC2 resources will make, written down with the policy (Task 2) +// before the resources exist. Task 3 moves each entry into MODULE_CALLS +// under its type (merging with the existing `aws_ecs_cluster`, +// `aws_ecs_cluster_capacity_providers`, `aws_iam_role`, `aws_ssm_parameter` +// and `data.aws_ssm_parameter` entries) and deletes this table. Names are +// the user's (`triple-c--[-instance]`). +const USER_CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-probe-0123456789ab"; +const CAPACITY_PROVIDER: &str = + "arn:aws:ecs:{region}:{account}:capacity-provider/triple-c-probe-0123456789ab"; +const LAUNCH_TEMPLATE: &str = "arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"; +const AUTO_SCALING_GROUP: &str = "arn:aws:autoscaling:{region}:{account}:autoScalingGroup:\ + 00000000-0000-0000-0000-000000000000:autoScalingGroupName/triple-c-probe-0123456789ab"; +const INSTANCE: &str = "arn:aws:ec2:{region}:{account}:instance/i-00000000000000000"; +const VOLUME: &str = "arn:aws:ec2:{region}:{account}:volume/vol-00000000000000000"; +const IMAGE: &str = "arn:aws:ec2:{region}::image/ami-00000000000000000"; +const INSTANCE_ROLE: &str = "arn:aws:iam::{account}:role/triple-c-probe-0123456789ab-instance"; +const INSTANCE_PROFILE: &str = + "arn:aws:iam::{account}:instance-profile/triple-c-probe-0123456789ab-instance"; +const AUTO_SCALING_SERVICE_ROLE: &str = "arn:aws:iam::{account}:role/aws-service-role/\ + autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"; +const ECS_SERVICE_ROLE: &str = + "arn:aws:iam::{account}:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS"; +const AMI_PARAMETER: &str = "arn:aws:ssm:{region}::parameter/aws/service/ecs/optimized-ami/\ + amazon-linux-2023/recommended/image_id"; +const USER_RECORD: &str = + "arn:aws:ssm:{region}:{account}:parameter/triple-c/users/probe/0123456789ab"; +/// A launch from the user's launch template (what creating the group +/// checks the caller for). +const FROM_TEMPLATE: Context = &[( + "ec2:LaunchTemplate", + Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"), +)]; +const AMAZON_IMAGE: Context = &[ + ("ec2:Owner", Literal("amazon")), + ( + "ec2:LaunchTemplate", + Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"), + ), +]; +const TO_EC2: Context = &[("iam:PassedToService", Literal("ec2.amazonaws.com"))]; + +const EC2_COMPUTE_CALLS: &[(&str, &[Check])] = &[ + ( + "aws_ecs_cluster (user)", + &[ + call("ecs:CreateCluster", USER_CLUSTER, USER_CREATE), + call( + "ecs:TagResource", + USER_CLUSTER, + &[("ecs:CreateAction", Literal("CreateCluster"))], + ), + call("ecs:DescribeClusters", USER_CLUSTER, NONE), + call("ecs:ListTagsForResource", USER_CLUSTER, NONE), + call("ecs:UpdateCluster", USER_CLUSTER, USER_TAGGED), + call("ecs:DeleteCluster", USER_CLUSTER, USER_TAGGED), + ], + ), + ( + // Hypothesis: authorized against the cluster and the provider. + "aws_ecs_cluster_capacity_providers (user)", + &[ + call("ecs:PutClusterCapacityProviders", USER_CLUSTER, USER_TAGGED), + call( + "ecs:PutClusterCapacityProviders", + CAPACITY_PROVIDER, + USER_TAGGED, + ), + call("ecs:DescribeClusters", USER_CLUSTER, NONE), + ], + ), + ( + // Managed scaling runs as ECS's service-linked role, created on + // first use if the account has none. + "aws_ecs_capacity_provider", + &[ + call("ecs:CreateCapacityProvider", CAPACITY_PROVIDER, USER_CREATE), + call( + "ecs:TagResource", + CAPACITY_PROVIDER, + &[("ecs:CreateAction", Literal("CreateCapacityProvider"))], + ), + call("ecs:DescribeCapacityProviders", "*", NONE), + call("ecs:ListTagsForResource", CAPACITY_PROVIDER, NONE), + call("ecs:UpdateCapacityProvider", CAPACITY_PROVIDER, USER_TAGGED), + call("ecs:TagResource", CAPACITY_PROVIDER, USER_TAGGED), + call("ecs:UntagResource", CAPACITY_PROVIDER, USER_TAGGED), + call("ecs:DeleteCapacityProvider", CAPACITY_PROVIDER, USER_TAGGED), + call( + "iam:CreateServiceLinkedRole", + ECS_SERVICE_ROLE, + &[("iam:AWSServiceName", Literal("ecs.amazonaws.com"))], + ), + ], + ), + ( + "aws_launch_template", + &[ + call("ec2:CreateLaunchTemplate", LAUNCH_TEMPLATE, USER_CREATE), + call( + "ec2:CreateTags", + LAUNCH_TEMPLATE, + created_by!("CreateLaunchTemplate"), + ), + call("ec2:DescribeLaunchTemplates", "*", NONE), + call("ec2:DescribeLaunchTemplateVersions", "*", NONE), + call( + "ec2:CreateLaunchTemplateVersion", + LAUNCH_TEMPLATE, + USER_TAGGED, + ), + call("ec2:ModifyLaunchTemplate", LAUNCH_TEMPLATE, USER_TAGGED), + call("ec2:CreateTags", LAUNCH_TEMPLATE, USER_TAGGED), + call("ec2:DeleteTags", LAUNCH_TEMPLATE, USER_TAGGED), + call("ec2:DeleteLaunchTemplate", LAUNCH_TEMPLATE, USER_TAGGED), + ], + ), + ( + // Creating the group checks that the caller could launch its + // template (RunInstances with what the template names, the tags the + // launch puts on, the instance role passed to EC2). The group's own + // launches run as Auto Scaling's service-linked role. ASG tags are + // not the provider's default_tags: the module sets them per group. + // SetInstanceProtection: hypothesis, for draining before destroy. + "aws_autoscaling_group", + &[ + call( + "autoscaling:CreateAutoScalingGroup", + AUTO_SCALING_GROUP, + USER_CREATE, + ), + call( + "autoscaling:CreateOrUpdateTags", + AUTO_SCALING_GROUP, + USER_CREATE, + ), + call( + "iam:CreateServiceLinkedRole", + AUTO_SCALING_SERVICE_ROLE, + &[("iam:AWSServiceName", Literal("autoscaling.amazonaws.com"))], + ), + call("ec2:RunInstances", LAUNCH_TEMPLATE, USER_TAGGED), + call("ec2:RunInstances", INSTANCE, FROM_TEMPLATE), + call("ec2:RunInstances", VOLUME, FROM_TEMPLATE), + call("ec2:RunInstances", ENI, FROM_TEMPLATE), + call("ec2:RunInstances", SUBNET, FROM_TEMPLATE), + call("ec2:RunInstances", SG, FROM_TEMPLATE), + call("ec2:RunInstances", IMAGE, AMAZON_IMAGE), + call("ec2:CreateTags", INSTANCE, created_by!("RunInstances")), + call("ec2:CreateTags", VOLUME, created_by!("RunInstances")), + call("ec2:CreateTags", ENI, created_by!("RunInstances")), + call("iam:PassRole", INSTANCE_ROLE, TO_EC2), + call("autoscaling:DescribeAutoScalingGroups", "*", NONE), + call("autoscaling:DescribeScalingActivities", "*", NONE), + call( + "autoscaling:UpdateAutoScalingGroup", + AUTO_SCALING_GROUP, + USER_TAGGED, + ), + call( + "autoscaling:SetInstanceProtection", + AUTO_SCALING_GROUP, + USER_TAGGED, + ), + call( + "autoscaling:CreateOrUpdateTags", + AUTO_SCALING_GROUP, + USER_TAGGED, + ), + call("autoscaling:DeleteTags", AUTO_SCALING_GROUP, USER_TAGGED), + call( + "autoscaling:DeleteAutoScalingGroup", + AUTO_SCALING_GROUP, + USER_TAGGED, + ), + ], + ), + ( + "aws_iam_role (instance)", + &[ + call("iam:CreateRole", INSTANCE_ROLE, BOUNDED), + call("iam:PutRolePolicy", INSTANCE_ROLE, BOUNDED), + call("iam:GetRole", INSTANCE_ROLE, NONE), + call("iam:ListInstanceProfilesForRole", INSTANCE_ROLE, NONE), + call("iam:DeleteRolePolicy", INSTANCE_ROLE, BOUNDED), + call("iam:DeleteRole", INSTANCE_ROLE, NONE), + ], + ), + ( + // Hypothesis: adding the role needs it passable to EC2. + "aws_iam_instance_profile", + &[ + call("iam:CreateInstanceProfile", INSTANCE_PROFILE, NONE), + call("iam:TagInstanceProfile", INSTANCE_PROFILE, NONE), + call("iam:AddRoleToInstanceProfile", INSTANCE_PROFILE, NONE), + call("iam:PassRole", INSTANCE_ROLE, TO_EC2), + call("iam:GetInstanceProfile", INSTANCE_PROFILE, NONE), + call("iam:ListInstanceProfileTags", INSTANCE_PROFILE, NONE), + call("iam:UntagInstanceProfile", INSTANCE_PROFILE, NONE), + call("iam:RemoveRoleFromInstanceProfile", INSTANCE_PROFILE, NONE), + call("iam:DeleteInstanceProfile", INSTANCE_PROFILE, NONE), + ], + ), + ( + "data.aws_ssm_parameter (AMI)", + &[call("ssm:GetParameter", AMI_PARAMETER, NONE)], + ), + ( + "aws_ssm_parameter (user record)", + &[ + call("ssm:PutParameter", USER_RECORD, USER_CREATE), + call("ssm:AddTagsToResource", USER_RECORD, USER_CREATE), + call("ssm:GetParameter", USER_RECORD, NONE), + call("ssm:ListTagsForResource", USER_RECORD, NONE), + call("ssm:DeleteParameter", USER_RECORD, NONE), + ], + ), +]; + +/// MODULE_CALLS and the phase-7 calls Task 3's resources will make. +fn all_module_calls() -> impl Iterator { + MODULE_CALLS.iter().chain(EC2_COMPUTE_CALLS.iter()) +} + /// `resource.` and `data.` of the environment and onboarding /// modules, and `backend.s3`. fn module_types() -> BTreeSet { @@ -1955,7 +2197,7 @@ fn the_admin_tier_can_apply_every_module_resource() { let admin = tier_statements(&[Tier::EnvironmentAdmin]); let both = tier_statements(&[Tier::EnvironmentAdmin, Tier::WorkspaceUser]); let mut missing = Vec::new(); - for (ty, calls) in MODULE_CALLS { + for (ty, calls) in all_module_calls() { for c in *calls { for (which, stmts) in [("admin", &admin), ("admin + workspace", &both)] { if !allowed_by(stmts, c) { @@ -2076,10 +2318,10 @@ const APP_ONLY_WRITES: &[&str] = &[ "s3:PutBucketPublicAccessBlock", "s3:PutBucketTagging", "s3:PutBucketPolicy", - // Workspaces (phase 5): task definitions and the roles they name. + // Workspaces (phase 5): task definitions and the roles they name + // (`iam:PassRole` is a module call too since phase 7: the instance role). "ecs:RegisterTaskDefinition", "ecs:DeregisterTaskDefinition", - "iam:PassRole", "iam:AttachRolePolicy", "iam:DetachRolePolicy", // The permission check itself. @@ -2103,8 +2345,7 @@ fn every_module_write_has_an_admin_check_and_vice_versa() { .map(|c| c.action) .filter(|a| is_write(a)) .collect(); - let module: BTreeSet<&str> = MODULE_CALLS - .iter() + let module: BTreeSet<&str> = all_module_calls() .flat_map(|(_, calls)| calls.iter().map(|c| c.action)) .filter(|a| is_write(a)) .collect(); diff --git a/app/src-tauri/src/commands/host_commands.rs b/app/src-tauri/src/commands/host_commands.rs index 6daa72e..ec0f74a 100644 --- a/app/src-tauri/src/commands/host_commands.rs +++ b/app/src-tauri/src/commands/host_commands.rs @@ -604,7 +604,14 @@ mod tests { fn the_policy_document_is_every_file_of_the_tier() { let admin = aws_policy_document(Tier::EnvironmentAdmin); let names: Vec<&str> = admin.iter().map(|f| f.name.as_str()).collect(); - assert_eq!(names, ["environment-admin.json", "environment-admin-network.json"]); + assert_eq!( + names, + [ + "environment-admin.json", + "environment-admin-network.json", + "environment-admin-compute.json" + ] + ); for f in &admin { serde_json::from_str::(&f.json).expect("policy JSON"); } diff --git a/aws/README.md b/aws/README.md index b30155c..80d2c8b 100644 --- a/aws/README.md +++ b/aws/README.md @@ -10,13 +10,14 @@ tier the signed-in identity has under **Settings → Hosts → Check**. | `policies/workspace-user-tasks.json` | The **workspace user** tier, part 2: register and tag **their own** ECS task definitions, read **their own** secrets, and read Fargate prices for the cost estimate (`workspace-user.json` has no room left) | | `policies/environment-admin.json` | The **environment admin** tier, part 1: apply and destroy the environment and onboarding modules (`terraform/`) with OpenTofu, and keep their state | | `policies/environment-admin-network.json` | The **environment admin** tier, part 2: the network those modules create (VPC, subnets, gateways, routes, security groups) | +| `policies/environment-admin-compute.json` | The **environment admin** tier, part 3: per-user EC2 capacity the onboarding module creates (phase 7): capacity providers, launch templates, Auto Scaling groups, instance profiles, the instance role passed to EC2 | | `policies/permissions-boundary.json` | The **permissions boundary** every Triple-C role must carry. It is never attached to a person | -The workspace tier and the admin tier are each **two** files, because one managed policy holds -only 6,144 characters; both files of a tier are required, and the app's **Copy** lists every -file of a tier. An environment admin attaches all four tier files (both workspace user files and -both admin files): the admin files add environment management on top of everything a workspace -user can do. Explicit Deny statements in any file apply to anyone +The workspace tier is **two** files and the admin tier **three**, because one managed policy +holds only 6,144 characters; every file of a tier is required, and the app's **Copy** lists every +file of a tier. An environment admin attaches all five tier files (both workspace user files and +the three admin files): the admin files add environment management on top of everything a +workspace user can do. Explicit Deny statements in any file apply to anyone who has it attached. ## Workspace user @@ -137,11 +138,18 @@ and nothing runs with more than the admin holds. It covers: - the per-account state bucket `triple-c-tfstate--` (created by the app, tagged `triple-c:component=state`, then read and written by OpenTofu's S3 backend, lock files included); - `triple-c-*` IAM roles, and reading the `triple-c-permissions-boundary` policy; -- ECS clusters (Fargate and Fargate Spot only) and task definitions; +- ECS clusters (the environment's: Fargate and Fargate Spot; a user's: their own EC2 capacity + provider) and task definitions; - the network: VPCs, subnets, an internet gateway, route tables and routes, an Elastic IP and NAT gateway, security groups and their rules (`environment-admin-network.json`); - EFS file systems, mount targets and file-system policies, and KMS keys and aliases; -- `/triple-c/*` log groups and `/triple-c/*` SSM parameters. +- `/triple-c/*` log groups and `/triple-c/*` SSM parameters (including each user's compute record + `/triple-c/users//`); +- per-user EC2 capacity (`environment-admin-compute.json`, phase 7): the user's own + `triple-c--` cluster and capacity provider, a component-tagged launch template + and `triple-c-*` Auto Scaling group, the `triple-c-*` instance profile, passing + `triple-c-*-instance` roles to EC2, reading the ECS-optimized AMI's public SSM parameter, and + the Auto Scaling and ECS service-linked roles. **Clearing workspace task definitions.** Removing a project leaves its revisions registered (family `triple-c---`). The admin tier may deregister any @@ -156,9 +164,9 @@ Deregistered revisions become INACTIVE; ECS keeps them until they are deleted wi `ecs:DeleteTaskDefinitions`, which the admin tier does not grant (an account administrator can). A task still running from a revision keeps running. -Not in v1, and so not in the policy: ECR (tasks pull from GHCR), custom ECS capacity providers, -and passing roles to EC2 (`iam:PassRole` is to `ecs-tasks.amazonaws.com` only). Phase 7's EC2 -capacity adds them back. +Not in the policy: ECR (tasks pull from GHCR). Phase 7's EC2 capacity added custom ECS capacity +providers and passing roles to EC2, the latter only for `triple-c-*-instance` roles (task and +execution roles still go to `ecs-tasks.amazonaws.com` only). ### What each module resource needs @@ -192,6 +200,16 @@ the proof; an action it shows missing is added to the table, the policy, the che | `aws_iam_role` | `iam:CreateRole` (with the boundary), `TagRole`, `UntagRole`, `GetRole`, `ListRolePolicies`, `ListAttachedRolePolicies`, `ListInstanceProfilesForRole`, `UpdateRole`, `UpdateRoleDescription`, `DeleteRole` (`triple-c-*`) | | `aws_iam_role_policy` | `iam:PutRolePolicy`, `DeleteRolePolicy` (with the boundary), `GetRolePolicy` (the role; untaggable) | | data sources | `sts:GetCallerIdentity`, `ec2:DescribeAvailabilityZones`, `ec2:DescribeSubnets`, `ssm:GetParameter` | +| *Phase 7, per-user EC2 (onboarding module, expected; `EC2_COMPUTE_CALLS` until the resources exist)* | | +| `aws_ecs_cluster` (the user's) | as the environment's cluster, on `cluster/triple-c--` | +| `aws_ecs_capacity_provider` | `ecs:CreateCapacityProvider`, `TagResource` (at create), `ListTagsForResource`, `UpdateCapacityProvider`, `UntagResource`, `DeleteCapacityProvider` (`capacity-provider/triple-c-*`), `DescribeCapacityProviders` (`*`); `iam:CreateServiceLinkedRole` for `ecs.amazonaws.com` (managed scaling runs as ECS's service-linked role) | +| `aws_ecs_cluster_capacity_providers` (the user's) | `ecs:PutClusterCapacityProviders` (the cluster and, expected, the capacity provider) | +| `aws_launch_template` | `ec2:CreateLaunchTemplate` (request tag), `CreateTags` (at create), `CreateLaunchTemplateVersion`, `ModifyLaunchTemplate`, `CreateTags`/`DeleteTags`, `DeleteLaunchTemplate` (tagged), `Describe*` | +| `aws_autoscaling_group` | `autoscaling:CreateAutoScalingGroup`, `CreateOrUpdateTags` (`triple-c-*`, request tag), `UpdateAutoScalingGroup`, `SetInstanceProtection`, `CreateOrUpdateTags`/`DeleteTags`, `DeleteAutoScalingGroup` (tagged), `Describe*` (`*`); `iam:CreateServiceLinkedRole` for `autoscaling.amazonaws.com`. Creating a group checks that the caller could launch its template: `ec2:RunInstances` on the tagged launch template, on instance, volume, network interface, subnet and security group only with `ec2:LaunchTemplate` set, and on images only Amazon's (`ec2:Owner = amazon`); `ec2:CreateTags` at `RunInstances`; `iam:PassRole` of the instance role to `ec2.amazonaws.com`. ASG tags are **not** the provider's `default_tags`: the module must set the component tag on the group itself | +| `aws_iam_role` (instance), `aws_iam_role_policy` | as the other per-user roles (bounded), on `triple-c---instance` | +| `aws_iam_instance_profile` | `iam:CreateInstanceProfile`, `TagInstanceProfile`, `AddRoleToInstanceProfile` (expected to need `iam:PassRole` of the role too), `GetInstanceProfile`, `ListInstanceProfileTags`, `UntagInstanceProfile`, `RemoveRoleFromInstanceProfile`, `DeleteInstanceProfile` (`instance-profile/triple-c-*`) | +| `data.aws_ssm_parameter` (AMI) | `ssm:GetParameter`/`GetParameters` on the public `parameter/aws/service/ecs/optimized-ami/*` | +| `aws_ssm_parameter` (user record) | as the environment record, on `/triple-c/users//` | | S3 backend | `s3:ListBucket` (the state bucket), `GetObject`/`PutObject`/`DeleteObject` (`triple-c-tfstate-*/*`, the `.tflock` objects included), in the caller's own account | The app also creates the state bucket: `s3:CreateBucket` with a `triple-c:component` request tag @@ -221,7 +239,14 @@ the role carries the `triple-c-permissions-boundary` managed policy as its permi (tagged `user-onboarding` by their onboarding module); the file system's own policy admits only its owner's task role, through an access point; - `sts:GetCallerIdentity`; - - invoking Bedrock models. + - invoking Bedrock models; + - for a user's EC2 instance role (phase 7, E4): the ECS agent's calls + (`RegisterContainerInstance`, `DeregisterContainerInstance`, `Poll`, `StartTelemetrySession`, + `Submit*`, `UpdateContainerInstancesState`) only on `triple-c-*` clusters and their container + instances, `ecs:TagResource` only on such a container instance as it registers + (`ecs:CreateAction = RegisterContainerInstance`), `ecs:DiscoverPollEndpoint`, and Session + Manager on the instance (`ssm:UpdateInstanceInformation`, the six `ec2messages:` actions) for an + admin's troubleshooting. ECS Exec into an EC2 task uses the task role, as on Fargate. - The boundary grants nothing in IAM. - Explicit Deny statements stop the admin from: - removing the boundary from a `triple-c-*` role; @@ -239,11 +264,15 @@ created only *inside* a Triple-C (tagged) VPC, subnet and address, and an intern attached, a route added or a route table associated only on tagged ones, so the admin cannot re-route a VPC that isn't Triple-C's. Tagging is allowed only as part of the creating call (`ec2:CreateAction`, `elasticfilesystem:CreateAction`), or on a resource that is already -Triple-C's. Resources that cannot carry a tag are authorized through one that does: routes and +Triple-C's. Launch templates (phase 7) are created only with the component tag and changed, +launched from or deleted only when they carry it; Auto Scaling groups must be named `triple-c-*` +and also carry it (request tag to create, resource tag to change, protect or delete). Resources +that cannot carry a tag are authorized through one that does: routes and route-table associations through the route table (and subnet), mount targets and the file-system policy through the file system, KMS aliases through the key, role policies through the -(boundary-carrying) role. Clusters, log groups, parameters, roles and the state bucket are scoped -by name (`triple-c-*`, `/triple-c/*`, `triple-c-tfstate-*`). +(boundary-carrying) role. Clusters, capacity providers, log groups, parameters, roles, instance +profiles and the state bucket are scoped by name (`triple-c-*`, `/triple-c/*`, +`triple-c-tfstate-*`). **What is not scoped.** The scoping above does not cover every action. These actions apply account-wide: @@ -276,6 +305,16 @@ account-wide: and mount targets are created and deleted under this statement alone. - Reads on `*`: `ec2:Describe*`, `elasticfilesystem:Describe*`, the KMS key reads and `ListAliases`, `logs:DescribeLogGroups` and `ssm:DescribeParameters`. +- `ec2:RunInstances` on instances, volumes, network interfaces, subnets and security groups + anywhere, as long as the launch comes from a launch template (`ec2:LaunchTemplate`), whose own + side must be a component-tagged template, and with Amazon's images only. The subnets and groups + are not tag-checked because an `existing`-network environment's are the user's own. The admin + never calls `RunInstances` itself: creating an Auto Scaling group checks that the caller could, + and the group's launches run as Auto Scaling's service-linked role. +- `iam:CreateServiceLinkedRole`, only for `autoscaling.amazonaws.com` and `ecs.amazonaws.com` + (AWS fixes those roles' policies). +- Reads on `*`: `autoscaling:Describe*`, `ecs:DescribeCapacityProviders`; and the public + ECS-optimized AMI parameters. - `s3:PutBucketPolicy` on the state bucket (only a bucket in the admin's own account, enforced by `s3:ResourceAccount`): an admin could open that bucket to other accounts. The state holds no secrets (the modules create none), but it maps the account's Triple-C resources. @@ -398,6 +437,13 @@ aws iam create-policy --policy-name triple-c-permissions-boundary \ --policy-document file://policies/permissions-boundary.json ``` +**Phase 7 changed the boundary** (version 2: the instance role's ECS agent and Session Manager +actions). An account administrator re-applies it once (the boundary module from the app, or +`aws iam create-policy-version --policy-arn arn:aws:iam:::policy/triple-c-permissions-boundary +--policy-document file://policies/permissions-boundary.json --set-as-default`) before anyone +onboards with EC2 capacity; Fargate users are unaffected. The module tags the policy +`triple-c:template-version = 2`. + Create the policy **without a path**. The admin policy expects exactly `arn:aws:iam:::policy/triple-c-permissions-boundary`. The `terraform/permissions-boundary` module creates the same policy, applied by an account administrator; the admin tier can read it @@ -408,11 +454,11 @@ 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 16,400), and a user's share 2,048. A managed policy +environment admin needs every tier file (about 20,200), 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,293 (including `ReadFargatePrices`), -`environment-admin.json` 5,805 (339) -and `environment-admin-network.json` 3,340; a unit test (`every_policy_fits_a_managed_policy`) +`environment-admin.json` 5,805 (339), `environment-admin-network.json` 3,340, +`environment-admin-compute.json` 3,705 and `permissions-boundary.json` 2,625; 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. @@ -461,6 +507,31 @@ aws iam attach-user-policy --user-name \ `containerOverrides`: every workspace user can read them through `ecs:Describe*` on `*`. Use Secrets Manager (`triple-c/*`) references instead. +**Phase 7 (per-user EC2 capacity): still open until the live run (Task 7)** + +The unit tests' evaluator is not IAM; these points of the compute file and the boundary are +expected, not verified: + +- **Creating an Auto Scaling group checks the caller's launch permissions.** Expected: a dry run + of `ec2:RunInstances` from the launch template as the admin, with `ec2:LaunchTemplate` set on + every resource, the template's own tags visible, `ec2:Owner = amazon` on the image, and + `iam:PassRole` of the instance role to `ec2.amazonaws.com`. If the dry run omits + `ec2:LaunchTemplate` on some resource, the group's create is denied and that statement needs + another condition. +- **`iam:AddRoleToInstanceProfile`** is expected to need `iam:PassRole` of the role; which + `iam:PassedToService` IAM sends then (if any) is unknown, and only `ec2.amazonaws.com` is allowed. +- **`ecs:PutClusterCapacityProviders`** may be authorized against the capacity provider as well as + the cluster (both are allowed); **`ecs:CreateCapacityProvider`** may check the caller's + `autoscaling:Describe*` on the group (allowed) or create ECS's service-linked role (allowed). +- **Service-linked roles.** The Auto Scaling and ECS roles exist in most accounts already; + creating them is allowed only for those two services. Whether creating a group in an account + without one creates it as the caller (needing this grant) is not verified. +- **The instance role's agent calls** (`ecs:Poll`, `StartTelemetrySession`, + `UpdateContainerInstancesState`) are expected to be authorized against + `container-instance//` and the rest against the cluster; the boundary allows both. +- **The public AMI parameter's ARN** has no account (`arn:aws:ssm:::parameter/aws/…`); + `arn:aws:ssm:*::parameter/aws/service/ecs/optimized-ami/*` is expected to match it. + **Phase 6** - **Access-point roots.** A workspace user creates their own access points, only on their own file diff --git a/aws/policies/environment-admin-compute.json b/aws/policies/environment-admin-compute.json new file mode 100644 index 0000000..0f31763 --- /dev/null +++ b/aws/policies/environment-admin-compute.json @@ -0,0 +1,222 @@ +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "ManageTripleCCapacityProviders", + "Effect": "Allow", + "Action": [ + "ecs:CreateCapacityProvider", + "ecs:UpdateCapacityProvider", + "ecs:DeleteCapacityProvider", + "ecs:PutClusterCapacityProviders", + "ecs:TagResource", + "ecs:UntagResource", + "ecs:ListTagsForResource" + ], + "Resource": [ + "arn:aws:ecs:*:*:capacity-provider/triple-c-*" + ] + }, + { + "Sid": "CreateTaggedLaunchTemplates", + "Effect": "Allow", + "Action": [ + "ec2:CreateLaunchTemplate" + ], + "Resource": [ + "arn:aws:ec2:*:*:launch-template/*" + ], + "Condition": { + "Null": { + "aws:RequestTag/triple-c:component": "false" + } + } + }, + { + "Sid": "TagComputeAtCreate", + "Effect": "Allow", + "Action": [ + "ec2:CreateTags" + ], + "Resource": [ + "arn:aws:ec2:*:*:launch-template/*", + "arn:aws:ec2:*:*:instance/*", + "arn:aws:ec2:*:*:volume/*", + "arn:aws:ec2:*:*:network-interface/*" + ], + "Condition": { + "StringEquals": { + "ec2:CreateAction": [ + "CreateLaunchTemplate", + "RunInstances" + ] + } + } + }, + { + "Sid": "ManageAndUseTripleCLaunchTemplates", + "Effect": "Allow", + "Action": [ + "ec2:CreateLaunchTemplateVersion", + "ec2:ModifyLaunchTemplate", + "ec2:DeleteLaunchTemplate", + "ec2:CreateTags", + "ec2:DeleteTags", + "ec2:RunInstances" + ], + "Resource": [ + "arn:aws:ec2:*:*:launch-template/*" + ], + "Condition": { + "Null": { + "aws:ResourceTag/triple-c:component": "false" + } + } + }, + { + "Sid": "LaunchOnlyFromLaunchTemplates", + "Effect": "Allow", + "Action": [ + "ec2:RunInstances" + ], + "Resource": [ + "arn:aws:ec2:*:*:instance/*", + "arn:aws:ec2:*:*:volume/*", + "arn:aws:ec2:*:*:network-interface/*", + "arn:aws:ec2:*:*:subnet/*", + "arn:aws:ec2:*:*:security-group/*" + ], + "Condition": { + "ArnLike": { + "ec2:LaunchTemplate": "arn:aws:ec2:*:*:launch-template/*" + } + } + }, + { + "Sid": "LaunchAmazonImages", + "Effect": "Allow", + "Action": [ + "ec2:RunInstances" + ], + "Resource": [ + "arn:aws:ec2:*::image/*" + ], + "Condition": { + "StringEquals": { + "ec2:Owner": "amazon" + }, + "ArnLike": { + "ec2:LaunchTemplate": "arn:aws:ec2:*:*:launch-template/*" + } + } + }, + { + "Sid": "CreateTaggedAutoScalingGroups", + "Effect": "Allow", + "Action": [ + "autoscaling:CreateAutoScalingGroup", + "autoscaling:CreateOrUpdateTags" + ], + "Resource": [ + "arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/triple-c-*" + ], + "Condition": { + "Null": { + "aws:RequestTag/triple-c:component": "false" + } + } + }, + { + "Sid": "ManageTripleCAutoScalingGroups", + "Effect": "Allow", + "Action": [ + "autoscaling:UpdateAutoScalingGroup", + "autoscaling:SetInstanceProtection", + "autoscaling:CreateOrUpdateTags", + "autoscaling:DeleteTags", + "autoscaling:DeleteAutoScalingGroup" + ], + "Resource": [ + "arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/triple-c-*" + ], + "Condition": { + "Null": { + "aws:ResourceTag/triple-c:component": "false" + } + } + }, + { + "Sid": "CreateComputeServiceLinkedRoles", + "Effect": "Allow", + "Action": [ + "iam:CreateServiceLinkedRole" + ], + "Resource": [ + "arn:aws:iam::*:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling*", + "arn:aws:iam::*:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS*" + ], + "Condition": { + "StringEquals": { + "iam:AWSServiceName": [ + "autoscaling.amazonaws.com", + "ecs.amazonaws.com" + ] + } + } + }, + { + "Sid": "ManageTripleCInstanceProfiles", + "Effect": "Allow", + "Action": [ + "iam:CreateInstanceProfile", + "iam:DeleteInstanceProfile", + "iam:GetInstanceProfile", + "iam:AddRoleToInstanceProfile", + "iam:RemoveRoleFromInstanceProfile", + "iam:TagInstanceProfile", + "iam:UntagInstanceProfile", + "iam:ListInstanceProfileTags" + ], + "Resource": [ + "arn:aws:iam::*:instance-profile/triple-c-*" + ] + }, + { + "Sid": "PassInstanceRolesToEc2", + "Effect": "Allow", + "Action": [ + "iam:PassRole" + ], + "Resource": [ + "arn:aws:iam::*:role/triple-c-*-instance" + ], + "Condition": { + "StringEquals": { + "iam:PassedToService": "ec2.amazonaws.com" + } + } + }, + { + "Sid": "ReadEcsOptimizedAmis", + "Effect": "Allow", + "Action": [ + "ssm:GetParameter", + "ssm:GetParameters" + ], + "Resource": [ + "arn:aws:ssm:*::parameter/aws/service/ecs/optimized-ami/*" + ] + }, + { + "Sid": "ReadCompute", + "Effect": "Allow", + "Action": [ + "ecs:DescribeCapacityProviders", + "autoscaling:Describe*" + ], + "Resource": [ + "*" + ] + } + ] +} diff --git a/aws/policies/permissions-boundary.json b/aws/policies/permissions-boundary.json index 08454ce..de69b2c 100644 --- a/aws/policies/permissions-boundary.json +++ b/aws/policies/permissions-boundary.json @@ -116,6 +116,54 @@ "arn:aws:bedrock:*:*:inference-profile/*", "arn:aws:bedrock:*:*:application-inference-profile/*" ] + }, + { + "Sid": "EcsAgentOnTripleCClusters", + "Effect": "Allow", + "Action": [ + "ecs:RegisterContainerInstance", + "ecs:DeregisterContainerInstance", + "ecs:Poll", + "ecs:StartTelemetrySession", + "ecs:Submit*", + "ecs:UpdateContainerInstancesState" + ], + "Resource": [ + "arn:aws:ecs:*:*:cluster/triple-c-*", + "arn:aws:ecs:*:*:container-instance/triple-c-*/*" + ] + }, + { + "Sid": "EcsAgentTagsItsInstance", + "Effect": "Allow", + "Action": [ + "ecs:TagResource" + ], + "Resource": [ + "arn:aws:ecs:*:*:container-instance/triple-c-*/*" + ], + "Condition": { + "StringEquals": { + "ecs:CreateAction": "RegisterContainerInstance" + } + } + }, + { + "Sid": "InstanceAgents", + "Effect": "Allow", + "Action": [ + "ecs:DiscoverPollEndpoint", + "ssm:UpdateInstanceInformation", + "ec2messages:AcknowledgeMessage", + "ec2messages:DeleteMessage", + "ec2messages:FailMessage", + "ec2messages:GetEndpoint", + "ec2messages:GetMessages", + "ec2messages:SendReply" + ], + "Resource": [ + "*" + ] } ] } diff --git a/aws/terraform/permissions-boundary/main.tf b/aws/terraform/permissions-boundary/main.tf index 6edd29c..64b82eb 100644 --- a/aws/terraform/permissions-boundary/main.tf +++ b/aws/terraform/permissions-boundary/main.tf @@ -1,12 +1,19 @@ # The permissions boundary every role a Triple-C module creates must carry: # the most any such role may ever hold. One per account. +locals { + # BOUNDARY_MODULE_VERSION in app/src-tauri/src/aws/tofu_modules.rs. + # 2: the instance role's ECS agent and Session Manager actions (phase 7). + template_version = 2 +} + provider "aws" { region = var.region default_tags { tags = { - "triple-c:component" = "boundary" + "triple-c:component" = "boundary" + "triple-c:template-version" = tostring(local.template_version) } } } -- 2.52.0 From e6fbf4e13355bdb5e6eb929262d26f901ea3be96 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 13:17:54 -0800 Subject: [PATCH 05/29] fix(aws): pin, type-limit and fence per-user EC2 capacity permissions Review fix round 1 for the phase 7 admin compute file and boundary: - Auto Scaling groups: create needs autoscaling:LaunchTemplateVersionSpecified (update BoolIfExists), no target groups / load balancers, supported instance types; CreateOrUpdateTags only on already-tagged groups. ModifyLaunchTemplate dropped (the default version never moves). - RunInstances: instance and volume need the component request tag, the instance a supported type (the app's ec2_instance_spec table, pinned by a test); the security group must be the template's own and component-tagged, the image Amazon's and the template's. - Boundary: the ECS agent only on the cluster its role's triple-c:cluster principal tag names (must be triple-c-*); Session Manager / ec2messages dropped (plan E4 amended). - Evaluator learns Bool/BoolIfExists; the simulator sends the Boolean keys typed Boolean. - README: instance types, pinning, -instance suffix is not an admin fence, RunInstances wording, still-open probes, IMDS/Docker note. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/permissions.rs | 16 +- app/src-tauri/src/aws/permissions/tests.rs | 23 + app/src-tauri/src/aws/policies.rs | 480 +++++++++++++++++--- app/src-tauri/src/aws/policy_eval.rs | 34 +- app/src-tauri/src/aws/tofu_modules/tests.rs | 63 ++- aws/README.md | 95 +++- aws/policies/environment-admin-compute.json | 182 +++++++- aws/policies/permissions-boundary.json | 29 +- 8 files changed, 788 insertions(+), 134 deletions(-) diff --git a/app/src-tauri/src/aws/permissions.rs b/app/src-tauri/src/aws/permissions.rs index cf51d1b..8d4038c 100644 --- a/app/src-tauri/src/aws/permissions.rs +++ b/app/src-tauri/src/aws/permissions.rs @@ -37,8 +37,20 @@ impl ContextEntry { pub fn is_list(&self) -> bool { self.values.len() > 1 } + + /// Keys IAM types as Boolean (a `Bool` condition does not match a + /// String-typed simulation value). + pub fn is_boolean(&self) -> bool { + BOOLEAN_KEYS.contains(&self.key.as_str()) + } } +/// The Boolean condition keys the checks send. +const BOOLEAN_KEYS: &[&str] = &[ + "autoscaling:LaunchTemplateVersionSpecified", + "ec2:IsLaunchTemplateResource", +]; + /// Builds the simulation for `check`: the resource and every literal context /// value rendered with `p`, `OwnerId` as `user_id`, and `aws:userid` = /// `user_id` added. A key appearing more than once becomes one entry holding @@ -175,7 +187,9 @@ impl PermissionApi for SdkPermissionApi { SdkEntry::builder() .context_key_name(&e.key) .set_context_key_values(Some(e.values.clone())) - .context_key_type(if e.is_list() { + .context_key_type(if e.is_boolean() { + ContextKeyTypeEnum::Boolean + } else if e.is_list() { ContextKeyTypeEnum::StringList } else { ContextKeyTypeEnum::String diff --git a/app/src-tauri/src/aws/permissions/tests.rs b/app/src-tauri/src/aws/permissions/tests.rs index ca2217e..497b268 100644 --- a/app/src-tauri/src/aws/permissions/tests.rs +++ b/app/src-tauri/src/aws/permissions/tests.rs @@ -344,6 +344,29 @@ fn a_repeated_context_key_is_one_string_list_entry() { ); assert!(req.context[0].is_list()); assert!(!req.context[1].is_list()); + assert!(!req.context[1].is_boolean()); +} + +/// Every Boolean-typed key a check sends is one `is_boolean` knows, so the +/// simulator gets it as Boolean (a `Bool` condition never matches a String). +#[test] +fn boolean_context_keys_are_sent_as_booleans() { + let mut seen = 0; + for tier in [Tier::WorkspaceUser, Tier::EnvironmentAdmin] { + for c in checks(tier) { + for (key, value) in c.context { + if matches!(value, ContextValue::Literal("true" | "false")) { + let e = ContextEntry { + key: key.to_string(), + values: vec!["true".into()], + }; + assert!(e.is_boolean(), "{key} is sent as a String"); + seen += 1; + } + } + } + } + assert!(seen >= 2, "only {seen} Boolean keys"); } #[test] diff --git a/app/src-tauri/src/aws/policies.rs b/app/src-tauri/src/aws/policies.rs index 37465e7..e0120a8 100644 --- a/app/src-tauri/src/aws/policies.rs +++ b/app/src-tauri/src/aws/policies.rs @@ -242,13 +242,57 @@ const FROM_LAUNCH_TEMPLATE: Context = &[( "ec2:LaunchTemplate", Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"), )]; -/// ...and the image is Amazon's. +const PROBE_LAUNCH_TEMPLATE_ARN: ContextValue = + Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"); +/// The instance and its volume carry the component tag, and the instance +/// is of a supported type. +const INSTANCE_LAUNCH: Context = &[ + ( + "aws:RequestTag/triple-c:component", + Literal("user-onboarding"), + ), + ("ec2:LaunchTemplate", PROBE_LAUNCH_TEMPLATE_ARN), + ("ec2:InstanceType", Literal("m7i.large")), +]; +const VOLUME_LAUNCH: Context = &[ + ( + "aws:RequestTag/triple-c:component", + Literal("user-onboarding"), + ), + ("ec2:LaunchTemplate", PROBE_LAUNCH_TEMPLATE_ARN), +]; +/// The environment's (component-tagged) tasks group, named by the template. +const SECURITY_GROUP_LAUNCH: Context = &[ + ("ec2:LaunchTemplate", PROBE_LAUNCH_TEMPLATE_ARN), + ("ec2:IsLaunchTemplateResource", Literal("true")), + (COMPONENT_RESOURCE_TAG, Literal("environment")), +]; +/// Amazon's image, named by the template. const AMAZON_IMAGE_FROM_LAUNCH_TEMPLATE: Context = &[ ("ec2:Owner", Literal("amazon")), + ("ec2:LaunchTemplate", PROBE_LAUNCH_TEMPLATE_ARN), + ("ec2:IsLaunchTemplateResource", Literal("true")), +]; +/// A group created with the component tag, its template pinned to a +/// version, of a supported type, with no load balancer. +const GROUP_CREATE: Context = &[ ( - "ec2:LaunchTemplate", - Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"), + "aws:RequestTag/triple-c:component", + Literal("user-onboarding"), ), + ( + "autoscaling:LaunchTemplateVersionSpecified", + Literal("true"), + ), + ("autoscaling:InstanceTypes", Literal("m7i.large")), +]; +const GROUP_UPDATE: Context = &[ + (COMPONENT_RESOURCE_TAG, Literal("user-onboarding")), + ( + "autoscaling:LaunchTemplateVersionSpecified", + Literal("true"), + ), + ("autoscaling:InstanceTypes", Literal("m7i.large")), ]; const PASSED_TO_EC2: Context = &[("iam:PassedToService", Literal("ec2.amazonaws.com"))]; @@ -867,11 +911,6 @@ const ENVIRONMENT_ADMIN_CHECKS: &[Check] = &[ PROBE_LAUNCH_TEMPLATE, COMPONENT_TAGGED, ), - write( - "ec2:ModifyLaunchTemplate", - PROBE_LAUNCH_TEMPLATE, - COMPONENT_TAGGED, - ), write( "ec2:DeleteLaunchTemplate", PROBE_LAUNCH_TEMPLATE, @@ -883,8 +922,8 @@ const ENVIRONMENT_ADMIN_CHECKS: &[Check] = &[ // its template: RunInstances, only from a Triple-C launch template and // only Amazon's images, and the tags the launch puts on. write("ec2:RunInstances", PROBE_LAUNCH_TEMPLATE, COMPONENT_TAGGED), - write("ec2:RunInstances", PROBE_INSTANCE, FROM_LAUNCH_TEMPLATE), - write("ec2:RunInstances", PROBE_VOLUME, FROM_LAUNCH_TEMPLATE), + write("ec2:RunInstances", PROBE_INSTANCE, INSTANCE_LAUNCH), + write("ec2:RunInstances", PROBE_VOLUME, VOLUME_LAUNCH), write( "ec2:RunInstances", PROBE_NETWORK_INTERFACE, @@ -894,7 +933,7 @@ const ENVIRONMENT_ADMIN_CHECKS: &[Check] = &[ write( "ec2:RunInstances", PROBE_SECURITY_GROUP, - FROM_LAUNCH_TEMPLATE, + SECURITY_GROUP_LAUNCH, ), write( "ec2:RunInstances", @@ -916,17 +955,13 @@ const ENVIRONMENT_ADMIN_CHECKS: &[Check] = &[ PROBE_NETWORK_INTERFACE, &[("ec2:CreateAction", Literal("RunInstances"))], ), - // Auto Scaling groups: `triple-c-*`, created with the component tag, - // changed and deleted only when they carry it. + // Auto Scaling groups: `triple-c-*`, created with the component tag + // (and pinned to a template version, of a supported type, with no load + // balancer), changed, tagged and deleted only when they carry it. write( "autoscaling:CreateAutoScalingGroup", PROBE_AUTO_SCALING_GROUP, - COMPONENT_REQUESTED, - ), - write( - "autoscaling:CreateOrUpdateTags", - PROBE_AUTO_SCALING_GROUP, - COMPONENT_REQUESTED, + GROUP_CREATE, ), write( "autoscaling:CreateOrUpdateTags", @@ -936,7 +971,7 @@ const ENVIRONMENT_ADMIN_CHECKS: &[Check] = &[ write( "autoscaling:UpdateAutoScalingGroup", PROBE_AUTO_SCALING_GROUP, - COMPONENT_TAGGED, + GROUP_UPDATE, ), write( "autoscaling:SetInstanceProtection", @@ -1912,9 +1947,6 @@ mod tests { "ecs:SubmitAttachmentStateChanges", "ecs:UpdateContainerInstancesState", "ecs:TagResource", - // Session Manager on the instance. - "ssm:UpdateInstanceInformation", - "ec2messages:GetMessages", ] { assert!( granted.iter().any(|a| glob(a, need)), @@ -1965,11 +1997,19 @@ mod tests { } } - /// The instance role's ECS agent (E4) reaches only Triple-C clusters and - /// their container instances, and tags only the instance it registers. + /// The instance role's ECS agent (E4) reaches only its own cluster — + /// the one its role's `triple-c:cluster` tag names, which must be a + /// `triple-c-*` cluster — and that cluster's container instances, and + /// tags only the instance it registers. A user who is root on their own + /// instance (Docker access) holds that role's credentials, so another + /// user's cluster must be out of its reach: otherwise it could register + /// into it and have the other user's tasks placed on its instance. #[test] - fn the_boundary_keeps_the_ecs_agent_on_triple_c_clusters() { + fn the_boundary_keeps_the_ecs_agent_on_its_own_cluster() { let stmts = statements_of(&boundary()); + const TAG: &str = "aws:PrincipalTag/triple-c:cluster"; + const MINE: Context = &[(TAG, Literal("triple-c-probe-0123456789ab"))]; + const PROD: Context = &[(TAG, Literal("prod"))]; let within = |action: &'static str, resource: &'static str, context: Context| { evaluate_in( &stmts, @@ -1980,41 +2020,81 @@ mod tests { }, ) }; + const CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-probe-0123456789ab"; const INSTANCE: &str = "arn:aws:ecs:{region}:{account}:container-instance/\ triple-c-probe-0123456789ab/0123456789abcdef0123456789abcdef"; - const OTHER_CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/prod"; - const OTHER_INSTANCE: &str = "arn:aws:ecs:{region}:{account}:container-instance/\ + const OTHER_USERS_CLUSTER: &str = + "arn:aws:ecs:{region}:{account}:cluster/triple-c-probe-ba9876543210"; + const OTHER_USERS_INSTANCE: &str = "arn:aws:ecs:{region}:{account}:container-instance/\ + triple-c-probe-ba9876543210/0123456789abcdef0123456789abcdef"; + const PROD_CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/prod"; + const PROD_INSTANCE: &str = "arn:aws:ecs:{region}:{account}:container-instance/\ prod/0123456789abcdef0123456789abcdef"; - const AT_REGISTER: Context = &[("ecs:CreateAction", Literal("RegisterContainerInstance"))]; - for action in [ - "ecs:RegisterContainerInstance", - "ecs:DeregisterContainerInstance", - "ecs:SubmitTaskStateChange", + let at_register = |tag: Context| -> Context { + let mut v = tag.to_vec(); + v.push(("ecs:CreateAction", Literal("RegisterContainerInstance"))); + Box::leak(v.into_boxed_slice()) + }; + for (action, own, other, prod) in [ + ( + "ecs:RegisterContainerInstance", + CLUSTER, + OTHER_USERS_CLUSTER, + PROD_CLUSTER, + ), + ( + "ecs:DeregisterContainerInstance", + CLUSTER, + OTHER_USERS_CLUSTER, + PROD_CLUSTER, + ), + ( + "ecs:SubmitTaskStateChange", + CLUSTER, + OTHER_USERS_CLUSTER, + PROD_CLUSTER, + ), + ("ecs:Poll", INSTANCE, OTHER_USERS_INSTANCE, PROD_INSTANCE), + ( + "ecs:StartTelemetrySession", + INSTANCE, + OTHER_USERS_INSTANCE, + PROD_INSTANCE, + ), + ( + "ecs:UpdateContainerInstancesState", + INSTANCE, + OTHER_USERS_INSTANCE, + PROD_INSTANCE, + ), ] { - assert!(within(action, PROBE_CLUSTER, &[]), "{action}"); - assert!(!within(action, OTHER_CLUSTER, &[]), "{action} elsewhere"); + assert!(within(action, own, MINE), "{action}"); + assert!( + !within(action, other, MINE), + "{action} on another user's cluster" + ); + assert!(!within(action, own, &[]), "{action} without the role tag"); + // A role tagged with a non-Triple-C cluster gets nothing. + assert!( + !within(action, prod, PROD), + "{action} on a non-Triple-C cluster" + ); } - for action in [ - "ecs:Poll", - "ecs:StartTelemetrySession", - "ecs:UpdateContainerInstancesState", - ] { - assert!(within(action, INSTANCE, &[]), "{action}"); - assert!(!within(action, OTHER_INSTANCE, &[]), "{action} elsewhere"); - } - assert!(within("ecs:TagResource", INSTANCE, AT_REGISTER)); - assert!(!within("ecs:TagResource", OTHER_INSTANCE, AT_REGISTER)); + assert!(within("ecs:TagResource", INSTANCE, at_register(MINE))); for (resource, context) in [ - (INSTANCE, &[][..]), - (PROBE_CLUSTER, AT_REGISTER), - (PROBE_TASK, &[][..]), + (OTHER_USERS_INSTANCE, at_register(MINE)), + (PROD_INSTANCE, at_register(PROD)), + (INSTANCE, MINE), + (CLUSTER, at_register(MINE)), + (PROBE_TASK, at_register(MINE)), ] { assert!( !within("ecs:TagResource", resource, context), "ecs:TagResource on {resource} with {context:?}" ); } - // The agent never runs, stops or changes tasks or clusters itself. + // The agent never runs, stops or changes tasks or clusters itself, + // and has no Session Manager channel of its own. for action in [ "ecs:RunTask", "ecs:StartTask", @@ -2023,8 +2103,11 @@ mod tests { "ecs:DeleteCluster", "ecs:ExecuteCommand", ] { - assert!(!within(action, PROBE_CLUSTER, &[]), "{action}"); - assert!(!within(action, PROBE_TASK, &[]), "{action}"); + assert!(!within(action, CLUSTER, MINE), "{action}"); + assert!(!within(action, PROBE_TASK, MINE), "{action}"); + } + for action in ["ssm:UpdateInstanceInformation", "ec2messages:GetMessages"] { + assert!(!within(action, "*", MINE), "{action}"); } } @@ -2457,27 +2540,63 @@ mod tests { #[test] fn per_user_compute_is_tag_and_name_scoped() { let tier = Tier::EnvironmentAdmin; - for (action, resource) in [ - ("ec2:CreateLaunchTemplate", PROBE_LAUNCH_TEMPLATE), - ( + assert!(allowed( + tier, + &write( + "ec2:CreateLaunchTemplate", + PROBE_LAUNCH_TEMPLATE, + COMPONENT_REQUESTED + ), + ME, + ME + )); + assert!(!allowed( + tier, + &write("ec2:CreateLaunchTemplate", PROBE_LAUNCH_TEMPLATE, &[]), + ME, + ME + )); + let untagged_group = without(&GROUP_CREATE, "aws:RequestTag/triple-c:component"); + assert!(!allowed( + tier, + &write( "autoscaling:CreateAutoScalingGroup", PROBE_AUTO_SCALING_GROUP, + untagged_group ), + ME, + ME + )); + // Tags go on a group only once it is Triple-C's: no request-tag-only + // tagging of an existing (untagged) `triple-c-*` group. + assert!(!allowed( + tier, + &write( + "autoscaling:CreateOrUpdateTags", + PROBE_AUTO_SCALING_GROUP, + COMPONENT_REQUESTED + ), + ME, + ME + )); + // The default version never moves: a group on `$Default` would + // launch whatever it points at. + for action in [ + "ec2:ModifyLaunchTemplate", + "ec2:DeleteLaunchTemplateVersions", ] { - assert!(allowed( - tier, - &write(action, resource, COMPONENT_REQUESTED), - ME, - ME - )); assert!( - !allowed(tier, &write(action, resource, &[]), ME, ME), - "untagged {action}" + !allowed( + tier, + &write(action, PROBE_LAUNCH_TEMPLATE, COMPONENT_TAGGED), + ME, + ME + ), + "{action}" ); } for (action, resource) in [ ("ec2:CreateLaunchTemplateVersion", PROBE_LAUNCH_TEMPLATE), - ("ec2:ModifyLaunchTemplate", PROBE_LAUNCH_TEMPLATE), ("ec2:DeleteLaunchTemplate", PROBE_LAUNCH_TEMPLATE), ("ec2:CreateTags", PROBE_LAUNCH_TEMPLATE), ("ec2:DeleteTags", PROBE_LAUNCH_TEMPLATE), @@ -2567,19 +2686,238 @@ mod tests { )); } + /// `context` without `key`. + fn without(context: Context, key: &str) -> Context { + Box::leak( + context + .iter() + .filter(|(k, _)| *k != key) + .copied() + .collect::>() + .into_boxed_slice(), + ) + } + + /// `context` with `key` set to `value` (replacing any value it had). + fn with(context: Context, key: &'static str, value: &'static str) -> Context { + let mut v = without(context, key).to_vec(); + v.push((key, Literal(value))); + Box::leak(v.into_boxed_slice()) + } + + /// The instance types a list in the compute file allows, for each list. + fn policy_instance_type_lists() -> Vec> { + let mut lists = Vec::new(); + for s in allows(Tier::EnvironmentAdmin) { + if let Some(ops) = s["Condition"].as_object() { + for entries in ops.values() { + for key in ["ec2:InstanceType", "autoscaling:InstanceTypes"] { + if let Some(v) = entries.get(key) { + lists.push(strings(v).into_iter().collect()); + } + } + } + } + } + lists + } + + /// The policy allows exactly the instance types the app knows how to + /// size (`ec2_instance_spec`): no GPU, no metal, nothing above 4xlarge. + #[test] + fn supported_instance_types_are_the_apps_table() { + let mut known = BTreeSet::new(); + for family in [ + "m7i", "m7g", "c7i", "c7g", "r7i", "r7g", "t3", "t4g", "m7a", "p5", "g6", + ] { + for size in [ + "medium", + "large", + "xlarge", + "2xlarge", + "4xlarge", + "8xlarge", + "48xlarge", + "metal-24xl", + ] { + let t = format!("{family}.{size}"); + if crate::models::project::ec2_instance_spec(&t).is_some() { + known.insert(t); + } + } + } + assert_eq!(known.len(), 30); + let lists = policy_instance_type_lists(); + assert_eq!(lists.len(), 3, "RunInstances, group create, group update"); + for list in lists { + assert_eq!(list, known); + } + } + + /// Creating or updating a group: pinned to a template version (a group + /// on `$Latest`/`$Default` would launch any later version, whose + /// instance profile was never checked), no load balancers, supported + /// types only. + #[test] + fn groups_are_pinned_supported_and_unbalanced() { + let tier = Tier::EnvironmentAdmin; + for (action, ok) in [ + ("autoscaling:CreateAutoScalingGroup", GROUP_CREATE), + ("autoscaling:UpdateAutoScalingGroup", GROUP_UPDATE), + ] { + let attempt = |context| { + allowed( + tier, + &write(action, PROBE_AUTO_SCALING_GROUP, context), + ME, + ME, + ) + }; + assert!(attempt(ok), "{action}"); + let version = "autoscaling:LaunchTemplateVersionSpecified"; + assert!(!attempt(with(ok, version, "false")), "{action} on $Latest"); + assert!( + !attempt(with( + ok, + "autoscaling:TargetGroupARNs", + "arn:aws:elasticloadbalancing:x" + )), + "{action} with a target group" + ); + assert!( + !attempt(with(ok, "autoscaling:LoadBalancerNames", "web")), + "{action} with a load balancer" + ); + for t in ["p5.48xlarge", "m7i.8xlarge", "m7i.metal-24xl", "g6.xlarge"] { + assert!( + !attempt(with(ok, "autoscaling:InstanceTypes", t)), + "{action} with {t}" + ); + } + } + // Creating always names the template version; an update may leave + // the template alone (a size change, the drain before destroy). + assert!(!allowed( + tier, + &write( + "autoscaling:CreateAutoScalingGroup", + PROBE_AUTO_SCALING_GROUP, + without(GROUP_CREATE, "autoscaling:LaunchTemplateVersionSpecified") + ), + ME, + ME + )); + assert!(allowed( + tier, + &write( + "autoscaling:UpdateAutoScalingGroup", + PROBE_AUTO_SCALING_GROUP, + COMPONENT_TAGGED + ), + ME, + ME + )); + } + /// RunInstances (which creating an Auto Scaling group checks the caller - /// for) works only from a Triple-C launch template, with Amazon's - /// images: never a bare launch, nor someone else's template or image. + /// for) works only from a Triple-C launch template: the instance and + /// its volume tagged and of a supported type, the environment's own + /// security group and Amazon's image, both named by the template. Never + /// a bare launch, nor someone else's template, group or image. #[test] fn instances_launch_only_from_triple_c_launch_templates() { let tier = Tier::EnvironmentAdmin; - for resource in [ - PROBE_INSTANCE, - PROBE_VOLUME, - PROBE_NETWORK_INTERFACE, - PROBE_SUBNET, - PROBE_SECURITY_GROUP, + for (resource, ok) in [ + (PROBE_INSTANCE, INSTANCE_LAUNCH), + (PROBE_VOLUME, VOLUME_LAUNCH), + (PROBE_INSTANCE, without(INSTANCE_LAUNCH, "ec2:InstanceType")), ] { + assert!(allowed( + tier, + &write("ec2:RunInstances", resource, ok), + ME, + ME + )); + assert!( + !allowed( + tier, + &write( + "ec2:RunInstances", + resource, + without(ok, "aws:RequestTag/triple-c:component") + ), + ME, + ME + ), + "untagged {resource}" + ); + } + for t in [ + "p5.48xlarge", + "m7i.8xlarge", + "m7i.metal-24xl", + "inf2.xlarge", + ] { + assert!( + !allowed( + tier, + &write( + "ec2:RunInstances", + PROBE_INSTANCE, + with(INSTANCE_LAUNCH, "ec2:InstanceType", t) + ), + ME, + ME + ), + "{t}" + ); + } + for (resource, ok) in [ + (PROBE_SECURITY_GROUP, SECURITY_GROUP_LAUNCH), + (PROBE_IMAGE, AMAZON_IMAGE_FROM_LAUNCH_TEMPLATE), + ] { + assert!(allowed( + tier, + &write("ec2:RunInstances", resource, ok), + ME, + ME + )); + // A request override (not the template's) is refused. + assert!(!allowed( + tier, + &write( + "ec2:RunInstances", + resource, + with(ok, "ec2:IsLaunchTemplateResource", "false") + ), + ME, + ME + )); + assert!(!allowed( + tier, + &write( + "ec2:RunInstances", + resource, + without(ok, "ec2:IsLaunchTemplateResource") + ), + ME, + ME + )); + } + assert!( + !allowed( + tier, + &write( + "ec2:RunInstances", + PROBE_SECURITY_GROUP, + without(SECURITY_GROUP_LAUNCH, COMPONENT_RESOURCE_TAG) + ), + ME, + ME + ), + "someone else's security group" + ); + for resource in [PROBE_NETWORK_INTERFACE, PROBE_SUBNET] { assert!(allowed( tier, &write("ec2:RunInstances", resource, FROM_LAUNCH_TEMPLATE), diff --git a/app/src-tauri/src/aws/policy_eval.rs b/app/src-tauri/src/aws/policy_eval.rs index fa3ab92..a804c1c 100644 --- a/app/src-tauri/src/aws/policy_eval.rs +++ b/app/src-tauri/src/aws/policy_eval.rs @@ -208,7 +208,8 @@ pub(crate) fn conditions_hold(stmt: &Value, req: &Request) -> bool { // A negated operator holds when the key is absent, and // otherwise when no value matches. let (matches, negated): (fn(&str, &str) -> bool, bool) = match base { - "StringEquals" => (|p, v| p == v, false), + // IAM's Bool compares "true"/"false"; the checks send strings. + "StringEquals" | "Bool" => (|p, v| p == v, false), "StringLike" | "ArnLike" => (glob, false), "StringNotEquals" => (|p, v| p == v, true), "StringNotLike" => (glob, true), @@ -268,6 +269,37 @@ mod tests { assert!(!glob(&literal, "arn:aws:ec2:us-west-2:1:elastic-ip/eipalloc-1")); } + #[test] + fn bool_needs_the_key_and_bool_if_exists_does_not() { + let stmt = |op: &str| -> Value { + serde_json::json!({ + "Sid": "T", "Effect": "Allow", "Action": "x:Y", "Resource": "*", + "Condition": { op: { "k:Pinned": "true" } } + }) + }; + let holds = |op: &str, context| { + let c = Check { + action: "x:Y", + resource: "*", + context, + write: true, + }; + conditions_hold( + &stmt(op), + &Request { + check: &c, + caller: ME, + owner: ME, + }, + ) + }; + assert!(holds("Bool", &[("k:Pinned", Literal("true"))])); + assert!(!holds("Bool", &[("k:Pinned", Literal("false"))])); + assert!(!holds("Bool", &[])); + assert!(holds("BoolIfExists", &[])); + assert!(!holds("BoolIfExists", &[("k:Pinned", Literal("false"))])); + } + #[test] fn for_all_values_is_vacuous_on_an_absent_key() { let stmt: Value = serde_json::json!({ diff --git a/app/src-tauri/src/aws/tofu_modules/tests.rs b/app/src-tauri/src/aws/tofu_modules/tests.rs index 575f6a3..b1a9a31 100644 --- a/app/src-tauri/src/aws/tofu_modules/tests.rs +++ b/app/src-tauri/src/aws/tofu_modules/tests.rs @@ -1892,7 +1892,7 @@ const MODULE_CALLS: &[(&str, &[Check])] = &[ ("backend.s3", BACKEND), ]; -// Phase 7 (per-user EC2 capacity, E1–E5, E11): the calls the onboarding +// Phase 7 (per-user EC2 capacity, E1–E5, E11; fix round 1): the calls the onboarding // module's EC2 resources will make, written down with the policy (Task 2) // before the resources exist. Task 3 moves each entry into MODULE_CALLS // under its type (merging with the existing `aws_ecs_cluster`, @@ -1925,12 +1925,46 @@ const FROM_TEMPLATE: Context = &[( "ec2:LaunchTemplate", Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"), )]; +const LT_ARN: ContextValue = + Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"); +/// The template's tag specifications tag the instance and its volume. +const TAGGED_INSTANCE: Context = &[ + (REQUEST_COMPONENT, Literal("user-onboarding")), + ("ec2:LaunchTemplate", LT_ARN), + ("ec2:InstanceType", Literal("m7i.large")), +]; +const TAGGED_VOLUME: Context = &[ + (REQUEST_COMPONENT, Literal("user-onboarding")), + ("ec2:LaunchTemplate", LT_ARN), +]; +/// The environment's tasks group, named in the template. +const TEMPLATE_GROUP: Context = &[ + ("ec2:LaunchTemplate", LT_ARN), + ("ec2:IsLaunchTemplateResource", Literal("true")), + (RESOURCE_COMPONENT, Literal("environment")), +]; const AMAZON_IMAGE: Context = &[ ("ec2:Owner", Literal("amazon")), + ("ec2:LaunchTemplate", LT_ARN), + ("ec2:IsLaunchTemplateResource", Literal("true")), +]; +/// The group pins the template to a version (`latest_version`, never +/// `$Latest`/`$Default`) and has no load balancer. +const GROUP_CREATE: Context = &[ + (REQUEST_COMPONENT, Literal("user-onboarding")), ( - "ec2:LaunchTemplate", - Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"), + "autoscaling:LaunchTemplateVersionSpecified", + Literal("true"), ), + ("autoscaling:InstanceTypes", Literal("m7i.large")), +]; +const GROUP_UPDATE: Context = &[ + (RESOURCE_COMPONENT, Literal("user-onboarding")), + ( + "autoscaling:LaunchTemplateVersionSpecified", + Literal("true"), + ), + ("autoscaling:InstanceTypes", Literal("m7i.large")), ]; const TO_EC2: Context = &[("iam:PassedToService", Literal("ec2.amazonaws.com"))]; @@ -2003,7 +2037,6 @@ const EC2_COMPUTE_CALLS: &[(&str, &[Check])] = &[ LAUNCH_TEMPLATE, USER_TAGGED, ), - call("ec2:ModifyLaunchTemplate", LAUNCH_TEMPLATE, USER_TAGGED), call("ec2:CreateTags", LAUNCH_TEMPLATE, USER_TAGGED), call("ec2:DeleteTags", LAUNCH_TEMPLATE, USER_TAGGED), call("ec2:DeleteLaunchTemplate", LAUNCH_TEMPLATE, USER_TAGGED), @@ -2021,12 +2054,7 @@ const EC2_COMPUTE_CALLS: &[(&str, &[Check])] = &[ call( "autoscaling:CreateAutoScalingGroup", AUTO_SCALING_GROUP, - USER_CREATE, - ), - call( - "autoscaling:CreateOrUpdateTags", - AUTO_SCALING_GROUP, - USER_CREATE, + GROUP_CREATE, ), call( "iam:CreateServiceLinkedRole", @@ -2034,11 +2062,11 @@ const EC2_COMPUTE_CALLS: &[(&str, &[Check])] = &[ &[("iam:AWSServiceName", Literal("autoscaling.amazonaws.com"))], ), call("ec2:RunInstances", LAUNCH_TEMPLATE, USER_TAGGED), - call("ec2:RunInstances", INSTANCE, FROM_TEMPLATE), - call("ec2:RunInstances", VOLUME, FROM_TEMPLATE), + call("ec2:RunInstances", INSTANCE, TAGGED_INSTANCE), + call("ec2:RunInstances", VOLUME, TAGGED_VOLUME), call("ec2:RunInstances", ENI, FROM_TEMPLATE), call("ec2:RunInstances", SUBNET, FROM_TEMPLATE), - call("ec2:RunInstances", SG, FROM_TEMPLATE), + call("ec2:RunInstances", SG, TEMPLATE_GROUP), call("ec2:RunInstances", IMAGE, AMAZON_IMAGE), call("ec2:CreateTags", INSTANCE, created_by!("RunInstances")), call("ec2:CreateTags", VOLUME, created_by!("RunInstances")), @@ -2046,6 +2074,12 @@ const EC2_COMPUTE_CALLS: &[(&str, &[Check])] = &[ call("iam:PassRole", INSTANCE_ROLE, TO_EC2), call("autoscaling:DescribeAutoScalingGroups", "*", NONE), call("autoscaling:DescribeScalingActivities", "*", NONE), + call( + "autoscaling:UpdateAutoScalingGroup", + AUTO_SCALING_GROUP, + GROUP_UPDATE, + ), + // The drain before destroy leaves the template alone. call( "autoscaling:UpdateAutoScalingGroup", AUTO_SCALING_GROUP, @@ -2073,6 +2107,9 @@ const EC2_COMPUTE_CALLS: &[(&str, &[Check])] = &[ "aws_iam_role (instance)", &[ call("iam:CreateRole", INSTANCE_ROLE, BOUNDED), + // `triple-c:cluster = `: the boundary keeps + // the ECS agent on that cluster. + call("iam:TagRole", INSTANCE_ROLE, NONE), call("iam:PutRolePolicy", INSTANCE_ROLE, BOUNDED), call("iam:GetRole", INSTANCE_ROLE, NONE), call("iam:ListInstanceProfilesForRole", INSTANCE_ROLE, NONE), diff --git a/aws/README.md b/aws/README.md index 80d2c8b..7b5d4d7 100644 --- a/aws/README.md +++ b/aws/README.md @@ -147,9 +147,16 @@ and nothing runs with more than the admin holds. It covers: `/triple-c/users//`); - per-user EC2 capacity (`environment-admin-compute.json`, phase 7): the user's own `triple-c--` cluster and capacity provider, a component-tagged launch template - and `triple-c-*` Auto Scaling group, the `triple-c-*` instance profile, passing - `triple-c-*-instance` roles to EC2, reading the ECS-optimized AMI's public SSM parameter, and - the Auto Scaling and ECS service-linked roles. + and `triple-c-*` Auto Scaling group (pinned to a template version, no load balancer, supported + instance types only), the `triple-c-*` instance profile, passing `triple-c-*-instance` roles to + EC2, reading the ECS-optimized AMI's public SSM parameter, and the Auto Scaling and ECS + service-linked roles. + +**Supported instance types.** Launches and groups are limited to the types the app sizes +(`ec2_instance_spec` in `models/project.rs`, pinned to the policy by a test): `m7i`, `m7g`, `c7i`, +`c7g`, `r7i`, `r7g` in `large` to `4xlarge`, and `t3`, `t4g` in `large` to `2xlarge`. No GPU, +accelerator or metal types. An onboarding with any other type is denied at apply; supporting one +means adding it to that table and to the three lists in the compute file together. **Clearing workspace task definitions.** Removing a project leaves its revisions registered (family `triple-c---`). The admin tier may deregister any @@ -165,8 +172,10 @@ Deregistered revisions become INACTIVE; ECS keeps them until they are deleted wi A task still running from a revision keeps running. Not in the policy: ECR (tasks pull from GHCR). Phase 7's EC2 capacity added custom ECS capacity -providers and passing roles to EC2, the latter only for `triple-c-*-instance` roles (task and -execution roles still go to `ecs-tasks.amazonaws.com` only). +providers and passing roles to EC2. The `triple-c-*-instance` name on that PassRole keeps a +user's task and execution roles from being handed to an instance by mistake; it is **not** a +fence against the admin, who can create a bounded role under any `triple-c-*` name. What fences +an instance role is the permissions boundary, as for every Triple-C role. ### What each module resource needs @@ -204,9 +213,9 @@ the proof; an action it shows missing is added to the table, the policy, the che | `aws_ecs_cluster` (the user's) | as the environment's cluster, on `cluster/triple-c--` | | `aws_ecs_capacity_provider` | `ecs:CreateCapacityProvider`, `TagResource` (at create), `ListTagsForResource`, `UpdateCapacityProvider`, `UntagResource`, `DeleteCapacityProvider` (`capacity-provider/triple-c-*`), `DescribeCapacityProviders` (`*`); `iam:CreateServiceLinkedRole` for `ecs.amazonaws.com` (managed scaling runs as ECS's service-linked role) | | `aws_ecs_cluster_capacity_providers` (the user's) | `ecs:PutClusterCapacityProviders` (the cluster and, expected, the capacity provider) | -| `aws_launch_template` | `ec2:CreateLaunchTemplate` (request tag), `CreateTags` (at create), `CreateLaunchTemplateVersion`, `ModifyLaunchTemplate`, `CreateTags`/`DeleteTags`, `DeleteLaunchTemplate` (tagged), `Describe*` | -| `aws_autoscaling_group` | `autoscaling:CreateAutoScalingGroup`, `CreateOrUpdateTags` (`triple-c-*`, request tag), `UpdateAutoScalingGroup`, `SetInstanceProtection`, `CreateOrUpdateTags`/`DeleteTags`, `DeleteAutoScalingGroup` (tagged), `Describe*` (`*`); `iam:CreateServiceLinkedRole` for `autoscaling.amazonaws.com`. Creating a group checks that the caller could launch its template: `ec2:RunInstances` on the tagged launch template, on instance, volume, network interface, subnet and security group only with `ec2:LaunchTemplate` set, and on images only Amazon's (`ec2:Owner = amazon`); `ec2:CreateTags` at `RunInstances`; `iam:PassRole` of the instance role to `ec2.amazonaws.com`. ASG tags are **not** the provider's `default_tags`: the module must set the component tag on the group itself | -| `aws_iam_role` (instance), `aws_iam_role_policy` | as the other per-user roles (bounded), on `triple-c---instance` | +| `aws_launch_template` | `ec2:CreateLaunchTemplate` (request tag), `CreateTags` (at create), `CreateLaunchTemplateVersion`, `CreateTags`/`DeleteTags`, `DeleteLaunchTemplate` (tagged), `Describe*`. Never `ModifyLaunchTemplate`: the default version never moves (the module must not set `update_default_version` or `default_version`) | +| `aws_autoscaling_group` | `autoscaling:CreateAutoScalingGroup` (`triple-c-*`, request tag, `autoscaling:LaunchTemplateVersionSpecified = true`, no `TargetGroupARNs`/`LoadBalancerNames`, `autoscaling:InstanceTypes` supported), `UpdateAutoScalingGroup` (tagged; the same, except that an update which leaves the template alone passes the version check), `SetInstanceProtection`, `CreateOrUpdateTags`/`DeleteTags`, `DeleteAutoScalingGroup` (tagged), `Describe*` (`*`); `iam:CreateServiceLinkedRole` for `autoscaling.amazonaws.com`. Creating a group checks that the caller could launch its template: `ec2:RunInstances` on the tagged launch template; on the instance and its volume only with the component request tag, `ec2:LaunchTemplate` set and (instance) a supported `ec2:InstanceType`; on the network interface and subnet with `ec2:LaunchTemplate`; on the security group only the template's own (`ec2:IsLaunchTemplateResource`) component-tagged group; on images only Amazon's, named by the template; `ec2:CreateTags` at `RunInstances`; `iam:PassRole` of the instance role to `ec2.amazonaws.com`. ASG tags are **not** the provider's `default_tags`: the module must set the component tag on the group itself | +| `aws_iam_role` (instance), `aws_iam_role_policy` | as the other per-user roles (bounded), on `triple-c---instance`, tagged `triple-c:cluster = triple-c--` (`iam:TagRole`) | | `aws_iam_instance_profile` | `iam:CreateInstanceProfile`, `TagInstanceProfile`, `AddRoleToInstanceProfile` (expected to need `iam:PassRole` of the role too), `GetInstanceProfile`, `ListInstanceProfileTags`, `UntagInstanceProfile`, `RemoveRoleFromInstanceProfile`, `DeleteInstanceProfile` (`instance-profile/triple-c-*`) | | `data.aws_ssm_parameter` (AMI) | `ssm:GetParameter`/`GetParameters` on the public `parameter/aws/service/ecs/optimized-ami/*` | | `aws_ssm_parameter` (user record) | as the environment record, on `/triple-c/users//` | @@ -242,11 +251,17 @@ the role carries the `triple-c-permissions-boundary` managed policy as its permi - invoking Bedrock models; - for a user's EC2 instance role (phase 7, E4): the ECS agent's calls (`RegisterContainerInstance`, `DeregisterContainerInstance`, `Poll`, `StartTelemetrySession`, - `Submit*`, `UpdateContainerInstancesState`) only on `triple-c-*` clusters and their container - instances, `ecs:TagResource` only on such a container instance as it registers - (`ecs:CreateAction = RegisterContainerInstance`), `ecs:DiscoverPollEndpoint`, and Session - Manager on the instance (`ssm:UpdateInstanceInformation`, the six `ec2messages:` actions) for an - admin's troubleshooting. ECS Exec into an EC2 task uses the task role, as on Fargate. + `Submit*`, `UpdateContainerInstancesState`) only on **the role's own cluster**, the one its + `triple-c:cluster` tag names (`cluster/${aws:PrincipalTag/triple-c:cluster}` and that + cluster's container instances; the tag must match `triple-c-*`), `ecs:TagResource` only on + such a container instance as it registers (`ecs:CreateAction = RegisterContainerInstance`), + and `ecs:DiscoverPollEndpoint`. A user with Docker access is root on their own instance and + so holds its role's credentials; the tag keeps them from registering that instance into + another user's cluster (and so having that user's tasks placed on it). An untagged instance + role can do nothing with ECS. The admin sets the tag when it creates the role (the admin + tier already tags `triple-c-*` roles freely, and a workspace user cannot tag roles at all). + **No Session Manager on the instance** (plan E4 amended in fix round 1): nobody is granted + host sessions, and ECS Exec into an EC2 task uses the task role, as on Fargate. - The boundary grants nothing in IAM. - Explicit Deny statements stop the admin from: - removing the boundary from a `triple-c-*` role; @@ -264,9 +279,13 @@ created only *inside* a Triple-C (tagged) VPC, subnet and address, and an intern attached, a route added or a route table associated only on tagged ones, so the admin cannot re-route a VPC that isn't Triple-C's. Tagging is allowed only as part of the creating call (`ec2:CreateAction`, `elasticfilesystem:CreateAction`), or on a resource that is already -Triple-C's. Launch templates (phase 7) are created only with the component tag and changed, -launched from or deleted only when they carry it; Auto Scaling groups must be named `triple-c-*` -and also carry it (request tag to create, resource tag to change, protect or delete). Resources +Triple-C's. Launch templates (phase 7) are created only with the component tag and versioned, +launched from or deleted only when they carry it; their default version never changes. Auto +Scaling groups must be named `triple-c-*` and also carry it (request tag to create; resource tag +to change, protect, tag or delete, so an existing untagged `triple-c-*` group can't be claimed by +tagging it). A group must name its template's version explicitly: a group on `$Latest` or +`$Default` would launch any later version, whose instance profile nobody checked, as Auto +Scaling's service-linked role. Resources that cannot carry a tag are authorized through one that does: routes and route-table associations through the route table (and subnet), mount targets and the file-system policy through the file system, KMS aliases through the key, role policies through the @@ -305,12 +324,14 @@ account-wide: and mount targets are created and deleted under this statement alone. - Reads on `*`: `ec2:Describe*`, `elasticfilesystem:Describe*`, the KMS key reads and `ListAliases`, `logs:DescribeLogGroups` and `ssm:DescribeParameters`. -- `ec2:RunInstances` on instances, volumes, network interfaces, subnets and security groups - anywhere, as long as the launch comes from a launch template (`ec2:LaunchTemplate`), whose own - side must be a component-tagged template, and with Amazon's images only. The subnets and groups - are not tag-checked because an `existing`-network environment's are the user's own. The admin - never calls `RunInstances` itself: creating an Auto Scaling group checks that the caller could, - and the group's launches run as Auto Scaling's service-linked role. +- `ec2:RunInstances`, directly as well as through a group: only from a component-tagged launch + template, the instance and its volume carrying the component tag, a supported instance type, + Amazon's image and the environment's (tagged) security group, both as the template names them + (`ec2:IsLaunchTemplateResource`), and only a `triple-c-*-instance` role passed. The network + interface and **subnet are not tag-checked**: the group supplies the subnets (not the template), + and an `existing`-network environment's subnets are the user's own, untagged. The modules never + call `RunInstances` themselves: creating a group checks that the caller could, and the group's + launches run as Auto Scaling's service-linked role. - `iam:CreateServiceLinkedRole`, only for `autoscaling.amazonaws.com` and `ecs.amazonaws.com` (AWS fixes those roles' policies). - Reads on `*`: `autoscaling:Describe*`, `ecs:DescribeCapacityProviders`; and the public @@ -437,8 +458,8 @@ aws iam create-policy --policy-name triple-c-permissions-boundary \ --policy-document file://policies/permissions-boundary.json ``` -**Phase 7 changed the boundary** (version 2: the instance role's ECS agent and Session Manager -actions). An account administrator re-applies it once (the boundary module from the app, or +**Phase 7 changed the boundary** (version 2: the instance role's ECS agent, on the cluster its +`triple-c:cluster` tag names). An account administrator re-applies it once (the boundary module from the app, or `aws iam create-policy-version --policy-arn arn:aws:iam:::policy/triple-c-permissions-boundary --policy-document file://policies/permissions-boundary.json --set-as-default`) before anyone onboards with EC2 capacity; Fargate users are unaffected. The module tags the policy @@ -458,7 +479,7 @@ environment admin needs every tier file (about 20,200), and a user's share 2,048 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,293 (including `ReadFargatePrices`), `environment-admin.json` 5,805 (339), `environment-admin-network.json` 3,340, -`environment-admin-compute.json` 3,705 and `permissions-boundary.json` 2,625; a unit test (`every_policy_fits_a_managed_policy`) +`environment-admin-compute.json` 6,020 (124) and `permissions-boundary.json` 2,651; 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. @@ -531,6 +552,30 @@ expected, not verified: `container-instance//` and the rest against the cluster; the boundary allows both. - **The public AMI parameter's ARN** has no account (`arn:aws:ssm:::parameter/aws/…`); `arn:aws:ssm:*::parameter/aws/service/ecs/optimized-ami/*` is expected to match it. +- **Version pinning.** `autoscaling:LaunchTemplateVersionSpecified` is expected to be `true` for a + numeric version and `false` for `$Latest`/`$Default`, and absent on an update that names no + template (allowed by `BoolIfExists`, so the drain before destroy works). Probe: create a group + with `$Latest` as the admin; it must be denied. +- **`ec2:IsLaunchTemplateResource`** is expected to be `true` on the image and security group the + template names, and `aws:RequestTag` to carry the template's tag specifications for the instance + and volume. If the group's launch check doesn't send either, that statement denies the create. +- **`autoscaling:InstanceTypes`** is expected to be absent (vacuously allowed) unless a request + names instance types (a mixed-instances override); the instance type itself is enforced at + `RunInstances`. +- **Tags at group create.** If `CreateAutoScalingGroup` with tags also needs + `autoscaling:CreateOrUpdateTags`, it is denied (that is allowed only on an already-tagged + group); then add it to the create statement with the same conditions. +- **A `triple-c-*` capacity provider pointing at someone else's group.** Whether + `CreateCapacityProvider` checks the caller's rights on the named Auto Scaling group is unknown; + if it does not, an admin could put a non-Triple-C group under a Triple-C capacity provider (and + ECS's managed scaling would then scale it). Probe: create one naming an untagged group. +- **`aws:PrincipalTag` for the instance role**: the role's session is expected to carry its role + tags, so `${aws:PrincipalTag/triple-c:cluster}` resolves for the agent's calls. +- **IMDS and Docker access.** Tasks use `awsvpc`, with `ECS_AWSVPC_BLOCK_IMDS=true` and a hop + limit of 1 so a task can't read the instance role. A project with Docker access mounts the + host's socket, so its user can start a host-network container and read IMDS (and so the + instance role): accepted, since Docker access is root on the user's own instance; the boundary + keeps that role on the user's own cluster. **Phase 6** diff --git a/aws/policies/environment-admin-compute.json b/aws/policies/environment-admin-compute.json index 0f31763..1adfa35 100644 --- a/aws/policies/environment-admin-compute.json +++ b/aws/policies/environment-admin-compute.json @@ -58,7 +58,6 @@ "Effect": "Allow", "Action": [ "ec2:CreateLaunchTemplateVersion", - "ec2:ModifyLaunchTemplate", "ec2:DeleteLaunchTemplate", "ec2:CreateTags", "ec2:DeleteTags", @@ -74,21 +73,92 @@ } }, { - "Sid": "LaunchOnlyFromLaunchTemplates", + "Sid": "LaunchSupportedInstances", "Effect": "Allow", "Action": [ "ec2:RunInstances" ], "Resource": [ "arn:aws:ec2:*:*:instance/*", - "arn:aws:ec2:*:*:volume/*", + "arn:aws:ec2:*:*:volume/*" + ], + "Condition": { + "Null": { + "aws:RequestTag/triple-c:component": "false" + }, + "ArnLike": { + "ec2:LaunchTemplate": "arn:aws:ec2:*:*:launch-template/*" + }, + "StringEqualsIfExists": { + "ec2:InstanceType": [ + "m7i.large", + "m7i.xlarge", + "m7i.2xlarge", + "m7i.4xlarge", + "m7g.large", + "m7g.xlarge", + "m7g.2xlarge", + "m7g.4xlarge", + "c7i.large", + "c7i.xlarge", + "c7i.2xlarge", + "c7i.4xlarge", + "c7g.large", + "c7g.xlarge", + "c7g.2xlarge", + "c7g.4xlarge", + "r7i.large", + "r7i.xlarge", + "r7i.2xlarge", + "r7i.4xlarge", + "r7g.large", + "r7g.xlarge", + "r7g.2xlarge", + "r7g.4xlarge", + "t3.large", + "t3.xlarge", + "t3.2xlarge", + "t4g.large", + "t4g.xlarge", + "t4g.2xlarge" + ] + } + } + }, + { + "Sid": "LaunchIntoSubnets", + "Effect": "Allow", + "Action": [ + "ec2:RunInstances" + ], + "Resource": [ "arn:aws:ec2:*:*:network-interface/*", - "arn:aws:ec2:*:*:subnet/*", + "arn:aws:ec2:*:*:subnet/*" + ], + "Condition": { + "ArnLike": { + "ec2:LaunchTemplate": "arn:aws:ec2:*:*:launch-template/*" + } + } + }, + { + "Sid": "LaunchWithTripleCGroups", + "Effect": "Allow", + "Action": [ + "ec2:RunInstances" + ], + "Resource": [ "arn:aws:ec2:*:*:security-group/*" ], "Condition": { "ArnLike": { "ec2:LaunchTemplate": "arn:aws:ec2:*:*:launch-template/*" + }, + "Bool": { + "ec2:IsLaunchTemplateResource": "true" + }, + "Null": { + "aws:ResourceTag/triple-c:component": "false" } } }, @@ -107,22 +177,117 @@ }, "ArnLike": { "ec2:LaunchTemplate": "arn:aws:ec2:*:*:launch-template/*" + }, + "Bool": { + "ec2:IsLaunchTemplateResource": "true" } } }, { - "Sid": "CreateTaggedAutoScalingGroups", + "Sid": "CreatePinnedGroups", "Effect": "Allow", "Action": [ - "autoscaling:CreateAutoScalingGroup", - "autoscaling:CreateOrUpdateTags" + "autoscaling:CreateAutoScalingGroup" ], "Resource": [ "arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/triple-c-*" ], "Condition": { "Null": { - "aws:RequestTag/triple-c:component": "false" + "aws:RequestTag/triple-c:component": "false", + "autoscaling:TargetGroupARNs": "true", + "autoscaling:LoadBalancerNames": "true" + }, + "Bool": { + "autoscaling:LaunchTemplateVersionSpecified": "true" + }, + "ForAllValues:StringEquals": { + "autoscaling:InstanceTypes": [ + "m7i.large", + "m7i.xlarge", + "m7i.2xlarge", + "m7i.4xlarge", + "m7g.large", + "m7g.xlarge", + "m7g.2xlarge", + "m7g.4xlarge", + "c7i.large", + "c7i.xlarge", + "c7i.2xlarge", + "c7i.4xlarge", + "c7g.large", + "c7g.xlarge", + "c7g.2xlarge", + "c7g.4xlarge", + "r7i.large", + "r7i.xlarge", + "r7i.2xlarge", + "r7i.4xlarge", + "r7g.large", + "r7g.xlarge", + "r7g.2xlarge", + "r7g.4xlarge", + "t3.large", + "t3.xlarge", + "t3.2xlarge", + "t4g.large", + "t4g.xlarge", + "t4g.2xlarge" + ] + } + } + }, + { + "Sid": "UpdatePinnedGroups", + "Effect": "Allow", + "Action": [ + "autoscaling:UpdateAutoScalingGroup" + ], + "Resource": [ + "arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/triple-c-*" + ], + "Condition": { + "Null": { + "aws:ResourceTag/triple-c:component": "false", + "autoscaling:TargetGroupARNs": "true", + "autoscaling:LoadBalancerNames": "true" + }, + "BoolIfExists": { + "autoscaling:LaunchTemplateVersionSpecified": "true" + }, + "ForAllValues:StringEquals": { + "autoscaling:InstanceTypes": [ + "m7i.large", + "m7i.xlarge", + "m7i.2xlarge", + "m7i.4xlarge", + "m7g.large", + "m7g.xlarge", + "m7g.2xlarge", + "m7g.4xlarge", + "c7i.large", + "c7i.xlarge", + "c7i.2xlarge", + "c7i.4xlarge", + "c7g.large", + "c7g.xlarge", + "c7g.2xlarge", + "c7g.4xlarge", + "r7i.large", + "r7i.xlarge", + "r7i.2xlarge", + "r7i.4xlarge", + "r7g.large", + "r7g.xlarge", + "r7g.2xlarge", + "r7g.4xlarge", + "t3.large", + "t3.xlarge", + "t3.2xlarge", + "t4g.large", + "t4g.xlarge", + "t4g.2xlarge" + ] } } }, @@ -130,7 +295,6 @@ "Sid": "ManageTripleCAutoScalingGroups", "Effect": "Allow", "Action": [ - "autoscaling:UpdateAutoScalingGroup", "autoscaling:SetInstanceProtection", "autoscaling:CreateOrUpdateTags", "autoscaling:DeleteTags", diff --git a/aws/policies/permissions-boundary.json b/aws/policies/permissions-boundary.json index de69b2c..c198a0f 100644 --- a/aws/policies/permissions-boundary.json +++ b/aws/policies/permissions-boundary.json @@ -118,7 +118,7 @@ ] }, { - "Sid": "EcsAgentOnTripleCClusters", + "Sid": "EcsAgentOnItsOwnCluster", "Effect": "Allow", "Action": [ "ecs:RegisterContainerInstance", @@ -129,9 +129,14 @@ "ecs:UpdateContainerInstancesState" ], "Resource": [ - "arn:aws:ecs:*:*:cluster/triple-c-*", - "arn:aws:ecs:*:*:container-instance/triple-c-*/*" - ] + "arn:aws:ecs:*:*:cluster/${aws:PrincipalTag/triple-c:cluster}", + "arn:aws:ecs:*:*:container-instance/${aws:PrincipalTag/triple-c:cluster}/*" + ], + "Condition": { + "StringLike": { + "aws:PrincipalTag/triple-c:cluster": "triple-c-*" + } + } }, { "Sid": "EcsAgentTagsItsInstance", @@ -140,26 +145,22 @@ "ecs:TagResource" ], "Resource": [ - "arn:aws:ecs:*:*:container-instance/triple-c-*/*" + "arn:aws:ecs:*:*:container-instance/${aws:PrincipalTag/triple-c:cluster}/*" ], "Condition": { "StringEquals": { "ecs:CreateAction": "RegisterContainerInstance" + }, + "StringLike": { + "aws:PrincipalTag/triple-c:cluster": "triple-c-*" } } }, { - "Sid": "InstanceAgents", + "Sid": "EcsAgentDiscovery", "Effect": "Allow", "Action": [ - "ecs:DiscoverPollEndpoint", - "ssm:UpdateInstanceInformation", - "ec2messages:AcknowledgeMessage", - "ec2messages:DeleteMessage", - "ec2messages:FailMessage", - "ec2messages:GetEndpoint", - "ec2messages:GetMessages", - "ec2messages:SendReply" + "ecs:DiscoverPollEndpoint" ], "Resource": [ "*" -- 2.52.0 From 9829ff0c43bc5837a69597991ed42ab8e31e0e3a Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 13:44:55 -0800 Subject: [PATCH 06/29] feat(aws): per-user EC2 clusters keyed by the triple-c-user principal tag Fix round 2 for the phase 7 policies (amends plan E1): - Per-user EC2 names: triple-c---u- for the cluster, capacity provider, Auto Scaling group and launch template (user_ec2_stem, validate_ec2_user_tag; `--` can't occur in environment names or user tags, so the patterns are unambiguous); the instance role/profile stay owner-key named (user_instance_role_name, <= 64). - workspace-user-tasks.json: RunTask/StartTask on a triple-c-*--u-* cluster is denied unless it is the caller's own (${aws:PrincipalTag/triple-c-user}), and denied without the tag. - Admin: capacity providers and groups narrowed to triple-c-*--u-*; the boundary's agent cluster tag must match triple-c-*--u-*. - Instance-type fail-open closed: ec2:InstanceType required (StringEquals, volumes in their own statement); group create requires autoscaling:InstanceTypes present. - The compute file is split: environment-admin-scaling.json (groups, instance profiles, service-linked roles) is the admin tier's fourth file. - Evaluator learns ArnNotLike. README: triple-c-user setup, sizes, still-open probes. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/policies.rs | 151 ++++++++++++--- app/src-tauri/src/aws/policy_eval.rs | 2 +- app/src-tauri/src/aws/tofu_modules.rs | 48 +++++ app/src-tauri/src/aws/tofu_modules/tests.rs | 74 +++++++- app/src-tauri/src/commands/host_commands.rs | 3 +- aws/README.md | 78 ++++++-- aws/policies/environment-admin-compute.json | 198 +++----------------- aws/policies/environment-admin-scaling.json | 179 ++++++++++++++++++ aws/policies/permissions-boundary.json | 4 +- aws/policies/workspace-user-tasks.json | 38 ++++ 10 files changed, 551 insertions(+), 224 deletions(-) create mode 100644 aws/policies/environment-admin-scaling.json diff --git a/app/src-tauri/src/aws/policies.rs b/app/src-tauri/src/aws/policies.rs index e0120a8..b1984c5 100644 --- a/app/src-tauri/src/aws/policies.rs +++ b/app/src-tauri/src/aws/policies.rs @@ -38,6 +38,10 @@ pub fn policy_files(tier: Tier) -> &'static [(&'static str, &'static str)] { "environment-admin-compute.json", include_str!("../../../../aws/policies/environment-admin-compute.json"), ), + ( + "environment-admin-scaling.json", + include_str!("../../../../aws/policies/environment-admin-scaling.json"), + ), ], Tier::WorkspaceUser => &[ ( @@ -214,7 +218,7 @@ const PROBE_STATE_OBJECT: &str = const PROBE_BOUNDARY: &str = "arn:aws:iam::{account}:policy/triple-c-permissions-boundary"; // Per-user EC2 capacity (phase 7, `environment-admin-compute.json`). const PROBE_CAPACITY_PROVIDER: &str = - "arn:aws:ecs:{region}:{account}:capacity-provider/triple-c-probe"; + "arn:aws:ecs:{region}:{account}:capacity-provider/triple-c-probe--u-alice"; const PROBE_LAUNCH_TEMPLATE: &str = "arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"; const PROBE_INSTANCE: &str = "arn:aws:ec2:{region}:{account}:instance/i-00000000000000000"; @@ -222,7 +226,7 @@ const PROBE_VOLUME: &str = "arn:aws:ec2:{region}:{account}:volume/vol-0000000000 /// Public images have no account in their ARN. const PROBE_IMAGE: &str = "arn:aws:ec2:{region}::image/ami-00000000000000000"; const PROBE_AUTO_SCALING_GROUP: &str = "arn:aws:autoscaling:{region}:{account}:autoScalingGroup:\ - 00000000-0000-0000-0000-000000000000:autoScalingGroupName/triple-c-probe"; + 00000000-0000-0000-0000-000000000000:autoScalingGroupName/triple-c-probe--u-alice"; const PROBE_INSTANCE_PROFILE: &str = "arn:aws:iam::{account}:instance-profile/triple-c-probe"; /// An instance role is `triple-c---instance`. const PROBE_INSTANCE_ROLE: &str = "arn:aws:iam::{account}:role/triple-c-probe-instance"; @@ -2008,8 +2012,10 @@ mod tests { fn the_boundary_keeps_the_ecs_agent_on_its_own_cluster() { let stmts = statements_of(&boundary()); const TAG: &str = "aws:PrincipalTag/triple-c:cluster"; - const MINE: Context = &[(TAG, Literal("triple-c-probe-0123456789ab"))]; + const MINE: Context = &[(TAG, Literal("triple-c-probe--u-alice"))]; const PROD: Context = &[(TAG, Literal("prod"))]; + // The environment's (shared) cluster is not an instance role's either. + const SHARED: Context = &[(TAG, Literal("triple-c-probe"))]; let within = |action: &'static str, resource: &'static str, context: Context| { evaluate_in( &stmts, @@ -2020,13 +2026,13 @@ mod tests { }, ) }; - const CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-probe-0123456789ab"; + const CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-probe--u-alice"; const INSTANCE: &str = "arn:aws:ecs:{region}:{account}:container-instance/\ - triple-c-probe-0123456789ab/0123456789abcdef0123456789abcdef"; + triple-c-probe--u-alice/0123456789abcdef0123456789abcdef"; const OTHER_USERS_CLUSTER: &str = - "arn:aws:ecs:{region}:{account}:cluster/triple-c-probe-ba9876543210"; + "arn:aws:ecs:{region}:{account}:cluster/triple-c-probe--u-bob"; const OTHER_USERS_INSTANCE: &str = "arn:aws:ecs:{region}:{account}:container-instance/\ - triple-c-probe-ba9876543210/0123456789abcdef0123456789abcdef"; + triple-c-probe--u-bob/0123456789abcdef0123456789abcdef"; const PROD_CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/prod"; const PROD_INSTANCE: &str = "arn:aws:ecs:{region}:{account}:container-instance/\ prod/0123456789abcdef0123456789abcdef"; @@ -2079,6 +2085,14 @@ mod tests { !within(action, prod, PROD), "{action} on a non-Triple-C cluster" ); + let shared: &'static str = Box::leak( + own.replace("triple-c-probe--u-alice", "triple-c-probe") + .into_boxed_str(), + ); + assert!( + !within(action, shared, SHARED), + "{action} on the shared cluster" + ); } assert!(within("ecs:TagResource", INSTANCE, at_register(MINE))); for (resource, context) in [ @@ -2228,7 +2242,8 @@ mod tests { [ "environment-admin.json", "environment-admin-network.json", - "environment-admin-compute.json" + "environment-admin-compute.json", + "environment-admin-scaling.json" ] ); assert_eq!( @@ -2509,15 +2524,18 @@ mod tests { /// The new compute checks of the admin tier. fn compute_checks() -> Vec<&'static Check> { - let compute = parse( - "environment-admin-compute.json", - policy_files(Tier::EnvironmentAdmin) - .iter() - .find(|(n, _)| *n == "environment-admin-compute.json") - .expect("the compute file") - .1, - ); - let stmts = statements_of(&compute); + let stmts: Vec = policy_files(Tier::EnvironmentAdmin) + .iter() + .filter(|(n, _)| { + [ + "environment-admin-compute.json", + "environment-admin-scaling.json", + ] + .contains(n) + }) + .flat_map(|(n, json)| statements_of(&parse(n, json))) + .collect(); + assert!(stmts.len() >= 10); let found: Vec<_> = checks(Tier::EnvironmentAdmin) .iter() .filter(|c| { @@ -2710,7 +2728,10 @@ mod tests { let mut lists = Vec::new(); for s in allows(Tier::EnvironmentAdmin) { if let Some(ops) = s["Condition"].as_object() { - for entries in ops.values() { + for (op, entries) in ops { + if op == "Null" { + continue; + } for key in ["ec2:InstanceType", "autoscaling:InstanceTypes"] { if let Some(v) = entries.get(key) { lists.push(strings(v).into_iter().collect()); @@ -2795,8 +2816,19 @@ mod tests { ); } } - // Creating always names the template version; an update may leave - // the template alone (a size change, the drain before destroy). + // Creating always names the template version and its types; an + // update may leave the template alone (a size change, the drain + // before destroy). + assert!(!allowed( + tier, + &write( + "autoscaling:CreateAutoScalingGroup", + PROBE_AUTO_SCALING_GROUP, + without(GROUP_CREATE, "autoscaling:InstanceTypes") + ), + ME, + ME + )); assert!(!allowed( tier, &write( @@ -2830,7 +2862,6 @@ mod tests { for (resource, ok) in [ (PROBE_INSTANCE, INSTANCE_LAUNCH), (PROBE_VOLUME, VOLUME_LAUNCH), - (PROBE_INSTANCE, without(INSTANCE_LAUNCH, "ec2:InstanceType")), ] { assert!(allowed( tier, @@ -2852,6 +2883,17 @@ mod tests { "untagged {resource}" ); } + // An instance whose type IAM doesn't see is refused too. + assert!(!allowed( + tier, + &write( + "ec2:RunInstances", + PROBE_INSTANCE, + without(INSTANCE_LAUNCH, "ec2:InstanceType") + ), + ME, + ME + )); for t in [ "p5.48xlarge", "m7i.8xlarge", @@ -3030,6 +3072,73 @@ mod tests { } } + /// Per-user EC2 clusters (`triple-c---u-`, amended E1): a + /// caller runs tasks only on the one named after their own + /// `triple-c-user` principal tag, never without the tag, and the + /// environment's (Fargate) cluster is unaffected. + #[test] + fn workspace_users_run_only_on_their_own_ec2_cluster() { + let run = ws_check("ecs:RunTask", "task-definition/"); + // (allowed, explicitly denied) for RunTask, then StartTask (never + // granted; only the Deny matters for it). + let attempt = |cluster: &'static str, tag: Option<&'static str>| { + let mut context: Vec<(&'static str, ContextValue)> = run + .context + .iter() + .filter(|(k, _)| *k != "ecs:cluster") + .copied() + .collect(); + context.push(("ecs:cluster", Literal(cluster))); + if let Some(t) = tag { + context.push(("aws:PrincipalTag/triple-c-user", Literal(t))); + } + let context: Context = Box::leak(context.into_boxed_slice()); + ["ecs:RunTask", "ecs:StartTask"].map(|action| { + let c = Check { + action, + context, + ..*run + }; + ( + allowed(Tier::WorkspaceUser, &c, ME, ME), + explicitly_denied(Tier::WorkspaceUser, &c), + ) + }) + }; + const ALICE: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-dev--u-alice"; + const BOB: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-dev--u-bob"; + const SHARED: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-dev"; + const U_ENV: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-my-u-env"; + let [(run_ok, run_denied), (_, start_denied)] = attempt(ALICE, Some("alice")); + assert!( + run_ok && !run_denied && !start_denied, + "alice on her own cluster" + ); + for (cluster, tag) in [ + (BOB, Some("alice")), + (ALICE, None), + (BOB, None), + (ALICE, Some("bob")), + (ALICE, Some("alic")), + (ALICE, Some("")), + ] { + let [(run_ok, run_denied), (_, start_denied)] = attempt(cluster, tag); + assert!( + !run_ok && run_denied && start_denied, + "{cluster} with {tag:?}" + ); + } + for cluster in [SHARED, U_ENV] { + for tag in [None, Some("alice")] { + let [(run_ok, run_denied), (_, start_denied)] = attempt(cluster, tag); + assert!( + run_ok && !run_denied && !start_denied, + "{cluster} with {tag:?}" + ); + } + } + } + /// A workspace user changes none of the compute (they may read, as /// they read all of ECS): their EC2 capacity is the admin's onboarding /// module's to create. diff --git a/app/src-tauri/src/aws/policy_eval.rs b/app/src-tauri/src/aws/policy_eval.rs index a804c1c..2f8105c 100644 --- a/app/src-tauri/src/aws/policy_eval.rs +++ b/app/src-tauri/src/aws/policy_eval.rs @@ -212,7 +212,7 @@ pub(crate) fn conditions_hold(stmt: &Value, req: &Request) -> bool { "StringEquals" | "Bool" => (|p, v| p == v, false), "StringLike" | "ArnLike" => (glob, false), "StringNotEquals" => (|p, v| p == v, true), - "StringNotLike" => (glob, true), + "StringNotLike" | "ArnNotLike" => (glob, true), other => panic!("{}: unsupported condition operator {other}", sid(stmt)), }; entries diff --git a/app/src-tauri/src/aws/tofu_modules.rs b/app/src-tauri/src/aws/tofu_modules.rs index a529269..067386d 100644 --- a/app/src-tauri/src/aws/tofu_modules.rs +++ b/app/src-tauri/src/aws/tofu_modules.rs @@ -137,6 +137,54 @@ pub fn user_role_names(env: &str, owner_key: &str) -> (String, String) { ) } +/// The principal tag every EC2 user's sign-in carries (phase 7, amended E1): +/// an admin sets it (an IAM Identity Center attribute for access control, +/// or a tag on the IAM user or role), and the workspace policy lets a +/// caller run tasks only on the per-user cluster named after its value. +#[allow(dead_code)] // the onboarding module (Task 3) and the UI read it +pub const EC2_USER_TAG_KEY: &str = "triple-c-user"; + +/// Checks a `triple-c-user` tag value: 1 to 32 characters of +/// `[A-Za-z0-9-]`, not starting or ending with a hyphen and without `--` +/// (the separator in [`user_ec2_stem`], which environment names can't hold +/// either, so a per-user name can be read back only one way). +#[allow(dead_code)] // the onboarding module (Task 3) uses it +pub fn validate_ec2_user_tag(tag: &str) -> Result { + let ok = (1..=32).contains(&tag.len()) + && tag.bytes().all(|c| c.is_ascii_alphanumeric() || c == b'-') + && !tag.starts_with('-') + && !tag.ends_with('-') + && !tag.contains("--"); + if ok { + Ok(tag.to_string()) + } else { + Err(format!( + "\"{}\" is not a valid triple-c-user tag: use 1 to 32 letters, digits and single \ + hyphens, not starting or ending with a hyphen", + tag.escape_debug() + )) + } +} + +/// The name of a user's EC2 cluster, capacity provider, Auto Scaling group +/// and launch template: `triple-c---u-` (at most 65 +/// characters). Environment names and user tags never contain `--`, so the +/// workspace policy's `cluster/triple-c-*--u-*` matches exactly the +/// per-user clusters, and `triple-c-*--u-` exactly that user's. +#[allow(dead_code)] // the onboarding module (Task 3) uses it +pub fn user_ec2_stem(env: &str, user_tag: &str) -> String { + format!("triple-c-{env}--u-{user_tag}") +} + +/// A user's EC2 instance role (and instance profile): named by owner key, +/// not the user tag, because role names are account-global and at most 64 +/// characters (this is at most 51). The admin's PassRole to EC2 names +/// `role/triple-c-*-instance`. +#[allow(dead_code)] // the onboarding module (Task 3) uses it +pub fn user_instance_role_name(env: &str, owner_key: &str) -> String { + format!("triple-c-{env}-{owner_key}-instance") +} + /// Whether a project id is used in names as it is: 1 to 64 characters of /// `[A-Za-z0-9-]`. Every UUID (how the app makes ids) is. fn is_clean_project_id(id: &str) -> bool { diff --git a/app/src-tauri/src/aws/tofu_modules/tests.rs b/app/src-tauri/src/aws/tofu_modules/tests.rs index b1a9a31..4dcb3d3 100644 --- a/app/src-tauri/src/aws/tofu_modules/tests.rs +++ b/app/src-tauri/src/aws/tofu_modules/tests.rs @@ -165,6 +165,63 @@ fn environment_names_are_validated() { ); } +#[test] +fn ec2_user_tags_are_validated() { + for ok in ["alice", "Bob-2", "a", "x".repeat(32).as_str(), "a-b-c"] { + assert_eq!(validate_ec2_user_tag(ok), Ok(ok.to_string()), "{ok}"); + } + for bad in [ + "", + "-a", + "a-", + "a--b", + "a_b", + "a.b", + "a b", + "ä", + &"x".repeat(33), + "a/b", + "a*", + ] { + assert!(validate_ec2_user_tag(bad).is_err(), "{bad:?} accepted"); + } +} + +#[test] +fn per_user_ec2_names_are_unambiguous_and_fit() { + assert_eq!(user_ec2_stem("dev", "alice"), "triple-c-dev--u-alice"); + assert_eq!( + user_instance_role_name("dev", "0123456789ab"), + "triple-c-dev-0123456789ab-instance" + ); + // The longest names fit: ECS 255, launch templates 128, Auto Scaling + // groups 255; roles and instance profiles 64. + let env = "a".repeat(20); + validate_environment_name(&env).unwrap(); + let tag = "t".repeat(32); + assert!(user_ec2_stem(&env, &tag).len() <= 65); + assert!(user_instance_role_name(&env, "0123456789ab").len() <= 64); + // An environment cluster is never a per-user one, and one user's + // pattern never matches another's cluster: neither half holds `--`. + use crate::aws::policy_eval::glob; + for env in ["dev", "my-u-env", "u-x", "a-u"] { + validate_environment_name(env).unwrap(); + assert!( + !glob("triple-c-*--u-*", &environment_cluster_name(env)), + "{env}" + ); + assert!(glob("triple-c-*--u-*", &user_ec2_stem(env, "alice"))); + assert!(glob("triple-c-*--u-alice", &user_ec2_stem(env, "alice"))); + for other in ["bob", "bob-alice", "u-alice", "alicex", "xalice"] { + validate_ec2_user_tag(other).unwrap(); + assert!( + !glob("triple-c-*--u-alice", &user_ec2_stem(env, other)), + "{env}/{other}" + ); + } + } +} + #[test] fn the_environment_cluster_and_log_group_names_match_the_module() { assert_eq!(environment_cluster_name("dev"), "triple-c-dev"); @@ -1899,12 +1956,12 @@ const MODULE_CALLS: &[(&str, &[Check])] = &[ // `aws_ecs_cluster_capacity_providers`, `aws_iam_role`, `aws_ssm_parameter` // and `data.aws_ssm_parameter` entries) and deletes this table. Names are // the user's (`triple-c--[-instance]`). -const USER_CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-probe-0123456789ab"; +const USER_CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-probe--u-alice"; const CAPACITY_PROVIDER: &str = - "arn:aws:ecs:{region}:{account}:capacity-provider/triple-c-probe-0123456789ab"; + "arn:aws:ecs:{region}:{account}:capacity-provider/triple-c-probe--u-alice"; const LAUNCH_TEMPLATE: &str = "arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"; const AUTO_SCALING_GROUP: &str = "arn:aws:autoscaling:{region}:{account}:autoScalingGroup:\ - 00000000-0000-0000-0000-000000000000:autoScalingGroupName/triple-c-probe-0123456789ab"; + 00000000-0000-0000-0000-000000000000:autoScalingGroupName/triple-c-probe--u-alice"; const INSTANCE: &str = "arn:aws:ec2:{region}:{account}:instance/i-00000000000000000"; const VOLUME: &str = "arn:aws:ec2:{region}:{account}:volume/vol-00000000000000000"; const IMAGE: &str = "arn:aws:ec2:{region}::image/ami-00000000000000000"; @@ -2185,6 +2242,17 @@ fn the_module_call_table_covers_every_type_the_modules_use() { assert_eq!(module_types(), table); } +#[test] +fn the_ec2_call_table_uses_the_shared_names() { + let stem = user_ec2_stem(ENV, "alice"); + assert!(USER_CLUSTER.ends_with(&format!("cluster/{stem}"))); + assert!(CAPACITY_PROVIDER.ends_with(&format!("capacity-provider/{stem}"))); + assert!(AUTO_SCALING_GROUP.ends_with(&format!("autoScalingGroupName/{stem}"))); + let role = user_instance_role_name(ENV, OWNER_KEY); + assert!(INSTANCE_ROLE.ends_with(&format!("role/{role}"))); + assert!(INSTANCE_PROFILE.ends_with(&format!("instance-profile/{role}"))); +} + #[test] fn the_module_call_table_uses_the_shared_names() { let (task, exec) = user_role_names(ENV, OWNER_KEY); diff --git a/app/src-tauri/src/commands/host_commands.rs b/app/src-tauri/src/commands/host_commands.rs index ec0f74a..66581b7 100644 --- a/app/src-tauri/src/commands/host_commands.rs +++ b/app/src-tauri/src/commands/host_commands.rs @@ -609,7 +609,8 @@ mod tests { [ "environment-admin.json", "environment-admin-network.json", - "environment-admin-compute.json" + "environment-admin-compute.json", + "environment-admin-scaling.json" ] ); for f in &admin { diff --git a/aws/README.md b/aws/README.md index 7b5d4d7..1d68b38 100644 --- a/aws/README.md +++ b/aws/README.md @@ -10,18 +10,33 @@ tier the signed-in identity has under **Settings → Hosts → Check**. | `policies/workspace-user-tasks.json` | The **workspace user** tier, part 2: register and tag **their own** ECS task definitions, read **their own** secrets, and read Fargate prices for the cost estimate (`workspace-user.json` has no room left) | | `policies/environment-admin.json` | The **environment admin** tier, part 1: apply and destroy the environment and onboarding modules (`terraform/`) with OpenTofu, and keep their state | | `policies/environment-admin-network.json` | The **environment admin** tier, part 2: the network those modules create (VPC, subnets, gateways, routes, security groups) | -| `policies/environment-admin-compute.json` | The **environment admin** tier, part 3: per-user EC2 capacity the onboarding module creates (phase 7): capacity providers, launch templates, Auto Scaling groups, instance profiles, the instance role passed to EC2 | +| `policies/environment-admin-compute.json` | The **environment admin** tier, part 3: per-user EC2 capacity the onboarding module creates (phase 7): capacity providers, launch templates, the launch rules, the instance role passed to EC2, the ECS-optimized AMI parameter | +| `policies/environment-admin-scaling.json` | The **environment admin** tier, part 4: the per-user Auto Scaling groups, instance profiles and the Auto Scaling/ECS service-linked roles | | `policies/permissions-boundary.json` | The **permissions boundary** every Triple-C role must carry. It is never attached to a person | -The workspace tier is **two** files and the admin tier **three**, because one managed policy +The workspace tier is **two** files and the admin tier **four**, because one managed policy holds only 6,144 characters; every file of a tier is required, and the app's **Copy** lists every -file of a tier. An environment admin attaches all five tier files (both workspace user files and -the three admin files): the admin files add environment management on top of everything a +file of a tier. An environment admin attaches all six tier files (both workspace user files and +the four admin files): the admin files add environment management on top of everything a workspace user can do. Explicit Deny statements in any file apply to anyone who has it attached. ## Workspace user +**EC2 users need a `triple-c-user` principal tag.** An admin gives each user who gets EC2 +capacity a unique tag value of 1 to 32 letters, digits and single hyphens (not starting or ending +with one; `validate_ec2_user_tag` in `tofu_modules.rs`): + +- **IAM Identity Center:** Settings → *Attributes for access control* → add key `triple-c-user` + with a value such as `${path:userName}`, as long as every user's value is valid as above and + unique (sanitise in the identity source if usernames hold `@`, `.` or `_`, e.g. a dedicated + user attribute). The permission set's sessions then carry `aws:PrincipalTag/triple-c-user`. +- **IAM users or roles:** tag the user (or the role they assume) `triple-c-user = `. + +The same value goes into the user's onboarding (`ec2_user_tag`), which names their cluster. +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. + 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: @@ -29,6 +44,13 @@ following: - **Run tasks.** The task definition must be a `triple-c-*` one tagged with the user's own owner ID, and the cluster must be a `triple-c-*` one. The new task is tagged with the user's owner ID. The user can pass only `triple-c-*` roles tagged with their owner ID, and only to ECS tasks. + **Per-user EC2 clusters** (phase 7) are `triple-c---u-`, and two Denies in + `workspace-user-tasks.json` keep everyone else off them: `RunTask`/`StartTask` on a + `cluster/triple-c-*--u-*` cluster is denied unless it is + `cluster/triple-c-*--u-${aws:PrincipalTag/triple-c-user}`, and denied outright when the caller + has no `triple-c-user` principal tag (so a missing tag never falls through, however IAM resolves + the variable). Environment names and user tags can't contain `--`, so an environment's (Fargate) + cluster never matches the pattern and one user's pattern never matches another's cluster. - **Register their own task definitions** (`workspace-user-tasks.json`). `ecs:RegisterTaskDefinition` on `triple-c-*` families needs `triple-c:owner = ${aws:userid}` in the request and only the three ordinary tag keys. `ecs:TagResource` on a task definition is allowed only at registration @@ -145,9 +167,9 @@ and nothing runs with more than the admin holds. It covers: - EFS file systems, mount targets and file-system policies, and KMS keys and aliases; - `/triple-c/*` log groups and `/triple-c/*` SSM parameters (including each user's compute record `/triple-c/users//`); -- per-user EC2 capacity (`environment-admin-compute.json`, phase 7): the user's own - `triple-c--` cluster and capacity provider, a component-tagged launch template - and `triple-c-*` Auto Scaling group (pinned to a template version, no load balancer, supported +- per-user EC2 capacity (`environment-admin-compute.json` and `-scaling.json`, phase 7): the + user's own `triple-c---u-` cluster, capacity provider (`triple-c-*--u-*`), a + component-tagged launch template and `triple-c-*--u-*` Auto Scaling group (pinned to a template version, no load balancer, supported instance types only), the `triple-c-*` instance profile, passing `triple-c-*-instance` roles to EC2, reading the ECS-optimized AMI's public SSM parameter, and the Auto Scaling and ECS service-linked roles. @@ -156,7 +178,8 @@ and nothing runs with more than the admin holds. It covers: (`ec2_instance_spec` in `models/project.rs`, pinned to the policy by a test): `m7i`, `m7g`, `c7i`, `c7g`, `r7i`, `r7g` in `large` to `4xlarge`, and `t3`, `t4g` in `large` to `2xlarge`. No GPU, accelerator or metal types. An onboarding with any other type is denied at apply; supporting one -means adding it to that table and to the three lists in the compute file together. +means adding it to that table and to the three lists (`ec2:InstanceType` in the compute file, +`autoscaling:InstanceTypes` twice in the scaling file) together. **Clearing workspace task definitions.** Removing a project leaves its revisions registered (family `triple-c---`). The admin tier may deregister any @@ -210,12 +233,12 @@ the proof; an action it shows missing is added to the table, the policy, the che | `aws_iam_role_policy` | `iam:PutRolePolicy`, `DeleteRolePolicy` (with the boundary), `GetRolePolicy` (the role; untaggable) | | data sources | `sts:GetCallerIdentity`, `ec2:DescribeAvailabilityZones`, `ec2:DescribeSubnets`, `ssm:GetParameter` | | *Phase 7, per-user EC2 (onboarding module, expected; `EC2_COMPUTE_CALLS` until the resources exist)* | | -| `aws_ecs_cluster` (the user's) | as the environment's cluster, on `cluster/triple-c--` | -| `aws_ecs_capacity_provider` | `ecs:CreateCapacityProvider`, `TagResource` (at create), `ListTagsForResource`, `UpdateCapacityProvider`, `UntagResource`, `DeleteCapacityProvider` (`capacity-provider/triple-c-*`), `DescribeCapacityProviders` (`*`); `iam:CreateServiceLinkedRole` for `ecs.amazonaws.com` (managed scaling runs as ECS's service-linked role) | +| `aws_ecs_cluster` (the user's) | as the environment's cluster, on `cluster/triple-c---u-` (the capacity provider, Auto Scaling group and launch template use the same name) | +| `aws_ecs_capacity_provider` | `ecs:CreateCapacityProvider`, `TagResource` (at create), `ListTagsForResource`, `UpdateCapacityProvider`, `UntagResource`, `DeleteCapacityProvider` (`capacity-provider/triple-c-*--u-*`), `DescribeCapacityProviders` (`*`); `iam:CreateServiceLinkedRole` for `ecs.amazonaws.com` (managed scaling runs as ECS's service-linked role) | | `aws_ecs_cluster_capacity_providers` (the user's) | `ecs:PutClusterCapacityProviders` (the cluster and, expected, the capacity provider) | | `aws_launch_template` | `ec2:CreateLaunchTemplate` (request tag), `CreateTags` (at create), `CreateLaunchTemplateVersion`, `CreateTags`/`DeleteTags`, `DeleteLaunchTemplate` (tagged), `Describe*`. Never `ModifyLaunchTemplate`: the default version never moves (the module must not set `update_default_version` or `default_version`) | -| `aws_autoscaling_group` | `autoscaling:CreateAutoScalingGroup` (`triple-c-*`, request tag, `autoscaling:LaunchTemplateVersionSpecified = true`, no `TargetGroupARNs`/`LoadBalancerNames`, `autoscaling:InstanceTypes` supported), `UpdateAutoScalingGroup` (tagged; the same, except that an update which leaves the template alone passes the version check), `SetInstanceProtection`, `CreateOrUpdateTags`/`DeleteTags`, `DeleteAutoScalingGroup` (tagged), `Describe*` (`*`); `iam:CreateServiceLinkedRole` for `autoscaling.amazonaws.com`. Creating a group checks that the caller could launch its template: `ec2:RunInstances` on the tagged launch template; on the instance and its volume only with the component request tag, `ec2:LaunchTemplate` set and (instance) a supported `ec2:InstanceType`; on the network interface and subnet with `ec2:LaunchTemplate`; on the security group only the template's own (`ec2:IsLaunchTemplateResource`) component-tagged group; on images only Amazon's, named by the template; `ec2:CreateTags` at `RunInstances`; `iam:PassRole` of the instance role to `ec2.amazonaws.com`. ASG tags are **not** the provider's `default_tags`: the module must set the component tag on the group itself | -| `aws_iam_role` (instance), `aws_iam_role_policy` | as the other per-user roles (bounded), on `triple-c---instance`, tagged `triple-c:cluster = triple-c--` (`iam:TagRole`) | +| `aws_autoscaling_group` | `autoscaling:CreateAutoScalingGroup` (`triple-c-*--u-*`, request tag, `autoscaling:LaunchTemplateVersionSpecified = true`, no `TargetGroupARNs`/`LoadBalancerNames`, `autoscaling:InstanceTypes` present and supported), `UpdateAutoScalingGroup` (tagged; the same, except that an update which leaves the template alone passes the version check), `SetInstanceProtection`, `CreateOrUpdateTags`/`DeleteTags`, `DeleteAutoScalingGroup` (tagged), `Describe*` (`*`); `iam:CreateServiceLinkedRole` for `autoscaling.amazonaws.com`. Creating a group checks that the caller could launch its template: `ec2:RunInstances` on the tagged launch template; on the instance and its volume only with the component request tag, `ec2:LaunchTemplate` set and (instance) a supported `ec2:InstanceType` (required: a launch whose type IAM doesn't see is denied); on the network interface and subnet with `ec2:LaunchTemplate`; on the security group only the template's own (`ec2:IsLaunchTemplateResource`) component-tagged group; on images only Amazon's, named by the template; `ec2:CreateTags` at `RunInstances`; `iam:PassRole` of the instance role to `ec2.amazonaws.com`. ASG tags are **not** the provider's `default_tags`: the module must set the component tag on the group itself | +| `aws_iam_role` (instance), `aws_iam_role_policy` | as the other per-user roles (bounded), on `triple-c---instance`, tagged `triple-c:cluster = triple-c---u-` (`iam:TagRole`) | | `aws_iam_instance_profile` | `iam:CreateInstanceProfile`, `TagInstanceProfile`, `AddRoleToInstanceProfile` (expected to need `iam:PassRole` of the role too), `GetInstanceProfile`, `ListInstanceProfileTags`, `UntagInstanceProfile`, `RemoveRoleFromInstanceProfile`, `DeleteInstanceProfile` (`instance-profile/triple-c-*`) | | `data.aws_ssm_parameter` (AMI) | `ssm:GetParameter`/`GetParameters` on the public `parameter/aws/service/ecs/optimized-ami/*` | | `aws_ssm_parameter` (user record) | as the environment record, on `/triple-c/users//` | @@ -253,7 +276,8 @@ the role carries the `triple-c-permissions-boundary` managed policy as its permi (`RegisterContainerInstance`, `DeregisterContainerInstance`, `Poll`, `StartTelemetrySession`, `Submit*`, `UpdateContainerInstancesState`) only on **the role's own cluster**, the one its `triple-c:cluster` tag names (`cluster/${aws:PrincipalTag/triple-c:cluster}` and that - cluster's container instances; the tag must match `triple-c-*`), `ecs:TagResource` only on + cluster's container instances; the tag must match `triple-c-*--u-*`, so never the environment's + shared cluster), `ecs:TagResource` only on such a container instance as it registers (`ecs:CreateAction = RegisterContainerInstance`), and `ecs:DiscoverPollEndpoint`. A user with Docker access is root on their own instance and so holds its role's credentials; the tag keeps them from registering that instance into @@ -475,11 +499,13 @@ 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 20,200), and a user's share 2,048. A managed policy +environment admin needs every tier file (about 23,300), 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,293 (including `ReadFargatePrices`), +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` 6,020 (124) and `permissions-boundary.json` 2,651; a unit test (`every_policy_fits_a_managed_policy`) +`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`) 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. @@ -559,9 +585,23 @@ expected, not verified: - **`ec2:IsLaunchTemplateResource`** is expected to be `true` on the image and security group the template names, and `aws:RequestTag` to carry the template's tag specifications for the instance and volume. If the group's launch check doesn't send either, that statement denies the create. -- **`autoscaling:InstanceTypes`** is expected to be absent (vacuously allowed) unless a request - names instance types (a mixed-instances override); the instance type itself is enforced at - `RunInstances`. +- **`autoscaling:InstanceTypes`** is required on a group create (`Null: false`) and checked + against the supported list (`ForAllValues`). Expected: Auto Scaling fills it with the launch + template's instance type. If it is absent for a template-only create, every create is denied: + then drop the `Null` and rely on the `RunInstances` check (instance type required there). On + update it is not required (an update that leaves the template alone, such as the drain before + destroy, names no type). There is **no condition key for `MixedInstancesPolicy` or + `InstanceRequirements`**; their overrides are expected to appear in `autoscaling:InstanceTypes` + and in the launch check, which is what keeps them to the list. +- **Instance types in templates.** `ec2:CreateLaunchTemplate`/`CreateLaunchTemplateVersion` are + not known to support `ec2:InstanceType` (not in the service authorization reference as I know + it), so a template may *name* any type; it can only be *launched* (directly or by a group) with a + supported one. Probe: create a version with `p5.48xlarge` and pin a group to it; the group + create must be denied. +- **`aws:PrincipalTag/triple-c-user` from Identity Center** attributes for access control is + expected in the SSO session's request context, and `${aws:PrincipalTag/triple-c-user}` in + `ArnNotLike` to resolve from it. Probe: as a tagged and an untagged user, `RunTask` on a + per-user cluster. - **Tags at group create.** If `CreateAutoScalingGroup` with tags also needs `autoscaling:CreateOrUpdateTags`, it is denied (that is allowed only on an already-tagged group); then add it to the create statement with the same conditions. diff --git a/aws/policies/environment-admin-compute.json b/aws/policies/environment-admin-compute.json index 1adfa35..ee8207d 100644 --- a/aws/policies/environment-admin-compute.json +++ b/aws/policies/environment-admin-compute.json @@ -14,7 +14,7 @@ "ecs:ListTagsForResource" ], "Resource": [ - "arn:aws:ecs:*:*:capacity-provider/triple-c-*" + "arn:aws:ecs:*:*:capacity-provider/triple-c-*--u-*" ] }, { @@ -79,8 +79,7 @@ "ec2:RunInstances" ], "Resource": [ - "arn:aws:ec2:*:*:instance/*", - "arn:aws:ec2:*:*:volume/*" + "arn:aws:ec2:*:*:instance/*" ], "Condition": { "Null": { @@ -89,7 +88,7 @@ "ArnLike": { "ec2:LaunchTemplate": "arn:aws:ec2:*:*:launch-template/*" }, - "StringEqualsIfExists": { + "StringEquals": { "ec2:InstanceType": [ "m7i.large", "m7i.xlarge", @@ -125,6 +124,24 @@ } } }, + { + "Sid": "LaunchTaggedVolumes", + "Effect": "Allow", + "Action": [ + "ec2:RunInstances" + ], + "Resource": [ + "arn:aws:ec2:*:*:volume/*" + ], + "Condition": { + "Null": { + "aws:RequestTag/triple-c:component": "false" + }, + "ArnLike": { + "ec2:LaunchTemplate": "arn:aws:ec2:*:*:launch-template/*" + } + } + }, { "Sid": "LaunchIntoSubnets", "Effect": "Allow", @@ -183,168 +200,6 @@ } } }, - { - "Sid": "CreatePinnedGroups", - "Effect": "Allow", - "Action": [ - "autoscaling:CreateAutoScalingGroup" - ], - "Resource": [ - "arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/triple-c-*" - ], - "Condition": { - "Null": { - "aws:RequestTag/triple-c:component": "false", - "autoscaling:TargetGroupARNs": "true", - "autoscaling:LoadBalancerNames": "true" - }, - "Bool": { - "autoscaling:LaunchTemplateVersionSpecified": "true" - }, - "ForAllValues:StringEquals": { - "autoscaling:InstanceTypes": [ - "m7i.large", - "m7i.xlarge", - "m7i.2xlarge", - "m7i.4xlarge", - "m7g.large", - "m7g.xlarge", - "m7g.2xlarge", - "m7g.4xlarge", - "c7i.large", - "c7i.xlarge", - "c7i.2xlarge", - "c7i.4xlarge", - "c7g.large", - "c7g.xlarge", - "c7g.2xlarge", - "c7g.4xlarge", - "r7i.large", - "r7i.xlarge", - "r7i.2xlarge", - "r7i.4xlarge", - "r7g.large", - "r7g.xlarge", - "r7g.2xlarge", - "r7g.4xlarge", - "t3.large", - "t3.xlarge", - "t3.2xlarge", - "t4g.large", - "t4g.xlarge", - "t4g.2xlarge" - ] - } - } - }, - { - "Sid": "UpdatePinnedGroups", - "Effect": "Allow", - "Action": [ - "autoscaling:UpdateAutoScalingGroup" - ], - "Resource": [ - "arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/triple-c-*" - ], - "Condition": { - "Null": { - "aws:ResourceTag/triple-c:component": "false", - "autoscaling:TargetGroupARNs": "true", - "autoscaling:LoadBalancerNames": "true" - }, - "BoolIfExists": { - "autoscaling:LaunchTemplateVersionSpecified": "true" - }, - "ForAllValues:StringEquals": { - "autoscaling:InstanceTypes": [ - "m7i.large", - "m7i.xlarge", - "m7i.2xlarge", - "m7i.4xlarge", - "m7g.large", - "m7g.xlarge", - "m7g.2xlarge", - "m7g.4xlarge", - "c7i.large", - "c7i.xlarge", - "c7i.2xlarge", - "c7i.4xlarge", - "c7g.large", - "c7g.xlarge", - "c7g.2xlarge", - "c7g.4xlarge", - "r7i.large", - "r7i.xlarge", - "r7i.2xlarge", - "r7i.4xlarge", - "r7g.large", - "r7g.xlarge", - "r7g.2xlarge", - "r7g.4xlarge", - "t3.large", - "t3.xlarge", - "t3.2xlarge", - "t4g.large", - "t4g.xlarge", - "t4g.2xlarge" - ] - } - } - }, - { - "Sid": "ManageTripleCAutoScalingGroups", - "Effect": "Allow", - "Action": [ - "autoscaling:SetInstanceProtection", - "autoscaling:CreateOrUpdateTags", - "autoscaling:DeleteTags", - "autoscaling:DeleteAutoScalingGroup" - ], - "Resource": [ - "arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/triple-c-*" - ], - "Condition": { - "Null": { - "aws:ResourceTag/triple-c:component": "false" - } - } - }, - { - "Sid": "CreateComputeServiceLinkedRoles", - "Effect": "Allow", - "Action": [ - "iam:CreateServiceLinkedRole" - ], - "Resource": [ - "arn:aws:iam::*:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling*", - "arn:aws:iam::*:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS*" - ], - "Condition": { - "StringEquals": { - "iam:AWSServiceName": [ - "autoscaling.amazonaws.com", - "ecs.amazonaws.com" - ] - } - } - }, - { - "Sid": "ManageTripleCInstanceProfiles", - "Effect": "Allow", - "Action": [ - "iam:CreateInstanceProfile", - "iam:DeleteInstanceProfile", - "iam:GetInstanceProfile", - "iam:AddRoleToInstanceProfile", - "iam:RemoveRoleFromInstanceProfile", - "iam:TagInstanceProfile", - "iam:UntagInstanceProfile", - "iam:ListInstanceProfileTags" - ], - "Resource": [ - "arn:aws:iam::*:instance-profile/triple-c-*" - ] - }, { "Sid": "PassInstanceRolesToEc2", "Effect": "Allow", @@ -370,17 +225,6 @@ "Resource": [ "arn:aws:ssm:*::parameter/aws/service/ecs/optimized-ami/*" ] - }, - { - "Sid": "ReadCompute", - "Effect": "Allow", - "Action": [ - "ecs:DescribeCapacityProviders", - "autoscaling:Describe*" - ], - "Resource": [ - "*" - ] } ] } diff --git a/aws/policies/environment-admin-scaling.json b/aws/policies/environment-admin-scaling.json new file mode 100644 index 0000000..a8104fc --- /dev/null +++ b/aws/policies/environment-admin-scaling.json @@ -0,0 +1,179 @@ +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "CreatePinnedGroups", + "Effect": "Allow", + "Action": [ + "autoscaling:CreateAutoScalingGroup" + ], + "Resource": [ + "arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/triple-c-*--u-*" + ], + "Condition": { + "Null": { + "aws:RequestTag/triple-c:component": "false", + "autoscaling:TargetGroupARNs": "true", + "autoscaling:LoadBalancerNames": "true", + "autoscaling:InstanceTypes": "false" + }, + "Bool": { + "autoscaling:LaunchTemplateVersionSpecified": "true" + }, + "ForAllValues:StringEquals": { + "autoscaling:InstanceTypes": [ + "m7i.large", + "m7i.xlarge", + "m7i.2xlarge", + "m7i.4xlarge", + "m7g.large", + "m7g.xlarge", + "m7g.2xlarge", + "m7g.4xlarge", + "c7i.large", + "c7i.xlarge", + "c7i.2xlarge", + "c7i.4xlarge", + "c7g.large", + "c7g.xlarge", + "c7g.2xlarge", + "c7g.4xlarge", + "r7i.large", + "r7i.xlarge", + "r7i.2xlarge", + "r7i.4xlarge", + "r7g.large", + "r7g.xlarge", + "r7g.2xlarge", + "r7g.4xlarge", + "t3.large", + "t3.xlarge", + "t3.2xlarge", + "t4g.large", + "t4g.xlarge", + "t4g.2xlarge" + ] + } + } + }, + { + "Sid": "UpdatePinnedGroups", + "Effect": "Allow", + "Action": [ + "autoscaling:UpdateAutoScalingGroup" + ], + "Resource": [ + "arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/triple-c-*--u-*" + ], + "Condition": { + "Null": { + "aws:ResourceTag/triple-c:component": "false", + "autoscaling:TargetGroupARNs": "true", + "autoscaling:LoadBalancerNames": "true" + }, + "BoolIfExists": { + "autoscaling:LaunchTemplateVersionSpecified": "true" + }, + "ForAllValues:StringEquals": { + "autoscaling:InstanceTypes": [ + "m7i.large", + "m7i.xlarge", + "m7i.2xlarge", + "m7i.4xlarge", + "m7g.large", + "m7g.xlarge", + "m7g.2xlarge", + "m7g.4xlarge", + "c7i.large", + "c7i.xlarge", + "c7i.2xlarge", + "c7i.4xlarge", + "c7g.large", + "c7g.xlarge", + "c7g.2xlarge", + "c7g.4xlarge", + "r7i.large", + "r7i.xlarge", + "r7i.2xlarge", + "r7i.4xlarge", + "r7g.large", + "r7g.xlarge", + "r7g.2xlarge", + "r7g.4xlarge", + "t3.large", + "t3.xlarge", + "t3.2xlarge", + "t4g.large", + "t4g.xlarge", + "t4g.2xlarge" + ] + } + } + }, + { + "Sid": "ManageTripleCAutoScalingGroups", + "Effect": "Allow", + "Action": [ + "autoscaling:SetInstanceProtection", + "autoscaling:CreateOrUpdateTags", + "autoscaling:DeleteTags", + "autoscaling:DeleteAutoScalingGroup" + ], + "Resource": [ + "arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/triple-c-*--u-*" + ], + "Condition": { + "Null": { + "aws:ResourceTag/triple-c:component": "false" + } + } + }, + { + "Sid": "CreateComputeServiceLinkedRoles", + "Effect": "Allow", + "Action": [ + "iam:CreateServiceLinkedRole" + ], + "Resource": [ + "arn:aws:iam::*:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling*", + "arn:aws:iam::*:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS*" + ], + "Condition": { + "StringEquals": { + "iam:AWSServiceName": [ + "autoscaling.amazonaws.com", + "ecs.amazonaws.com" + ] + } + } + }, + { + "Sid": "ManageTripleCInstanceProfiles", + "Effect": "Allow", + "Action": [ + "iam:CreateInstanceProfile", + "iam:DeleteInstanceProfile", + "iam:GetInstanceProfile", + "iam:AddRoleToInstanceProfile", + "iam:RemoveRoleFromInstanceProfile", + "iam:TagInstanceProfile", + "iam:UntagInstanceProfile", + "iam:ListInstanceProfileTags" + ], + "Resource": [ + "arn:aws:iam::*:instance-profile/triple-c-*" + ] + }, + { + "Sid": "ReadCompute", + "Effect": "Allow", + "Action": [ + "ecs:DescribeCapacityProviders", + "autoscaling:Describe*" + ], + "Resource": [ + "*" + ] + } + ] +} diff --git a/aws/policies/permissions-boundary.json b/aws/policies/permissions-boundary.json index c198a0f..8e7a524 100644 --- a/aws/policies/permissions-boundary.json +++ b/aws/policies/permissions-boundary.json @@ -134,7 +134,7 @@ ], "Condition": { "StringLike": { - "aws:PrincipalTag/triple-c:cluster": "triple-c-*" + "aws:PrincipalTag/triple-c:cluster": "triple-c-*--u-*" } } }, @@ -152,7 +152,7 @@ "ecs:CreateAction": "RegisterContainerInstance" }, "StringLike": { - "aws:PrincipalTag/triple-c:cluster": "triple-c-*" + "aws:PrincipalTag/triple-c:cluster": "triple-c-*--u-*" } } }, diff --git a/aws/policies/workspace-user-tasks.json b/aws/policies/workspace-user-tasks.json index d88c745..9e649bc 100644 --- a/aws/policies/workspace-user-tasks.json +++ b/aws/policies/workspace-user-tasks.json @@ -85,6 +85,44 @@ "aws:ResourceTag/triple-c:component": "false" } } + }, + { + "Sid": "RunOnlyOnOwnEc2Cluster", + "Effect": "Deny", + "Action": [ + "ecs:RunTask", + "ecs:StartTask" + ], + "Resource": [ + "*" + ], + "Condition": { + "ArnLike": { + "ecs:cluster": "arn:aws:ecs:*:*:cluster/triple-c-*--u-*" + }, + "ArnNotLike": { + "ecs:cluster": "arn:aws:ecs:*:*:cluster/triple-c-*--u-${aws:PrincipalTag/triple-c-user}" + } + } + }, + { + "Sid": "NoEc2ClusterWithoutUserTag", + "Effect": "Deny", + "Action": [ + "ecs:RunTask", + "ecs:StartTask" + ], + "Resource": [ + "*" + ], + "Condition": { + "ArnLike": { + "ecs:cluster": "arn:aws:ecs:*:*:cluster/triple-c-*--u-*" + }, + "Null": { + "aws:PrincipalTag/triple-c-user": "true" + } + } } ] } -- 2.52.0 From 9410c098ed7e3f19fc1f9c5cd8eb4c54558f55db Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 14:00:23 -0800 Subject: [PATCH 07/29] feat(aws): optional per-user EC2 capacity in the onboarding module Phase 7 Task 3 (E1-E4, E11; onboarding module version 2): - ec2.tf: with ec2_instance_type set, the user's own cluster triple-c---u- with exactly one capacity provider (managed termination protection, managed scaling 100% one instance at a time, 60 s warm-up), an Auto Scaling group of 0..ec2_max_instances (desired left to ECS, protect_from_scale_in, force_delete off so the provider drains before deleting, fixed launch-template version, default tags + AmazonECSManaged), a launch template on the ECS-optimized AL2023 AMI by architecture (IMDSv2 hop 1, 50 GiB gp3 encrypted root, the environment's tasks group, public IP as the environment's tasks get one, ECS_CLUSTER + ECS_AWSVPC_BLOCK_IMDS), the instance role triple-c---instance (bounded, tagged triple-c:cluster, ECS agent on its cluster only, ECR pull, logs; no SSM core) and its instance profile, and the user record /triple-c/users//. Empty type (the default): count 0 everywhere, Fargate plan unchanged. - Variables ec2_instance_type (the app's 30 types), ec2_max_instances (1-4), ec2_user_tag (as validate_ec2_user_tag, required with a type); onboarding_vars takes Option<&Ec2Compute> and validates the same. - The environment record's assign_public_ip is now format-checked. - tofu_modules.rs: ONBOARD_MODULE_VERSION 2, user_record_parameter_name, USER_RECORD_FIELDS, Ec2Compute, EC2_MAX_INSTANCES, ec2.tf embedded. - Tests: EC2 calls merged into MODULE_CALLS under real types (all_module_calls removed); gating + version-1 resource fingerprint; launch template, group, capacity provider, instance role, AMI by arch, record fields, names, variable rules; the instance role inside the boundary with its cluster principal tag. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/live_tests.rs | 6 +- app/src-tauri/src/aws/tofu_modules.rs | 89 +- app/src-tauri/src/aws/tofu_modules/tests.rs | 1121 ++++++++++++++--- .../src/commands/environment_commands.rs | 4 +- .../commands/environment_commands/tests.rs | 2 +- aws/terraform/user-onboard/ec2.tf | 314 +++++ aws/terraform/user-onboard/main.tf | 12 +- aws/terraform/user-onboard/outputs.tf | 23 + aws/terraform/user-onboard/variables.tf | 55 + 9 files changed, 1430 insertions(+), 196 deletions(-) create mode 100644 aws/terraform/user-onboard/ec2.tf diff --git a/app/src-tauri/src/aws/live_tests.rs b/app/src-tauri/src/aws/live_tests.rs index 10156bf..8d5a502 100644 --- a/app/src-tauri/src/aws/live_tests.rs +++ b/app/src-tauri/src/aws/live_tests.rs @@ -1592,7 +1592,7 @@ mod environment { .run( ModuleKind::UserOnboard, Deployment::User { env: &name, owner_key: &okey }, - &onboarding_vars(&name, &t.e.region, &owner), + &onboarding_vars(&name, &t.e.region, &owner, None).unwrap(), TofuOp::Apply, t.keys_env(&keys), ) @@ -1643,7 +1643,7 @@ mod environment { .run( ModuleKind::UserOnboard, Deployment::User { env: &name, owner_key: &okey }, - &onboarding_vars(&name, &t.e.region, &owner), + &onboarding_vars(&name, &t.e.region, &owner, None).unwrap(), TofuOp::Destroy, t.keys_env(&keys), ) @@ -2003,7 +2003,7 @@ mod environment { .run( ModuleKind::UserOnboard, Deployment::User { env: &name, owner_key: &okey }, - &onboarding_vars(&name, ®ion, &owner), + &onboarding_vars(&name, ®ion, &owner, None).unwrap(), TofuOp::Apply, t.keys_env(&keys), ) diff --git a/app/src-tauri/src/aws/tofu_modules.rs b/app/src-tauri/src/aws/tofu_modules.rs index 067386d..293fb0f 100644 --- a/app/src-tauri/src/aws/tofu_modules.rs +++ b/app/src-tauri/src/aws/tofu_modules.rs @@ -16,9 +16,11 @@ use crate::models::host_connection::validate_supported_region; /// `locals.template_version` (and the `triple-c:template-version` default /// tag) of `aws/terraform/environment`. pub const ENVIRONMENT_MODULE_VERSION: u32 = 2; -/// The same for the user-onboarding module. +/// The same for the user-onboarding module. 2: optional per-user EC2 +/// capacity (phase 7); an onboarding without it plans as version 1 did, +/// apart from this tag. #[allow(dead_code)] // the onboarding module's version; checked against its HCL by a test -pub const ONBOARD_MODULE_VERSION: u32 = 1; +pub const ONBOARD_MODULE_VERSION: u32 = 2; /// The same for the permissions-boundary module. 2: the instance role's ECS /// agent and Session Manager actions (phase 7, E4); an account admin /// re-applies the boundary once. @@ -57,6 +59,7 @@ const USER_ONBOARD_FILES: &[(&str, &str)] = module!("user-onboard": "main.tf", "iam.tf", "efs.tf", + "ec2.tf", "outputs.tf", ".terraform.lock.hcl", ); @@ -148,7 +151,6 @@ pub const EC2_USER_TAG_KEY: &str = "triple-c-user"; /// `[A-Za-z0-9-]`, not starting or ending with a hyphen and without `--` /// (the separator in [`user_ec2_stem`], which environment names can't hold /// either, so a per-user name can be read back only one way). -#[allow(dead_code)] // the onboarding module (Task 3) uses it pub fn validate_ec2_user_tag(tag: &str) -> Result { let ok = (1..=32).contains(&tag.len()) && tag.bytes().all(|c| c.is_ascii_alphanumeric() || c == b'-') @@ -171,7 +173,7 @@ pub fn validate_ec2_user_tag(tag: &str) -> Result { /// characters). Environment names and user tags never contain `--`, so the /// workspace policy's `cluster/triple-c-*--u-*` matches exactly the /// per-user clusters, and `triple-c-*--u-` exactly that user's. -#[allow(dead_code)] // the onboarding module (Task 3) uses it +#[allow(dead_code)] // the onboarding module builds it; the app's EC2 runs (Task 5) will pub fn user_ec2_stem(env: &str, user_tag: &str) -> String { format!("triple-c-{env}--u-{user_tag}") } @@ -180,11 +182,48 @@ pub fn user_ec2_stem(env: &str, user_tag: &str) -> String { /// not the user tag, because role names are account-global and at most 64 /// characters (this is at most 51). The admin's PassRole to EC2 names /// `role/triple-c-*-instance`. -#[allow(dead_code)] // the onboarding module (Task 3) uses it +#[allow(dead_code)] // the onboarding module builds it; pinned by tests pub fn user_instance_role_name(env: &str, owner_key: &str) -> String { format!("triple-c-{env}-{owner_key}-instance") } +/// The SSM parameter holding a user's EC2 record (E11), written by their +/// onboarding module only while it has EC2 capacity: a String of JSON with +/// exactly [`USER_RECORD_FIELDS`]. Workspace users can read it +/// (`parameter/triple-c/*`) though not the state bucket; it lives outside +/// `/triple-c/environments/`, which environment detection lists. +#[allow(dead_code)] // the app reads it from Task 4 on +pub fn user_record_parameter_name(env: &str, owner_key: &str) -> String { + format!("/triple-c/users/{env}/{owner_key}") +} + +/// The fields of a user's EC2 record, schema 1: `instance_type`, +/// `cluster_arn` (the user's cluster, [`user_ec2_stem`]), +/// `capacity_provider` (its one provider, the same name) and `user_tag` +/// (the `triple-c-user` value the cluster is named after). +#[allow(dead_code)] // the app reads it from Task 4 on +pub const USER_RECORD_FIELDS: [&str; 5] = [ + "schema", + "instance_type", + "cluster_arn", + "capacity_provider", + "user_tag", +]; + +/// The most instances a user's EC2 capacity may run at once. +pub const EC2_MAX_INSTANCES: u32 = 4; + +/// A user's optional EC2 capacity, as the onboarding module takes it. +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] +pub struct Ec2Compute { + /// One of the types `ec2_instance_spec` knows. + pub instance_type: String, + /// 1 to [`EC2_MAX_INSTANCES`]. + pub max_instances: u32, + /// The user's `triple-c-user` principal tag value. + pub user_tag: String, +} + /// Whether a project id is used in names as it is: 1 to 64 characters of /// `[A-Za-z0-9-]`. Every UUID (how the app makes ids) is. fn is_clean_project_id(id: &str) -> bool { @@ -400,16 +439,46 @@ pub fn environment_vars( } /// The onboarding module's `terraform.tfvars.json` for the user whose -/// `aws:userid` is `owner_id`. Bedrock stays on the workspace user's own -/// credentials unless a later setting opts the task role in. -pub fn onboarding_vars(env: &str, region: &str, owner_id: &str) -> serde_json::Value { - json!({ +/// `aws:userid` is `owner_id`, with their EC2 capacity or none (empty +/// `ec2_instance_type`: the module makes nothing for EC2). Applies the same +/// rules as the module's EC2 variable validations. Bedrock stays on the +/// workspace user's own credentials unless a later setting opts the task +/// role in. +pub fn onboarding_vars( + env: &str, + region: &str, + owner_id: &str, + ec2: Option<&Ec2Compute>, +) -> Result { + let (instance_type, max_instances, user_tag) = match ec2 { + None => (String::new(), 1, String::new()), + Some(c) => { + if crate::models::project::ec2_instance_spec(&c.instance_type).is_none() { + return Err(format!( + "\"{}\" is not an instance type Triple-C supports (m7i, m7g, c7i, c7g, r7i, \ + r7g from large to 4xlarge; t3, t4g from large to 2xlarge)", + c.instance_type.escape_debug() + )); + } + if !(1..=EC2_MAX_INSTANCES).contains(&c.max_instances) { + return Err(format!( + "The number of instances must be from 1 to {EC2_MAX_INSTANCES}" + )); + } + let tag = validate_ec2_user_tag(&c.user_tag)?; + (c.instance_type.clone(), c.max_instances, tag) + } + }; + Ok(json!({ "environment_name": env, "region": region, "owner_id": owner_id, "owner_key": owner_key(region, owner_id), "bedrock_on_task_role": false, - }) + "ec2_instance_type": instance_type, + "ec2_max_instances": max_instances, + "ec2_user_tag": user_tag, + })) } /// The boundary module's `terraform.tfvars.json`: the shipped boundary diff --git a/app/src-tauri/src/aws/tofu_modules/tests.rs b/app/src-tauri/src/aws/tofu_modules/tests.rs index 4dcb3d3..fc6ec0b 100644 --- a/app/src-tauri/src/aws/tofu_modules/tests.rs +++ b/app/src-tauri/src/aws/tofu_modules/tests.rs @@ -242,8 +242,14 @@ fn same_user_and_environment_in_two_regions_do_not_collide() { assert_ne!(wt, et); assert_ne!(we, ee); assert_ne!( - state_key(Deployment::User { env: "dev", owner_key: &west }), - state_key(Deployment::User { env: "dev", owner_key: &east }) + state_key(Deployment::User { + env: "dev", + owner_key: &west + }), + state_key(Deployment::User { + env: "dev", + owner_key: &east + }) ); } @@ -361,7 +367,10 @@ fn an_existing_network_is_checked_before_anything_is_built() { let lookup = lookups[0]; assert_eq!(label(lookup, 1), Some("existing")); let count = render(attr(&lookup.body, "count").expect("count")); - assert!(count.contains("var.network_mode") && count.contains("\"existing\""), "{count}"); + assert!( + count.contains("var.network_mode") && count.contains("\"existing\""), + "{count}" + ); assert!(count.contains('2'), "{count}"); let id = render(attr(&lookup.body, "id").expect("id")); assert!(id.contains("var.subnet_ids[count.index]"), "{id}"); @@ -396,7 +405,10 @@ fn the_onboarding_completion_output_waits_for_every_resource() { let mut n = 0; for r in top_blocks(&body, "resource") { let addr = format!("{}.{}", label(r, 0).unwrap(), label(r, 1).unwrap()); - assert!(deps.contains(&addr), "onboarding_complete doesn't wait for {addr}: {deps}"); + assert!( + deps.contains(&addr), + "onboarding_complete doesn't wait for {addr}: {deps}" + ); n += 1; } assert!(n >= 9, "only {n} resources"); @@ -405,7 +417,7 @@ fn the_onboarding_completion_output_waits_for_every_resource() { #[test] fn the_module_versions_agree() { assert_eq!(ENVIRONMENT_MODULE_VERSION, 2); - assert_eq!(ONBOARD_MODULE_VERSION, 1); + assert_eq!(ONBOARD_MODULE_VERSION, 2); let body = parsed(ModuleKind::Environment); let locals: Vec<_> = top_blocks(&body, "locals") .filter_map(|b| attr(&b.body, "template_version")) @@ -626,7 +638,7 @@ fn every_variable_is_validated() { fn module_files_ship_the_lock_file() { for (kind, extra) in [ (ModuleKind::Environment, &["network.tf"][..]), - (ModuleKind::UserOnboard, &["iam.tf", "efs.tf"][..]), + (ModuleKind::UserOnboard, &["iam.tf", "efs.tf", "ec2.tf"][..]), (ModuleKind::PermissionsBoundary, &[][..]), ] { let names: Vec<_> = module_files(kind).iter().map(|(n, _)| *n).collect(); @@ -737,12 +749,15 @@ fn environment_vars_cover_every_network_mode() { // The onboarding and permissions-boundary modules. // --------------------------------------------------------------------------- -const ONBOARD_VARIABLES: [&str; 5] = [ +const ONBOARD_VARIABLES: [&str; 8] = [ "environment_name", "region", "owner_id", "owner_key", "bedrock_on_task_role", + "ec2_instance_type", + "ec2_max_instances", + "ec2_user_tag", ]; /// The boundary ARN every module-created role carries, as the module writes it. @@ -894,15 +909,38 @@ fn every_onboarding_role_carries_the_boundary_and_owner_tag() { .count(), 1 ); + // What default tags don't reach (a launch's instances and volumes, the + // group) gets them whole from `aws_default_tags`; the one other + // `triple-c:` tag is the instance role's cluster. for block in all_blocks(&body) { if block.identifier.as_str() == "default_tags" { continue; } for key in ["tags", "tags_all"] { if let Some(t) = attr(&block.body, key) { + if !matches!(t, Expression::Object(_)) { + assert_eq!( + render(t), + "data.aws_default_tags.current[0].tags", + "{:?}", + block.labels + ); + continue; + } let keys = object_keys(t); + let allowed: &[&str] = if block + .labels + .iter() + .map(|l| l.as_str()) + .eq(["aws_iam_role", "instance"]) + { + &["triple-c:cluster"] + } else { + &[] + }; assert!( - keys.iter().all(|k| !k.starts_with("triple-c:")), + keys.iter() + .all(|k| !k.starts_with("triple-c:") || allowed.contains(&k.as_str())), "{:?} sets triple-c tags {keys:?}", block.labels ); @@ -910,14 +948,15 @@ fn every_onboarding_role_carries_the_boundary_and_owner_tag() { } } - // Exactly the two per-user roles, named as the app names them, each + // Exactly the per-user roles, named as the app names them, each // bounded; their permissions are inline only (nothing attached that the // module doesn't spell out). let roles = resources(&body, "aws_iam_role"); - assert_eq!(roles.len(), 2, "task and exec roles"); + assert_eq!(roles.len(), 3, "task, exec and instance roles"); let key = owner_key("us-west-2", "AROAEXAMPLE:alice"); let (task, exec) = user_role_names("dev", &key); - for (name, want) in [("task", task), ("exec", exec)] { + let instance = user_instance_role_name("dev", &key); + for (name, want) in [("task", task), ("exec", exec), ("instance", instance)] { let role = resource(&body, "aws_iam_role", name); let named = expand_locals(&body, &template_text(attr(&role.body, "name").unwrap())) .replace("${var.environment_name}", "dev") @@ -938,7 +977,6 @@ fn every_onboarding_role_carries_the_boundary_and_owner_tag() { "aws_iam_policy_attachment", "aws_iam_policy", "aws_iam_user", - "aws_iam_instance_profile", ] { assert!(resources(&body, ty).is_empty(), "{ty} present"); } @@ -955,7 +993,12 @@ fn every_onboarding_role_carries_the_boundary_and_owner_tag() { #[test] fn role_trust_is_ecs_tasks_in_this_account_only() { let body = parsed(ModuleKind::UserOnboard); + let mut seen = 0; for role in resources(&body, "aws_iam_role") { + if label(role, 1) == Some("instance") { + continue; // EC2's: `the_instance_role_is_ec2s_and_runs_only_the_ecs_agent` + } + seen += 1; let trust = jsonencoded(role, "assume_role_policy"); assert_eq!( statements(&trust), @@ -973,6 +1016,7 @@ fn role_trust_is_ecs_tasks_in_this_account_only() { role.labels ); } + assert_eq!(seen, 2); } #[test] @@ -1154,13 +1198,14 @@ fn the_environment_security_group_gains_no_ingress() { assert_eq!(attr(&sg.body, "egress"), Some(&Expression::Array(vec![]))); assert!(top_blocks(&sg.body, "egress").next().is_none()); - // The environment's group is referenced only as that rule's source. + // The environment's group is referenced only as that rule's source and + // as the EC2 instances' group (which adds no rule to it). let text = tf_text(ModuleKind::UserOnboard); - assert_eq!(text.matches("local.env.security_group_id").count(), 1); + assert_eq!(text.matches("local.env.security_group_id").count(), 2); assert_eq!( text.matches("security_group_id").count(), - 4, - "the rule, the record check and its message, and the efs group output" + 5, + "the rule, the launch template, the record check and its message, and the efs group output" ); } @@ -1274,8 +1319,9 @@ fn exec_role_reads_only_its_owners_secrets() { #[test] fn onboarding_reads_the_environment_only_from_its_record() { let body = parsed(ModuleKind::UserOnboard); + // The other parameter read is the public AMI id (EC2 capacity). let params: Vec<_> = top_blocks(&body, "data") - .filter(|b| label(b, 0) == Some("aws_ssm_parameter")) + .filter(|b| label(b, 0) == Some("aws_ssm_parameter") && label(b, 1) != Some("ecs_ami")) .collect(); assert_eq!(params.len(), 1); assert_eq!( @@ -1286,13 +1332,19 @@ fn onboarding_reads_the_environment_only_from_its_record() { // No remote state, no other reads of the environment's deployment. let text = tf_text(ModuleKind::UserOnboard); assert!(!text.contains("terraform_remote_state")); - assert!(resources(&body, "aws_ssm_parameter").is_empty()); + // The one parameter it writes is the user's own record, not the + // environment's. + let written: Vec<_> = resources(&body, "aws_ssm_parameter") + .into_iter() + .filter_map(|b| label(b, 1)) + .collect(); + assert_eq!(written, ["user"]); } #[test] fn onboarding_vars_name_the_owner() { let owner = "AROAEXAMPLEID:alice@example.com"; - let vars = onboarding_vars("dev", "us-west-2", owner); + let vars = onboarding_vars("dev", "us-west-2", owner, None).unwrap(); assert_eq!( vars, json!({ @@ -1301,9 +1353,82 @@ fn onboarding_vars_name_the_owner() { "owner_id": owner, "owner_key": owner_key("us-west-2", owner), "bedrock_on_task_role": false, + "ec2_instance_type": "", + "ec2_max_instances": 1, + "ec2_user_tag": "", }) ); + // Without EC2 capacity the EC2 variables are the module's defaults, so + // the plan is the Fargate-only one. let body = parsed(ModuleKind::UserOnboard); + for (name, value) in [ + ("ec2_instance_type", json!("")), + ("ec2_max_instances", json!(1)), + ("ec2_user_tag", json!("")), + ] { + let v = top_blocks(&body, "variable") + .find(|b| label(b, 0) == Some(name)) + .unwrap(); + assert_eq!(to_json(attr(&v.body, "default").unwrap()), value, "{name}"); + assert_eq!(vars[name], value, "{name}"); + } + + let ec2 = Ec2Compute { + instance_type: "m7g.xlarge".into(), + max_instances: 3, + user_tag: "alice-1".into(), + }; + let vars = onboarding_vars("dev", "us-west-2", owner, Some(&ec2)).unwrap(); + assert_eq!(vars["ec2_instance_type"], "m7g.xlarge"); + assert_eq!(vars["ec2_max_instances"], 3); + assert_eq!(vars["ec2_user_tag"], "alice-1"); + for bad in [ + Ec2Compute { + instance_type: "".into(), + ..ec2.clone() + }, + Ec2Compute { + instance_type: "p5.48xlarge".into(), + ..ec2.clone() + }, + Ec2Compute { + instance_type: "m7i.8xlarge".into(), + ..ec2.clone() + }, + Ec2Compute { + instance_type: "t3.4xlarge".into(), + ..ec2.clone() + }, + Ec2Compute { + max_instances: 0, + ..ec2.clone() + }, + Ec2Compute { + max_instances: EC2_MAX_INSTANCES + 1, + ..ec2.clone() + }, + Ec2Compute { + user_tag: "".into(), + ..ec2.clone() + }, + Ec2Compute { + user_tag: "a--b".into(), + ..ec2.clone() + }, + Ec2Compute { + user_tag: "-a".into(), + ..ec2.clone() + }, + Ec2Compute { + user_tag: "x".repeat(33), + ..ec2.clone() + }, + ] { + assert!( + onboarding_vars("dev", "us-west-2", owner, Some(&bad)).is_err(), + "{bad:?} accepted" + ); + } let declared: BTreeSet<_> = top_blocks(&body, "variable") .filter_map(|b| label(b, 0)) .collect(); @@ -1612,6 +1737,82 @@ const BACKEND: &[Check] = &[ call("s3:DeleteObject", USER_LOCK, IN_ACCOUNT), ]; +// The onboarding module's EC2 capacity (phase 7, E1–E5, E11) for the user +// whose `triple-c-user` tag is `alice`: cluster, capacity provider, group and +// launch template are `triple-c---u-`, the instance role and +// profile `triple-c---instance` (pinned to the naming +// functions by `the_ec2_call_table_uses_the_shared_names`). +const USER_CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-probe--u-alice"; +const CAPACITY_PROVIDER: &str = + "arn:aws:ecs:{region}:{account}:capacity-provider/triple-c-probe--u-alice"; +const LAUNCH_TEMPLATE: &str = "arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"; +const AUTO_SCALING_GROUP: &str = "arn:aws:autoscaling:{region}:{account}:autoScalingGroup:\ + 00000000-0000-0000-0000-000000000000:autoScalingGroupName/triple-c-probe--u-alice"; +const INSTANCE: &str = "arn:aws:ec2:{region}:{account}:instance/i-00000000000000000"; +const VOLUME: &str = "arn:aws:ec2:{region}:{account}:volume/vol-00000000000000000"; +const IMAGE: &str = "arn:aws:ec2:{region}::image/ami-00000000000000000"; +const INSTANCE_ROLE: &str = "arn:aws:iam::{account}:role/triple-c-probe-0123456789ab-instance"; +const INSTANCE_PROFILE: &str = + "arn:aws:iam::{account}:instance-profile/triple-c-probe-0123456789ab-instance"; +const AUTO_SCALING_SERVICE_ROLE: &str = "arn:aws:iam::{account}:role/aws-service-role/\ + autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"; +const ECS_SERVICE_ROLE: &str = + "arn:aws:iam::{account}:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS"; +const AMI_PARAMETER: &str = "arn:aws:ssm:{region}::parameter/aws/service/ecs/optimized-ami/\ + amazon-linux-2023/recommended/image_id"; +const ARM64_AMI_PARAMETER: &str = "arn:aws:ssm:{region}::parameter/aws/service/ecs/optimized-ami/\ + amazon-linux-2023/arm64/recommended/image_id"; +const USER_RECORD: &str = + "arn:aws:ssm:{region}:{account}:parameter/triple-c/users/probe/0123456789ab"; +/// A launch from the user's launch template (what creating the group +/// checks the caller for). +const FROM_TEMPLATE: Context = &[( + "ec2:LaunchTemplate", + Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"), +)]; +const LT_ARN: ContextValue = + Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"); +/// The template's tag specifications tag the instance and its volume. +const TAGGED_INSTANCE: Context = &[ + (REQUEST_COMPONENT, Literal("user-onboarding")), + ("ec2:LaunchTemplate", LT_ARN), + ("ec2:InstanceType", Literal("m7i.large")), +]; +const TAGGED_VOLUME: Context = &[ + (REQUEST_COMPONENT, Literal("user-onboarding")), + ("ec2:LaunchTemplate", LT_ARN), +]; +/// The environment's tasks group, named in the template. +const TEMPLATE_GROUP: Context = &[ + ("ec2:LaunchTemplate", LT_ARN), + ("ec2:IsLaunchTemplateResource", Literal("true")), + (RESOURCE_COMPONENT, Literal("environment")), +]; +const AMAZON_IMAGE: Context = &[ + ("ec2:Owner", Literal("amazon")), + ("ec2:LaunchTemplate", LT_ARN), + ("ec2:IsLaunchTemplateResource", Literal("true")), +]; +/// The group pins the template to a version (`latest_version`, never +/// `$Latest`/`$Default`) and has no load balancer. +const GROUP_CREATE: Context = &[ + (REQUEST_COMPONENT, Literal("user-onboarding")), + ( + "autoscaling:LaunchTemplateVersionSpecified", + Literal("true"), + ), + ("autoscaling:InstanceTypes", Literal("m7i.large")), +]; +const GROUP_UPDATE: Context = &[ + (RESOURCE_COMPONENT, Literal("user-onboarding")), + ( + "autoscaling:LaunchTemplateVersionSpecified", + Literal("true"), + ), + ("autoscaling:InstanceTypes", Literal("m7i.large")), +]; +const TO_EC2: Context = &[("iam:PassedToService", Literal("ec2.amazonaws.com"))]; + const MODULE_CALLS: &[(&str, &[Check])] = &[ ( "aws_ecs_cluster", @@ -1628,14 +1829,35 @@ const MODULE_CALLS: &[(&str, &[Check])] = &[ call("ecs:TagResource", CLUSTER, ENV_TAGGED), call("ecs:UntagResource", CLUSTER, ENV_TAGGED), call("ecs:DeleteCluster", CLUSTER, ENV_TAGGED), + // The user's own cluster (onboarding, EC2 capacity). + call("ecs:CreateCluster", USER_CLUSTER, USER_CREATE), + call( + "ecs:TagResource", + USER_CLUSTER, + &[("ecs:CreateAction", Literal("CreateCluster"))], + ), + call("ecs:DescribeClusters", USER_CLUSTER, NONE), + call("ecs:ListTagsForResource", USER_CLUSTER, NONE), + call("ecs:UpdateCluster", USER_CLUSTER, USER_TAGGED), + call("ecs:TagResource", USER_CLUSTER, USER_TAGGED), + call("ecs:UntagResource", USER_CLUSTER, USER_TAGGED), + call("ecs:DeleteCluster", USER_CLUSTER, USER_TAGGED), ], ), ( - // Untaggable: authorized against the (named) cluster. + // Untaggable: authorized against the (named) cluster, and (a + // hypothesis) the user's capacity provider. "aws_ecs_cluster_capacity_providers", &[ call("ecs:PutClusterCapacityProviders", CLUSTER, ENV_TAGGED), call("ecs:DescribeClusters", CLUSTER, NONE), + call("ecs:PutClusterCapacityProviders", USER_CLUSTER, USER_TAGGED), + call( + "ecs:PutClusterCapacityProviders", + CAPACITY_PROVIDER, + USER_TAGGED, + ), + call("ecs:DescribeClusters", USER_CLUSTER, NONE), ], ), ( @@ -1731,6 +1953,13 @@ const MODULE_CALLS: &[(&str, &[Check])] = &[ call("ssm:ListTagsForResource", PARAMETER, NONE), call("ssm:RemoveTagsFromResource", PARAMETER, NONE), call("ssm:DeleteParameter", PARAMETER, NONE), + // The user's EC2 record (onboarding, E11). + call("ssm:PutParameter", USER_RECORD, USER_CREATE), + call("ssm:AddTagsToResource", USER_RECORD, USER_CREATE), + call("ssm:GetParameter", USER_RECORD, NONE), + call("ssm:ListTagsForResource", USER_RECORD, NONE), + call("ssm:RemoveTagsFromResource", USER_RECORD, NONE), + call("ssm:DeleteParameter", USER_RECORD, NONE), ], ), ( @@ -1921,6 +2150,14 @@ const MODULE_CALLS: &[(&str, &[Check])] = &[ call("iam:UpdateRoleDescription", TASK_ROLE, NONE), call("iam:UntagRole", TASK_ROLE, NONE), call("iam:DeleteRole", EXEC_ROLE, NONE), + // The EC2 instance role, tagged `triple-c:cluster = `: the boundary keeps the ECS agent on that cluster. + call("iam:CreateRole", INSTANCE_ROLE, BOUNDED), + call("iam:TagRole", INSTANCE_ROLE, NONE), + call("iam:GetRole", INSTANCE_ROLE, NONE), + call("iam:ListInstanceProfilesForRole", INSTANCE_ROLE, NONE), + call("iam:UntagRole", INSTANCE_ROLE, NONE), + call("iam:DeleteRole", INSTANCE_ROLE, NONE), ], ), ( @@ -1930,128 +2167,9 @@ const MODULE_CALLS: &[(&str, &[Check])] = &[ call("iam:PutRolePolicy", TASK_ROLE, BOUNDED), call("iam:GetRolePolicy", TASK_ROLE, NONE), call("iam:DeleteRolePolicy", EXEC_ROLE, BOUNDED), - ], - ), - ( - "data.aws_caller_identity", - &[call("sts:GetCallerIdentity", "*", NONE)], - ), - ("data.aws_partition", &[]), - ( - "data.aws_availability_zones", - &[call("ec2:DescribeAvailabilityZones", "*", NONE)], - ), - ( - "data.aws_ssm_parameter", - &[call("ssm:GetParameter", PARAMETER, NONE)], - ), - ("data.aws_subnet", &[call("ec2:DescribeSubnets", "*", NONE)]), - ("backend.s3", BACKEND), -]; - -// Phase 7 (per-user EC2 capacity, E1–E5, E11; fix round 1): the calls the onboarding -// module's EC2 resources will make, written down with the policy (Task 2) -// before the resources exist. Task 3 moves each entry into MODULE_CALLS -// under its type (merging with the existing `aws_ecs_cluster`, -// `aws_ecs_cluster_capacity_providers`, `aws_iam_role`, `aws_ssm_parameter` -// and `data.aws_ssm_parameter` entries) and deletes this table. Names are -// the user's (`triple-c--[-instance]`). -const USER_CLUSTER: &str = "arn:aws:ecs:{region}:{account}:cluster/triple-c-probe--u-alice"; -const CAPACITY_PROVIDER: &str = - "arn:aws:ecs:{region}:{account}:capacity-provider/triple-c-probe--u-alice"; -const LAUNCH_TEMPLATE: &str = "arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"; -const AUTO_SCALING_GROUP: &str = "arn:aws:autoscaling:{region}:{account}:autoScalingGroup:\ - 00000000-0000-0000-0000-000000000000:autoScalingGroupName/triple-c-probe--u-alice"; -const INSTANCE: &str = "arn:aws:ec2:{region}:{account}:instance/i-00000000000000000"; -const VOLUME: &str = "arn:aws:ec2:{region}:{account}:volume/vol-00000000000000000"; -const IMAGE: &str = "arn:aws:ec2:{region}::image/ami-00000000000000000"; -const INSTANCE_ROLE: &str = "arn:aws:iam::{account}:role/triple-c-probe-0123456789ab-instance"; -const INSTANCE_PROFILE: &str = - "arn:aws:iam::{account}:instance-profile/triple-c-probe-0123456789ab-instance"; -const AUTO_SCALING_SERVICE_ROLE: &str = "arn:aws:iam::{account}:role/aws-service-role/\ - autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"; -const ECS_SERVICE_ROLE: &str = - "arn:aws:iam::{account}:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS"; -const AMI_PARAMETER: &str = "arn:aws:ssm:{region}::parameter/aws/service/ecs/optimized-ami/\ - amazon-linux-2023/recommended/image_id"; -const USER_RECORD: &str = - "arn:aws:ssm:{region}:{account}:parameter/triple-c/users/probe/0123456789ab"; -/// A launch from the user's launch template (what creating the group -/// checks the caller for). -const FROM_TEMPLATE: Context = &[( - "ec2:LaunchTemplate", - Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"), -)]; -const LT_ARN: ContextValue = - Literal("arn:aws:ec2:{region}:{account}:launch-template/lt-00000000000000000"); -/// The template's tag specifications tag the instance and its volume. -const TAGGED_INSTANCE: Context = &[ - (REQUEST_COMPONENT, Literal("user-onboarding")), - ("ec2:LaunchTemplate", LT_ARN), - ("ec2:InstanceType", Literal("m7i.large")), -]; -const TAGGED_VOLUME: Context = &[ - (REQUEST_COMPONENT, Literal("user-onboarding")), - ("ec2:LaunchTemplate", LT_ARN), -]; -/// The environment's tasks group, named in the template. -const TEMPLATE_GROUP: Context = &[ - ("ec2:LaunchTemplate", LT_ARN), - ("ec2:IsLaunchTemplateResource", Literal("true")), - (RESOURCE_COMPONENT, Literal("environment")), -]; -const AMAZON_IMAGE: Context = &[ - ("ec2:Owner", Literal("amazon")), - ("ec2:LaunchTemplate", LT_ARN), - ("ec2:IsLaunchTemplateResource", Literal("true")), -]; -/// The group pins the template to a version (`latest_version`, never -/// `$Latest`/`$Default`) and has no load balancer. -const GROUP_CREATE: Context = &[ - (REQUEST_COMPONENT, Literal("user-onboarding")), - ( - "autoscaling:LaunchTemplateVersionSpecified", - Literal("true"), - ), - ("autoscaling:InstanceTypes", Literal("m7i.large")), -]; -const GROUP_UPDATE: Context = &[ - (RESOURCE_COMPONENT, Literal("user-onboarding")), - ( - "autoscaling:LaunchTemplateVersionSpecified", - Literal("true"), - ), - ("autoscaling:InstanceTypes", Literal("m7i.large")), -]; -const TO_EC2: Context = &[("iam:PassedToService", Literal("ec2.amazonaws.com"))]; - -const EC2_COMPUTE_CALLS: &[(&str, &[Check])] = &[ - ( - "aws_ecs_cluster (user)", - &[ - call("ecs:CreateCluster", USER_CLUSTER, USER_CREATE), - call( - "ecs:TagResource", - USER_CLUSTER, - &[("ecs:CreateAction", Literal("CreateCluster"))], - ), - call("ecs:DescribeClusters", USER_CLUSTER, NONE), - call("ecs:ListTagsForResource", USER_CLUSTER, NONE), - call("ecs:UpdateCluster", USER_CLUSTER, USER_TAGGED), - call("ecs:DeleteCluster", USER_CLUSTER, USER_TAGGED), - ], - ), - ( - // Hypothesis: authorized against the cluster and the provider. - "aws_ecs_cluster_capacity_providers (user)", - &[ - call("ecs:PutClusterCapacityProviders", USER_CLUSTER, USER_TAGGED), - call( - "ecs:PutClusterCapacityProviders", - CAPACITY_PROVIDER, - USER_TAGGED, - ), - call("ecs:DescribeClusters", USER_CLUSTER, NONE), + call("iam:PutRolePolicy", INSTANCE_ROLE, BOUNDED), + call("iam:GetRolePolicy", INSTANCE_ROLE, NONE), + call("iam:DeleteRolePolicy", INSTANCE_ROLE, BOUNDED), ], ), ( @@ -2105,7 +2223,9 @@ const EC2_COMPUTE_CALLS: &[(&str, &[Check])] = &[ // launch puts on, the instance role passed to EC2). The group's own // launches run as Auto Scaling's service-linked role. ASG tags are // not the provider's default_tags: the module sets them per group. - // SetInstanceProtection: hypothesis, for draining before destroy. + // Deleting first drains the group (`force_delete` off): an update to + // 0 naming no template, scale-in protection cleared on its + // instances, then the wait for them to terminate. "aws_autoscaling_group", &[ call( @@ -2136,7 +2256,6 @@ const EC2_COMPUTE_CALLS: &[(&str, &[Check])] = &[ AUTO_SCALING_GROUP, GROUP_UPDATE, ), - // The drain before destroy leaves the template alone. call( "autoscaling:UpdateAutoScalingGroup", AUTO_SCALING_GROUP, @@ -2160,20 +2279,6 @@ const EC2_COMPUTE_CALLS: &[(&str, &[Check])] = &[ ), ], ), - ( - "aws_iam_role (instance)", - &[ - call("iam:CreateRole", INSTANCE_ROLE, BOUNDED), - // `triple-c:cluster = `: the boundary keeps - // the ECS agent on that cluster. - call("iam:TagRole", INSTANCE_ROLE, NONE), - call("iam:PutRolePolicy", INSTANCE_ROLE, BOUNDED), - call("iam:GetRole", INSTANCE_ROLE, NONE), - call("iam:ListInstanceProfilesForRole", INSTANCE_ROLE, NONE), - call("iam:DeleteRolePolicy", INSTANCE_ROLE, BOUNDED), - call("iam:DeleteRole", INSTANCE_ROLE, NONE), - ], - ), ( // Hypothesis: adding the role needs it passable to EC2. "aws_iam_instance_profile", @@ -2190,26 +2295,29 @@ const EC2_COMPUTE_CALLS: &[(&str, &[Check])] = &[ ], ), ( - "data.aws_ssm_parameter (AMI)", - &[call("ssm:GetParameter", AMI_PARAMETER, NONE)], + "data.aws_caller_identity", + &[call("sts:GetCallerIdentity", "*", NONE)], + ), + ("data.aws_partition", &[]), + // The provider's own configuration: no call. + ("data.aws_default_tags", &[]), + ( + "data.aws_availability_zones", + &[call("ec2:DescribeAvailabilityZones", "*", NONE)], ), ( - "aws_ssm_parameter (user record)", + "data.aws_ssm_parameter", &[ - call("ssm:PutParameter", USER_RECORD, USER_CREATE), - call("ssm:AddTagsToResource", USER_RECORD, USER_CREATE), - call("ssm:GetParameter", USER_RECORD, NONE), - call("ssm:ListTagsForResource", USER_RECORD, NONE), - call("ssm:DeleteParameter", USER_RECORD, NONE), + call("ssm:GetParameter", PARAMETER, NONE), + // The public ECS-optimized image ids (EC2 capacity). + call("ssm:GetParameter", AMI_PARAMETER, NONE), + call("ssm:GetParameter", ARM64_AMI_PARAMETER, NONE), ], ), + ("data.aws_subnet", &[call("ec2:DescribeSubnets", "*", NONE)]), + ("backend.s3", BACKEND), ]; -/// MODULE_CALLS and the phase-7 calls Task 3's resources will make. -fn all_module_calls() -> impl Iterator { - MODULE_CALLS.iter().chain(EC2_COMPUTE_CALLS.iter()) -} - /// `resource.` and `data.` of the environment and onboarding /// modules, and `backend.s3`. fn module_types() -> BTreeSet { @@ -2302,7 +2410,7 @@ fn the_admin_tier_can_apply_every_module_resource() { let admin = tier_statements(&[Tier::EnvironmentAdmin]); let both = tier_statements(&[Tier::EnvironmentAdmin, Tier::WorkspaceUser]); let mut missing = Vec::new(); - for (ty, calls) in all_module_calls() { + for (ty, calls) in MODULE_CALLS { for c in *calls { for (which, stmts) in [("admin", &admin), ("admin + workspace", &both)] { if !allowed_by(stmts, c) { @@ -2331,6 +2439,8 @@ const ONBOARD_SAMPLES: &[(&str, &str)] = &[ ), ("${var.region}", "us-west-2"), ("${var.owner_id}", "AROAEXAMPLEME:alice@example.com"), + ("${var.environment_name}", "probe"), + ("${var.ec2_user_tag}", "alice"), ("${local.env.log_group}", "/triple-c/probe"), ( "${local.env.kms_key_arn}", @@ -2380,6 +2490,16 @@ fn every_onboarding_role_stays_inside_the_boundary() { } let mut context: Vec<(&'static str, ContextValue)> = vec![(RESOURCE_COMPONENT, Literal("user-onboarding"))]; + // The instance role's sessions carry its `triple-c:cluster` tag. + if render(attr(&policy.body, "role").unwrap()) == "aws_iam_role.instance[0].id" { + let role = resource(&body, "aws_iam_role", "instance"); + let tag = object_get(attr(&role.body, "tags").unwrap(), "triple-c:cluster") + .expect("the instance role's cluster tag"); + context.push(( + "aws:PrincipalTag/triple-c:cluster", + Literal(leak(render_sample(&template_text(tag)))), + )); + } if let Some(cond) = stmt.get("Condition") { for (op, entries) in cond.as_object().unwrap() { assert_eq!(op, "StringEquals", "{:?}: unexpected {op}", policy.labels); @@ -2410,7 +2530,7 @@ fn every_onboarding_role_stays_inside_the_boundary() { } } } - assert!(seen >= 15, "only {seen} role grants checked"); + assert!(seen >= 25, "only {seen} role grants checked"); } /// Admin write checks for calls the app makes itself, not the modules. @@ -2450,7 +2570,8 @@ fn every_module_write_has_an_admin_check_and_vice_versa() { .map(|c| c.action) .filter(|a| is_write(a)) .collect(); - let module: BTreeSet<&str> = all_module_calls() + let module: BTreeSet<&str> = MODULE_CALLS + .iter() .flat_map(|(_, calls)| calls.iter().map(|c| c.action)) .filter(|a| is_write(a)) .collect(); @@ -2483,7 +2604,9 @@ fn the_lifetime_cap_maximum_is_the_same_in_rust_typescript_and_hcl() { .find(|(f, _)| *f == "variables.tf") .unwrap() .1; - let block = &vars[vars.find("variable \"max_workspace_hours\"").expect("the variable")..]; + let block = &vars[vars + .find("variable \"max_workspace_hours\"") + .expect("the variable")..]; let block = &block[..block.find("\n}\n").unwrap()]; assert!( block.contains(&format!("var.max_workspace_hours <= {max}")), @@ -2499,3 +2622,651 @@ fn the_lifetime_cap_maximum_is_the_same_in_rust_typescript_and_hcl() { let envs = include_str!("../environments.rs"); assert!(envs.contains(&format!("from 0 to {max}"))); } + +// --------------------------------------------------------------------------- +// The onboarding module's optional EC2 capacity (phase 7). +// --------------------------------------------------------------------------- + +/// The onboarding module's EC2 file, parsed alone. +fn ec2_body() -> Body { + let text = module_files(ModuleKind::UserOnboard) + .iter() + .find(|(n, _)| *n == "ec2.tf") + .expect("ec2.tf") + .1; + hcl::parse(text).unwrap() +} + +/// The 30 instance types the app can size (`ec2_instance_spec`). +fn supported_instance_types() -> BTreeSet { + let mut known = BTreeSet::new(); + for family in [ + "m7i", "m7g", "c7i", "c7g", "r7i", "r7g", "t3", "t4g", "m7a", "p5", "g6", + ] { + for size in [ + "medium", "large", "xlarge", "2xlarge", "4xlarge", "8xlarge", "48xlarge", + ] { + let t = format!("{family}.{size}"); + if crate::models::project::ec2_instance_spec(&t).is_some() { + known.insert(t); + } + } + } + assert_eq!(known.len(), 30); + known +} + +/// `render` without whitespace, for comparing short lists. +fn flat(expr: &Expression) -> String { + render(expr).split_whitespace().collect() +} + +fn one_block<'a>(body: &'a Body, ident: &str) -> &'a Block { + let found: Vec<_> = body + .blocks() + .filter(|b| b.identifier.as_str() == ident) + .collect(); + assert_eq!(found.len(), 1, "one {ident} block"); + found[0] +} + +fn variable<'a>(body: &'a Body, name: &str) -> &'a Block { + top_blocks(body, "variable") + .find(|b| label(b, 0) == Some(name)) + .unwrap_or_else(|| panic!("variable {name}")) +} + +/// Without `ec2_instance_type` (the default) the module makes nothing for +/// EC2: every resource and data source of ec2.tf is counted by it, and +/// every other one is the version-1 set, unchanged (its rendered HCL is +/// pinned), so a Fargate-only onboarding plans as before apart from the +/// version tag. +#[test] +fn ec2_capacity_exists_only_with_an_instance_type() { + let body = parsed(ModuleKind::UserOnboard); + assert_eq!( + render(local_def(&body, "ec2")), + "var.ec2_instance_type != \"\"" + ); + assert_eq!(render(local_def(&body, "ec2_count")), "local.ec2 ? 1 : 0"); + assert_eq!( + attr(&variable(&body, "ec2_instance_type").body, "default"), + Some(&Expression::String(String::new())) + ); + + let ec2 = ec2_body(); + let mut gated = 0; + for b in ec2.blocks() { + if matches!(b.identifier.as_str(), "resource" | "data") { + assert_eq!( + attr(&b.body, "count").map(render).as_deref(), + Some("local.ec2_count"), + "{:?} is not counted by the instance type", + b.labels + ); + gated += 1; + } + } + assert_eq!(gated, 11); + + // Everything else: exactly version 1's resources, as they were, and its + // reads (the environment record's check gained `assign_public_ip`, + // which the launch template uses; checks change no plan). + let ec2_addrs: BTreeSet = ec2 + .blocks() + .filter(|b| matches!(b.identifier.as_str(), "resource" | "data")) + .map(|b| format!("{} {:?}", b.identifier.as_str(), b.labels)) + .collect(); + let mut rest = Vec::new(); + let mut reads = BTreeSet::new(); + for b in body.blocks() { + let addr = format!("{} {:?}", b.identifier.as_str(), b.labels); + if ec2_addrs.contains(&addr) { + continue; + } + match b.identifier.as_str() { + "resource" => rest.push(hcl::format::to_string(b).unwrap()), + "data" => { + reads.insert(format!("{}.{}", label(b, 0).unwrap(), label(b, 1).unwrap())); + } + _ => {} + } + } + assert_eq!(rest.len(), 9, "version 1's 9 resources"); + assert_eq!( + reads, + BTreeSet::from([ + "aws_caller_identity.current".to_string(), + "aws_partition.current".to_string(), + "aws_ssm_parameter.environment".to_string(), + "aws_subnet.task".to_string(), + ]) + ); + let fingerprint = sha256_prefix(&rest.join("\n")); + assert_eq!( + fingerprint, FARGATE_ONBOARDING_FINGERPRINT, + "a version-1 resource changed: Fargate onboardings would plan differently" + ); +} + +/// `sha256_prefix` of the onboarding module's non-EC2 resources as of +/// version 1 (rendered by hcl-rs, in file order). +const FARGATE_ONBOARDING_FINGERPRINT: &str = "ab948d6ab8be"; + +#[test] +fn ec2_names_are_the_shared_names() { + let body = parsed(ModuleKind::UserOnboard); + let env = "${var.environment_name}"; + assert_eq!( + template_text(local_def(&body, "ec2_name")), + user_ec2_stem(env, "${var.ec2_user_tag}") + ); + assert_eq!( + expand_locals( + &body, + &template_text(local_def(&body, "instance_role_name")) + ), + user_instance_role_name(env, "${var.owner_key}") + ); + let ec2 = ec2_body(); + for ty in [ + "aws_ecs_cluster", + "aws_ecs_capacity_provider", + "aws_launch_template", + "aws_autoscaling_group", + ] { + let r = resource(&ec2, ty, "ec2"); + assert_eq!( + render(attr(&r.body, "name").unwrap()), + "local.ec2_name", + "{ty}" + ); + } + let role = resource(&ec2, "aws_iam_role", "instance"); + assert_eq!( + render(attr(&role.body, "name").unwrap()), + "local.instance_role_name" + ); + let profile = resource(&ec2, "aws_iam_instance_profile", "instance"); + assert_eq!( + render(attr(&profile.body, "name").unwrap()), + "aws_iam_role.instance[0].name" + ); + assert_eq!( + render(attr(&profile.body, "role").unwrap()), + "aws_iam_role.instance[0].name" + ); +} + +/// The EC2 variables follow the app's rules: the instance type is one of +/// the 30 the app can size (the admin policy's lists, `policies.rs` pins +/// those), 1 to 4 instances, the user tag as `validate_ec2_user_tag` and +/// required with a type. +#[test] +fn ec2_variables_mirror_the_apps_rules() { + let body = parsed(ModuleKind::UserOnboard); + let ty = variable(&body, "ec2_instance_type"); + let cond = render(attr(&one_block(&ty.body, "validation").body, "condition").unwrap()); + let listed: BTreeSet = cond + .split('"') + .filter(|s| s.contains('.') && !s.contains(' ')) + .map(str::to_string) + .collect(); + assert_eq!(listed, supported_instance_types()); + assert!( + cond.starts_with("var.ec2_instance_type == \"\" || contains(["), + "{cond}" + ); + + let max = variable(&body, "ec2_max_instances"); + assert_eq!( + attr(&max.body, "default"), + Some(&Expression::Number(1.into())) + ); + let cond = render(attr(&one_block(&max.body, "validation").body, "condition").unwrap()); + assert!( + cond.contains(&format!("var.ec2_max_instances <= {EC2_MAX_INSTANCES}")), + "{cond}" + ); + assert!(cond.contains("var.ec2_max_instances >= 1"), "{cond}"); + + let tag = variable(&body, "ec2_user_tag"); + let conds: Vec = top_blocks(&tag.body, "validation") + .map(|v| render(attr(&v.body, "condition").unwrap())) + .collect(); + assert_eq!(conds.len(), 2); + for needle in [ + "\"^[A-Za-z0-9-]{1,32}$\"", + "!startswith(var.ec2_user_tag, \"-\")", + "!endswith(var.ec2_user_tag, \"-\")", + "!strcontains(var.ec2_user_tag, \"--\")", + ] { + assert!( + conds[0].contains(needle), + "{needle} missing from {}", + conds[0] + ); + } + assert_eq!( + conds[1], + "var.ec2_instance_type == \"\" || var.ec2_user_tag != \"\"" + ); +} + +/// The image is the ECS-optimized Amazon Linux 2023 one for the type's +/// architecture: arm64 for Graviton families (a `g` after the generation). +#[test] +fn the_ami_is_the_ecs_optimized_one_for_the_architecture() { + let body = parsed(ModuleKind::UserOnboard); + assert_eq!( + render(local_def(&body, "ec2_arm64")), + "can(regex(\"^[a-z]+[0-9]+g[a-z]*\\\\.\", var.ec2_instance_type))" + ); + assert_eq!( + render(local_def(&body, "ecs_ami_parameter")), + "(local.ec2_arm64 ? \"/aws/service/ecs/optimized-ami/amazon-linux-2023/arm64/recommended/\ + image_id\" : \"/aws/service/ecs/optimized-ami/amazon-linux-2023/recommended/image_id\")" + ); + // What that rule says for the supported types. + for t in supported_instance_types() { + let family = t.split('.').next().unwrap(); + let arm = matches!(family, "m7g" | "c7g" | "r7g" | "t4g"); + let rule = family + .trim_start_matches(|c: char| c.is_ascii_lowercase()) + .trim_start_matches(|c: char| c.is_ascii_digit()) + .starts_with('g'); + assert_eq!(rule, arm, "{t}"); + } + let ec2 = ec2_body(); + let ami = top_blocks(&ec2, "data") + .find(|b| label(b, 0) == Some("aws_ssm_parameter")) + .unwrap(); + assert_eq!( + render(attr(&ami.body, "name").unwrap()), + "local.ecs_ami_parameter" + ); + let lt = resource(&ec2, "aws_launch_template", "ec2"); + assert_eq!( + render(attr(<.body, "image_id").unwrap()), + "data.aws_ssm_parameter.ecs_ami[0].insecure_value" + ); +} + +/// The launch template: the variable's type, IMDSv2 at one hop, an +/// encrypted 50 GiB gp3 root volume, the environment's tasks group named in +/// the template, the instance profile, the agent pointed at the user's +/// cluster with task IMDS blocked, and the default tags on what a launch +/// creates. Never a default-version change (no `ModifyLaunchTemplate`). +#[test] +fn the_launch_template_is_pinned() { + let ec2 = ec2_body(); + let lt = resource(&ec2, "aws_launch_template", "ec2"); + let b = <.body; + assert_eq!( + render(attr(b, "instance_type").unwrap()), + "var.ec2_instance_type" + ); + for forbidden in [ + "update_default_version", + "default_version", + "vpc_security_group_ids", + ] { + assert!(attr(b, forbidden).is_none(), "{forbidden}"); + } + for forbidden in [ + "instance_market_options", + "instance_requirements", + "placement", + ] { + assert!(top_blocks(b, forbidden).next().is_none(), "{forbidden}"); + } + + let md = &one_block(b, "metadata_options").body; + assert_eq!( + attr(md, "http_tokens"), + Some(&Expression::String("required".into())) + ); + assert_eq!( + attr(md, "http_put_response_hop_limit"), + Some(&Expression::Number(1.into())) + ); + assert_eq!( + attr(md, "http_endpoint"), + Some(&Expression::String("enabled".into())) + ); + + let bdm = &one_block(b, "block_device_mappings").body; + assert_eq!( + attr(bdm, "device_name"), + Some(&Expression::String("/dev/xvda".into())) + ); + let ebs = &one_block(bdm, "ebs").body; + assert_eq!( + attr(ebs, "volume_size"), + Some(&Expression::Number(50.into())) + ); + assert_eq!( + attr(ebs, "volume_type"), + Some(&Expression::String("gp3".into())) + ); + assert_eq!(attr(ebs, "encrypted"), Some(&Expression::Bool(true))); + assert_eq!( + attr(ebs, "delete_on_termination"), + Some(&Expression::Bool(true)) + ); + + let nic = &one_block(b, "network_interfaces").body; + assert_eq!( + flat(attr(nic, "security_groups").unwrap()), + "[local.env.security_group_id]" + ); + assert_eq!( + render(attr(nic, "associate_public_ip_address").unwrap()), + "local.env.assign_public_ip" + ); + assert!( + attr(nic, "subnet_id").is_none(), + "the group picks the subnet" + ); + + assert_eq!( + render(attr(&one_block(b, "iam_instance_profile").body, "name").unwrap()), + "aws_iam_instance_profile.instance[0].name" + ); + + let user_data = render(attr(b, "user_data").unwrap()); + for needle in [ + "#!/bin/bash", + ">>/etc/ecs/ecs.config", + "ECS_CLUSTER=${aws_ecs_cluster.ec2[0].name}\n", + "ECS_AWSVPC_BLOCK_IMDS=true\n", + ] { + assert!( + user_data.contains(needle), + "{needle:?} missing from {user_data}" + ); + } + assert!( + !user_data.contains("ECS_ENABLE_TASK_ENI"), + "no trunking (E3)" + ); + + let specs: BTreeSet = top_blocks(b, "tag_specifications") + .map(|t| { + assert_eq!( + render(attr(&t.body, "tags").unwrap()), + "data.aws_default_tags.current[0].tags" + ); + match attr(&t.body, "resource_type") { + Some(Expression::String(s)) => s.clone(), + other => panic!("{other:?}"), + } + }) + .collect(); + assert_eq!( + specs, + BTreeSet::from([ + "instance".into(), + "volume".into(), + "network-interface".into() + ]) + ); +} + +/// The group: 0 to `ec2_max_instances`, desired left to ECS, protected from +/// scale-in (ECS's managed termination protection decides), drained before +/// deletion, on a fixed template version, in the environment's subnets, no +/// load balancers, every default tag plus the one ECS adds. +#[test] +fn the_auto_scaling_group_is_pinned() { + let ec2 = ec2_body(); + let asg = resource(&ec2, "aws_autoscaling_group", "ec2"); + let b = &asg.body; + assert_eq!(attr(b, "min_size"), Some(&Expression::Number(0.into()))); + assert_eq!( + render(attr(b, "max_size").unwrap()), + "var.ec2_max_instances" + ); + assert!(attr(b, "desired_capacity").is_none()); + assert_eq!( + attr(b, "protect_from_scale_in"), + Some(&Expression::Bool(true)) + ); + assert_eq!(attr(b, "force_delete"), Some(&Expression::Bool(false))); + assert_eq!( + render(attr(b, "vpc_zone_identifier").unwrap()), + "local.env.subnet_ids" + ); + for forbidden in [ + "target_group_arns", + "load_balancers", + "availability_zones", + "launch_configuration", + ] { + assert!(attr(b, forbidden).is_none(), "{forbidden}"); + } + for forbidden in ["mixed_instances_policy", "warm_pool", "instance_refresh"] { + assert!(top_blocks(b, forbidden).next().is_none(), "{forbidden}"); + } + let lt = &one_block(b, "launch_template").body; + assert_eq!( + render(attr(lt, "id").unwrap()), + "aws_launch_template.ec2[0].id" + ); + assert_eq!( + render(attr(lt, "version").unwrap()), + "aws_launch_template.ec2[0].latest_version" + ); + assert_eq!( + flat(attr(&one_block(b, "lifecycle").body, "ignore_changes").unwrap()), + "[desired_capacity]" + ); + + let dynamic = one_block(b, "dynamic"); + assert_eq!(label(dynamic, 0), Some("tag")); + assert_eq!( + render(attr(&dynamic.body, "for_each").unwrap()), + "data.aws_default_tags.current[0].tags" + ); + let content = &one_block(&dynamic.body, "content").body; + assert_eq!(render(attr(content, "key").unwrap()), "tag.key"); + assert_eq!(render(attr(content, "value").unwrap()), "tag.value"); + let tag = &one_block(b, "tag").body; + assert_eq!( + attr(tag, "key"), + Some(&Expression::String("AmazonECSManaged".into())) + ); +} + +/// The capacity provider and the cluster's provider list: exactly the +/// user's provider, the default strategy, managed scaling to a full fleet +/// one instance at a time. +#[test] +fn the_capacity_provider_scales_one_instance_at_a_time() { + let ec2 = ec2_body(); + let cp = resource(&ec2, "aws_ecs_capacity_provider", "ec2"); + let asgp = &one_block(&cp.body, "auto_scaling_group_provider").body; + assert_eq!( + render(attr(asgp, "auto_scaling_group_arn").unwrap()), + "aws_autoscaling_group.ec2[0].arn" + ); + assert_eq!( + attr(asgp, "managed_termination_protection"), + Some(&Expression::String("ENABLED".into())) + ); + let ms = &one_block(asgp, "managed_scaling").body; + assert_eq!( + attr(ms, "status"), + Some(&Expression::String("ENABLED".into())) + ); + for (k, v) in [ + ("target_capacity", 100), + ("minimum_scaling_step_size", 1), + ("maximum_scaling_step_size", 1), + ("instance_warmup_period", 60), + ] { + assert_eq!(attr(ms, k), Some(&Expression::Number(v.into())), "{k}"); + } + + let ccp = resource(&ec2, "aws_ecs_cluster_capacity_providers", "ec2"); + assert_eq!( + render(attr(&ccp.body, "cluster_name").unwrap()), + "aws_ecs_cluster.ec2[0].name" + ); + assert_eq!( + flat(attr(&ccp.body, "capacity_providers").unwrap()), + "[aws_ecs_capacity_provider.ec2[0].name]" + ); + let strategy = &one_block(&ccp.body, "default_capacity_provider_strategy").body; + assert_eq!( + render(attr(strategy, "capacity_provider").unwrap()), + "aws_ecs_capacity_provider.ec2[0].name" + ); + assert_eq!( + attr(strategy, "weight"), + Some(&Expression::Number(1.into())) + ); +} + +/// The instance role: trusted by EC2, bounded, tagged with the user's +/// cluster (the boundary's fence), and granting exactly the ECS agent's +/// calls on that cluster and its container instances, endpoint discovery, +/// image pulls and the environment's logs. No Session Manager core: ECS +/// Exec's channels run on the task role. +#[test] +fn the_instance_role_is_ec2s_and_runs_only_the_ecs_agent() { + let body = parsed(ModuleKind::UserOnboard); + let role = resource(&body, "aws_iam_role", "instance"); + let trust = jsonencoded(&role, "assume_role_policy"); + assert_eq!( + statements(&trust), + vec![json!({ + "Effect": "Allow", + "Principal": { "Service": "ec2.amazonaws.com" }, + "Action": "sts:AssumeRole", + })] + ); + let tags = attr(&role.body, "tags").unwrap(); + assert_eq!( + object_keys(tags), + BTreeSet::from(["triple-c:cluster".to_string()]) + ); + assert_eq!( + render(object_get(tags, "triple-c:cluster").unwrap()), + "local.ec2_name" + ); + + let policies = role_policies(&body, "instance[0]"); + assert_eq!(policies.len(), 1); + let stmts = statements(&jsonencoded(&policies[0], "policy")); + let mut granted = BTreeSet::new(); + let cluster = + "arn:${local.partition}:ecs:${var.region}:${local.account}:cluster/${local.ec2_name}"; + let instances = "arn:${local.partition}:ecs:${var.region}:${local.account}:\ + container-instance/${local.ec2_name}/*"; + for stmt in &stmts { + assert!(stmt.get("Condition").is_none()); + let resources = eval::strings(&stmt["Resource"]); + for a in actions(stmt) { + if a.starts_with("ecs:") && a != "ecs:DiscoverPollEndpoint" { + assert_eq!( + resources, + vec![cluster.to_string(), instances.to_string()], + "{a}" + ); + } + if a == "ecs:DiscoverPollEndpoint" || a == "ecr:GetAuthorizationToken" { + assert_eq!(resources, vec!["*".to_string()], "{a}"); + } + if a.starts_with("logs:") { + assert_eq!(resources, vec!["${local.log_group_arn}".to_string()], "{a}"); + } + granted.insert(a); + } + } + let want: BTreeSet = [ + "ecs:RegisterContainerInstance", + "ecs:DeregisterContainerInstance", + "ecs:Poll", + "ecs:StartTelemetrySession", + "ecs:Submit*", + "ecs:UpdateContainerInstancesState", + "ecs:DiscoverPollEndpoint", + "ecr:GetAuthorizationToken", + "ecr:BatchGetImage", + "ecr:GetDownloadUrlForLayer", + "ecr:BatchCheckLayerAvailability", + "logs:CreateLogStream", + "logs:PutLogEvents", + ] + .into_iter() + .map(String::from) + .collect(); + assert_eq!(granted, want); +} + +/// The user record (E11): `/triple-c/users//`, a String of +/// exactly the schema-1 fields, written only with EC2 capacity and after +/// the cluster has its provider. +#[test] +fn the_user_record_has_exactly_the_schema_fields() { + let ec2 = ec2_body(); + let param = resource(&ec2, "aws_ssm_parameter", "user"); + assert_eq!( + template_text(attr(¶m.body, "name").unwrap()), + user_record_parameter_name("${var.environment_name}", "${var.owner_key}") + ); + assert_eq!( + user_record_parameter_name("dev", "0123456789ab"), + "/triple-c/users/dev/0123456789ab" + ); + assert!(USER_RECORD.ends_with(&format!( + "parameter{}", + user_record_parameter_name(ENV, OWNER_KEY) + ))); + assert!(!user_record_parameter_name("dev", "x").starts_with(&environment_parameter_name(""))); + assert_eq!( + attr(¶m.body, "type"), + Some(&Expression::String("String".into())) + ); + let value = jsonencoded(¶m, "value"); + let fields: BTreeSet = value.as_object().unwrap().keys().cloned().collect(); + assert_eq!( + fields, + USER_RECORD_FIELDS.iter().map(|s| s.to_string()).collect() + ); + assert_eq!(value["schema"], 1); + assert_eq!(value["instance_type"], "${var.ec2_instance_type}"); + assert_eq!(value["cluster_arn"], "${aws_ecs_cluster.ec2[0].arn}"); + assert_eq!( + value["capacity_provider"], + "${aws_ecs_capacity_provider.ec2[0].name}" + ); + assert_eq!(value["user_tag"], "${var.ec2_user_tag}"); + assert_eq!( + flat(attr(¶m.body, "depends_on").unwrap()), + "[aws_ecs_cluster_capacity_providers.ec2]" + ); +} + +/// Removing EC2 capacity tears it down in a safe order (see ec2.tf): the +/// cluster outlives the launch template (its user data names the cluster), +/// so every instance is gone before the cluster is deleted. +#[test] +fn the_cluster_outlives_its_instances() { + let ec2 = ec2_body(); + let lt = resource(&ec2, "aws_launch_template", "ec2"); + assert!(render(attr(<.body, "user_data").unwrap()).contains("aws_ecs_cluster.ec2[0].name")); + let asg = resource(&ec2, "aws_autoscaling_group", "ec2"); + assert!(hcl::format::to_string(&asg) + .unwrap() + .contains("aws_launch_template.ec2[0].id")); + let cp = resource(&ec2, "aws_ecs_capacity_provider", "ec2"); + assert!(hcl::format::to_string(&cp) + .unwrap() + .contains("aws_autoscaling_group.ec2[0].arn")); + let ccp = resource(&ec2, "aws_ecs_cluster_capacity_providers", "ec2"); + assert!(hcl::format::to_string(&ccp) + .unwrap() + .contains("aws_ecs_capacity_provider.ec2[0].name")); +} diff --git a/app/src-tauri/src/commands/environment_commands.rs b/app/src-tauri/src/commands/environment_commands.rs index 3edc6a5..dd7484f 100644 --- a/app/src-tauri/src/commands/environment_commands.rs +++ b/app/src-tauri/src/commands/environment_commands.rs @@ -1331,7 +1331,7 @@ pub async fn onboard_aws_user( let owner = validate_owner_id(&ctx.who.user_id).map_err(other)?; let found = detect(&ctx).await?; onboard_refusal(&found, &env).map_err(other)?; - let vars = onboarding_vars(&env, &ctx.region, &owner); + let vars = onboarding_vars(&env, &ctx.region, &owner, None).map_err(other)?; let key = DeploymentKey::User { owner_key: owner_key(&ctx.region, &owner), env, @@ -1420,7 +1420,7 @@ pub async fn save_aws_admin_bundle( .map(str::trim) .ok_or_else(|| other("The user's owner id (aws:userid) is required")) .and_then(|o| validate_owner_id(o).map_err(other))?; - let vars = onboarding_vars(&env, ®ion_ok, &owner); + let vars = onboarding_vars(&env, ®ion_ok, &owner, None).map_err(other)?; ( DeploymentKey::User { owner_key: owner_key(®ion_ok, &owner), diff --git a/app/src-tauri/src/commands/environment_commands/tests.rs b/app/src-tauri/src/commands/environment_commands/tests.rs index b419554..b7829c7 100644 --- a/app/src-tauri/src/commands/environment_commands/tests.rs +++ b/app/src-tauri/src/commands/environment_commands/tests.rs @@ -195,7 +195,7 @@ fn bundles_contain_the_module_backend_vars_and_readme() { let dir = tempfile::tempdir().unwrap(); let ok = owner_key(REGION, USER_ID); let d = Deployment::User { env: "dev", owner_key: &ok }; - let vars = onboarding_vars("dev", REGION, USER_ID); + let vars = onboarding_vars("dev", REGION, USER_ID, None).unwrap(); let written = write_bundle(dir.path(), d, ACCOUNT, REGION, &vars).unwrap(); for (name, text) in module_files(ModuleKind::UserOnboard) { diff --git a/aws/terraform/user-onboard/ec2.tf b/aws/terraform/user-onboard/ec2.tf new file mode 100644 index 0000000..30d2578 --- /dev/null +++ b/aws/terraform/user-onboard/ec2.tf @@ -0,0 +1,314 @@ +# The user's own EC2 capacity (phase 7, E1–E4, E11), made only when +# `ec2_instance_type` is set: every resource and data source here has +# `count = local.ec2_count`, so an onboarding without it plans exactly as +# before. One cluster per user (`triple-c---u-`, the name the +# workspace policy lets only that `triple-c-user` principal tag run tasks on) +# with exactly one capacity provider: an Auto Scaling group of 0 to +# `ec2_max_instances` instances that ECS's managed scaling grows when a task +# needs one and shrinks back to zero when none does. +# +# Removing it (re-applying with an empty type, or destroying) goes in +# dependency order: the user record first, then the cluster's provider list +# (ECS refuses while a task still runs on the provider, so a running +# workspace stops the removal before anything is torn down), the capacity +# provider, the group (`force_delete` off: the provider first drains it to +# zero, clearing scale-in protection, and waits for the instances to +# terminate), the launch template, the instance profile and role, and last +# the cluster, which the launch template's user data references so that it +# outlives every instance registered into it. + +locals { + ec2 = var.ec2_instance_type != "" + ec2_count = local.ec2 ? 1 : 0 + + # `user_ec2_stem` and `user_instance_role_name` in tofu_modules.rs. + ec2_name = "triple-c-${var.environment_name}--u-${var.ec2_user_tag}" + instance_role_name = "${local.name}-instance" + + # Graviton families (m7g, c7g, r7g, t4g: a `g` after the generation) run + # the arm64 image. + ec2_arm64 = can(regex("^[a-z]+[0-9]+g[a-z]*\\.", var.ec2_instance_type)) + ecs_ami_parameter = ( + local.ec2_arm64 + ? "/aws/service/ecs/optimized-ami/amazon-linux-2023/arm64/recommended/image_id" + : "/aws/service/ecs/optimized-ami/amazon-linux-2023/recommended/image_id" + ) +} + +# The provider's default tags (component, environment, owner, version), for +# the places they don't reach by themselves: the launch template's tag +# specifications and the group's tags. +data "aws_default_tags" "current" { + count = local.ec2_count +} + +# The current ECS-optimized Amazon Linux 2023 image, resolved at apply time. +data "aws_ssm_parameter" "ecs_ami" { + count = local.ec2_count + name = local.ecs_ami_parameter +} + +resource "aws_ecs_cluster" "ec2" { + count = local.ec2_count + name = local.ec2_name + + setting { + name = "containerInsights" + value = "disabled" + } +} + +# The instance's role: the ECS agent on this user's cluster only (the +# boundary allows the agent's calls only on the cluster this role's +# `triple-c:cluster` tag names), image pulls and the environment's logs. +# ECS Exec needs nothing here: its channels run on the task role. +resource "aws_iam_role" "instance" { + count = local.ec2_count + name = local.instance_role_name + description = "Triple-C ${var.environment_name}: EC2 instances of ${var.owner_id}" + permissions_boundary = local.boundary_arn + assume_role_policy = jsonencode({ + Version = "2012-10-17" + Statement = [{ + Effect = "Allow" + Principal = { Service = "ec2.amazonaws.com" } + Action = "sts:AssumeRole" + }] + }) + + tags = { "triple-c:cluster" = local.ec2_name } +} + +resource "aws_iam_role_policy" "instance" { + count = local.ec2_count + name = "triple-c-instance" + role = aws_iam_role.instance[0].id + policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Sid = "EcsAgentOnOwnCluster" + Effect = "Allow" + Action = [ + "ecs:RegisterContainerInstance", + "ecs:DeregisterContainerInstance", + "ecs:Poll", + "ecs:StartTelemetrySession", + "ecs:Submit*", + "ecs:UpdateContainerInstancesState", + ] + Resource = [ + "arn:${local.partition}:ecs:${var.region}:${local.account}:cluster/${local.ec2_name}", + "arn:${local.partition}:ecs:${var.region}:${local.account}:container-instance/${local.ec2_name}/*", + ] + }, + { + Sid = "EcsAgentDiscovery" + Effect = "Allow" + Action = "ecs:DiscoverPollEndpoint" + Resource = "*" + }, + { + Sid = "EcrAuthorization" + Effect = "Allow" + Action = "ecr:GetAuthorizationToken" + Resource = "*" + }, + { + Sid = "PullTripleCImages" + Effect = "Allow" + Action = [ + "ecr:BatchGetImage", + "ecr:GetDownloadUrlForLayer", + "ecr:BatchCheckLayerAvailability", + ] + Resource = [ + "arn:${local.partition}:ecr:${var.region}:${local.account}:repository/triple-c-*", + "arn:${local.partition}:ecr:${var.region}:${local.account}:repository/triple-c/*", + ] + }, + { + # The awslogs driver runs in the instance's Docker daemon. + Sid = "WriteEnvironmentLogs" + Effect = "Allow" + Action = ["logs:CreateLogStream", "logs:PutLogEvents"] + Resource = local.log_group_arn + }, + ] + }) +} + +resource "aws_iam_instance_profile" "instance" { + count = local.ec2_count + name = aws_iam_role.instance[0].name + role = aws_iam_role.instance[0].name +} + +resource "aws_launch_template" "ec2" { + count = local.ec2_count + name = local.ec2_name + description = "Triple-C ${var.environment_name}: EC2 capacity of ${var.owner_id}" + + image_id = data.aws_ssm_parameter.ecs_ami[0].insecure_value + instance_type = var.ec2_instance_type + + iam_instance_profile { + name = aws_iam_instance_profile.instance[0].name + } + + # The environment's tasks group (outbound only), named in the template so + # the admin policy sees it as a launch-template resource. A public IP only + # where the environment's tasks get one: in a public-subnet environment + # the agent reaches ECS through the internet gateway. + network_interfaces { + device_index = 0 + security_groups = [local.env.security_group_id] + associate_public_ip_address = local.env.assign_public_ip + delete_on_termination = true + } + + # IMDSv2 only, one hop: the agent (host network) reaches it, bridge + # containers don't, and awsvpc tasks are blocked by the agent below. + metadata_options { + http_endpoint = "enabled" + http_tokens = "required" + http_put_response_hop_limit = 1 + instance_metadata_tags = "disabled" + } + + block_device_mappings { + device_name = "/dev/xvda" + + ebs { + volume_size = 50 + volume_type = "gp3" + encrypted = true + delete_on_termination = true + } + } + + user_data = base64encode(<<-EOT + #!/bin/bash + cat >>/etc/ecs/ecs.config <<'EOF' + ECS_CLUSTER=${aws_ecs_cluster.ec2[0].name} + ECS_AWSVPC_BLOCK_IMDS=true + EOF + EOT + ) + + # Default tags don't reach what a launch creates: the instance, its + # volume and its interface are tagged here (the admin policy lets a launch + # create only component-tagged instances and volumes). + tag_specifications { + resource_type = "instance" + tags = data.aws_default_tags.current[0].tags + } + + tag_specifications { + resource_type = "volume" + tags = data.aws_default_tags.current[0].tags + } + + tag_specifications { + resource_type = "network-interface" + tags = data.aws_default_tags.current[0].tags + } +} + +resource "aws_autoscaling_group" "ec2" { + count = local.ec2_count + name = local.ec2_name + vpc_zone_identifier = local.env.subnet_ids + + # Zero when idle; ECS's managed scaling sets the desired count. + min_size = 0 + max_size = var.ec2_max_instances + protect_from_scale_in = true + force_delete = false + + # A fixed version, never $Latest/$Default (the admin policy refuses a + # group that would follow later versions). Running instances keep theirs + # until they scale in. + launch_template { + id = aws_launch_template.ec2[0].id + version = aws_launch_template.ec2[0].latest_version + } + + # Provider default tags don't apply to groups. + dynamic "tag" { + for_each = data.aws_default_tags.current[0].tags + content { + key = tag.key + value = tag.value + propagate_at_launch = false + } + } + + # ECS adds this when the capacity provider takes the group over; declared + # so a re-apply doesn't remove it. + tag { + key = "AmazonECSManaged" + value = "true" + propagate_at_launch = true + } + + # The drain before deletion waits for the instances to terminate. + timeouts { + delete = "20m" + } + + lifecycle { + ignore_changes = [desired_capacity] + } +} + +resource "aws_ecs_capacity_provider" "ec2" { + count = local.ec2_count + name = local.ec2_name + + auto_scaling_group_provider { + auto_scaling_group_arn = aws_autoscaling_group.ec2[0].arn + + # ECS protects an instance from scale-in while a task runs on it. + managed_termination_protection = "ENABLED" + + managed_scaling { + status = "ENABLED" + target_capacity = 100 + minimum_scaling_step_size = 1 + maximum_scaling_step_size = 1 + instance_warmup_period = 60 + } + } +} + +resource "aws_ecs_cluster_capacity_providers" "ec2" { + count = local.ec2_count + cluster_name = aws_ecs_cluster.ec2[0].name + capacity_providers = [aws_ecs_capacity_provider.ec2[0].name] + + default_capacity_provider_strategy { + capacity_provider = aws_ecs_capacity_provider.ec2[0].name + weight = 1 + } +} + +# The user's record (E11): what the app reads to run EC2 projects, since +# workspace users can't read the state bucket. Outside +# /triple-c/environments/, so environment detection never sees it. Written +# last, removed first. +resource "aws_ssm_parameter" "user" { + count = local.ec2_count + name = "/triple-c/users/${var.environment_name}/${var.owner_key}" + description = "Triple-C ${var.environment_name}: EC2 capacity of ${var.owner_id}" + type = "String" + value = jsonencode({ + schema = 1 + instance_type = var.ec2_instance_type + cluster_arn = aws_ecs_cluster.ec2[0].arn + capacity_provider = aws_ecs_capacity_provider.ec2[0].name + user_tag = var.ec2_user_tag + }) + + depends_on = [aws_ecs_cluster_capacity_providers.ec2] +} diff --git a/aws/terraform/user-onboard/main.tf b/aws/terraform/user-onboard/main.tf index e100951..33edf21 100644 --- a/aws/terraform/user-onboard/main.tf +++ b/aws/terraform/user-onboard/main.tf @@ -1,10 +1,11 @@ # One user's place in an environment: their task and execution roles and -# their own EFS file system (D2, strict tenancy). The environment itself is -# read only from its record, never from its state. +# their own EFS file system (D2, strict tenancy), and optionally their own +# EC2 capacity (ec2.tf, phase 7). The environment itself is read only from +# its record, never from its state. locals { # ONBOARD_MODULE_VERSION in app/src-tauri/src/aws/tofu_modules.rs. - template_version = 1 + template_version = 2 name = "triple-c-${var.environment_name}-${var.owner_key}" partition = data.aws_partition.current.partition @@ -64,10 +65,11 @@ data "aws_ssm_parameter" "environment" { )) && jsondecode(self.insecure_value).log_group == "/triple-c/${var.environment_name}" && can(regex("^sg-[0-9a-f]{8,17}$", jsondecode(self.insecure_value).security_group_id)) - && alltrue([for s in jsondecode(self.insecure_value).subnet_ids : can(regex("^subnet-[0-9a-f]{8,17}$", s))]), + && alltrue([for s in jsondecode(self.insecure_value).subnet_ids : can(regex("^subnet-[0-9a-f]{8,17}$", s))]) + && (jsondecode(self.insecure_value).assign_public_ip == true || jsondecode(self.insecure_value).assign_public_ip == false), false ) - error_message = "The environment record has a malformed kms_key_arn (not a key in this region and account), log_group (not /triple-c/), security_group_id or subnet id." + error_message = "The environment record has a malformed kms_key_arn (not a key in this region and account), log_group (not /triple-c/), security_group_id, subnet id or assign_public_ip." } } } diff --git a/aws/terraform/user-onboard/outputs.tf b/aws/terraform/user-onboard/outputs.tf index a630c65..8926882 100644 --- a/aws/terraform/user-onboard/outputs.tf +++ b/aws/terraform/user-onboard/outputs.tf @@ -18,6 +18,20 @@ output "efs_security_group_id" { value = aws_security_group.efs.id } +# The user's EC2 capacity, null without it. The app reads these from the +# user record (/triple-c/users//), not from the state. +output "ec2_cluster_arn" { + value = one(aws_ecs_cluster.ec2[*].arn) +} + +output "ec2_capacity_provider" { + value = one(aws_ecs_capacity_provider.ec2[*].name) +} + +output "ec2_instance_type" { + value = local.ec2 ? var.ec2_instance_type : null +} + # Written only when every resource above was applied: a run that fails # part-way never evaluates it, so the app reads its absence from the state # as "the last onboarding didn't finish" (Incomplete, Join re-applies) @@ -34,5 +48,14 @@ output "onboarding_complete" { aws_iam_role_policy.task_bedrock, aws_iam_role.exec, aws_iam_role_policy.exec, + aws_ecs_cluster.ec2, + aws_iam_role.instance, + aws_iam_role_policy.instance, + aws_iam_instance_profile.instance, + aws_launch_template.ec2, + aws_autoscaling_group.ec2, + aws_ecs_capacity_provider.ec2, + aws_ecs_cluster_capacity_providers.ec2, + aws_ssm_parameter.user, ] } diff --git a/aws/terraform/user-onboard/variables.tf b/aws/terraform/user-onboard/variables.tf index eee1894..f9d8805 100644 --- a/aws/terraform/user-onboard/variables.tf +++ b/aws/terraform/user-onboard/variables.tf @@ -54,3 +54,58 @@ variable "bedrock_on_task_role" { type = bool default = false } + +# Optional per-user EC2 capacity (phase 7). Empty = none: the module then +# makes nothing for EC2 and the user's projects run on Fargate only. +variable "ec2_instance_type" { + description = "The instance type of the user's own EC2 capacity (e.g. m7i.large or m7g.large), or empty for none. Only the types the app can size are accepted." + type = string + default = "" + + # The app's table (`ec2_instance_spec`) and the admin policy's lists. + validation { + condition = var.ec2_instance_type == "" || contains([ + "m7i.large", "m7i.xlarge", "m7i.2xlarge", "m7i.4xlarge", + "m7g.large", "m7g.xlarge", "m7g.2xlarge", "m7g.4xlarge", + "c7i.large", "c7i.xlarge", "c7i.2xlarge", "c7i.4xlarge", + "c7g.large", "c7g.xlarge", "c7g.2xlarge", "c7g.4xlarge", + "r7i.large", "r7i.xlarge", "r7i.2xlarge", "r7i.4xlarge", + "r7g.large", "r7g.xlarge", "r7g.2xlarge", "r7g.4xlarge", + "t3.large", "t3.xlarge", "t3.2xlarge", + "t4g.large", "t4g.xlarge", "t4g.2xlarge", + ], var.ec2_instance_type) + error_message = "ec2_instance_type must be empty or one of the m7i, m7g, c7i, c7g, r7i, r7g (large to 4xlarge), t3 or t4g (large to 2xlarge) types." + } +} + +variable "ec2_max_instances" { + description = "How many of the user's instances may run at once (1 to 4); each holds one workspace as expected use." + type = number + default = 1 + + validation { + condition = var.ec2_max_instances >= 1 && var.ec2_max_instances <= 4 && floor(var.ec2_max_instances) == var.ec2_max_instances + error_message = "ec2_max_instances must be a whole number from 1 to 4." + } +} + +variable "ec2_user_tag" { + description = "The value of the triple-c-user principal tag the user signs in with; names their EC2 cluster (triple-c---u-). Required with ec2_instance_type." + type = string + default = "" + + validation { + condition = var.ec2_user_tag == "" || ( + can(regex("^[A-Za-z0-9-]{1,32}$", var.ec2_user_tag)) + && !startswith(var.ec2_user_tag, "-") + && !endswith(var.ec2_user_tag, "-") + && !strcontains(var.ec2_user_tag, "--") + ) + error_message = "ec2_user_tag must be 1 to 32 letters, digits and single hyphens, not starting or ending with a hyphen." + } + + validation { + condition = var.ec2_instance_type == "" || var.ec2_user_tag != "" + error_message = "ec2_user_tag (the user's triple-c-user principal tag) is required when ec2_instance_type is set." + } +} -- 2.52.0 From e9c20287b71975009de8de90a045aec39e551d03 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 14:07:28 -0800 Subject: [PATCH 08/29] fix(aws): EC2 name-collision step in onboarding bundles; bridge agent config Task 3 fix round 1 (rulings R2, R3): - Onboarding admin bundles' README gains an "EC2 capacity" step: before applying with ec2_instance_type, check with describe-clusters / describe-auto-scaling-groups that triple-c---u- is unused unless this owner's /triple-c/users// record names it (exact names; when the bundle has none). Tested. - User data for bridge tasks (R2): ECS_ENABLE_TASK_IAM_ROLE=true instead of ECS_AWSVPC_BLOCK_IMDS; IMDSv2 hop limit 1 kept, comment corrected; the test asserts no ECS_ENABLE_TASK_ENI / awsvpc settings. - Reverted unrelated rustfmt churn in tofu_modules/tests.rs. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/tofu_modules/tests.rs | 37 +++++-------- .../src/commands/environment_commands.rs | 54 +++++++++++++++++-- .../commands/environment_commands/tests.rs | 32 +++++++++++ aws/terraform/user-onboard/ec2.tf | 10 ++-- 4 files changed, 100 insertions(+), 33 deletions(-) diff --git a/app/src-tauri/src/aws/tofu_modules/tests.rs b/app/src-tauri/src/aws/tofu_modules/tests.rs index fc6ec0b..1f07ffb 100644 --- a/app/src-tauri/src/aws/tofu_modules/tests.rs +++ b/app/src-tauri/src/aws/tofu_modules/tests.rs @@ -242,14 +242,8 @@ fn same_user_and_environment_in_two_regions_do_not_collide() { assert_ne!(wt, et); assert_ne!(we, ee); assert_ne!( - state_key(Deployment::User { - env: "dev", - owner_key: &west - }), - state_key(Deployment::User { - env: "dev", - owner_key: &east - }) + state_key(Deployment::User { env: "dev", owner_key: &west }), + state_key(Deployment::User { env: "dev", owner_key: &east }) ); } @@ -367,10 +361,7 @@ fn an_existing_network_is_checked_before_anything_is_built() { let lookup = lookups[0]; assert_eq!(label(lookup, 1), Some("existing")); let count = render(attr(&lookup.body, "count").expect("count")); - assert!( - count.contains("var.network_mode") && count.contains("\"existing\""), - "{count}" - ); + assert!(count.contains("var.network_mode") && count.contains("\"existing\""), "{count}"); assert!(count.contains('2'), "{count}"); let id = render(attr(&lookup.body, "id").expect("id")); assert!(id.contains("var.subnet_ids[count.index]"), "{id}"); @@ -405,10 +396,7 @@ fn the_onboarding_completion_output_waits_for_every_resource() { let mut n = 0; for r in top_blocks(&body, "resource") { let addr = format!("{}.{}", label(r, 0).unwrap(), label(r, 1).unwrap()); - assert!( - deps.contains(&addr), - "onboarding_complete doesn't wait for {addr}: {deps}" - ); + assert!(deps.contains(&addr), "onboarding_complete doesn't wait for {addr}: {deps}"); n += 1; } assert!(n >= 9, "only {n} resources"); @@ -2604,9 +2592,7 @@ fn the_lifetime_cap_maximum_is_the_same_in_rust_typescript_and_hcl() { .find(|(f, _)| *f == "variables.tf") .unwrap() .1; - let block = &vars[vars - .find("variable \"max_workspace_hours\"") - .expect("the variable")..]; + let block = &vars[vars.find("variable \"max_workspace_hours\"").expect("the variable")..]; let block = &block[..block.find("\n}\n").unwrap()]; assert!( block.contains(&format!("var.max_workspace_hours <= {max}")), @@ -2895,7 +2881,7 @@ fn the_ami_is_the_ecs_optimized_one_for_the_architecture() { /// The launch template: the variable's type, IMDSv2 at one hop, an /// encrypted 50 GiB gp3 root volume, the environment's tasks group named in /// the template, the instance profile, the agent pointed at the user's -/// cluster with task IMDS blocked, and the default tags on what a launch +/// cluster with task roles for bridge tasks, and the default tags on what a launch /// creates. Never a default-version change (no `ModifyLaunchTemplate`). #[test] fn the_launch_template_is_pinned() { @@ -2979,17 +2965,18 @@ fn the_launch_template_is_pinned() { "#!/bin/bash", ">>/etc/ecs/ecs.config", "ECS_CLUSTER=${aws_ecs_cluster.ec2[0].name}\n", - "ECS_AWSVPC_BLOCK_IMDS=true\n", + // Bridge tasks (R2) get task-role credentials from the agent's + // endpoint; IMDS stays out of their reach at hop limit 1. + "ECS_ENABLE_TASK_IAM_ROLE=true\n", ] { assert!( user_data.contains(needle), "{needle:?} missing from {user_data}" ); } - assert!( - !user_data.contains("ECS_ENABLE_TASK_ENI"), - "no trunking (E3)" - ); + // Bridge networking: no task ENIs, and no awsvpc-only settings. + assert!(!user_data.contains("ECS_ENABLE_TASK_ENI"), "{user_data}"); + assert!(!user_data.contains("AWSVPC"), "{user_data}"); let specs: BTreeSet = top_blocks(b, "tag_specifications") .map(|t| { diff --git a/app/src-tauri/src/commands/environment_commands.rs b/app/src-tauri/src/commands/environment_commands.rs index dd7484f..79162c8 100644 --- a/app/src-tauri/src/commands/environment_commands.rs +++ b/app/src-tauri/src/commands/environment_commands.rs @@ -47,7 +47,8 @@ use crate::aws::tofu::{ }; use crate::aws::tofu_modules::{ boundary_vars, environment_vars, module_files, onboarding_vars, owner_key, state_bucket_name, - state_key, validate_environment_name, Deployment, ModuleKind, NetworkChoice, + state_key, user_ec2_stem, user_record_parameter_name, validate_ec2_user_tag, + validate_environment_name, Deployment, ModuleKind, NetworkChoice, }; use crate::aws::{caller_identity, sdk_config, AwsError, CallerIdentity}; use crate::models::{validate_supported_region, AwsAuth, HostConnection, HostKind}; @@ -415,7 +416,43 @@ const README: &str = "README.txt"; const BACKEND: &str = "backend.hcl"; const TFVARS: &str = "terraform.tfvars.json"; -fn bundle_readme(d: Deployment, account: &str, region: &str, bucket: &str, key: &str) -> String { +/// The onboarding bundle's EC2 step: before applying with EC2 capacity, the +/// admin checks that the per-user names are free or already this user's +/// (the module can't: a name taken by someone else's onboarding would be +/// adopted by neither, and a collision only fails at create). `user_tag` is +/// the bundle's `ec2_user_tag` when set and valid; otherwise the commands +/// show `` for the admin to fill in. +fn ec2_collision_step(env: &str, owner_key: &str, region: &str, user_tag: Option<&str>) -> String { + let stem = user_ec2_stem(env, user_tag.unwrap_or("")); + let record = user_record_parameter_name(env, owner_key); + format!( + " +EC2 capacity (only if ec2_instance_type is set) +------------------------------------------------ +ec2_user_tag must be the value of the user's triple-c-user principal tag. +BEFORE tofu apply, check that the per-user EC2 names are not already in use +by another onboarding. Run: + + aws ecs describe-clusters --region {region} --clusters {stem} --query 'clusters[?status==`ACTIVE`].clusterName' --output text + aws autoscaling describe-auto-scaling-groups --region {region} --auto-scaling-group-names {stem} --query 'AutoScalingGroups[].AutoScalingGroupName' --output text + aws ssm get-parameter --region {region} --name {record} --query Parameter.Value --output text + +If either of the first two prints {stem}, apply ONLY if the third (this +user's record) succeeds and its cluster_arn ends in cluster/{stem}; +otherwise the name belongs to someone else's onboarding: stop and choose +the correct ec2_user_tag. (The app runs the same check before applying.) +" + ) +} + +fn bundle_readme( + d: Deployment, + account: &str, + region: &str, + bucket: &str, + key: &str, + vars: &Value, +) -> String { let what = match d { Deployment::Environment(env) => format!( "the Triple-C environment \"{env}\" (ECS cluster, security group, KMS key, log \ @@ -442,6 +479,15 @@ fn bundle_readme(d: Deployment, account: &str, region: &str, bucket: &str, key: format!(r#"{{"LocationConstraint":"{region}",{tags}}}"#) }; let policy = state_bucket_policy(bucket); + let ec2_step = match d { + Deployment::User { env, owner_key } => { + let tag = vars["ec2_user_tag"] + .as_str() + .filter(|t| validate_ec2_user_tag(t).is_ok()); + ec2_collision_step(env, owner_key, region, tag) + } + _ => String::new(), + }; let credentials = match d { Deployment::Boundary => format!( "- Credentials of an account administrator for account {account} WITHOUT @@ -498,7 +544,7 @@ From this folder: (With Terraform: terraform init -backend-config=backend.hcl, then terraform apply.) - +{ec2_step} 3. Remove --------- From this folder, after tofu init: @@ -529,7 +575,7 @@ fn bundle_files( let json = serde_json::to_string_pretty(vars) .map_err(|e| format!("Could not encode the module variables: {e}"))?; files.push((TFVARS.into(), json + "\n")); - files.push((README.into(), bundle_readme(d, account, ®ion, &bucket, &key))); + files.push((README.into(), bundle_readme(d, account, ®ion, &bucket, &key, vars))); Ok(files) } diff --git a/app/src-tauri/src/commands/environment_commands/tests.rs b/app/src-tauri/src/commands/environment_commands/tests.rs index b7829c7..ad7553e 100644 --- a/app/src-tauri/src/commands/environment_commands/tests.rs +++ b/app/src-tauri/src/commands/environment_commands/tests.rs @@ -253,6 +253,38 @@ fn bundles_contain_the_module_backend_vars_and_readme() { } assert!(!readme.contains("put-bucket-tagging"), "a later tag can't satisfy the create"); + // The EC2 name-collision check (the app does it too, Task 4): the + // exact per-user names, and this user's record to compare against. + let record = format!("/triple-c/users/dev/{ok}"); + for needle in [ + "BEFORE tofu apply", + &format!("aws ecs describe-clusters --region {REGION} --clusters triple-c-dev--u-"), + &format!( + "aws autoscaling describe-auto-scaling-groups --region {REGION} \ + --auto-scaling-group-names triple-c-dev--u-" + ), + &format!("aws ssm get-parameter --region {REGION} --name {record}"), + "cluster/triple-c-dev--u-", + ] { + assert!(readme.contains(needle), "README lacks {needle:?}:\n{readme}"); + } + // With a tag in the variables, the commands name it. + let mut tagged = vars.clone(); + tagged["ec2_instance_type"] = "m7i.large".into(); + tagged["ec2_user_tag"] = "alice".into(); + let other = tempfile::tempdir().unwrap(); + write_bundle(other.path(), d, ACCOUNT, REGION, &tagged).unwrap(); + let readme_tagged = fs::read_to_string(other.path().join("README.txt")).unwrap(); + assert!(readme_tagged.contains("--clusters triple-c-dev--u-alice "), "{readme_tagged}"); + assert!(readme_tagged.contains("--auto-scaling-group-names triple-c-dev--u-alice ")); + assert!(!readme_tagged.contains("")); + // Not in the other bundles. + let env_dir = tempfile::tempdir().unwrap(); + let env_vars = environment_vars("dev", REGION, &NetworkChoice::Public, 0).unwrap(); + write_bundle(env_dir.path(), Deployment::Environment("dev"), ACCOUNT, REGION, &env_vars).unwrap(); + let env_readme = fs::read_to_string(env_dir.path().join("README.txt")).unwrap(); + assert!(!env_readme.contains("EC2 capacity"), "{env_readme}"); + // Writing again over our own files is fine... write_bundle(dir.path(), d, ACCOUNT, REGION, &vars).unwrap(); // ...but an unrelated file (or folder) means the wrong folder. diff --git a/aws/terraform/user-onboard/ec2.tf b/aws/terraform/user-onboard/ec2.tf index 30d2578..b29b55e 100644 --- a/aws/terraform/user-onboard/ec2.tf +++ b/aws/terraform/user-onboard/ec2.tf @@ -159,7 +159,8 @@ resource "aws_launch_template" "ec2" { # The environment's tasks group (outbound only), named in the template so # the admin policy sees it as a launch-template resource. A public IP only # where the environment's tasks get one: in a public-subnet environment - # the agent reaches ECS through the internet gateway. + # the agent, and bridge-network tasks through the instance, reach out + # through the internet gateway. network_interfaces { device_index = 0 security_groups = [local.env.security_group_id] @@ -167,8 +168,9 @@ resource "aws_launch_template" "ec2" { delete_on_termination = true } - # IMDSv2 only, one hop: the agent (host network) reaches it, bridge - # containers don't, and awsvpc tasks are blocked by the agent below. + # IMDSv2 only, one hop: the agent (host network) reaches it, while + # bridge-network containers are one hop further and their token request + # never comes back, so they can't take the instance role's credentials. metadata_options { http_endpoint = "enabled" http_tokens = "required" @@ -191,7 +193,7 @@ resource "aws_launch_template" "ec2" { #!/bin/bash cat >>/etc/ecs/ecs.config <<'EOF' ECS_CLUSTER=${aws_ecs_cluster.ec2[0].name} - ECS_AWSVPC_BLOCK_IMDS=true + ECS_ENABLE_TASK_IAM_ROLE=true EOF EOT ) -- 2.52.0 From 1a2c530be8ed909730ce646e83bc6d3294c77098 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 14:22:31 -0800 Subject: [PATCH 09/29] feat(aws): choose EC2 capacity when onboarding Self-onboarding and the onboarding bundle take an EC2 capacity choice: none, or an instance type from the app's table (grouped x86/ARM, default m7i.large), 1-4 instances and the user's triple-c-user value. A re-apply keeps the recorded capacity unless changed (the record gains max_instances). Before any self-onboarding apply with EC2 the app refuses per-user names (ACTIVE cluster or Auto Scaling group) that this owner's record doesn't name (R3). OnboardingState carries the user's compute from their record; the panel shows it. The bundle README's collision check now comes before the apply step. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/Cargo.lock | 27 +++ app/src-tauri/Cargo.toml | 3 + app/src-tauri/capabilities/default.json | 1 + app/src-tauri/gen/schemas/acl-manifests.json | 2 +- app/src-tauri/gen/schemas/capabilities.json | 2 +- app/src-tauri/gen/schemas/desktop-schema.json | 12 ++ app/src-tauri/gen/schemas/linux-schema.json | 12 ++ app/src-tauri/src/aws/environments.rs | 198 +++++++++++++++++- app/src-tauri/src/aws/environments/tests.rs | 166 ++++++++++++++- app/src-tauri/src/aws/live_tests.rs | 2 +- app/src-tauri/src/aws/tofu_modules.rs | 9 +- app/src-tauri/src/aws/tofu_modules/tests.rs | 1 + .../src/commands/environment_commands.rs | 123 +++++++++-- .../commands/environment_commands/tests.rs | 95 ++++++++- app/src-tauri/src/lib.rs | 1 + app/src-tauri/src/models/project.rs | 67 ++++++ .../settings/hosts/AdminBundleModal.test.tsx | 41 +++- .../settings/hosts/AdminBundleModal.tsx | 28 ++- .../settings/hosts/Ec2CapacityFields.tsx | 141 +++++++++++++ .../settings/hosts/EnvironmentsPanel.test.tsx | 138 +++++++++++- .../settings/hosts/EnvironmentsPanel.tsx | 71 ++++++- .../settings/hosts/JoinEnvironmentModal.tsx | 80 +++++++ .../settings/hosts/environmentFormat.ts | 46 +++- app/src/components/settings/hosts/testkit.ts | 25 +++ app/src/lib/tauri-commands.ts | 21 +- app/src/lib/types.ts | 41 +++- app/src/test/awsFixtures.ts | 2 +- aws/terraform/user-onboard/ec2.tf | 1 + 28 files changed, 1286 insertions(+), 70 deletions(-) create mode 100644 app/src/components/settings/hosts/Ec2CapacityFields.tsx create mode 100644 app/src/components/settings/hosts/JoinEnvironmentModal.tsx diff --git a/app/src-tauri/Cargo.lock b/app/src-tauri/Cargo.lock index 2235acb..366ff62 100644 --- a/app/src-tauri/Cargo.lock +++ b/app/src-tauri/Cargo.lock @@ -367,6 +367,32 @@ dependencies = [ "uuid", ] +[[package]] +name = "aws-sdk-autoscaling" +version = "1.144.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08cb197f98dad7b1a3d4e7fcc94fbc13a66c2ea5465ba57fdb5dd00f865d6e8" +dependencies = [ + "arc-swap", + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-observability", + "aws-smithy-query", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-schema", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "fastrand", + "http", + "regex-lite", + "tracing", +] + [[package]] name = "aws-sdk-cloudwatchlogs" version = "1.165.0" @@ -7466,6 +7492,7 @@ dependencies = [ "aws-config", "aws-credential-types", "aws-runtime", + "aws-sdk-autoscaling", "aws-sdk-cloudwatchlogs", "aws-sdk-ecs", "aws-sdk-efs", diff --git a/app/src-tauri/Cargo.toml b/app/src-tauri/Cargo.toml index 17f373c..cfe1915 100644 --- a/app/src-tauri/Cargo.toml +++ b/app/src-tauri/Cargo.toml @@ -80,6 +80,9 @@ aws-runtime = { version = "1.10.4", default-features = false } # The default sleep and time source for the hand-built SdkConfig (no env/profile # loading); the version and feature already in the tree. aws-smithy-async = { version = "1.3.1", default-features = false, features = ["rt-tokio"] } +# commands/environment_commands.rs: the pre-apply check that a user's EC2 names +# (Auto Scaling group) are not another onboarding's (phase 7, R3). +aws-sdk-autoscaling = { version = "1.144.0", default-features = false, features = ["default-https-client", "rt-tokio", "behavior-version-latest"] } aws-sdk-s3 = { version = "1.159.0", default-features = false, features = ["default-https-client", "rt-tokio", "behavior-version-latest"] } # aws/tofu.rs: `setsid` puts the detached OpenTofu runner in its own session, diff --git a/app/src-tauri/capabilities/default.json b/app/src-tauri/capabilities/default.json index fb9284c..4dfe397 100644 --- a/app/src-tauri/capabilities/default.json +++ b/app/src-tauri/capabilities/default.json @@ -82,6 +82,7 @@ "allow-cancel-aws-deployment", "allow-push-aws-saved-state", "allow-onboard-aws-user", + "allow-list-ec2-instance-types", "allow-deploy-aws-permissions-boundary", "allow-save-aws-admin-bundle", "allow-detect-host-timezone", diff --git a/app/src-tauri/gen/schemas/acl-manifests.json b/app/src-tauri/gen/schemas/acl-manifests.json index 3167ff1..8956c25 100644 --- a/app/src-tauri/gen/schemas/acl-manifests.json +++ b/app/src-tauri/gen/schemas/acl-manifests.json @@ -1 +1 @@ -{"__app-acl__":{"default_permission":null,"permissions":{"allow-acquire-claude-token":{"identifier":"allow-acquire-claude-token","description":"Enables the acquire_claude_token command without any pre-configured scope.","commands":{"allow":["acquire_claude_token"],"deny":[]}},"allow-add-aws-keys-connection":{"identifier":"allow-add-aws-keys-connection","description":"Enables the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":["add_aws_keys_connection"],"deny":[]}},"allow-add-aws-profile-connection":{"identifier":"allow-add-aws-profile-connection","description":"Enables the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":["add_aws_profile_connection"],"deny":[]}},"allow-add-marketplace":{"identifier":"allow-add-marketplace","description":"Enables the add_marketplace command without any pre-configured scope.","commands":{"allow":["add_marketplace"],"deny":[]}},"allow-add-marketplace-gh-host-account":{"identifier":"allow-add-marketplace-gh-host-account","description":"Enables the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_gh_host_account"],"deny":[]}},"allow-add-marketplace-token-account":{"identifier":"allow-add-marketplace-token-account","description":"Enables the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_token_account"],"deny":[]}},"allow-add-project":{"identifier":"allow-add-project","description":"Enables the add_project command without any pre-configured scope.","commands":{"allow":["add_project"],"deny":[]}},"allow-add-scheduled-task":{"identifier":"allow-add-scheduled-task","description":"Enables the add_scheduled_task command without any pre-configured scope.","commands":{"allow":["add_scheduled_task"],"deny":[]}},"allow-apply-marketplace-now":{"identifier":"allow-apply-marketplace-now","description":"Enables the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":["apply_marketplace_now"],"deny":[]}},"allow-apply-settings-import":{"identifier":"allow-apply-settings-import","description":"Enables the apply_settings_import command without any pre-configured scope.","commands":{"allow":["apply_settings_import"],"deny":[]}},"allow-aws-connection-identity":{"identifier":"allow-aws-connection-identity","description":"Enables the aws_connection_identity command without any pre-configured scope.","commands":{"allow":["aws_connection_identity"],"deny":[]}},"allow-aws-connection-sso-login":{"identifier":"allow-aws-connection-sso-login","description":"Enables the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":["aws_connection_sso_login"],"deny":[]}},"allow-aws-cost-estimate":{"identifier":"allow-aws-cost-estimate","description":"Enables the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":["aws_cost_estimate"],"deny":[]}},"allow-aws-environment-max-hours":{"identifier":"allow-aws-environment-max-hours","description":"Enables the aws_environment_max_hours command without any pre-configured scope.","commands":{"allow":["aws_environment_max_hours"],"deny":[]}},"allow-aws-policy-document":{"identifier":"allow-aws-policy-document","description":"Enables the aws_policy_document command without any pre-configured scope.","commands":{"allow":["aws_policy_document"],"deny":[]}},"allow-aws-sso-refresh":{"identifier":"allow-aws-sso-refresh","description":"Enables the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":["aws_sso_refresh"],"deny":[]}},"allow-aws-task-log":{"identifier":"allow-aws-task-log","description":"Enables the aws_task_log command without any pre-configured scope.","commands":{"allow":["aws_task_log"],"deny":[]}},"allow-aws-workspace-status":{"identifier":"allow-aws-workspace-status","description":"Enables the aws_workspace_status command without any pre-configured scope.","commands":{"allow":["aws_workspace_status"],"deny":[]}},"allow-build-gateway-image":{"identifier":"allow-build-gateway-image","description":"Enables the build_gateway_image command without any pre-configured scope.","commands":{"allow":["build_gateway_image"],"deny":[]}},"allow-build-image":{"identifier":"allow-build-image","description":"Enables the build_image command without any pre-configured scope.","commands":{"allow":["build_image"],"deny":[]}},"allow-build-stt-image":{"identifier":"allow-build-stt-image","description":"Enables the build_stt_image command without any pre-configured scope.","commands":{"allow":["build_stt_image"],"deny":[]}},"allow-cancel-aws-deployment":{"identifier":"allow-cancel-aws-deployment","description":"Enables the cancel_aws_deployment command without any pre-configured scope.","commands":{"allow":["cancel_aws_deployment"],"deny":[]}},"allow-cancel-claude-token":{"identifier":"allow-cancel-claude-token","description":"Enables the cancel_claude_token command without any pre-configured scope.","commands":{"allow":["cancel_claude_token"],"deny":[]}},"allow-cancel-marketplace-gh-login":{"identifier":"allow-cancel-marketplace-gh-login","description":"Enables the cancel_marketplace_gh_login command without any pre-configured scope.","commands":{"allow":["cancel_marketplace_gh_login"],"deny":[]}},"allow-check-aws-permissions":{"identifier":"allow-check-aws-permissions","description":"Enables the check_aws_permissions command without any pre-configured scope.","commands":{"allow":["check_aws_permissions"],"deny":[]}},"allow-check-browser-view-support":{"identifier":"allow-check-browser-view-support","description":"Enables the check_browser_view_support command without any pre-configured scope.","commands":{"allow":["check_browser_view_support"],"deny":[]}},"allow-check-docker":{"identifier":"allow-check-docker","description":"Enables the check_docker command without any pre-configured scope.","commands":{"allow":["check_docker"],"deny":[]}},"allow-check-for-updates":{"identifier":"allow-check-for-updates","description":"Enables the check_for_updates command without any pre-configured scope.","commands":{"allow":["check_for_updates"],"deny":[]}},"allow-check-gateway-health":{"identifier":"allow-check-gateway-health","description":"Enables the check_gateway_health command without any pre-configured scope.","commands":{"allow":["check_gateway_health"],"deny":[]}},"allow-check-image-exists":{"identifier":"allow-check-image-exists","description":"Enables the check_image_exists command without any pre-configured scope.","commands":{"allow":["check_image_exists"],"deny":[]}},"allow-check-image-update":{"identifier":"allow-check-image-update","description":"Enables the check_image_update command without any pre-configured scope.","commands":{"allow":["check_image_update"],"deny":[]}},"allow-check-unsaved-work":{"identifier":"allow-check-unsaved-work","description":"Enables the check_unsaved_work command without any pre-configured scope.","commands":{"allow":["check_unsaved_work"],"deny":[]}},"allow-clear-claude-token":{"identifier":"allow-clear-claude-token","description":"Enables the clear_claude_token command without any pre-configured scope.","commands":{"allow":["clear_claude_token"],"deny":[]}},"allow-clear-gateway-api-key":{"identifier":"allow-clear-gateway-api-key","description":"Enables the clear_gateway_api_key command without any pre-configured scope.","commands":{"allow":["clear_gateway_api_key"],"deny":[]}},"allow-clear-scheduler-notifications":{"identifier":"allow-clear-scheduler-notifications","description":"Enables the clear_scheduler_notifications command without any pre-configured scope.","commands":{"allow":["clear_scheduler_notifications"],"deny":[]}},"allow-close-browser-view-popout":{"identifier":"allow-close-browser-view-popout","description":"Enables the close_browser_view_popout command without any pre-configured scope.","commands":{"allow":["close_browser_view_popout"],"deny":[]}},"allow-close-container-page":{"identifier":"allow-close-container-page","description":"Enables the close_container_page command without any pre-configured scope.","commands":{"allow":["close_container_page"],"deny":[]}},"allow-close-terminal-session":{"identifier":"allow-close-terminal-session","description":"Enables the close_terminal_session command without any pre-configured scope.","commands":{"allow":["close_terminal_session"],"deny":[]}},"allow-confirm-migration":{"identifier":"allow-confirm-migration","description":"Enables the confirm_migration command without any pre-configured scope.","commands":{"allow":["confirm_migration"],"deny":[]}},"allow-create-container-directory":{"identifier":"allow-create-container-directory","description":"Enables the create_container_directory command without any pre-configured scope.","commands":{"allow":["create_container_directory"],"deny":[]}},"allow-delete-note":{"identifier":"allow-delete-note","description":"Enables the delete_note command without any pre-configured scope.","commands":{"allow":["delete_note"],"deny":[]}},"allow-deploy-aws-environment":{"identifier":"allow-deploy-aws-environment","description":"Enables the deploy_aws_environment command without any pre-configured scope.","commands":{"allow":["deploy_aws_environment"],"deny":[]}},"allow-deploy-aws-permissions-boundary":{"identifier":"allow-deploy-aws-permissions-boundary","description":"Enables the deploy_aws_permissions_boundary command without any pre-configured scope.","commands":{"allow":["deploy_aws_permissions_boundary"],"deny":[]}},"allow-destroy-incomplete-aws-environment":{"identifier":"allow-destroy-incomplete-aws-environment","description":"Enables the destroy_incomplete_aws_environment command without any pre-configured scope.","commands":{"allow":["destroy_incomplete_aws_environment"],"deny":[]}},"allow-detect-aws-config":{"identifier":"allow-detect-aws-config","description":"Enables the detect_aws_config command without any pre-configured scope.","commands":{"allow":["detect_aws_config"],"deny":[]}},"allow-detect-aws-environments":{"identifier":"allow-detect-aws-environments","description":"Enables the detect_aws_environments command without any pre-configured scope.","commands":{"allow":["detect_aws_environments"],"deny":[]}},"allow-detect-host-timezone":{"identifier":"allow-detect-host-timezone","description":"Enables the detect_host_timezone command without any pre-configured scope.","commands":{"allow":["detect_host_timezone"],"deny":[]}},"allow-detect-install-options":{"identifier":"allow-detect-install-options","description":"Enables the detect_install_options command without any pre-configured scope.","commands":{"allow":["detect_install_options"],"deny":[]}},"allow-download-container-backup":{"identifier":"allow-download-container-backup","description":"Enables the download_container_backup command without any pre-configured scope.","commands":{"allow":["download_container_backup"],"deny":[]}},"allow-download-container-file":{"identifier":"allow-download-container-file","description":"Enables the download_container_file command without any pre-configured scope.","commands":{"allow":["download_container_file"],"deny":[]}},"allow-export-settings":{"identifier":"allow-export-settings","description":"Enables the export_settings command without any pre-configured scope.","commands":{"allow":["export_settings"],"deny":[]}},"allow-follow-aws-deployment":{"identifier":"allow-follow-aws-deployment","description":"Enables the follow_aws_deployment command without any pre-configured scope.","commands":{"allow":["follow_aws_deployment"],"deny":[]}},"allow-forget-marketplace-installs":{"identifier":"allow-forget-marketplace-installs","description":"Enables the forget_marketplace_installs command without any pre-configured scope.","commands":{"allow":["forget_marketplace_installs"],"deny":[]}},"allow-get-app-version":{"identifier":"allow-get-app-version","description":"Enables the get_app_version command without any pre-configured scope.","commands":{"allow":["get_app_version"],"deny":[]}},"allow-get-auth-bridge-status":{"identifier":"allow-get-auth-bridge-status","description":"Enables the get_auth_bridge_status command without any pre-configured scope.","commands":{"allow":["get_auth_bridge_status"],"deny":[]}},"allow-get-browser-view-match-window":{"identifier":"allow-get-browser-view-match-window","description":"Enables the get_browser_view_match_window command without any pre-configured scope.","commands":{"allow":["get_browser_view_match_window"],"deny":[]}},"allow-get-browser-view-popout-state":{"identifier":"allow-get-browser-view-popout-state","description":"Enables the get_browser_view_popout_state command without any pre-configured scope.","commands":{"allow":["get_browser_view_popout_state"],"deny":[]}},"allow-get-browser-view-status":{"identifier":"allow-get-browser-view-status","description":"Enables the get_browser_view_status command without any pre-configured scope.","commands":{"allow":["get_browser_view_status"],"deny":[]}},"allow-get-container-info":{"identifier":"allow-get-container-info","description":"Enables the get_container_info command without any pre-configured scope.","commands":{"allow":["get_container_info"],"deny":[]}},"allow-get-container-page-state":{"identifier":"allow-get-container-page-state","description":"Enables the get_container_page_state command without any pre-configured scope.","commands":{"allow":["get_container_page_state"],"deny":[]}},"allow-get-container-staleness":{"identifier":"allow-get-container-staleness","description":"Enables the get_container_staleness command without any pre-configured scope.","commands":{"allow":["get_container_staleness"],"deny":[]}},"allow-get-gateway-auth-token":{"identifier":"allow-get-gateway-auth-token","description":"Enables the get_gateway_auth_token command without any pre-configured scope.","commands":{"allow":["get_gateway_auth_token"],"deny":[]}},"allow-get-gateway-status":{"identifier":"allow-get-gateway-status","description":"Enables the get_gateway_status command without any pre-configured scope.","commands":{"allow":["get_gateway_status"],"deny":[]}},"allow-get-help-content":{"identifier":"allow-get-help-content","description":"Enables the get_help_content command without any pre-configured scope.","commands":{"allow":["get_help_content"],"deny":[]}},"allow-get-marketplace-sync-report":{"identifier":"allow-get-marketplace-sync-report","description":"Enables the get_marketplace_sync_report command without any pre-configured scope.","commands":{"allow":["get_marketplace_sync_report"],"deny":[]}},"allow-get-migration-state":{"identifier":"allow-get-migration-state","description":"Enables the get_migration_state command without any pre-configured scope.","commands":{"allow":["get_migration_state"],"deny":[]}},"allow-get-scheduled-task-log":{"identifier":"allow-get-scheduled-task-log","description":"Enables the get_scheduled_task_log command without any pre-configured scope.","commands":{"allow":["get_scheduled_task_log"],"deny":[]}},"allow-get-scheduler-notifications":{"identifier":"allow-get-scheduler-notifications","description":"Enables the get_scheduler_notifications command without any pre-configured scope.","commands":{"allow":["get_scheduler_notifications"],"deny":[]}},"allow-get-settings":{"identifier":"allow-get-settings","description":"Enables the get_settings command without any pre-configured scope.","commands":{"allow":["get_settings"],"deny":[]}},"allow-get-stt-status":{"identifier":"allow-get-stt-status","description":"Enables the get_stt_status command without any pre-configured scope.","commands":{"allow":["get_stt_status"],"deny":[]}},"allow-get-web-terminal-status":{"identifier":"allow-get-web-terminal-status","description":"Enables the get_web_terminal_status command without any pre-configured scope.","commands":{"allow":["get_web_terminal_status"],"deny":[]}},"allow-has-claude-token":{"identifier":"allow-has-claude-token","description":"Enables the has_claude_token command without any pre-configured scope.","commands":{"allow":["has_claude_token"],"deny":[]}},"allow-inspect-ca-cert-path":{"identifier":"allow-inspect-ca-cert-path","description":"Enables the inspect_ca_cert_path command without any pre-configured scope.","commands":{"allow":["inspect_ca_cert_path"],"deny":[]}},"allow-install-browser-view-browser":{"identifier":"allow-install-browser-view-browser","description":"Enables the install_browser_view_browser command without any pre-configured scope.","commands":{"allow":["install_browser_view_browser"],"deny":[]}},"allow-install-browser-view-support":{"identifier":"allow-install-browser-view-support","description":"Enables the install_browser_view_support command without any pre-configured scope.","commands":{"allow":["install_browser_view_support"],"deny":[]}},"allow-install-marketplace-item":{"identifier":"allow-install-marketplace-item","description":"Enables the install_marketplace_item command without any pre-configured scope.","commands":{"allow":["install_marketplace_item"],"deny":[]}},"allow-list-aws-profiles":{"identifier":"allow-list-aws-profiles","description":"Enables the list_aws_profiles command without any pre-configured scope.","commands":{"allow":["list_aws_profiles"],"deny":[]}},"allow-list-claude-sessions":{"identifier":"allow-list-claude-sessions","description":"Enables the list_claude_sessions command without any pre-configured scope.","commands":{"allow":["list_claude_sessions"],"deny":[]}},"allow-list-container-capabilities":{"identifier":"allow-list-container-capabilities","description":"Enables the list_container_capabilities command without any pre-configured scope.","commands":{"allow":["list_container_capabilities"],"deny":[]}},"allow-list-container-files":{"identifier":"allow-list-container-files","description":"Enables the list_container_files command without any pre-configured scope.","commands":{"allow":["list_container_files"],"deny":[]}},"allow-list-marketplace-snapshots":{"identifier":"allow-list-marketplace-snapshots","description":"Enables the list_marketplace_snapshots command without any pre-configured scope.","commands":{"allow":["list_marketplace_snapshots"],"deny":[]}},"allow-list-marketplace-updates":{"identifier":"allow-list-marketplace-updates","description":"Enables the list_marketplace_updates command without any pre-configured scope.","commands":{"allow":["list_marketplace_updates"],"deny":[]}},"allow-list-notes":{"identifier":"allow-list-notes","description":"Enables the list_notes command without any pre-configured scope.","commands":{"allow":["list_notes"],"deny":[]}},"allow-list-projects":{"identifier":"allow-list-projects","description":"Enables the list_projects command without any pre-configured scope.","commands":{"allow":["list_projects"],"deny":[]}},"allow-list-scheduled-tasks":{"identifier":"allow-list-scheduled-tasks","description":"Enables the list_scheduled_tasks command without any pre-configured scope.","commands":{"allow":["list_scheduled_tasks"],"deny":[]}},"allow-marketplace-gh-host-available":{"identifier":"allow-marketplace-gh-host-available","description":"Enables the marketplace_gh_host_available command without any pre-configured scope.","commands":{"allow":["marketplace_gh_host_available"],"deny":[]}},"allow-marketplace-item-diff":{"identifier":"allow-marketplace-item-diff","description":"Enables the marketplace_item_diff command without any pre-configured scope.","commands":{"allow":["marketplace_item_diff"],"deny":[]}},"allow-migrate-project-to-base":{"identifier":"allow-migrate-project-to-base","description":"Enables the migrate_project_to_base command without any pre-configured scope.","commands":{"allow":["migrate_project_to_base"],"deny":[]}},"allow-onboard-aws-user":{"identifier":"allow-onboard-aws-user","description":"Enables the onboard_aws_user command without any pre-configured scope.","commands":{"allow":["onboard_aws_user"],"deny":[]}},"allow-open-browser-view-popout":{"identifier":"allow-open-browser-view-popout","description":"Enables the open_browser_view_popout command without any pre-configured scope.","commands":{"allow":["open_browser_view_popout"],"deny":[]}},"allow-open-file-viewer":{"identifier":"allow-open-file-viewer","description":"Enables the open_file_viewer command without any pre-configured scope.","commands":{"allow":["open_file_viewer"],"deny":[]}},"allow-open-page-in-container-browser":{"identifier":"allow-open-page-in-container-browser","description":"Enables the open_page_in_container_browser command without any pre-configured scope.","commands":{"allow":["open_page_in_container_browser"],"deny":[]}},"allow-open-terminal-session":{"identifier":"allow-open-terminal-session","description":"Enables the open_terminal_session command without any pre-configured scope.","commands":{"allow":["open_terminal_session"],"deny":[]}},"allow-open-url-external":{"identifier":"allow-open-url-external","description":"Enables the open_url_external command without any pre-configured scope.","commands":{"allow":["open_url_external"],"deny":[]}},"allow-paste-image-to-terminal":{"identifier":"allow-paste-image-to-terminal","description":"Enables the paste_image_to_terminal command without any pre-configured scope.","commands":{"allow":["paste_image_to_terminal"],"deny":[]}},"allow-preview-settings-import":{"identifier":"allow-preview-settings-import","description":"Enables the preview_settings_import command without any pre-configured scope.","commands":{"allow":["preview_settings_import"],"deny":[]}},"allow-pull-gateway-image":{"identifier":"allow-pull-gateway-image","description":"Enables the pull_gateway_image command without any pre-configured scope.","commands":{"allow":["pull_gateway_image"],"deny":[]}},"allow-pull-image":{"identifier":"allow-pull-image","description":"Enables the pull_image command without any pre-configured scope.","commands":{"allow":["pull_image"],"deny":[]}},"allow-pull-stt-image":{"identifier":"allow-pull-stt-image","description":"Enables the pull_stt_image command without any pre-configured scope.","commands":{"allow":["pull_stt_image"],"deny":[]}},"allow-push-aws-saved-state":{"identifier":"allow-push-aws-saved-state","description":"Enables the push_aws_saved_state command without any pre-configured scope.","commands":{"allow":["push_aws_saved_state"],"deny":[]}},"allow-read-container-file":{"identifier":"allow-read-container-file","description":"Enables the read_container_file command without any pre-configured scope.","commands":{"allow":["read_container_file"],"deny":[]}},"allow-rebuild-project-container":{"identifier":"allow-rebuild-project-container","description":"Enables the rebuild_project_container command without any pre-configured scope.","commands":{"allow":["rebuild_project_container"],"deny":[]}},"allow-reconcile-aws-projects":{"identifier":"allow-reconcile-aws-projects","description":"Enables the reconcile_aws_projects command without any pre-configured scope.","commands":{"allow":["reconcile_aws_projects"],"deny":[]}},"allow-reconcile-project-statuses":{"identifier":"allow-reconcile-project-statuses","description":"Enables the reconcile_project_statuses command without any pre-configured scope.","commands":{"allow":["reconcile_project_statuses"],"deny":[]}},"allow-refresh-marketplaces":{"identifier":"allow-refresh-marketplaces","description":"Enables the refresh_marketplaces command without any pre-configured scope.","commands":{"allow":["refresh_marketplaces"],"deny":[]}},"allow-regenerate-gateway-auth-token":{"identifier":"allow-regenerate-gateway-auth-token","description":"Enables the regenerate_gateway_auth_token command without any pre-configured scope.","commands":{"allow":["regenerate_gateway_auth_token"],"deny":[]}},"allow-regenerate-web-terminal-token":{"identifier":"allow-regenerate-web-terminal-token","description":"Enables the regenerate_web_terminal_token command without any pre-configured scope.","commands":{"allow":["regenerate_web_terminal_token"],"deny":[]}},"allow-remove-aws-resources":{"identifier":"allow-remove-aws-resources","description":"Enables the remove_aws_resources command without any pre-configured scope.","commands":{"allow":["remove_aws_resources"],"deny":[]}},"allow-remove-host-connection":{"identifier":"allow-remove-host-connection","description":"Enables the remove_host_connection command without any pre-configured scope.","commands":{"allow":["remove_host_connection"],"deny":[]}},"allow-remove-marketplace":{"identifier":"allow-remove-marketplace","description":"Enables the remove_marketplace command without any pre-configured scope.","commands":{"allow":["remove_marketplace"],"deny":[]}},"allow-remove-marketplace-account":{"identifier":"allow-remove-marketplace-account","description":"Enables the remove_marketplace_account command without any pre-configured scope.","commands":{"allow":["remove_marketplace_account"],"deny":[]}},"allow-remove-project":{"identifier":"allow-remove-project","description":"Enables the remove_project command without any pre-configured scope.","commands":{"allow":["remove_project"],"deny":[]}},"allow-remove-scheduled-task":{"identifier":"allow-remove-scheduled-task","description":"Enables the remove_scheduled_task command without any pre-configured scope.","commands":{"allow":["remove_scheduled_task"],"deny":[]}},"allow-rename-container-path":{"identifier":"allow-rename-container-path","description":"Enables the rename_container_path command without any pre-configured scope.","commands":{"allow":["rename_container_path"],"deny":[]}},"allow-repair-aws-environment":{"identifier":"allow-repair-aws-environment","description":"Enables the repair_aws_environment command without any pre-configured scope.","commands":{"allow":["repair_aws_environment"],"deny":[]}},"allow-rollback-migration":{"identifier":"allow-rollback-migration","description":"Enables the rollback_migration command without any pre-configured scope.","commands":{"allow":["rollback_migration"],"deny":[]}},"allow-run-docker-install":{"identifier":"allow-run-docker-install","description":"Enables the run_docker_install command without any pre-configured scope.","commands":{"allow":["run_docker_install"],"deny":[]}},"allow-run-scheduled-task-now":{"identifier":"allow-run-scheduled-task-now","description":"Enables the run_scheduled_task_now command without any pre-configured scope.","commands":{"allow":["run_scheduled_task_now"],"deny":[]}},"allow-save-aws-admin-bundle":{"identifier":"allow-save-aws-admin-bundle","description":"Enables the save_aws_admin_bundle command without any pre-configured scope.","commands":{"allow":["save_aws_admin_bundle"],"deny":[]}},"allow-save-note":{"identifier":"allow-save-note","description":"Enables the save_note command without any pre-configured scope.","commands":{"allow":["save_note"],"deny":[]}},"allow-send-audio-data":{"identifier":"allow-send-audio-data","description":"Enables the send_audio_data command without any pre-configured scope.","commands":{"allow":["send_audio_data"],"deny":[]}},"allow-set-auth-bridge-enabled":{"identifier":"allow-set-auth-bridge-enabled","description":"Enables the set_auth_bridge_enabled command without any pre-configured scope.","commands":{"allow":["set_auth_bridge_enabled"],"deny":[]}},"allow-set-browser-view-enabled":{"identifier":"allow-set-browser-view-enabled","description":"Enables the set_browser_view_enabled command without any pre-configured scope.","commands":{"allow":["set_browser_view_enabled"],"deny":[]}},"allow-set-browser-view-match-window":{"identifier":"allow-set-browser-view-match-window","description":"Enables the set_browser_view_match_window command without any pre-configured scope.","commands":{"allow":["set_browser_view_match_window"],"deny":[]}},"allow-set-browser-view-popout-always-on-top":{"identifier":"allow-set-browser-view-popout-always-on-top","description":"Enables the set_browser_view_popout_always_on_top command without any pre-configured scope.","commands":{"allow":["set_browser_view_popout_always_on_top"],"deny":[]}},"allow-set-container-page-viewport":{"identifier":"allow-set-container-page-viewport","description":"Enables the set_container_page_viewport command without any pre-configured scope.","commands":{"allow":["set_container_page_viewport"],"deny":[]}},"allow-set-gateway-api-key":{"identifier":"allow-set-gateway-api-key","description":"Enables the set_gateway_api_key command without any pre-configured scope.","commands":{"allow":["set_gateway_api_key"],"deny":[]}},"allow-set-global-item-disabled":{"identifier":"allow-set-global-item-disabled","description":"Enables the set_global_item_disabled command without any pre-configured scope.","commands":{"allow":["set_global_item_disabled"],"deny":[]}},"allow-set-scheduled-task-enabled":{"identifier":"allow-set-scheduled-task-enabled","description":"Enables the set_scheduled_task_enabled command without any pre-configured scope.","commands":{"allow":["set_scheduled_task_enabled"],"deny":[]}},"allow-start-audio-bridge":{"identifier":"allow-start-audio-bridge","description":"Enables the start_audio_bridge command without any pre-configured scope.","commands":{"allow":["start_audio_bridge"],"deny":[]}},"allow-start-gateway":{"identifier":"allow-start-gateway","description":"Enables the start_gateway command without any pre-configured scope.","commands":{"allow":["start_gateway"],"deny":[]}},"allow-start-marketplace-gh-container-login":{"identifier":"allow-start-marketplace-gh-container-login","description":"Enables the start_marketplace_gh_container_login command without any pre-configured scope.","commands":{"allow":["start_marketplace_gh_container_login"],"deny":[]}},"allow-start-project-container":{"identifier":"allow-start-project-container","description":"Enables the start_project_container command without any pre-configured scope.","commands":{"allow":["start_project_container"],"deny":[]}},"allow-start-stt":{"identifier":"allow-start-stt","description":"Enables the start_stt command without any pre-configured scope.","commands":{"allow":["start_stt"],"deny":[]}},"allow-start-web-terminal":{"identifier":"allow-start-web-terminal","description":"Enables the start_web_terminal command without any pre-configured scope.","commands":{"allow":["start_web_terminal"],"deny":[]}},"allow-stop-audio-bridge":{"identifier":"allow-stop-audio-bridge","description":"Enables the stop_audio_bridge command without any pre-configured scope.","commands":{"allow":["stop_audio_bridge"],"deny":[]}},"allow-stop-gateway":{"identifier":"allow-stop-gateway","description":"Enables the stop_gateway command without any pre-configured scope.","commands":{"allow":["stop_gateway"],"deny":[]}},"allow-stop-project-container":{"identifier":"allow-stop-project-container","description":"Enables the stop_project_container command without any pre-configured scope.","commands":{"allow":["stop_project_container"],"deny":[]}},"allow-stop-stt":{"identifier":"allow-stop-stt","description":"Enables the stop_stt command without any pre-configured scope.","commands":{"allow":["stop_stt"],"deny":[]}},"allow-stop-web-terminal":{"identifier":"allow-stop-web-terminal","description":"Enables the stop_web_terminal command without any pre-configured scope.","commands":{"allow":["stop_web_terminal"],"deny":[]}},"allow-submit-claude-token-code":{"identifier":"allow-submit-claude-token-code","description":"Enables the submit_claude_token_code command without any pre-configured scope.","commands":{"allow":["submit_claude_token_code"],"deny":[]}},"allow-sweep-claude-token-snapshots":{"identifier":"allow-sweep-claude-token-snapshots","description":"Enables the sweep_claude_token_snapshots command without any pre-configured scope.","commands":{"allow":["sweep_claude_token_snapshots"],"deny":[]}},"allow-terminal-input":{"identifier":"allow-terminal-input","description":"Enables the terminal_input command without any pre-configured scope.","commands":{"allow":["terminal_input"],"deny":[]}},"allow-terminal-resize":{"identifier":"allow-terminal-resize","description":"Enables the terminal_resize command without any pre-configured scope.","commands":{"allow":["terminal_resize"],"deny":[]}},"allow-test-marketplace-account":{"identifier":"allow-test-marketplace-account","description":"Enables the test_marketplace_account command without any pre-configured scope.","commands":{"allow":["test_marketplace_account"],"deny":[]}},"allow-transcribe-audio":{"identifier":"allow-transcribe-audio","description":"Enables the transcribe_audio command without any pre-configured scope.","commands":{"allow":["transcribe_audio"],"deny":[]}},"allow-uninstall-marketplace-item":{"identifier":"allow-uninstall-marketplace-item","description":"Enables the uninstall_marketplace_item command without any pre-configured scope.","commands":{"allow":["uninstall_marketplace_item"],"deny":[]}},"allow-unlock-aws-state":{"identifier":"allow-unlock-aws-state","description":"Enables the unlock_aws_state command without any pre-configured scope.","commands":{"allow":["unlock_aws_state"],"deny":[]}},"allow-update-aws-connection":{"identifier":"allow-update-aws-connection","description":"Enables the update_aws_connection command without any pre-configured scope.","commands":{"allow":["update_aws_connection"],"deny":[]}},"allow-update-aws-environment":{"identifier":"allow-update-aws-environment","description":"Enables the update_aws_environment command without any pre-configured scope.","commands":{"allow":["update_aws_environment"],"deny":[]}},"allow-update-marketplace":{"identifier":"allow-update-marketplace","description":"Enables the update_marketplace command without any pre-configured scope.","commands":{"allow":["update_marketplace"],"deny":[]}},"allow-update-marketplace-item":{"identifier":"allow-update-marketplace-item","description":"Enables the update_marketplace_item command without any pre-configured scope.","commands":{"allow":["update_marketplace_item"],"deny":[]}},"allow-update-project":{"identifier":"allow-update-project","description":"Enables the update_project command without any pre-configured scope.","commands":{"allow":["update_project"],"deny":[]}},"allow-update-scheduled-task":{"identifier":"allow-update-scheduled-task","description":"Enables the update_scheduled_task command without any pre-configured scope.","commands":{"allow":["update_scheduled_task"],"deny":[]}},"allow-update-settings":{"identifier":"allow-update-settings","description":"Enables the update_settings command without any pre-configured scope.","commands":{"allow":["update_settings"],"deny":[]}},"allow-upload-files-to-container":{"identifier":"allow-upload-files-to-container","description":"Enables the upload_files_to_container command without any pre-configured scope.","commands":{"allow":["upload_files_to_container"],"deny":[]}},"allow-upload-host-file-to-terminal":{"identifier":"allow-upload-host-file-to-terminal","description":"Enables the upload_host_file_to_terminal command without any pre-configured scope.","commands":{"allow":["upload_host_file_to_terminal"],"deny":[]}},"allow-viewer-choose-file":{"identifier":"allow-viewer-choose-file","description":"Enables the viewer_choose_file command without any pre-configured scope.","commands":{"allow":["viewer_choose_file"],"deny":[]}},"allow-viewer-get-state":{"identifier":"allow-viewer-get-state","description":"Enables the viewer_get_state command without any pre-configured scope.","commands":{"allow":["viewer_get_state"],"deny":[]}},"allow-viewer-poll-file":{"identifier":"allow-viewer-poll-file","description":"Enables the viewer_poll_file command without any pre-configured scope.","commands":{"allow":["viewer_poll_file"],"deny":[]}},"allow-viewer-read-file":{"identifier":"allow-viewer-read-file","description":"Enables the viewer_read_file command without any pre-configured scope.","commands":{"allow":["viewer_read_file"],"deny":[]}},"allow-viewer-write-file":{"identifier":"allow-viewer-write-file","description":"Enables the viewer_write_file command without any pre-configured scope.","commands":{"allow":["viewer_write_file"],"deny":[]}},"deny-acquire-claude-token":{"identifier":"deny-acquire-claude-token","description":"Denies the acquire_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["acquire_claude_token"]}},"deny-add-aws-keys-connection":{"identifier":"deny-add-aws-keys-connection","description":"Denies the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["add_aws_keys_connection"]}},"deny-add-aws-profile-connection":{"identifier":"deny-add-aws-profile-connection","description":"Denies the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["add_aws_profile_connection"]}},"deny-add-marketplace":{"identifier":"deny-add-marketplace","description":"Denies the add_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace"]}},"deny-add-marketplace-gh-host-account":{"identifier":"deny-add-marketplace-gh-host-account","description":"Denies the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace_gh_host_account"]}},"deny-add-marketplace-token-account":{"identifier":"deny-add-marketplace-token-account","description":"Denies the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace_token_account"]}},"deny-add-project":{"identifier":"deny-add-project","description":"Denies the add_project command without any pre-configured scope.","commands":{"allow":[],"deny":["add_project"]}},"deny-add-scheduled-task":{"identifier":"deny-add-scheduled-task","description":"Denies the add_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["add_scheduled_task"]}},"deny-apply-marketplace-now":{"identifier":"deny-apply-marketplace-now","description":"Denies the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":[],"deny":["apply_marketplace_now"]}},"deny-apply-settings-import":{"identifier":"deny-apply-settings-import","description":"Denies the apply_settings_import command without any pre-configured scope.","commands":{"allow":[],"deny":["apply_settings_import"]}},"deny-aws-connection-identity":{"identifier":"deny-aws-connection-identity","description":"Denies the aws_connection_identity command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_connection_identity"]}},"deny-aws-connection-sso-login":{"identifier":"deny-aws-connection-sso-login","description":"Denies the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_connection_sso_login"]}},"deny-aws-cost-estimate":{"identifier":"deny-aws-cost-estimate","description":"Denies the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_cost_estimate"]}},"deny-aws-environment-max-hours":{"identifier":"deny-aws-environment-max-hours","description":"Denies the aws_environment_max_hours command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_environment_max_hours"]}},"deny-aws-policy-document":{"identifier":"deny-aws-policy-document","description":"Denies the aws_policy_document command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_policy_document"]}},"deny-aws-sso-refresh":{"identifier":"deny-aws-sso-refresh","description":"Denies the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_sso_refresh"]}},"deny-aws-task-log":{"identifier":"deny-aws-task-log","description":"Denies the aws_task_log command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_task_log"]}},"deny-aws-workspace-status":{"identifier":"deny-aws-workspace-status","description":"Denies the aws_workspace_status command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_workspace_status"]}},"deny-build-gateway-image":{"identifier":"deny-build-gateway-image","description":"Denies the build_gateway_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_gateway_image"]}},"deny-build-image":{"identifier":"deny-build-image","description":"Denies the build_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_image"]}},"deny-build-stt-image":{"identifier":"deny-build-stt-image","description":"Denies the build_stt_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_stt_image"]}},"deny-cancel-aws-deployment":{"identifier":"deny-cancel-aws-deployment","description":"Denies the cancel_aws_deployment command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_aws_deployment"]}},"deny-cancel-claude-token":{"identifier":"deny-cancel-claude-token","description":"Denies the cancel_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_claude_token"]}},"deny-cancel-marketplace-gh-login":{"identifier":"deny-cancel-marketplace-gh-login","description":"Denies the cancel_marketplace_gh_login command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_marketplace_gh_login"]}},"deny-check-aws-permissions":{"identifier":"deny-check-aws-permissions","description":"Denies the check_aws_permissions command without any pre-configured scope.","commands":{"allow":[],"deny":["check_aws_permissions"]}},"deny-check-browser-view-support":{"identifier":"deny-check-browser-view-support","description":"Denies the check_browser_view_support command without any pre-configured scope.","commands":{"allow":[],"deny":["check_browser_view_support"]}},"deny-check-docker":{"identifier":"deny-check-docker","description":"Denies the check_docker command without any pre-configured scope.","commands":{"allow":[],"deny":["check_docker"]}},"deny-check-for-updates":{"identifier":"deny-check-for-updates","description":"Denies the check_for_updates command without any pre-configured scope.","commands":{"allow":[],"deny":["check_for_updates"]}},"deny-check-gateway-health":{"identifier":"deny-check-gateway-health","description":"Denies the check_gateway_health command without any pre-configured scope.","commands":{"allow":[],"deny":["check_gateway_health"]}},"deny-check-image-exists":{"identifier":"deny-check-image-exists","description":"Denies the check_image_exists command without any pre-configured scope.","commands":{"allow":[],"deny":["check_image_exists"]}},"deny-check-image-update":{"identifier":"deny-check-image-update","description":"Denies the check_image_update command without any pre-configured scope.","commands":{"allow":[],"deny":["check_image_update"]}},"deny-check-unsaved-work":{"identifier":"deny-check-unsaved-work","description":"Denies the check_unsaved_work command without any pre-configured scope.","commands":{"allow":[],"deny":["check_unsaved_work"]}},"deny-clear-claude-token":{"identifier":"deny-clear-claude-token","description":"Denies the clear_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_claude_token"]}},"deny-clear-gateway-api-key":{"identifier":"deny-clear-gateway-api-key","description":"Denies the clear_gateway_api_key command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_gateway_api_key"]}},"deny-clear-scheduler-notifications":{"identifier":"deny-clear-scheduler-notifications","description":"Denies the clear_scheduler_notifications command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_scheduler_notifications"]}},"deny-close-browser-view-popout":{"identifier":"deny-close-browser-view-popout","description":"Denies the close_browser_view_popout command without any pre-configured scope.","commands":{"allow":[],"deny":["close_browser_view_popout"]}},"deny-close-container-page":{"identifier":"deny-close-container-page","description":"Denies the close_container_page command without any pre-configured scope.","commands":{"allow":[],"deny":["close_container_page"]}},"deny-close-terminal-session":{"identifier":"deny-close-terminal-session","description":"Denies the close_terminal_session command without any pre-configured scope.","commands":{"allow":[],"deny":["close_terminal_session"]}},"deny-confirm-migration":{"identifier":"deny-confirm-migration","description":"Denies the confirm_migration command without any pre-configured scope.","commands":{"allow":[],"deny":["confirm_migration"]}},"deny-create-container-directory":{"identifier":"deny-create-container-directory","description":"Denies the create_container_directory command without any pre-configured scope.","commands":{"allow":[],"deny":["create_container_directory"]}},"deny-delete-note":{"identifier":"deny-delete-note","description":"Denies the delete_note command without any pre-configured scope.","commands":{"allow":[],"deny":["delete_note"]}},"deny-deploy-aws-environment":{"identifier":"deny-deploy-aws-environment","description":"Denies the deploy_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["deploy_aws_environment"]}},"deny-deploy-aws-permissions-boundary":{"identifier":"deny-deploy-aws-permissions-boundary","description":"Denies the deploy_aws_permissions_boundary command without any pre-configured scope.","commands":{"allow":[],"deny":["deploy_aws_permissions_boundary"]}},"deny-destroy-incomplete-aws-environment":{"identifier":"deny-destroy-incomplete-aws-environment","description":"Denies the destroy_incomplete_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["destroy_incomplete_aws_environment"]}},"deny-detect-aws-config":{"identifier":"deny-detect-aws-config","description":"Denies the detect_aws_config command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_aws_config"]}},"deny-detect-aws-environments":{"identifier":"deny-detect-aws-environments","description":"Denies the detect_aws_environments command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_aws_environments"]}},"deny-detect-host-timezone":{"identifier":"deny-detect-host-timezone","description":"Denies the detect_host_timezone command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_host_timezone"]}},"deny-detect-install-options":{"identifier":"deny-detect-install-options","description":"Denies the detect_install_options command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_install_options"]}},"deny-download-container-backup":{"identifier":"deny-download-container-backup","description":"Denies the download_container_backup command without any pre-configured scope.","commands":{"allow":[],"deny":["download_container_backup"]}},"deny-download-container-file":{"identifier":"deny-download-container-file","description":"Denies the download_container_file command without any pre-configured scope.","commands":{"allow":[],"deny":["download_container_file"]}},"deny-export-settings":{"identifier":"deny-export-settings","description":"Denies the export_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["export_settings"]}},"deny-follow-aws-deployment":{"identifier":"deny-follow-aws-deployment","description":"Denies the follow_aws_deployment command without any pre-configured scope.","commands":{"allow":[],"deny":["follow_aws_deployment"]}},"deny-forget-marketplace-installs":{"identifier":"deny-forget-marketplace-installs","description":"Denies the forget_marketplace_installs command without any pre-configured scope.","commands":{"allow":[],"deny":["forget_marketplace_installs"]}},"deny-get-app-version":{"identifier":"deny-get-app-version","description":"Denies the get_app_version command without any pre-configured scope.","commands":{"allow":[],"deny":["get_app_version"]}},"deny-get-auth-bridge-status":{"identifier":"deny-get-auth-bridge-status","description":"Denies the get_auth_bridge_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_auth_bridge_status"]}},"deny-get-browser-view-match-window":{"identifier":"deny-get-browser-view-match-window","description":"Denies the get_browser_view_match_window command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_match_window"]}},"deny-get-browser-view-popout-state":{"identifier":"deny-get-browser-view-popout-state","description":"Denies the get_browser_view_popout_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_popout_state"]}},"deny-get-browser-view-status":{"identifier":"deny-get-browser-view-status","description":"Denies the get_browser_view_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_status"]}},"deny-get-container-info":{"identifier":"deny-get-container-info","description":"Denies the get_container_info command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_info"]}},"deny-get-container-page-state":{"identifier":"deny-get-container-page-state","description":"Denies the get_container_page_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_page_state"]}},"deny-get-container-staleness":{"identifier":"deny-get-container-staleness","description":"Denies the get_container_staleness command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_staleness"]}},"deny-get-gateway-auth-token":{"identifier":"deny-get-gateway-auth-token","description":"Denies the get_gateway_auth_token command without any pre-configured scope.","commands":{"allow":[],"deny":["get_gateway_auth_token"]}},"deny-get-gateway-status":{"identifier":"deny-get-gateway-status","description":"Denies the get_gateway_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_gateway_status"]}},"deny-get-help-content":{"identifier":"deny-get-help-content","description":"Denies the get_help_content command without any pre-configured scope.","commands":{"allow":[],"deny":["get_help_content"]}},"deny-get-marketplace-sync-report":{"identifier":"deny-get-marketplace-sync-report","description":"Denies the get_marketplace_sync_report command without any pre-configured scope.","commands":{"allow":[],"deny":["get_marketplace_sync_report"]}},"deny-get-migration-state":{"identifier":"deny-get-migration-state","description":"Denies the get_migration_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_migration_state"]}},"deny-get-scheduled-task-log":{"identifier":"deny-get-scheduled-task-log","description":"Denies the get_scheduled_task_log command without any pre-configured scope.","commands":{"allow":[],"deny":["get_scheduled_task_log"]}},"deny-get-scheduler-notifications":{"identifier":"deny-get-scheduler-notifications","description":"Denies the get_scheduler_notifications command without any pre-configured scope.","commands":{"allow":[],"deny":["get_scheduler_notifications"]}},"deny-get-settings":{"identifier":"deny-get-settings","description":"Denies the get_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["get_settings"]}},"deny-get-stt-status":{"identifier":"deny-get-stt-status","description":"Denies the get_stt_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_stt_status"]}},"deny-get-web-terminal-status":{"identifier":"deny-get-web-terminal-status","description":"Denies the get_web_terminal_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_web_terminal_status"]}},"deny-has-claude-token":{"identifier":"deny-has-claude-token","description":"Denies the has_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["has_claude_token"]}},"deny-inspect-ca-cert-path":{"identifier":"deny-inspect-ca-cert-path","description":"Denies the inspect_ca_cert_path command without any pre-configured scope.","commands":{"allow":[],"deny":["inspect_ca_cert_path"]}},"deny-install-browser-view-browser":{"identifier":"deny-install-browser-view-browser","description":"Denies the install_browser_view_browser command without any pre-configured scope.","commands":{"allow":[],"deny":["install_browser_view_browser"]}},"deny-install-browser-view-support":{"identifier":"deny-install-browser-view-support","description":"Denies the install_browser_view_support command without any pre-configured scope.","commands":{"allow":[],"deny":["install_browser_view_support"]}},"deny-install-marketplace-item":{"identifier":"deny-install-marketplace-item","description":"Denies the install_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["install_marketplace_item"]}},"deny-list-aws-profiles":{"identifier":"deny-list-aws-profiles","description":"Denies the list_aws_profiles command without any pre-configured scope.","commands":{"allow":[],"deny":["list_aws_profiles"]}},"deny-list-claude-sessions":{"identifier":"deny-list-claude-sessions","description":"Denies the list_claude_sessions command without any pre-configured scope.","commands":{"allow":[],"deny":["list_claude_sessions"]}},"deny-list-container-capabilities":{"identifier":"deny-list-container-capabilities","description":"Denies the list_container_capabilities command without any pre-configured scope.","commands":{"allow":[],"deny":["list_container_capabilities"]}},"deny-list-container-files":{"identifier":"deny-list-container-files","description":"Denies the list_container_files command without any pre-configured scope.","commands":{"allow":[],"deny":["list_container_files"]}},"deny-list-marketplace-snapshots":{"identifier":"deny-list-marketplace-snapshots","description":"Denies the list_marketplace_snapshots command without any pre-configured scope.","commands":{"allow":[],"deny":["list_marketplace_snapshots"]}},"deny-list-marketplace-updates":{"identifier":"deny-list-marketplace-updates","description":"Denies the list_marketplace_updates command without any pre-configured scope.","commands":{"allow":[],"deny":["list_marketplace_updates"]}},"deny-list-notes":{"identifier":"deny-list-notes","description":"Denies the list_notes command without any pre-configured scope.","commands":{"allow":[],"deny":["list_notes"]}},"deny-list-projects":{"identifier":"deny-list-projects","description":"Denies the list_projects command without any pre-configured scope.","commands":{"allow":[],"deny":["list_projects"]}},"deny-list-scheduled-tasks":{"identifier":"deny-list-scheduled-tasks","description":"Denies the list_scheduled_tasks command without any pre-configured scope.","commands":{"allow":[],"deny":["list_scheduled_tasks"]}},"deny-marketplace-gh-host-available":{"identifier":"deny-marketplace-gh-host-available","description":"Denies the marketplace_gh_host_available command without any pre-configured scope.","commands":{"allow":[],"deny":["marketplace_gh_host_available"]}},"deny-marketplace-item-diff":{"identifier":"deny-marketplace-item-diff","description":"Denies the marketplace_item_diff command without any pre-configured scope.","commands":{"allow":[],"deny":["marketplace_item_diff"]}},"deny-migrate-project-to-base":{"identifier":"deny-migrate-project-to-base","description":"Denies the migrate_project_to_base command without any pre-configured scope.","commands":{"allow":[],"deny":["migrate_project_to_base"]}},"deny-onboard-aws-user":{"identifier":"deny-onboard-aws-user","description":"Denies the onboard_aws_user command without any pre-configured scope.","commands":{"allow":[],"deny":["onboard_aws_user"]}},"deny-open-browser-view-popout":{"identifier":"deny-open-browser-view-popout","description":"Denies the open_browser_view_popout command without any pre-configured scope.","commands":{"allow":[],"deny":["open_browser_view_popout"]}},"deny-open-file-viewer":{"identifier":"deny-open-file-viewer","description":"Denies the open_file_viewer command without any pre-configured scope.","commands":{"allow":[],"deny":["open_file_viewer"]}},"deny-open-page-in-container-browser":{"identifier":"deny-open-page-in-container-browser","description":"Denies the open_page_in_container_browser command without any pre-configured scope.","commands":{"allow":[],"deny":["open_page_in_container_browser"]}},"deny-open-terminal-session":{"identifier":"deny-open-terminal-session","description":"Denies the open_terminal_session command without any pre-configured scope.","commands":{"allow":[],"deny":["open_terminal_session"]}},"deny-open-url-external":{"identifier":"deny-open-url-external","description":"Denies the open_url_external command without any pre-configured scope.","commands":{"allow":[],"deny":["open_url_external"]}},"deny-paste-image-to-terminal":{"identifier":"deny-paste-image-to-terminal","description":"Denies the paste_image_to_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["paste_image_to_terminal"]}},"deny-preview-settings-import":{"identifier":"deny-preview-settings-import","description":"Denies the preview_settings_import command without any pre-configured scope.","commands":{"allow":[],"deny":["preview_settings_import"]}},"deny-pull-gateway-image":{"identifier":"deny-pull-gateway-image","description":"Denies the pull_gateway_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_gateway_image"]}},"deny-pull-image":{"identifier":"deny-pull-image","description":"Denies the pull_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_image"]}},"deny-pull-stt-image":{"identifier":"deny-pull-stt-image","description":"Denies the pull_stt_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_stt_image"]}},"deny-push-aws-saved-state":{"identifier":"deny-push-aws-saved-state","description":"Denies the push_aws_saved_state command without any pre-configured scope.","commands":{"allow":[],"deny":["push_aws_saved_state"]}},"deny-read-container-file":{"identifier":"deny-read-container-file","description":"Denies the read_container_file command without any pre-configured scope.","commands":{"allow":[],"deny":["read_container_file"]}},"deny-rebuild-project-container":{"identifier":"deny-rebuild-project-container","description":"Denies the rebuild_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["rebuild_project_container"]}},"deny-reconcile-aws-projects":{"identifier":"deny-reconcile-aws-projects","description":"Denies the reconcile_aws_projects command without any pre-configured scope.","commands":{"allow":[],"deny":["reconcile_aws_projects"]}},"deny-reconcile-project-statuses":{"identifier":"deny-reconcile-project-statuses","description":"Denies the reconcile_project_statuses command without any pre-configured scope.","commands":{"allow":[],"deny":["reconcile_project_statuses"]}},"deny-refresh-marketplaces":{"identifier":"deny-refresh-marketplaces","description":"Denies the refresh_marketplaces command without any pre-configured scope.","commands":{"allow":[],"deny":["refresh_marketplaces"]}},"deny-regenerate-gateway-auth-token":{"identifier":"deny-regenerate-gateway-auth-token","description":"Denies the regenerate_gateway_auth_token command without any pre-configured scope.","commands":{"allow":[],"deny":["regenerate_gateway_auth_token"]}},"deny-regenerate-web-terminal-token":{"identifier":"deny-regenerate-web-terminal-token","description":"Denies the regenerate_web_terminal_token command without any pre-configured scope.","commands":{"allow":[],"deny":["regenerate_web_terminal_token"]}},"deny-remove-aws-resources":{"identifier":"deny-remove-aws-resources","description":"Denies the remove_aws_resources command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_aws_resources"]}},"deny-remove-host-connection":{"identifier":"deny-remove-host-connection","description":"Denies the remove_host_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_host_connection"]}},"deny-remove-marketplace":{"identifier":"deny-remove-marketplace","description":"Denies the remove_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_marketplace"]}},"deny-remove-marketplace-account":{"identifier":"deny-remove-marketplace-account","description":"Denies the remove_marketplace_account command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_marketplace_account"]}},"deny-remove-project":{"identifier":"deny-remove-project","description":"Denies the remove_project command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_project"]}},"deny-remove-scheduled-task":{"identifier":"deny-remove-scheduled-task","description":"Denies the remove_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_scheduled_task"]}},"deny-rename-container-path":{"identifier":"deny-rename-container-path","description":"Denies the rename_container_path command without any pre-configured scope.","commands":{"allow":[],"deny":["rename_container_path"]}},"deny-repair-aws-environment":{"identifier":"deny-repair-aws-environment","description":"Denies the repair_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["repair_aws_environment"]}},"deny-rollback-migration":{"identifier":"deny-rollback-migration","description":"Denies the rollback_migration command without any pre-configured scope.","commands":{"allow":[],"deny":["rollback_migration"]}},"deny-run-docker-install":{"identifier":"deny-run-docker-install","description":"Denies the run_docker_install command without any pre-configured scope.","commands":{"allow":[],"deny":["run_docker_install"]}},"deny-run-scheduled-task-now":{"identifier":"deny-run-scheduled-task-now","description":"Denies the run_scheduled_task_now command without any pre-configured scope.","commands":{"allow":[],"deny":["run_scheduled_task_now"]}},"deny-save-aws-admin-bundle":{"identifier":"deny-save-aws-admin-bundle","description":"Denies the save_aws_admin_bundle command without any pre-configured scope.","commands":{"allow":[],"deny":["save_aws_admin_bundle"]}},"deny-save-note":{"identifier":"deny-save-note","description":"Denies the save_note command without any pre-configured scope.","commands":{"allow":[],"deny":["save_note"]}},"deny-send-audio-data":{"identifier":"deny-send-audio-data","description":"Denies the send_audio_data command without any pre-configured scope.","commands":{"allow":[],"deny":["send_audio_data"]}},"deny-set-auth-bridge-enabled":{"identifier":"deny-set-auth-bridge-enabled","description":"Denies the set_auth_bridge_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_auth_bridge_enabled"]}},"deny-set-browser-view-enabled":{"identifier":"deny-set-browser-view-enabled","description":"Denies the set_browser_view_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_enabled"]}},"deny-set-browser-view-match-window":{"identifier":"deny-set-browser-view-match-window","description":"Denies the set_browser_view_match_window command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_match_window"]}},"deny-set-browser-view-popout-always-on-top":{"identifier":"deny-set-browser-view-popout-always-on-top","description":"Denies the set_browser_view_popout_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_popout_always_on_top"]}},"deny-set-container-page-viewport":{"identifier":"deny-set-container-page-viewport","description":"Denies the set_container_page_viewport command without any pre-configured scope.","commands":{"allow":[],"deny":["set_container_page_viewport"]}},"deny-set-gateway-api-key":{"identifier":"deny-set-gateway-api-key","description":"Denies the set_gateway_api_key command without any pre-configured scope.","commands":{"allow":[],"deny":["set_gateway_api_key"]}},"deny-set-global-item-disabled":{"identifier":"deny-set-global-item-disabled","description":"Denies the set_global_item_disabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_global_item_disabled"]}},"deny-set-scheduled-task-enabled":{"identifier":"deny-set-scheduled-task-enabled","description":"Denies the set_scheduled_task_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_scheduled_task_enabled"]}},"deny-start-audio-bridge":{"identifier":"deny-start-audio-bridge","description":"Denies the start_audio_bridge command without any pre-configured scope.","commands":{"allow":[],"deny":["start_audio_bridge"]}},"deny-start-gateway":{"identifier":"deny-start-gateway","description":"Denies the start_gateway command without any pre-configured scope.","commands":{"allow":[],"deny":["start_gateway"]}},"deny-start-marketplace-gh-container-login":{"identifier":"deny-start-marketplace-gh-container-login","description":"Denies the start_marketplace_gh_container_login command without any pre-configured scope.","commands":{"allow":[],"deny":["start_marketplace_gh_container_login"]}},"deny-start-project-container":{"identifier":"deny-start-project-container","description":"Denies the start_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["start_project_container"]}},"deny-start-stt":{"identifier":"deny-start-stt","description":"Denies the start_stt command without any pre-configured scope.","commands":{"allow":[],"deny":["start_stt"]}},"deny-start-web-terminal":{"identifier":"deny-start-web-terminal","description":"Denies the start_web_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["start_web_terminal"]}},"deny-stop-audio-bridge":{"identifier":"deny-stop-audio-bridge","description":"Denies the stop_audio_bridge command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_audio_bridge"]}},"deny-stop-gateway":{"identifier":"deny-stop-gateway","description":"Denies the stop_gateway command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_gateway"]}},"deny-stop-project-container":{"identifier":"deny-stop-project-container","description":"Denies the stop_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_project_container"]}},"deny-stop-stt":{"identifier":"deny-stop-stt","description":"Denies the stop_stt command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_stt"]}},"deny-stop-web-terminal":{"identifier":"deny-stop-web-terminal","description":"Denies the stop_web_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_web_terminal"]}},"deny-submit-claude-token-code":{"identifier":"deny-submit-claude-token-code","description":"Denies the submit_claude_token_code command without any pre-configured scope.","commands":{"allow":[],"deny":["submit_claude_token_code"]}},"deny-sweep-claude-token-snapshots":{"identifier":"deny-sweep-claude-token-snapshots","description":"Denies the sweep_claude_token_snapshots command without any pre-configured scope.","commands":{"allow":[],"deny":["sweep_claude_token_snapshots"]}},"deny-terminal-input":{"identifier":"deny-terminal-input","description":"Denies the terminal_input command without any pre-configured scope.","commands":{"allow":[],"deny":["terminal_input"]}},"deny-terminal-resize":{"identifier":"deny-terminal-resize","description":"Denies the terminal_resize command without any pre-configured scope.","commands":{"allow":[],"deny":["terminal_resize"]}},"deny-test-marketplace-account":{"identifier":"deny-test-marketplace-account","description":"Denies the test_marketplace_account command without any pre-configured scope.","commands":{"allow":[],"deny":["test_marketplace_account"]}},"deny-transcribe-audio":{"identifier":"deny-transcribe-audio","description":"Denies the transcribe_audio command without any pre-configured scope.","commands":{"allow":[],"deny":["transcribe_audio"]}},"deny-uninstall-marketplace-item":{"identifier":"deny-uninstall-marketplace-item","description":"Denies the uninstall_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["uninstall_marketplace_item"]}},"deny-unlock-aws-state":{"identifier":"deny-unlock-aws-state","description":"Denies the unlock_aws_state command without any pre-configured scope.","commands":{"allow":[],"deny":["unlock_aws_state"]}},"deny-update-aws-connection":{"identifier":"deny-update-aws-connection","description":"Denies the update_aws_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["update_aws_connection"]}},"deny-update-aws-environment":{"identifier":"deny-update-aws-environment","description":"Denies the update_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["update_aws_environment"]}},"deny-update-marketplace":{"identifier":"deny-update-marketplace","description":"Denies the update_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["update_marketplace"]}},"deny-update-marketplace-item":{"identifier":"deny-update-marketplace-item","description":"Denies the update_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["update_marketplace_item"]}},"deny-update-project":{"identifier":"deny-update-project","description":"Denies the update_project command without any pre-configured scope.","commands":{"allow":[],"deny":["update_project"]}},"deny-update-scheduled-task":{"identifier":"deny-update-scheduled-task","description":"Denies the update_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["update_scheduled_task"]}},"deny-update-settings":{"identifier":"deny-update-settings","description":"Denies the update_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["update_settings"]}},"deny-upload-files-to-container":{"identifier":"deny-upload-files-to-container","description":"Denies the upload_files_to_container command without any pre-configured scope.","commands":{"allow":[],"deny":["upload_files_to_container"]}},"deny-upload-host-file-to-terminal":{"identifier":"deny-upload-host-file-to-terminal","description":"Denies the upload_host_file_to_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["upload_host_file_to_terminal"]}},"deny-viewer-choose-file":{"identifier":"deny-viewer-choose-file","description":"Denies the viewer_choose_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_choose_file"]}},"deny-viewer-get-state":{"identifier":"deny-viewer-get-state","description":"Denies the viewer_get_state command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_get_state"]}},"deny-viewer-poll-file":{"identifier":"deny-viewer-poll-file","description":"Denies the viewer_poll_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_poll_file"]}},"deny-viewer-read-file":{"identifier":"deny-viewer-read-file","description":"Denies the viewer_read_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_read_file"]}},"deny-viewer-write-file":{"identifier":"deny-viewer-write-file","description":"Denies the viewer_write_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_write_file"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","commands":{"allow":["name"],"deny":[]}},"allow-register-listener":{"identifier":"allow-register-listener","description":"Enables the register_listener command without any pre-configured scope.","commands":{"allow":["register_listener"],"deny":[]}},"allow-remove-data-store":{"identifier":"allow-remove-data-store","description":"Enables the remove_data_store command without any pre-configured scope.","commands":{"allow":["remove_data_store"],"deny":[]}},"allow-remove-listener":{"identifier":"allow-remove-listener","description":"Enables the remove_listener command without any pre-configured scope.","commands":{"allow":["remove_listener"],"deny":[]}},"allow-set-app-theme":{"identifier":"allow-set-app-theme","description":"Enables the set_app_theme command without any pre-configured scope.","commands":{"allow":["set_app_theme"],"deny":[]}},"allow-set-dock-visibility":{"identifier":"allow-set-dock-visibility","description":"Enables the set_dock_visibility command without any pre-configured scope.","commands":{"allow":["set_dock_visibility"],"deny":[]}},"allow-supports-multiple-windows":{"identifier":"allow-supports-multiple-windows","description":"Enables the supports_multiple_windows command without any pre-configured scope.","commands":{"allow":["supports_multiple_windows"],"deny":[]}},"allow-tauri-version":{"identifier":"allow-tauri-version","description":"Enables the tauri_version command without any pre-configured scope.","commands":{"allow":["tauri_version"],"deny":[]}},"allow-version":{"identifier":"allow-version","description":"Enables the version command without any pre-configured scope.","commands":{"allow":["version"],"deny":[]}},"deny-app-hide":{"identifier":"deny-app-hide","description":"Denies the app_hide command without any pre-configured scope.","commands":{"allow":[],"deny":["app_hide"]}},"deny-app-show":{"identifier":"deny-app-show","description":"Denies the app_show command without any pre-configured scope.","commands":{"allow":[],"deny":["app_show"]}},"deny-bundle-type":{"identifier":"deny-bundle-type","description":"Denies the bundle_type command without any pre-configured scope.","commands":{"allow":[],"deny":["bundle_type"]}},"deny-default-window-icon":{"identifier":"deny-default-window-icon","description":"Denies the default_window_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["default_window_icon"]}},"deny-fetch-data-store-identifiers":{"identifier":"deny-fetch-data-store-identifiers","description":"Denies the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":[],"deny":["fetch_data_store_identifiers"]}},"deny-identifier":{"identifier":"deny-identifier","description":"Denies the identifier command without any pre-configured scope.","commands":{"allow":[],"deny":["identifier"]}},"deny-name":{"identifier":"deny-name","description":"Denies the name command without any pre-configured scope.","commands":{"allow":[],"deny":["name"]}},"deny-register-listener":{"identifier":"deny-register-listener","description":"Denies the register_listener command without any pre-configured scope.","commands":{"allow":[],"deny":["register_listener"]}},"deny-remove-data-store":{"identifier":"deny-remove-data-store","description":"Denies the remove_data_store command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_data_store"]}},"deny-remove-listener":{"identifier":"deny-remove-listener","description":"Denies the remove_listener command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_listener"]}},"deny-set-app-theme":{"identifier":"deny-set-app-theme","description":"Denies the set_app_theme command without any pre-configured scope.","commands":{"allow":[],"deny":["set_app_theme"]}},"deny-set-dock-visibility":{"identifier":"deny-set-dock-visibility","description":"Denies the set_dock_visibility command without any pre-configured scope.","commands":{"allow":[],"deny":["set_dock_visibility"]}},"deny-supports-multiple-windows":{"identifier":"deny-supports-multiple-windows","description":"Denies the supports_multiple_windows command without any pre-configured scope.","commands":{"allow":[],"deny":["supports_multiple_windows"]}},"deny-tauri-version":{"identifier":"deny-tauri-version","description":"Denies the tauri_version command without any pre-configured scope.","commands":{"allow":[],"deny":["tauri_version"]}},"deny-version":{"identifier":"deny-version","description":"Denies the version command without any pre-configured scope.","commands":{"allow":[],"deny":["version"]}}},"permission_sets":{},"global_scope_schema":null},"core:event":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-listen","allow-unlisten","allow-emit","allow-emit-to"]},"permissions":{"allow-emit":{"identifier":"allow-emit","description":"Enables the emit command without any pre-configured scope.","commands":{"allow":["emit"],"deny":[]}},"allow-emit-to":{"identifier":"allow-emit-to","description":"Enables the emit_to command without any pre-configured scope.","commands":{"allow":["emit_to"],"deny":[]}},"allow-listen":{"identifier":"allow-listen","description":"Enables the listen command without any pre-configured scope.","commands":{"allow":["listen"],"deny":[]}},"allow-unlisten":{"identifier":"allow-unlisten","description":"Enables the unlisten command without any pre-configured scope.","commands":{"allow":["unlisten"],"deny":[]}},"deny-emit":{"identifier":"deny-emit","description":"Denies the emit command without any pre-configured scope.","commands":{"allow":[],"deny":["emit"]}},"deny-emit-to":{"identifier":"deny-emit-to","description":"Denies the emit_to command without any pre-configured scope.","commands":{"allow":[],"deny":["emit_to"]}},"deny-listen":{"identifier":"deny-listen","description":"Denies the listen command without any pre-configured scope.","commands":{"allow":[],"deny":["listen"]}},"deny-unlisten":{"identifier":"deny-unlisten","description":"Denies the unlisten command without any pre-configured scope.","commands":{"allow":[],"deny":["unlisten"]}}},"permission_sets":{},"global_scope_schema":null},"core:image":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-from-bytes","allow-from-path","allow-rgba","allow-size"]},"permissions":{"allow-from-bytes":{"identifier":"allow-from-bytes","description":"Enables the from_bytes command without any pre-configured scope.","commands":{"allow":["from_bytes"],"deny":[]}},"allow-from-path":{"identifier":"allow-from-path","description":"Enables the from_path command without any pre-configured scope.","commands":{"allow":["from_path"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-rgba":{"identifier":"allow-rgba","description":"Enables the rgba command without any pre-configured scope.","commands":{"allow":["rgba"],"deny":[]}},"allow-size":{"identifier":"allow-size","description":"Enables the size command without any pre-configured scope.","commands":{"allow":["size"],"deny":[]}},"deny-from-bytes":{"identifier":"deny-from-bytes","description":"Denies the from_bytes command without any pre-configured scope.","commands":{"allow":[],"deny":["from_bytes"]}},"deny-from-path":{"identifier":"deny-from-path","description":"Denies the from_path command without any pre-configured scope.","commands":{"allow":[],"deny":["from_path"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-rgba":{"identifier":"deny-rgba","description":"Denies the rgba command without any pre-configured scope.","commands":{"allow":[],"deny":["rgba"]}},"deny-size":{"identifier":"deny-size","description":"Denies the size command without any pre-configured scope.","commands":{"allow":[],"deny":["size"]}}},"permission_sets":{},"global_scope_schema":null},"core:menu":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-append","allow-prepend","allow-insert","allow-remove","allow-remove-at","allow-items","allow-get","allow-popup","allow-create-default","allow-set-as-app-menu","allow-set-as-window-menu","allow-text","allow-set-text","allow-is-enabled","allow-set-enabled","allow-set-accelerator","allow-set-as-windows-menu-for-nsapp","allow-set-as-help-menu-for-nsapp","allow-is-checked","allow-set-checked","allow-set-icon"]},"permissions":{"allow-append":{"identifier":"allow-append","description":"Enables the append command without any pre-configured scope.","commands":{"allow":["append"],"deny":[]}},"allow-create-default":{"identifier":"allow-create-default","description":"Enables the create_default command without any pre-configured scope.","commands":{"allow":["create_default"],"deny":[]}},"allow-get":{"identifier":"allow-get","description":"Enables the get command without any pre-configured scope.","commands":{"allow":["get"],"deny":[]}},"allow-insert":{"identifier":"allow-insert","description":"Enables the insert command without any pre-configured scope.","commands":{"allow":["insert"],"deny":[]}},"allow-is-checked":{"identifier":"allow-is-checked","description":"Enables the is_checked command without any pre-configured scope.","commands":{"allow":["is_checked"],"deny":[]}},"allow-is-enabled":{"identifier":"allow-is-enabled","description":"Enables the is_enabled command without any pre-configured scope.","commands":{"allow":["is_enabled"],"deny":[]}},"allow-items":{"identifier":"allow-items","description":"Enables the items command without any pre-configured scope.","commands":{"allow":["items"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-popup":{"identifier":"allow-popup","description":"Enables the popup command without any pre-configured scope.","commands":{"allow":["popup"],"deny":[]}},"allow-prepend":{"identifier":"allow-prepend","description":"Enables the prepend command without any pre-configured scope.","commands":{"allow":["prepend"],"deny":[]}},"allow-remove":{"identifier":"allow-remove","description":"Enables the remove command without any pre-configured scope.","commands":{"allow":["remove"],"deny":[]}},"allow-remove-at":{"identifier":"allow-remove-at","description":"Enables the remove_at command without any pre-configured scope.","commands":{"allow":["remove_at"],"deny":[]}},"allow-set-accelerator":{"identifier":"allow-set-accelerator","description":"Enables the set_accelerator command without any pre-configured scope.","commands":{"allow":["set_accelerator"],"deny":[]}},"allow-set-as-app-menu":{"identifier":"allow-set-as-app-menu","description":"Enables the set_as_app_menu command without any pre-configured scope.","commands":{"allow":["set_as_app_menu"],"deny":[]}},"allow-set-as-help-menu-for-nsapp":{"identifier":"allow-set-as-help-menu-for-nsapp","description":"Enables the set_as_help_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":["set_as_help_menu_for_nsapp"],"deny":[]}},"allow-set-as-window-menu":{"identifier":"allow-set-as-window-menu","description":"Enables the set_as_window_menu command without any pre-configured scope.","commands":{"allow":["set_as_window_menu"],"deny":[]}},"allow-set-as-windows-menu-for-nsapp":{"identifier":"allow-set-as-windows-menu-for-nsapp","description":"Enables the set_as_windows_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":["set_as_windows_menu_for_nsapp"],"deny":[]}},"allow-set-checked":{"identifier":"allow-set-checked","description":"Enables the set_checked command without any pre-configured scope.","commands":{"allow":["set_checked"],"deny":[]}},"allow-set-enabled":{"identifier":"allow-set-enabled","description":"Enables the set_enabled command without any pre-configured scope.","commands":{"allow":["set_enabled"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-text":{"identifier":"allow-set-text","description":"Enables the set_text command without any pre-configured scope.","commands":{"allow":["set_text"],"deny":[]}},"allow-text":{"identifier":"allow-text","description":"Enables the text command without any pre-configured scope.","commands":{"allow":["text"],"deny":[]}},"deny-append":{"identifier":"deny-append","description":"Denies the append command without any pre-configured scope.","commands":{"allow":[],"deny":["append"]}},"deny-create-default":{"identifier":"deny-create-default","description":"Denies the create_default command without any pre-configured scope.","commands":{"allow":[],"deny":["create_default"]}},"deny-get":{"identifier":"deny-get","description":"Denies the get command without any pre-configured scope.","commands":{"allow":[],"deny":["get"]}},"deny-insert":{"identifier":"deny-insert","description":"Denies the insert command without any pre-configured scope.","commands":{"allow":[],"deny":["insert"]}},"deny-is-checked":{"identifier":"deny-is-checked","description":"Denies the is_checked command without any pre-configured scope.","commands":{"allow":[],"deny":["is_checked"]}},"deny-is-enabled":{"identifier":"deny-is-enabled","description":"Denies the is_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["is_enabled"]}},"deny-items":{"identifier":"deny-items","description":"Denies the items command without any pre-configured scope.","commands":{"allow":[],"deny":["items"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-popup":{"identifier":"deny-popup","description":"Denies the popup command without any pre-configured scope.","commands":{"allow":[],"deny":["popup"]}},"deny-prepend":{"identifier":"deny-prepend","description":"Denies the prepend command without any pre-configured scope.","commands":{"allow":[],"deny":["prepend"]}},"deny-remove":{"identifier":"deny-remove","description":"Denies the remove command without any pre-configured scope.","commands":{"allow":[],"deny":["remove"]}},"deny-remove-at":{"identifier":"deny-remove-at","description":"Denies the remove_at command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_at"]}},"deny-set-accelerator":{"identifier":"deny-set-accelerator","description":"Denies the set_accelerator command without any pre-configured scope.","commands":{"allow":[],"deny":["set_accelerator"]}},"deny-set-as-app-menu":{"identifier":"deny-set-as-app-menu","description":"Denies the set_as_app_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_app_menu"]}},"deny-set-as-help-menu-for-nsapp":{"identifier":"deny-set-as-help-menu-for-nsapp","description":"Denies the set_as_help_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_help_menu_for_nsapp"]}},"deny-set-as-window-menu":{"identifier":"deny-set-as-window-menu","description":"Denies the set_as_window_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_window_menu"]}},"deny-set-as-windows-menu-for-nsapp":{"identifier":"deny-set-as-windows-menu-for-nsapp","description":"Denies the set_as_windows_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_windows_menu_for_nsapp"]}},"deny-set-checked":{"identifier":"deny-set-checked","description":"Denies the set_checked command without any pre-configured scope.","commands":{"allow":[],"deny":["set_checked"]}},"deny-set-enabled":{"identifier":"deny-set-enabled","description":"Denies the set_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_enabled"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-text":{"identifier":"deny-set-text","description":"Denies the set_text command without any pre-configured scope.","commands":{"allow":[],"deny":["set_text"]}},"deny-text":{"identifier":"deny-text","description":"Denies the text command without any pre-configured scope.","commands":{"allow":[],"deny":["text"]}}},"permission_sets":{},"global_scope_schema":null},"core:path":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-resolve-directory","allow-resolve","allow-normalize","allow-join","allow-dirname","allow-extname","allow-basename","allow-is-absolute"]},"permissions":{"allow-basename":{"identifier":"allow-basename","description":"Enables the basename command without any pre-configured scope.","commands":{"allow":["basename"],"deny":[]}},"allow-dirname":{"identifier":"allow-dirname","description":"Enables the dirname command without any pre-configured scope.","commands":{"allow":["dirname"],"deny":[]}},"allow-extname":{"identifier":"allow-extname","description":"Enables the extname command without any pre-configured scope.","commands":{"allow":["extname"],"deny":[]}},"allow-is-absolute":{"identifier":"allow-is-absolute","description":"Enables the is_absolute command without any pre-configured scope.","commands":{"allow":["is_absolute"],"deny":[]}},"allow-join":{"identifier":"allow-join","description":"Enables the join command without any pre-configured scope.","commands":{"allow":["join"],"deny":[]}},"allow-normalize":{"identifier":"allow-normalize","description":"Enables the normalize command without any pre-configured scope.","commands":{"allow":["normalize"],"deny":[]}},"allow-resolve":{"identifier":"allow-resolve","description":"Enables the resolve command without any pre-configured scope.","commands":{"allow":["resolve"],"deny":[]}},"allow-resolve-directory":{"identifier":"allow-resolve-directory","description":"Enables the resolve_directory command without any pre-configured scope.","commands":{"allow":["resolve_directory"],"deny":[]}},"deny-basename":{"identifier":"deny-basename","description":"Denies the basename command without any pre-configured scope.","commands":{"allow":[],"deny":["basename"]}},"deny-dirname":{"identifier":"deny-dirname","description":"Denies the dirname command without any pre-configured scope.","commands":{"allow":[],"deny":["dirname"]}},"deny-extname":{"identifier":"deny-extname","description":"Denies the extname command without any pre-configured scope.","commands":{"allow":[],"deny":["extname"]}},"deny-is-absolute":{"identifier":"deny-is-absolute","description":"Denies the is_absolute command without any pre-configured scope.","commands":{"allow":[],"deny":["is_absolute"]}},"deny-join":{"identifier":"deny-join","description":"Denies the join command without any pre-configured scope.","commands":{"allow":[],"deny":["join"]}},"deny-normalize":{"identifier":"deny-normalize","description":"Denies the normalize command without any pre-configured scope.","commands":{"allow":[],"deny":["normalize"]}},"deny-resolve":{"identifier":"deny-resolve","description":"Denies the resolve command without any pre-configured scope.","commands":{"allow":[],"deny":["resolve"]}},"deny-resolve-directory":{"identifier":"deny-resolve-directory","description":"Denies the resolve_directory command without any pre-configured scope.","commands":{"allow":[],"deny":["resolve_directory"]}}},"permission_sets":{},"global_scope_schema":null},"core:resources":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-close"]},"permissions":{"allow-close":{"identifier":"allow-close","description":"Enables the close command without any pre-configured scope.","commands":{"allow":["close"],"deny":[]}},"deny-close":{"identifier":"deny-close","description":"Denies the close command without any pre-configured scope.","commands":{"allow":[],"deny":["close"]}}},"permission_sets":{},"global_scope_schema":null},"core:tray":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-get-by-id","allow-remove-by-id","allow-set-icon","allow-set-menu","allow-set-tooltip","allow-set-title","allow-set-visible","allow-set-temp-dir-path","allow-set-icon-as-template","allow-set-icon-with-as-template","allow-set-show-menu-on-left-click"]},"permissions":{"allow-get-by-id":{"identifier":"allow-get-by-id","description":"Enables the get_by_id command without any pre-configured scope.","commands":{"allow":["get_by_id"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-remove-by-id":{"identifier":"allow-remove-by-id","description":"Enables the remove_by_id command without any pre-configured scope.","commands":{"allow":["remove_by_id"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-icon-as-template":{"identifier":"allow-set-icon-as-template","description":"Enables the set_icon_as_template command without any pre-configured scope.","commands":{"allow":["set_icon_as_template"],"deny":[]}},"allow-set-icon-with-as-template":{"identifier":"allow-set-icon-with-as-template","description":"Enables the set_icon_with_as_template command without any pre-configured scope.","commands":{"allow":["set_icon_with_as_template"],"deny":[]}},"allow-set-menu":{"identifier":"allow-set-menu","description":"Enables the set_menu command without any pre-configured scope.","commands":{"allow":["set_menu"],"deny":[]}},"allow-set-show-menu-on-left-click":{"identifier":"allow-set-show-menu-on-left-click","description":"Enables the set_show_menu_on_left_click command without any pre-configured scope.","commands":{"allow":["set_show_menu_on_left_click"],"deny":[]}},"allow-set-temp-dir-path":{"identifier":"allow-set-temp-dir-path","description":"Enables the set_temp_dir_path command without any pre-configured scope.","commands":{"allow":["set_temp_dir_path"],"deny":[]}},"allow-set-title":{"identifier":"allow-set-title","description":"Enables the set_title command without any pre-configured scope.","commands":{"allow":["set_title"],"deny":[]}},"allow-set-tooltip":{"identifier":"allow-set-tooltip","description":"Enables the set_tooltip command without any pre-configured scope.","commands":{"allow":["set_tooltip"],"deny":[]}},"allow-set-visible":{"identifier":"allow-set-visible","description":"Enables the set_visible command without any pre-configured scope.","commands":{"allow":["set_visible"],"deny":[]}},"deny-get-by-id":{"identifier":"deny-get-by-id","description":"Denies the get_by_id command without any pre-configured scope.","commands":{"allow":[],"deny":["get_by_id"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-remove-by-id":{"identifier":"deny-remove-by-id","description":"Denies the remove_by_id command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_by_id"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-icon-as-template":{"identifier":"deny-set-icon-as-template","description":"Denies the set_icon_as_template command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon_as_template"]}},"deny-set-icon-with-as-template":{"identifier":"deny-set-icon-with-as-template","description":"Denies the set_icon_with_as_template command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon_with_as_template"]}},"deny-set-menu":{"identifier":"deny-set-menu","description":"Denies the set_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_menu"]}},"deny-set-show-menu-on-left-click":{"identifier":"deny-set-show-menu-on-left-click","description":"Denies the set_show_menu_on_left_click command without any pre-configured scope.","commands":{"allow":[],"deny":["set_show_menu_on_left_click"]}},"deny-set-temp-dir-path":{"identifier":"deny-set-temp-dir-path","description":"Denies the set_temp_dir_path command without any pre-configured scope.","commands":{"allow":[],"deny":["set_temp_dir_path"]}},"deny-set-title":{"identifier":"deny-set-title","description":"Denies the set_title command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title"]}},"deny-set-tooltip":{"identifier":"deny-set-tooltip","description":"Denies the set_tooltip command without any pre-configured scope.","commands":{"allow":[],"deny":["set_tooltip"]}},"deny-set-visible":{"identifier":"deny-set-visible","description":"Denies the set_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["set_visible"]}}},"permission_sets":{},"global_scope_schema":null},"core:webview":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-get-all-webviews","allow-webview-position","allow-webview-size","allow-internal-toggle-devtools"]},"permissions":{"allow-clear-all-browsing-data":{"identifier":"allow-clear-all-browsing-data","description":"Enables the clear_all_browsing_data command without any pre-configured scope.","commands":{"allow":["clear_all_browsing_data"],"deny":[]}},"allow-create-webview":{"identifier":"allow-create-webview","description":"Enables the create_webview command without any pre-configured scope.","commands":{"allow":["create_webview"],"deny":[]}},"allow-create-webview-window":{"identifier":"allow-create-webview-window","description":"Enables the create_webview_window command without any pre-configured scope.","commands":{"allow":["create_webview_window"],"deny":[]}},"allow-get-all-webviews":{"identifier":"allow-get-all-webviews","description":"Enables the get_all_webviews command without any pre-configured scope.","commands":{"allow":["get_all_webviews"],"deny":[]}},"allow-internal-toggle-devtools":{"identifier":"allow-internal-toggle-devtools","description":"Enables the internal_toggle_devtools command without any pre-configured scope.","commands":{"allow":["internal_toggle_devtools"],"deny":[]}},"allow-print":{"identifier":"allow-print","description":"Enables the print command without any pre-configured scope.","commands":{"allow":["print"],"deny":[]}},"allow-reparent":{"identifier":"allow-reparent","description":"Enables the reparent command without any pre-configured scope.","commands":{"allow":["reparent"],"deny":[]}},"allow-set-webview-auto-resize":{"identifier":"allow-set-webview-auto-resize","description":"Enables the set_webview_auto_resize command without any pre-configured scope.","commands":{"allow":["set_webview_auto_resize"],"deny":[]}},"allow-set-webview-background-color":{"identifier":"allow-set-webview-background-color","description":"Enables the set_webview_background_color command without any pre-configured scope.","commands":{"allow":["set_webview_background_color"],"deny":[]}},"allow-set-webview-focus":{"identifier":"allow-set-webview-focus","description":"Enables the set_webview_focus command without any pre-configured scope.","commands":{"allow":["set_webview_focus"],"deny":[]}},"allow-set-webview-position":{"identifier":"allow-set-webview-position","description":"Enables the set_webview_position command without any pre-configured scope.","commands":{"allow":["set_webview_position"],"deny":[]}},"allow-set-webview-size":{"identifier":"allow-set-webview-size","description":"Enables the set_webview_size command without any pre-configured scope.","commands":{"allow":["set_webview_size"],"deny":[]}},"allow-set-webview-zoom":{"identifier":"allow-set-webview-zoom","description":"Enables the set_webview_zoom command without any pre-configured scope.","commands":{"allow":["set_webview_zoom"],"deny":[]}},"allow-webview-close":{"identifier":"allow-webview-close","description":"Enables the webview_close command without any pre-configured scope.","commands":{"allow":["webview_close"],"deny":[]}},"allow-webview-hide":{"identifier":"allow-webview-hide","description":"Enables the webview_hide command without any pre-configured scope.","commands":{"allow":["webview_hide"],"deny":[]}},"allow-webview-position":{"identifier":"allow-webview-position","description":"Enables the webview_position command without any pre-configured scope.","commands":{"allow":["webview_position"],"deny":[]}},"allow-webview-show":{"identifier":"allow-webview-show","description":"Enables the webview_show command without any pre-configured scope.","commands":{"allow":["webview_show"],"deny":[]}},"allow-webview-size":{"identifier":"allow-webview-size","description":"Enables the webview_size command without any pre-configured scope.","commands":{"allow":["webview_size"],"deny":[]}},"deny-clear-all-browsing-data":{"identifier":"deny-clear-all-browsing-data","description":"Denies the clear_all_browsing_data command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_all_browsing_data"]}},"deny-create-webview":{"identifier":"deny-create-webview","description":"Denies the create_webview command without any pre-configured scope.","commands":{"allow":[],"deny":["create_webview"]}},"deny-create-webview-window":{"identifier":"deny-create-webview-window","description":"Denies the create_webview_window command without any pre-configured scope.","commands":{"allow":[],"deny":["create_webview_window"]}},"deny-get-all-webviews":{"identifier":"deny-get-all-webviews","description":"Denies the get_all_webviews command without any pre-configured scope.","commands":{"allow":[],"deny":["get_all_webviews"]}},"deny-internal-toggle-devtools":{"identifier":"deny-internal-toggle-devtools","description":"Denies the internal_toggle_devtools command without any pre-configured scope.","commands":{"allow":[],"deny":["internal_toggle_devtools"]}},"deny-print":{"identifier":"deny-print","description":"Denies the print command without any pre-configured scope.","commands":{"allow":[],"deny":["print"]}},"deny-reparent":{"identifier":"deny-reparent","description":"Denies the reparent command without any pre-configured scope.","commands":{"allow":[],"deny":["reparent"]}},"deny-set-webview-auto-resize":{"identifier":"deny-set-webview-auto-resize","description":"Denies the set_webview_auto_resize command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_auto_resize"]}},"deny-set-webview-background-color":{"identifier":"deny-set-webview-background-color","description":"Denies the set_webview_background_color command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_background_color"]}},"deny-set-webview-focus":{"identifier":"deny-set-webview-focus","description":"Denies the set_webview_focus command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_focus"]}},"deny-set-webview-position":{"identifier":"deny-set-webview-position","description":"Denies the set_webview_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_position"]}},"deny-set-webview-size":{"identifier":"deny-set-webview-size","description":"Denies the set_webview_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_size"]}},"deny-set-webview-zoom":{"identifier":"deny-set-webview-zoom","description":"Denies the set_webview_zoom command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_zoom"]}},"deny-webview-close":{"identifier":"deny-webview-close","description":"Denies the webview_close command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_close"]}},"deny-webview-hide":{"identifier":"deny-webview-hide","description":"Denies the webview_hide command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_hide"]}},"deny-webview-position":{"identifier":"deny-webview-position","description":"Denies the webview_position command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_position"]}},"deny-webview-show":{"identifier":"deny-webview-show","description":"Denies the webview_show command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_show"]}},"deny-webview-size":{"identifier":"deny-webview-size","description":"Denies the webview_size command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_size"]}}},"permission_sets":{},"global_scope_schema":null},"core:window":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-get-all-windows","allow-scale-factor","allow-inner-position","allow-outer-position","allow-inner-size","allow-outer-size","allow-is-fullscreen","allow-is-minimized","allow-is-maximized","allow-is-focused","allow-is-decorated","allow-is-resizable","allow-is-maximizable","allow-is-minimizable","allow-is-closable","allow-is-visible","allow-is-enabled","allow-title","allow-current-monitor","allow-primary-monitor","allow-monitor-from-point","allow-available-monitors","allow-cursor-position","allow-theme","allow-is-always-on-top","allow-activity-name","allow-scene-identifier","allow-internal-toggle-maximize"]},"permissions":{"allow-activity-name":{"identifier":"allow-activity-name","description":"Enables the activity_name command without any pre-configured scope.","commands":{"allow":["activity_name"],"deny":[]}},"allow-available-monitors":{"identifier":"allow-available-monitors","description":"Enables the available_monitors command without any pre-configured scope.","commands":{"allow":["available_monitors"],"deny":[]}},"allow-center":{"identifier":"allow-center","description":"Enables the center command without any pre-configured scope.","commands":{"allow":["center"],"deny":[]}},"allow-close":{"identifier":"allow-close","description":"Enables the close command without any pre-configured scope.","commands":{"allow":["close"],"deny":[]}},"allow-create":{"identifier":"allow-create","description":"Enables the create command without any pre-configured scope.","commands":{"allow":["create"],"deny":[]}},"allow-current-monitor":{"identifier":"allow-current-monitor","description":"Enables the current_monitor command without any pre-configured scope.","commands":{"allow":["current_monitor"],"deny":[]}},"allow-cursor-position":{"identifier":"allow-cursor-position","description":"Enables the cursor_position command without any pre-configured scope.","commands":{"allow":["cursor_position"],"deny":[]}},"allow-destroy":{"identifier":"allow-destroy","description":"Enables the destroy command without any pre-configured scope.","commands":{"allow":["destroy"],"deny":[]}},"allow-get-all-windows":{"identifier":"allow-get-all-windows","description":"Enables the get_all_windows command without any pre-configured scope.","commands":{"allow":["get_all_windows"],"deny":[]}},"allow-hide":{"identifier":"allow-hide","description":"Enables the hide command without any pre-configured scope.","commands":{"allow":["hide"],"deny":[]}},"allow-inner-position":{"identifier":"allow-inner-position","description":"Enables the inner_position command without any pre-configured scope.","commands":{"allow":["inner_position"],"deny":[]}},"allow-inner-size":{"identifier":"allow-inner-size","description":"Enables the inner_size command without any pre-configured scope.","commands":{"allow":["inner_size"],"deny":[]}},"allow-internal-toggle-maximize":{"identifier":"allow-internal-toggle-maximize","description":"Enables the internal_toggle_maximize command without any pre-configured scope.","commands":{"allow":["internal_toggle_maximize"],"deny":[]}},"allow-is-always-on-top":{"identifier":"allow-is-always-on-top","description":"Enables the is_always_on_top command without any pre-configured scope.","commands":{"allow":["is_always_on_top"],"deny":[]}},"allow-is-closable":{"identifier":"allow-is-closable","description":"Enables the is_closable command without any pre-configured scope.","commands":{"allow":["is_closable"],"deny":[]}},"allow-is-decorated":{"identifier":"allow-is-decorated","description":"Enables the is_decorated command without any pre-configured scope.","commands":{"allow":["is_decorated"],"deny":[]}},"allow-is-enabled":{"identifier":"allow-is-enabled","description":"Enables the is_enabled command without any pre-configured scope.","commands":{"allow":["is_enabled"],"deny":[]}},"allow-is-focused":{"identifier":"allow-is-focused","description":"Enables the is_focused command without any pre-configured scope.","commands":{"allow":["is_focused"],"deny":[]}},"allow-is-fullscreen":{"identifier":"allow-is-fullscreen","description":"Enables the is_fullscreen command without any pre-configured scope.","commands":{"allow":["is_fullscreen"],"deny":[]}},"allow-is-maximizable":{"identifier":"allow-is-maximizable","description":"Enables the is_maximizable command without any pre-configured scope.","commands":{"allow":["is_maximizable"],"deny":[]}},"allow-is-maximized":{"identifier":"allow-is-maximized","description":"Enables the is_maximized command without any pre-configured scope.","commands":{"allow":["is_maximized"],"deny":[]}},"allow-is-minimizable":{"identifier":"allow-is-minimizable","description":"Enables the is_minimizable command without any pre-configured scope.","commands":{"allow":["is_minimizable"],"deny":[]}},"allow-is-minimized":{"identifier":"allow-is-minimized","description":"Enables the is_minimized command without any pre-configured scope.","commands":{"allow":["is_minimized"],"deny":[]}},"allow-is-resizable":{"identifier":"allow-is-resizable","description":"Enables the is_resizable command without any pre-configured scope.","commands":{"allow":["is_resizable"],"deny":[]}},"allow-is-visible":{"identifier":"allow-is-visible","description":"Enables the is_visible command without any pre-configured scope.","commands":{"allow":["is_visible"],"deny":[]}},"allow-maximize":{"identifier":"allow-maximize","description":"Enables the maximize command without any pre-configured scope.","commands":{"allow":["maximize"],"deny":[]}},"allow-minimize":{"identifier":"allow-minimize","description":"Enables the minimize command without any pre-configured scope.","commands":{"allow":["minimize"],"deny":[]}},"allow-monitor-from-point":{"identifier":"allow-monitor-from-point","description":"Enables the monitor_from_point command without any pre-configured scope.","commands":{"allow":["monitor_from_point"],"deny":[]}},"allow-outer-position":{"identifier":"allow-outer-position","description":"Enables the outer_position command without any pre-configured scope.","commands":{"allow":["outer_position"],"deny":[]}},"allow-outer-size":{"identifier":"allow-outer-size","description":"Enables the outer_size command without any pre-configured scope.","commands":{"allow":["outer_size"],"deny":[]}},"allow-primary-monitor":{"identifier":"allow-primary-monitor","description":"Enables the primary_monitor command without any pre-configured scope.","commands":{"allow":["primary_monitor"],"deny":[]}},"allow-request-user-attention":{"identifier":"allow-request-user-attention","description":"Enables the request_user_attention command without any pre-configured scope.","commands":{"allow":["request_user_attention"],"deny":[]}},"allow-scale-factor":{"identifier":"allow-scale-factor","description":"Enables the scale_factor command without any pre-configured scope.","commands":{"allow":["scale_factor"],"deny":[]}},"allow-scene-identifier":{"identifier":"allow-scene-identifier","description":"Enables the scene_identifier command without any pre-configured scope.","commands":{"allow":["scene_identifier"],"deny":[]}},"allow-set-always-on-bottom":{"identifier":"allow-set-always-on-bottom","description":"Enables the set_always_on_bottom command without any pre-configured scope.","commands":{"allow":["set_always_on_bottom"],"deny":[]}},"allow-set-always-on-top":{"identifier":"allow-set-always-on-top","description":"Enables the set_always_on_top command without any pre-configured scope.","commands":{"allow":["set_always_on_top"],"deny":[]}},"allow-set-background-color":{"identifier":"allow-set-background-color","description":"Enables the set_background_color command without any pre-configured scope.","commands":{"allow":["set_background_color"],"deny":[]}},"allow-set-badge-count":{"identifier":"allow-set-badge-count","description":"Enables the set_badge_count command without any pre-configured scope.","commands":{"allow":["set_badge_count"],"deny":[]}},"allow-set-badge-label":{"identifier":"allow-set-badge-label","description":"Enables the set_badge_label command without any pre-configured scope.","commands":{"allow":["set_badge_label"],"deny":[]}},"allow-set-closable":{"identifier":"allow-set-closable","description":"Enables the set_closable command without any pre-configured scope.","commands":{"allow":["set_closable"],"deny":[]}},"allow-set-content-protected":{"identifier":"allow-set-content-protected","description":"Enables the set_content_protected command without any pre-configured scope.","commands":{"allow":["set_content_protected"],"deny":[]}},"allow-set-cursor-grab":{"identifier":"allow-set-cursor-grab","description":"Enables the set_cursor_grab command without any pre-configured scope.","commands":{"allow":["set_cursor_grab"],"deny":[]}},"allow-set-cursor-icon":{"identifier":"allow-set-cursor-icon","description":"Enables the set_cursor_icon command without any pre-configured scope.","commands":{"allow":["set_cursor_icon"],"deny":[]}},"allow-set-cursor-position":{"identifier":"allow-set-cursor-position","description":"Enables the set_cursor_position command without any pre-configured scope.","commands":{"allow":["set_cursor_position"],"deny":[]}},"allow-set-cursor-visible":{"identifier":"allow-set-cursor-visible","description":"Enables the set_cursor_visible command without any pre-configured scope.","commands":{"allow":["set_cursor_visible"],"deny":[]}},"allow-set-decorations":{"identifier":"allow-set-decorations","description":"Enables the set_decorations command without any pre-configured scope.","commands":{"allow":["set_decorations"],"deny":[]}},"allow-set-effects":{"identifier":"allow-set-effects","description":"Enables the set_effects command without any pre-configured scope.","commands":{"allow":["set_effects"],"deny":[]}},"allow-set-enabled":{"identifier":"allow-set-enabled","description":"Enables the set_enabled command without any pre-configured scope.","commands":{"allow":["set_enabled"],"deny":[]}},"allow-set-focus":{"identifier":"allow-set-focus","description":"Enables the set_focus command without any pre-configured scope.","commands":{"allow":["set_focus"],"deny":[]}},"allow-set-focusable":{"identifier":"allow-set-focusable","description":"Enables the set_focusable command without any pre-configured scope.","commands":{"allow":["set_focusable"],"deny":[]}},"allow-set-fullscreen":{"identifier":"allow-set-fullscreen","description":"Enables the set_fullscreen command without any pre-configured scope.","commands":{"allow":["set_fullscreen"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-ignore-cursor-events":{"identifier":"allow-set-ignore-cursor-events","description":"Enables the set_ignore_cursor_events command without any pre-configured scope.","commands":{"allow":["set_ignore_cursor_events"],"deny":[]}},"allow-set-max-size":{"identifier":"allow-set-max-size","description":"Enables the set_max_size command without any pre-configured scope.","commands":{"allow":["set_max_size"],"deny":[]}},"allow-set-maximizable":{"identifier":"allow-set-maximizable","description":"Enables the set_maximizable command without any pre-configured scope.","commands":{"allow":["set_maximizable"],"deny":[]}},"allow-set-min-size":{"identifier":"allow-set-min-size","description":"Enables the set_min_size command without any pre-configured scope.","commands":{"allow":["set_min_size"],"deny":[]}},"allow-set-minimizable":{"identifier":"allow-set-minimizable","description":"Enables the set_minimizable command without any pre-configured scope.","commands":{"allow":["set_minimizable"],"deny":[]}},"allow-set-overlay-icon":{"identifier":"allow-set-overlay-icon","description":"Enables the set_overlay_icon command without any pre-configured scope.","commands":{"allow":["set_overlay_icon"],"deny":[]}},"allow-set-position":{"identifier":"allow-set-position","description":"Enables the set_position command without any pre-configured scope.","commands":{"allow":["set_position"],"deny":[]}},"allow-set-progress-bar":{"identifier":"allow-set-progress-bar","description":"Enables the set_progress_bar command without any pre-configured scope.","commands":{"allow":["set_progress_bar"],"deny":[]}},"allow-set-resizable":{"identifier":"allow-set-resizable","description":"Enables the set_resizable command without any pre-configured scope.","commands":{"allow":["set_resizable"],"deny":[]}},"allow-set-shadow":{"identifier":"allow-set-shadow","description":"Enables the set_shadow command without any pre-configured scope.","commands":{"allow":["set_shadow"],"deny":[]}},"allow-set-simple-fullscreen":{"identifier":"allow-set-simple-fullscreen","description":"Enables the set_simple_fullscreen command without any pre-configured scope.","commands":{"allow":["set_simple_fullscreen"],"deny":[]}},"allow-set-size":{"identifier":"allow-set-size","description":"Enables the set_size command without any pre-configured scope.","commands":{"allow":["set_size"],"deny":[]}},"allow-set-size-constraints":{"identifier":"allow-set-size-constraints","description":"Enables the set_size_constraints command without any pre-configured scope.","commands":{"allow":["set_size_constraints"],"deny":[]}},"allow-set-skip-taskbar":{"identifier":"allow-set-skip-taskbar","description":"Enables the set_skip_taskbar command without any pre-configured scope.","commands":{"allow":["set_skip_taskbar"],"deny":[]}},"allow-set-theme":{"identifier":"allow-set-theme","description":"Enables the set_theme command without any pre-configured scope.","commands":{"allow":["set_theme"],"deny":[]}},"allow-set-title":{"identifier":"allow-set-title","description":"Enables the set_title command without any pre-configured scope.","commands":{"allow":["set_title"],"deny":[]}},"allow-set-title-bar-style":{"identifier":"allow-set-title-bar-style","description":"Enables the set_title_bar_style command without any pre-configured scope.","commands":{"allow":["set_title_bar_style"],"deny":[]}},"allow-set-visible-on-all-workspaces":{"identifier":"allow-set-visible-on-all-workspaces","description":"Enables the set_visible_on_all_workspaces command without any pre-configured scope.","commands":{"allow":["set_visible_on_all_workspaces"],"deny":[]}},"allow-show":{"identifier":"allow-show","description":"Enables the show command without any pre-configured scope.","commands":{"allow":["show"],"deny":[]}},"allow-start-dragging":{"identifier":"allow-start-dragging","description":"Enables the start_dragging command without any pre-configured scope.","commands":{"allow":["start_dragging"],"deny":[]}},"allow-start-resize-dragging":{"identifier":"allow-start-resize-dragging","description":"Enables the start_resize_dragging command without any pre-configured scope.","commands":{"allow":["start_resize_dragging"],"deny":[]}},"allow-theme":{"identifier":"allow-theme","description":"Enables the theme command without any pre-configured scope.","commands":{"allow":["theme"],"deny":[]}},"allow-title":{"identifier":"allow-title","description":"Enables the title command without any pre-configured scope.","commands":{"allow":["title"],"deny":[]}},"allow-toggle-maximize":{"identifier":"allow-toggle-maximize","description":"Enables the toggle_maximize command without any pre-configured scope.","commands":{"allow":["toggle_maximize"],"deny":[]}},"allow-unmaximize":{"identifier":"allow-unmaximize","description":"Enables the unmaximize command without any pre-configured scope.","commands":{"allow":["unmaximize"],"deny":[]}},"allow-unminimize":{"identifier":"allow-unminimize","description":"Enables the unminimize command without any pre-configured scope.","commands":{"allow":["unminimize"],"deny":[]}},"deny-activity-name":{"identifier":"deny-activity-name","description":"Denies the activity_name command without any pre-configured scope.","commands":{"allow":[],"deny":["activity_name"]}},"deny-available-monitors":{"identifier":"deny-available-monitors","description":"Denies the available_monitors command without any pre-configured scope.","commands":{"allow":[],"deny":["available_monitors"]}},"deny-center":{"identifier":"deny-center","description":"Denies the center command without any pre-configured scope.","commands":{"allow":[],"deny":["center"]}},"deny-close":{"identifier":"deny-close","description":"Denies the close command without any pre-configured scope.","commands":{"allow":[],"deny":["close"]}},"deny-create":{"identifier":"deny-create","description":"Denies the create command without any pre-configured scope.","commands":{"allow":[],"deny":["create"]}},"deny-current-monitor":{"identifier":"deny-current-monitor","description":"Denies the current_monitor command without any pre-configured scope.","commands":{"allow":[],"deny":["current_monitor"]}},"deny-cursor-position":{"identifier":"deny-cursor-position","description":"Denies the cursor_position command without any pre-configured scope.","commands":{"allow":[],"deny":["cursor_position"]}},"deny-destroy":{"identifier":"deny-destroy","description":"Denies the destroy command without any pre-configured scope.","commands":{"allow":[],"deny":["destroy"]}},"deny-get-all-windows":{"identifier":"deny-get-all-windows","description":"Denies the get_all_windows command without any pre-configured scope.","commands":{"allow":[],"deny":["get_all_windows"]}},"deny-hide":{"identifier":"deny-hide","description":"Denies the hide command without any pre-configured scope.","commands":{"allow":[],"deny":["hide"]}},"deny-inner-position":{"identifier":"deny-inner-position","description":"Denies the inner_position command without any pre-configured scope.","commands":{"allow":[],"deny":["inner_position"]}},"deny-inner-size":{"identifier":"deny-inner-size","description":"Denies the inner_size command without any pre-configured scope.","commands":{"allow":[],"deny":["inner_size"]}},"deny-internal-toggle-maximize":{"identifier":"deny-internal-toggle-maximize","description":"Denies the internal_toggle_maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["internal_toggle_maximize"]}},"deny-is-always-on-top":{"identifier":"deny-is-always-on-top","description":"Denies the is_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["is_always_on_top"]}},"deny-is-closable":{"identifier":"deny-is-closable","description":"Denies the is_closable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_closable"]}},"deny-is-decorated":{"identifier":"deny-is-decorated","description":"Denies the is_decorated command without any pre-configured scope.","commands":{"allow":[],"deny":["is_decorated"]}},"deny-is-enabled":{"identifier":"deny-is-enabled","description":"Denies the is_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["is_enabled"]}},"deny-is-focused":{"identifier":"deny-is-focused","description":"Denies the is_focused command without any pre-configured scope.","commands":{"allow":[],"deny":["is_focused"]}},"deny-is-fullscreen":{"identifier":"deny-is-fullscreen","description":"Denies the is_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["is_fullscreen"]}},"deny-is-maximizable":{"identifier":"deny-is-maximizable","description":"Denies the is_maximizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_maximizable"]}},"deny-is-maximized":{"identifier":"deny-is-maximized","description":"Denies the is_maximized command without any pre-configured scope.","commands":{"allow":[],"deny":["is_maximized"]}},"deny-is-minimizable":{"identifier":"deny-is-minimizable","description":"Denies the is_minimizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_minimizable"]}},"deny-is-minimized":{"identifier":"deny-is-minimized","description":"Denies the is_minimized command without any pre-configured scope.","commands":{"allow":[],"deny":["is_minimized"]}},"deny-is-resizable":{"identifier":"deny-is-resizable","description":"Denies the is_resizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_resizable"]}},"deny-is-visible":{"identifier":"deny-is-visible","description":"Denies the is_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["is_visible"]}},"deny-maximize":{"identifier":"deny-maximize","description":"Denies the maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["maximize"]}},"deny-minimize":{"identifier":"deny-minimize","description":"Denies the minimize command without any pre-configured scope.","commands":{"allow":[],"deny":["minimize"]}},"deny-monitor-from-point":{"identifier":"deny-monitor-from-point","description":"Denies the monitor_from_point command without any pre-configured scope.","commands":{"allow":[],"deny":["monitor_from_point"]}},"deny-outer-position":{"identifier":"deny-outer-position","description":"Denies the outer_position command without any pre-configured scope.","commands":{"allow":[],"deny":["outer_position"]}},"deny-outer-size":{"identifier":"deny-outer-size","description":"Denies the outer_size command without any pre-configured scope.","commands":{"allow":[],"deny":["outer_size"]}},"deny-primary-monitor":{"identifier":"deny-primary-monitor","description":"Denies the primary_monitor command without any pre-configured scope.","commands":{"allow":[],"deny":["primary_monitor"]}},"deny-request-user-attention":{"identifier":"deny-request-user-attention","description":"Denies the request_user_attention command without any pre-configured scope.","commands":{"allow":[],"deny":["request_user_attention"]}},"deny-scale-factor":{"identifier":"deny-scale-factor","description":"Denies the scale_factor command without any pre-configured scope.","commands":{"allow":[],"deny":["scale_factor"]}},"deny-scene-identifier":{"identifier":"deny-scene-identifier","description":"Denies the scene_identifier command without any pre-configured scope.","commands":{"allow":[],"deny":["scene_identifier"]}},"deny-set-always-on-bottom":{"identifier":"deny-set-always-on-bottom","description":"Denies the set_always_on_bottom command without any pre-configured scope.","commands":{"allow":[],"deny":["set_always_on_bottom"]}},"deny-set-always-on-top":{"identifier":"deny-set-always-on-top","description":"Denies the set_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["set_always_on_top"]}},"deny-set-background-color":{"identifier":"deny-set-background-color","description":"Denies the set_background_color command without any pre-configured scope.","commands":{"allow":[],"deny":["set_background_color"]}},"deny-set-badge-count":{"identifier":"deny-set-badge-count","description":"Denies the set_badge_count command without any pre-configured scope.","commands":{"allow":[],"deny":["set_badge_count"]}},"deny-set-badge-label":{"identifier":"deny-set-badge-label","description":"Denies the set_badge_label command without any pre-configured scope.","commands":{"allow":[],"deny":["set_badge_label"]}},"deny-set-closable":{"identifier":"deny-set-closable","description":"Denies the set_closable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_closable"]}},"deny-set-content-protected":{"identifier":"deny-set-content-protected","description":"Denies the set_content_protected command without any pre-configured scope.","commands":{"allow":[],"deny":["set_content_protected"]}},"deny-set-cursor-grab":{"identifier":"deny-set-cursor-grab","description":"Denies the set_cursor_grab command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_grab"]}},"deny-set-cursor-icon":{"identifier":"deny-set-cursor-icon","description":"Denies the set_cursor_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_icon"]}},"deny-set-cursor-position":{"identifier":"deny-set-cursor-position","description":"Denies the set_cursor_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_position"]}},"deny-set-cursor-visible":{"identifier":"deny-set-cursor-visible","description":"Denies the set_cursor_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_visible"]}},"deny-set-decorations":{"identifier":"deny-set-decorations","description":"Denies the set_decorations command without any pre-configured scope.","commands":{"allow":[],"deny":["set_decorations"]}},"deny-set-effects":{"identifier":"deny-set-effects","description":"Denies the set_effects command without any pre-configured scope.","commands":{"allow":[],"deny":["set_effects"]}},"deny-set-enabled":{"identifier":"deny-set-enabled","description":"Denies the set_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_enabled"]}},"deny-set-focus":{"identifier":"deny-set-focus","description":"Denies the set_focus command without any pre-configured scope.","commands":{"allow":[],"deny":["set_focus"]}},"deny-set-focusable":{"identifier":"deny-set-focusable","description":"Denies the set_focusable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_focusable"]}},"deny-set-fullscreen":{"identifier":"deny-set-fullscreen","description":"Denies the set_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["set_fullscreen"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-ignore-cursor-events":{"identifier":"deny-set-ignore-cursor-events","description":"Denies the set_ignore_cursor_events command without any pre-configured scope.","commands":{"allow":[],"deny":["set_ignore_cursor_events"]}},"deny-set-max-size":{"identifier":"deny-set-max-size","description":"Denies the set_max_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_max_size"]}},"deny-set-maximizable":{"identifier":"deny-set-maximizable","description":"Denies the set_maximizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_maximizable"]}},"deny-set-min-size":{"identifier":"deny-set-min-size","description":"Denies the set_min_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_min_size"]}},"deny-set-minimizable":{"identifier":"deny-set-minimizable","description":"Denies the set_minimizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_minimizable"]}},"deny-set-overlay-icon":{"identifier":"deny-set-overlay-icon","description":"Denies the set_overlay_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_overlay_icon"]}},"deny-set-position":{"identifier":"deny-set-position","description":"Denies the set_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_position"]}},"deny-set-progress-bar":{"identifier":"deny-set-progress-bar","description":"Denies the set_progress_bar command without any pre-configured scope.","commands":{"allow":[],"deny":["set_progress_bar"]}},"deny-set-resizable":{"identifier":"deny-set-resizable","description":"Denies the set_resizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_resizable"]}},"deny-set-shadow":{"identifier":"deny-set-shadow","description":"Denies the set_shadow command without any pre-configured scope.","commands":{"allow":[],"deny":["set_shadow"]}},"deny-set-simple-fullscreen":{"identifier":"deny-set-simple-fullscreen","description":"Denies the set_simple_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["set_simple_fullscreen"]}},"deny-set-size":{"identifier":"deny-set-size","description":"Denies the set_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_size"]}},"deny-set-size-constraints":{"identifier":"deny-set-size-constraints","description":"Denies the set_size_constraints command without any pre-configured scope.","commands":{"allow":[],"deny":["set_size_constraints"]}},"deny-set-skip-taskbar":{"identifier":"deny-set-skip-taskbar","description":"Denies the set_skip_taskbar command without any pre-configured scope.","commands":{"allow":[],"deny":["set_skip_taskbar"]}},"deny-set-theme":{"identifier":"deny-set-theme","description":"Denies the set_theme command without any pre-configured scope.","commands":{"allow":[],"deny":["set_theme"]}},"deny-set-title":{"identifier":"deny-set-title","description":"Denies the set_title command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title"]}},"deny-set-title-bar-style":{"identifier":"deny-set-title-bar-style","description":"Denies the set_title_bar_style command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title_bar_style"]}},"deny-set-visible-on-all-workspaces":{"identifier":"deny-set-visible-on-all-workspaces","description":"Denies the set_visible_on_all_workspaces command without any pre-configured scope.","commands":{"allow":[],"deny":["set_visible_on_all_workspaces"]}},"deny-show":{"identifier":"deny-show","description":"Denies the show command without any pre-configured scope.","commands":{"allow":[],"deny":["show"]}},"deny-start-dragging":{"identifier":"deny-start-dragging","description":"Denies the start_dragging command without any pre-configured scope.","commands":{"allow":[],"deny":["start_dragging"]}},"deny-start-resize-dragging":{"identifier":"deny-start-resize-dragging","description":"Denies the start_resize_dragging command without any pre-configured scope.","commands":{"allow":[],"deny":["start_resize_dragging"]}},"deny-theme":{"identifier":"deny-theme","description":"Denies the theme command without any pre-configured scope.","commands":{"allow":[],"deny":["theme"]}},"deny-title":{"identifier":"deny-title","description":"Denies the title command without any pre-configured scope.","commands":{"allow":[],"deny":["title"]}},"deny-toggle-maximize":{"identifier":"deny-toggle-maximize","description":"Denies the toggle_maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["toggle_maximize"]}},"deny-unmaximize":{"identifier":"deny-unmaximize","description":"Denies the unmaximize command without any pre-configured scope.","commands":{"allow":[],"deny":["unmaximize"]}},"deny-unminimize":{"identifier":"deny-unminimize","description":"Denies the unminimize command without any pre-configured scope.","commands":{"allow":[],"deny":["unminimize"]}}},"permission_sets":{},"global_scope_schema":null},"dialog":{"default_permission":{"identifier":"default","description":"This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n","permissions":["allow-message","allow-save","allow-open"]},"permissions":{"allow-ask":{"identifier":"allow-ask","description":"Enables the ask command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `allow-message` and will be removed in v3)","commands":{"allow":["message"],"deny":[]}},"allow-confirm":{"identifier":"allow-confirm","description":"Enables the confirm command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `allow-message` and will be removed in v3)","commands":{"allow":["message"],"deny":[]}},"allow-message":{"identifier":"allow-message","description":"Enables the message command without any pre-configured scope.","commands":{"allow":["message"],"deny":[]}},"allow-open":{"identifier":"allow-open","description":"Enables the open command without any pre-configured scope.","commands":{"allow":["open"],"deny":[]}},"allow-save":{"identifier":"allow-save","description":"Enables the save command without any pre-configured scope.","commands":{"allow":["save"],"deny":[]}},"deny-ask":{"identifier":"deny-ask","description":"Denies the ask command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `deny-message` and will be removed in v3)","commands":{"allow":[],"deny":["message"]}},"deny-confirm":{"identifier":"deny-confirm","description":"Denies the confirm command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `deny-message` and will be removed in v3)","commands":{"allow":[],"deny":["message"]}},"deny-message":{"identifier":"deny-message","description":"Denies the message command without any pre-configured scope.","commands":{"allow":[],"deny":["message"]}},"deny-open":{"identifier":"deny-open","description":"Denies the open command without any pre-configured scope.","commands":{"allow":[],"deny":["open"]}},"deny-save":{"identifier":"deny-save","description":"Denies the save command without any pre-configured scope.","commands":{"allow":[],"deny":["save"]}}},"permission_sets":{},"global_scope_schema":null},"opener":{"default_permission":{"identifier":"default","description":"This permission set allows opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application\nas well as reveal file in directories using default file explorer","permissions":["allow-open-url","allow-reveal-item-in-dir","allow-default-urls"]},"permissions":{"allow-default-urls":{"identifier":"allow-default-urls","description":"This enables opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application.","commands":{"allow":[],"deny":[]},"scope":{"allow":[{"url":"mailto:*"},{"url":"tel:*"},{"url":"http://*"},{"url":"https://*"}]}},"allow-open-path":{"identifier":"allow-open-path","description":"Enables the open_path command without any pre-configured scope.","commands":{"allow":["open_path"],"deny":[]}},"allow-open-url":{"identifier":"allow-open-url","description":"Enables the open_url command without any pre-configured scope.","commands":{"allow":["open_url"],"deny":[]}},"allow-reveal-item-in-dir":{"identifier":"allow-reveal-item-in-dir","description":"Enables the reveal_item_in_dir command without any pre-configured scope.","commands":{"allow":["reveal_item_in_dir"],"deny":[]}},"deny-open-path":{"identifier":"deny-open-path","description":"Denies the open_path command without any pre-configured scope.","commands":{"allow":[],"deny":["open_path"]}},"deny-open-url":{"identifier":"deny-open-url","description":"Denies the open_url command without any pre-configured scope.","commands":{"allow":[],"deny":["open_url"]}},"deny-reveal-item-in-dir":{"identifier":"deny-reveal-item-in-dir","description":"Denies the reveal_item_in_dir command without any pre-configured scope.","commands":{"allow":[],"deny":["reveal_item_in_dir"]}}},"permission_sets":{},"global_scope_schema":{"$schema":"http://json-schema.org/draft-07/schema#","anyOf":[{"properties":{"app":{"allOf":[{"$ref":"#/definitions/Application"}],"description":"An application to open this url with, for example: firefox."},"url":{"description":"A URL that can be opened by the webview when using the Opener APIs.\n\nWildcards can be used following the UNIX glob pattern.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"","type":"string"}},"required":["url"],"type":"object"},{"properties":{"app":{"allOf":[{"$ref":"#/definitions/Application"}],"description":"An application to open this path with, for example: xdg-open."},"path":{"description":"A path that can be opened by the webview when using the Opener APIs.\n\nThe pattern can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.","type":"string"}},"required":["path"],"type":"object"}],"definitions":{"Application":{"anyOf":[{"description":"Open in default application.","type":"null"},{"description":"If true, allow open with any application.","type":"boolean"},{"description":"Allow specific application to open with.","type":"string"}],"description":"Opener scope application."}},"description":"Opener scope entry.","title":"OpenerScopeEntry"}}} \ No newline at end of file +{"__app-acl__":{"default_permission":null,"permissions":{"allow-acquire-claude-token":{"identifier":"allow-acquire-claude-token","description":"Enables the acquire_claude_token command without any pre-configured scope.","commands":{"allow":["acquire_claude_token"],"deny":[]}},"allow-add-aws-keys-connection":{"identifier":"allow-add-aws-keys-connection","description":"Enables the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":["add_aws_keys_connection"],"deny":[]}},"allow-add-aws-profile-connection":{"identifier":"allow-add-aws-profile-connection","description":"Enables the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":["add_aws_profile_connection"],"deny":[]}},"allow-add-marketplace":{"identifier":"allow-add-marketplace","description":"Enables the add_marketplace command without any pre-configured scope.","commands":{"allow":["add_marketplace"],"deny":[]}},"allow-add-marketplace-gh-host-account":{"identifier":"allow-add-marketplace-gh-host-account","description":"Enables the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_gh_host_account"],"deny":[]}},"allow-add-marketplace-token-account":{"identifier":"allow-add-marketplace-token-account","description":"Enables the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_token_account"],"deny":[]}},"allow-add-project":{"identifier":"allow-add-project","description":"Enables the add_project command without any pre-configured scope.","commands":{"allow":["add_project"],"deny":[]}},"allow-add-scheduled-task":{"identifier":"allow-add-scheduled-task","description":"Enables the add_scheduled_task command without any pre-configured scope.","commands":{"allow":["add_scheduled_task"],"deny":[]}},"allow-apply-marketplace-now":{"identifier":"allow-apply-marketplace-now","description":"Enables the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":["apply_marketplace_now"],"deny":[]}},"allow-apply-settings-import":{"identifier":"allow-apply-settings-import","description":"Enables the apply_settings_import command without any pre-configured scope.","commands":{"allow":["apply_settings_import"],"deny":[]}},"allow-aws-connection-identity":{"identifier":"allow-aws-connection-identity","description":"Enables the aws_connection_identity command without any pre-configured scope.","commands":{"allow":["aws_connection_identity"],"deny":[]}},"allow-aws-connection-sso-login":{"identifier":"allow-aws-connection-sso-login","description":"Enables the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":["aws_connection_sso_login"],"deny":[]}},"allow-aws-cost-estimate":{"identifier":"allow-aws-cost-estimate","description":"Enables the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":["aws_cost_estimate"],"deny":[]}},"allow-aws-environment-max-hours":{"identifier":"allow-aws-environment-max-hours","description":"Enables the aws_environment_max_hours command without any pre-configured scope.","commands":{"allow":["aws_environment_max_hours"],"deny":[]}},"allow-aws-policy-document":{"identifier":"allow-aws-policy-document","description":"Enables the aws_policy_document command without any pre-configured scope.","commands":{"allow":["aws_policy_document"],"deny":[]}},"allow-aws-sso-refresh":{"identifier":"allow-aws-sso-refresh","description":"Enables the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":["aws_sso_refresh"],"deny":[]}},"allow-aws-task-log":{"identifier":"allow-aws-task-log","description":"Enables the aws_task_log command without any pre-configured scope.","commands":{"allow":["aws_task_log"],"deny":[]}},"allow-aws-workspace-status":{"identifier":"allow-aws-workspace-status","description":"Enables the aws_workspace_status command without any pre-configured scope.","commands":{"allow":["aws_workspace_status"],"deny":[]}},"allow-build-gateway-image":{"identifier":"allow-build-gateway-image","description":"Enables the build_gateway_image command without any pre-configured scope.","commands":{"allow":["build_gateway_image"],"deny":[]}},"allow-build-image":{"identifier":"allow-build-image","description":"Enables the build_image command without any pre-configured scope.","commands":{"allow":["build_image"],"deny":[]}},"allow-build-stt-image":{"identifier":"allow-build-stt-image","description":"Enables the build_stt_image command without any pre-configured scope.","commands":{"allow":["build_stt_image"],"deny":[]}},"allow-cancel-aws-deployment":{"identifier":"allow-cancel-aws-deployment","description":"Enables the cancel_aws_deployment command without any pre-configured scope.","commands":{"allow":["cancel_aws_deployment"],"deny":[]}},"allow-cancel-claude-token":{"identifier":"allow-cancel-claude-token","description":"Enables the cancel_claude_token command without any pre-configured scope.","commands":{"allow":["cancel_claude_token"],"deny":[]}},"allow-cancel-marketplace-gh-login":{"identifier":"allow-cancel-marketplace-gh-login","description":"Enables the cancel_marketplace_gh_login command without any pre-configured scope.","commands":{"allow":["cancel_marketplace_gh_login"],"deny":[]}},"allow-check-aws-permissions":{"identifier":"allow-check-aws-permissions","description":"Enables the check_aws_permissions command without any pre-configured scope.","commands":{"allow":["check_aws_permissions"],"deny":[]}},"allow-check-browser-view-support":{"identifier":"allow-check-browser-view-support","description":"Enables the check_browser_view_support command without any pre-configured scope.","commands":{"allow":["check_browser_view_support"],"deny":[]}},"allow-check-docker":{"identifier":"allow-check-docker","description":"Enables the check_docker command without any pre-configured scope.","commands":{"allow":["check_docker"],"deny":[]}},"allow-check-for-updates":{"identifier":"allow-check-for-updates","description":"Enables the check_for_updates command without any pre-configured scope.","commands":{"allow":["check_for_updates"],"deny":[]}},"allow-check-gateway-health":{"identifier":"allow-check-gateway-health","description":"Enables the check_gateway_health command without any pre-configured scope.","commands":{"allow":["check_gateway_health"],"deny":[]}},"allow-check-image-exists":{"identifier":"allow-check-image-exists","description":"Enables the check_image_exists command without any pre-configured scope.","commands":{"allow":["check_image_exists"],"deny":[]}},"allow-check-image-update":{"identifier":"allow-check-image-update","description":"Enables the check_image_update command without any pre-configured scope.","commands":{"allow":["check_image_update"],"deny":[]}},"allow-check-unsaved-work":{"identifier":"allow-check-unsaved-work","description":"Enables the check_unsaved_work command without any pre-configured scope.","commands":{"allow":["check_unsaved_work"],"deny":[]}},"allow-clear-claude-token":{"identifier":"allow-clear-claude-token","description":"Enables the clear_claude_token command without any pre-configured scope.","commands":{"allow":["clear_claude_token"],"deny":[]}},"allow-clear-gateway-api-key":{"identifier":"allow-clear-gateway-api-key","description":"Enables the clear_gateway_api_key command without any pre-configured scope.","commands":{"allow":["clear_gateway_api_key"],"deny":[]}},"allow-clear-scheduler-notifications":{"identifier":"allow-clear-scheduler-notifications","description":"Enables the clear_scheduler_notifications command without any pre-configured scope.","commands":{"allow":["clear_scheduler_notifications"],"deny":[]}},"allow-close-browser-view-popout":{"identifier":"allow-close-browser-view-popout","description":"Enables the close_browser_view_popout command without any pre-configured scope.","commands":{"allow":["close_browser_view_popout"],"deny":[]}},"allow-close-container-page":{"identifier":"allow-close-container-page","description":"Enables the close_container_page command without any pre-configured scope.","commands":{"allow":["close_container_page"],"deny":[]}},"allow-close-terminal-session":{"identifier":"allow-close-terminal-session","description":"Enables the close_terminal_session command without any pre-configured scope.","commands":{"allow":["close_terminal_session"],"deny":[]}},"allow-confirm-migration":{"identifier":"allow-confirm-migration","description":"Enables the confirm_migration command without any pre-configured scope.","commands":{"allow":["confirm_migration"],"deny":[]}},"allow-create-container-directory":{"identifier":"allow-create-container-directory","description":"Enables the create_container_directory command without any pre-configured scope.","commands":{"allow":["create_container_directory"],"deny":[]}},"allow-delete-note":{"identifier":"allow-delete-note","description":"Enables the delete_note command without any pre-configured scope.","commands":{"allow":["delete_note"],"deny":[]}},"allow-deploy-aws-environment":{"identifier":"allow-deploy-aws-environment","description":"Enables the deploy_aws_environment command without any pre-configured scope.","commands":{"allow":["deploy_aws_environment"],"deny":[]}},"allow-deploy-aws-permissions-boundary":{"identifier":"allow-deploy-aws-permissions-boundary","description":"Enables the deploy_aws_permissions_boundary command without any pre-configured scope.","commands":{"allow":["deploy_aws_permissions_boundary"],"deny":[]}},"allow-destroy-incomplete-aws-environment":{"identifier":"allow-destroy-incomplete-aws-environment","description":"Enables the destroy_incomplete_aws_environment command without any pre-configured scope.","commands":{"allow":["destroy_incomplete_aws_environment"],"deny":[]}},"allow-detect-aws-config":{"identifier":"allow-detect-aws-config","description":"Enables the detect_aws_config command without any pre-configured scope.","commands":{"allow":["detect_aws_config"],"deny":[]}},"allow-detect-aws-environments":{"identifier":"allow-detect-aws-environments","description":"Enables the detect_aws_environments command without any pre-configured scope.","commands":{"allow":["detect_aws_environments"],"deny":[]}},"allow-detect-host-timezone":{"identifier":"allow-detect-host-timezone","description":"Enables the detect_host_timezone command without any pre-configured scope.","commands":{"allow":["detect_host_timezone"],"deny":[]}},"allow-detect-install-options":{"identifier":"allow-detect-install-options","description":"Enables the detect_install_options command without any pre-configured scope.","commands":{"allow":["detect_install_options"],"deny":[]}},"allow-download-container-backup":{"identifier":"allow-download-container-backup","description":"Enables the download_container_backup command without any pre-configured scope.","commands":{"allow":["download_container_backup"],"deny":[]}},"allow-download-container-file":{"identifier":"allow-download-container-file","description":"Enables the download_container_file command without any pre-configured scope.","commands":{"allow":["download_container_file"],"deny":[]}},"allow-export-settings":{"identifier":"allow-export-settings","description":"Enables the export_settings command without any pre-configured scope.","commands":{"allow":["export_settings"],"deny":[]}},"allow-follow-aws-deployment":{"identifier":"allow-follow-aws-deployment","description":"Enables the follow_aws_deployment command without any pre-configured scope.","commands":{"allow":["follow_aws_deployment"],"deny":[]}},"allow-forget-marketplace-installs":{"identifier":"allow-forget-marketplace-installs","description":"Enables the forget_marketplace_installs command without any pre-configured scope.","commands":{"allow":["forget_marketplace_installs"],"deny":[]}},"allow-get-app-version":{"identifier":"allow-get-app-version","description":"Enables the get_app_version command without any pre-configured scope.","commands":{"allow":["get_app_version"],"deny":[]}},"allow-get-auth-bridge-status":{"identifier":"allow-get-auth-bridge-status","description":"Enables the get_auth_bridge_status command without any pre-configured scope.","commands":{"allow":["get_auth_bridge_status"],"deny":[]}},"allow-get-browser-view-match-window":{"identifier":"allow-get-browser-view-match-window","description":"Enables the get_browser_view_match_window command without any pre-configured scope.","commands":{"allow":["get_browser_view_match_window"],"deny":[]}},"allow-get-browser-view-popout-state":{"identifier":"allow-get-browser-view-popout-state","description":"Enables the get_browser_view_popout_state command without any pre-configured scope.","commands":{"allow":["get_browser_view_popout_state"],"deny":[]}},"allow-get-browser-view-status":{"identifier":"allow-get-browser-view-status","description":"Enables the get_browser_view_status command without any pre-configured scope.","commands":{"allow":["get_browser_view_status"],"deny":[]}},"allow-get-container-info":{"identifier":"allow-get-container-info","description":"Enables the get_container_info command without any pre-configured scope.","commands":{"allow":["get_container_info"],"deny":[]}},"allow-get-container-page-state":{"identifier":"allow-get-container-page-state","description":"Enables the get_container_page_state command without any pre-configured scope.","commands":{"allow":["get_container_page_state"],"deny":[]}},"allow-get-container-staleness":{"identifier":"allow-get-container-staleness","description":"Enables the get_container_staleness command without any pre-configured scope.","commands":{"allow":["get_container_staleness"],"deny":[]}},"allow-get-gateway-auth-token":{"identifier":"allow-get-gateway-auth-token","description":"Enables the get_gateway_auth_token command without any pre-configured scope.","commands":{"allow":["get_gateway_auth_token"],"deny":[]}},"allow-get-gateway-status":{"identifier":"allow-get-gateway-status","description":"Enables the get_gateway_status command without any pre-configured scope.","commands":{"allow":["get_gateway_status"],"deny":[]}},"allow-get-help-content":{"identifier":"allow-get-help-content","description":"Enables the get_help_content command without any pre-configured scope.","commands":{"allow":["get_help_content"],"deny":[]}},"allow-get-marketplace-sync-report":{"identifier":"allow-get-marketplace-sync-report","description":"Enables the get_marketplace_sync_report command without any pre-configured scope.","commands":{"allow":["get_marketplace_sync_report"],"deny":[]}},"allow-get-migration-state":{"identifier":"allow-get-migration-state","description":"Enables the get_migration_state command without any pre-configured scope.","commands":{"allow":["get_migration_state"],"deny":[]}},"allow-get-scheduled-task-log":{"identifier":"allow-get-scheduled-task-log","description":"Enables the get_scheduled_task_log command without any pre-configured scope.","commands":{"allow":["get_scheduled_task_log"],"deny":[]}},"allow-get-scheduler-notifications":{"identifier":"allow-get-scheduler-notifications","description":"Enables the get_scheduler_notifications command without any pre-configured scope.","commands":{"allow":["get_scheduler_notifications"],"deny":[]}},"allow-get-settings":{"identifier":"allow-get-settings","description":"Enables the get_settings command without any pre-configured scope.","commands":{"allow":["get_settings"],"deny":[]}},"allow-get-stt-status":{"identifier":"allow-get-stt-status","description":"Enables the get_stt_status command without any pre-configured scope.","commands":{"allow":["get_stt_status"],"deny":[]}},"allow-get-web-terminal-status":{"identifier":"allow-get-web-terminal-status","description":"Enables the get_web_terminal_status command without any pre-configured scope.","commands":{"allow":["get_web_terminal_status"],"deny":[]}},"allow-has-claude-token":{"identifier":"allow-has-claude-token","description":"Enables the has_claude_token command without any pre-configured scope.","commands":{"allow":["has_claude_token"],"deny":[]}},"allow-inspect-ca-cert-path":{"identifier":"allow-inspect-ca-cert-path","description":"Enables the inspect_ca_cert_path command without any pre-configured scope.","commands":{"allow":["inspect_ca_cert_path"],"deny":[]}},"allow-install-browser-view-browser":{"identifier":"allow-install-browser-view-browser","description":"Enables the install_browser_view_browser command without any pre-configured scope.","commands":{"allow":["install_browser_view_browser"],"deny":[]}},"allow-install-browser-view-support":{"identifier":"allow-install-browser-view-support","description":"Enables the install_browser_view_support command without any pre-configured scope.","commands":{"allow":["install_browser_view_support"],"deny":[]}},"allow-install-marketplace-item":{"identifier":"allow-install-marketplace-item","description":"Enables the install_marketplace_item command without any pre-configured scope.","commands":{"allow":["install_marketplace_item"],"deny":[]}},"allow-list-aws-profiles":{"identifier":"allow-list-aws-profiles","description":"Enables the list_aws_profiles command without any pre-configured scope.","commands":{"allow":["list_aws_profiles"],"deny":[]}},"allow-list-claude-sessions":{"identifier":"allow-list-claude-sessions","description":"Enables the list_claude_sessions command without any pre-configured scope.","commands":{"allow":["list_claude_sessions"],"deny":[]}},"allow-list-container-capabilities":{"identifier":"allow-list-container-capabilities","description":"Enables the list_container_capabilities command without any pre-configured scope.","commands":{"allow":["list_container_capabilities"],"deny":[]}},"allow-list-container-files":{"identifier":"allow-list-container-files","description":"Enables the list_container_files command without any pre-configured scope.","commands":{"allow":["list_container_files"],"deny":[]}},"allow-list-ec2-instance-types":{"identifier":"allow-list-ec2-instance-types","description":"Enables the list_ec2_instance_types command without any pre-configured scope.","commands":{"allow":["list_ec2_instance_types"],"deny":[]}},"allow-list-marketplace-snapshots":{"identifier":"allow-list-marketplace-snapshots","description":"Enables the list_marketplace_snapshots command without any pre-configured scope.","commands":{"allow":["list_marketplace_snapshots"],"deny":[]}},"allow-list-marketplace-updates":{"identifier":"allow-list-marketplace-updates","description":"Enables the list_marketplace_updates command without any pre-configured scope.","commands":{"allow":["list_marketplace_updates"],"deny":[]}},"allow-list-notes":{"identifier":"allow-list-notes","description":"Enables the list_notes command without any pre-configured scope.","commands":{"allow":["list_notes"],"deny":[]}},"allow-list-projects":{"identifier":"allow-list-projects","description":"Enables the list_projects command without any pre-configured scope.","commands":{"allow":["list_projects"],"deny":[]}},"allow-list-scheduled-tasks":{"identifier":"allow-list-scheduled-tasks","description":"Enables the list_scheduled_tasks command without any pre-configured scope.","commands":{"allow":["list_scheduled_tasks"],"deny":[]}},"allow-marketplace-gh-host-available":{"identifier":"allow-marketplace-gh-host-available","description":"Enables the marketplace_gh_host_available command without any pre-configured scope.","commands":{"allow":["marketplace_gh_host_available"],"deny":[]}},"allow-marketplace-item-diff":{"identifier":"allow-marketplace-item-diff","description":"Enables the marketplace_item_diff command without any pre-configured scope.","commands":{"allow":["marketplace_item_diff"],"deny":[]}},"allow-migrate-project-to-base":{"identifier":"allow-migrate-project-to-base","description":"Enables the migrate_project_to_base command without any pre-configured scope.","commands":{"allow":["migrate_project_to_base"],"deny":[]}},"allow-onboard-aws-user":{"identifier":"allow-onboard-aws-user","description":"Enables the onboard_aws_user command without any pre-configured scope.","commands":{"allow":["onboard_aws_user"],"deny":[]}},"allow-open-browser-view-popout":{"identifier":"allow-open-browser-view-popout","description":"Enables the open_browser_view_popout command without any pre-configured scope.","commands":{"allow":["open_browser_view_popout"],"deny":[]}},"allow-open-file-viewer":{"identifier":"allow-open-file-viewer","description":"Enables the open_file_viewer command without any pre-configured scope.","commands":{"allow":["open_file_viewer"],"deny":[]}},"allow-open-page-in-container-browser":{"identifier":"allow-open-page-in-container-browser","description":"Enables the open_page_in_container_browser command without any pre-configured scope.","commands":{"allow":["open_page_in_container_browser"],"deny":[]}},"allow-open-terminal-session":{"identifier":"allow-open-terminal-session","description":"Enables the open_terminal_session command without any pre-configured scope.","commands":{"allow":["open_terminal_session"],"deny":[]}},"allow-open-url-external":{"identifier":"allow-open-url-external","description":"Enables the open_url_external command without any pre-configured scope.","commands":{"allow":["open_url_external"],"deny":[]}},"allow-paste-image-to-terminal":{"identifier":"allow-paste-image-to-terminal","description":"Enables the paste_image_to_terminal command without any pre-configured scope.","commands":{"allow":["paste_image_to_terminal"],"deny":[]}},"allow-preview-settings-import":{"identifier":"allow-preview-settings-import","description":"Enables the preview_settings_import command without any pre-configured scope.","commands":{"allow":["preview_settings_import"],"deny":[]}},"allow-pull-gateway-image":{"identifier":"allow-pull-gateway-image","description":"Enables the pull_gateway_image command without any pre-configured scope.","commands":{"allow":["pull_gateway_image"],"deny":[]}},"allow-pull-image":{"identifier":"allow-pull-image","description":"Enables the pull_image command without any pre-configured scope.","commands":{"allow":["pull_image"],"deny":[]}},"allow-pull-stt-image":{"identifier":"allow-pull-stt-image","description":"Enables the pull_stt_image command without any pre-configured scope.","commands":{"allow":["pull_stt_image"],"deny":[]}},"allow-push-aws-saved-state":{"identifier":"allow-push-aws-saved-state","description":"Enables the push_aws_saved_state command without any pre-configured scope.","commands":{"allow":["push_aws_saved_state"],"deny":[]}},"allow-read-container-file":{"identifier":"allow-read-container-file","description":"Enables the read_container_file command without any pre-configured scope.","commands":{"allow":["read_container_file"],"deny":[]}},"allow-rebuild-project-container":{"identifier":"allow-rebuild-project-container","description":"Enables the rebuild_project_container command without any pre-configured scope.","commands":{"allow":["rebuild_project_container"],"deny":[]}},"allow-reconcile-aws-projects":{"identifier":"allow-reconcile-aws-projects","description":"Enables the reconcile_aws_projects command without any pre-configured scope.","commands":{"allow":["reconcile_aws_projects"],"deny":[]}},"allow-reconcile-project-statuses":{"identifier":"allow-reconcile-project-statuses","description":"Enables the reconcile_project_statuses command without any pre-configured scope.","commands":{"allow":["reconcile_project_statuses"],"deny":[]}},"allow-refresh-marketplaces":{"identifier":"allow-refresh-marketplaces","description":"Enables the refresh_marketplaces command without any pre-configured scope.","commands":{"allow":["refresh_marketplaces"],"deny":[]}},"allow-regenerate-gateway-auth-token":{"identifier":"allow-regenerate-gateway-auth-token","description":"Enables the regenerate_gateway_auth_token command without any pre-configured scope.","commands":{"allow":["regenerate_gateway_auth_token"],"deny":[]}},"allow-regenerate-web-terminal-token":{"identifier":"allow-regenerate-web-terminal-token","description":"Enables the regenerate_web_terminal_token command without any pre-configured scope.","commands":{"allow":["regenerate_web_terminal_token"],"deny":[]}},"allow-remove-aws-resources":{"identifier":"allow-remove-aws-resources","description":"Enables the remove_aws_resources command without any pre-configured scope.","commands":{"allow":["remove_aws_resources"],"deny":[]}},"allow-remove-host-connection":{"identifier":"allow-remove-host-connection","description":"Enables the remove_host_connection command without any pre-configured scope.","commands":{"allow":["remove_host_connection"],"deny":[]}},"allow-remove-marketplace":{"identifier":"allow-remove-marketplace","description":"Enables the remove_marketplace command without any pre-configured scope.","commands":{"allow":["remove_marketplace"],"deny":[]}},"allow-remove-marketplace-account":{"identifier":"allow-remove-marketplace-account","description":"Enables the remove_marketplace_account command without any pre-configured scope.","commands":{"allow":["remove_marketplace_account"],"deny":[]}},"allow-remove-project":{"identifier":"allow-remove-project","description":"Enables the remove_project command without any pre-configured scope.","commands":{"allow":["remove_project"],"deny":[]}},"allow-remove-scheduled-task":{"identifier":"allow-remove-scheduled-task","description":"Enables the remove_scheduled_task command without any pre-configured scope.","commands":{"allow":["remove_scheduled_task"],"deny":[]}},"allow-rename-container-path":{"identifier":"allow-rename-container-path","description":"Enables the rename_container_path command without any pre-configured scope.","commands":{"allow":["rename_container_path"],"deny":[]}},"allow-repair-aws-environment":{"identifier":"allow-repair-aws-environment","description":"Enables the repair_aws_environment command without any pre-configured scope.","commands":{"allow":["repair_aws_environment"],"deny":[]}},"allow-rollback-migration":{"identifier":"allow-rollback-migration","description":"Enables the rollback_migration command without any pre-configured scope.","commands":{"allow":["rollback_migration"],"deny":[]}},"allow-run-docker-install":{"identifier":"allow-run-docker-install","description":"Enables the run_docker_install command without any pre-configured scope.","commands":{"allow":["run_docker_install"],"deny":[]}},"allow-run-scheduled-task-now":{"identifier":"allow-run-scheduled-task-now","description":"Enables the run_scheduled_task_now command without any pre-configured scope.","commands":{"allow":["run_scheduled_task_now"],"deny":[]}},"allow-save-aws-admin-bundle":{"identifier":"allow-save-aws-admin-bundle","description":"Enables the save_aws_admin_bundle command without any pre-configured scope.","commands":{"allow":["save_aws_admin_bundle"],"deny":[]}},"allow-save-note":{"identifier":"allow-save-note","description":"Enables the save_note command without any pre-configured scope.","commands":{"allow":["save_note"],"deny":[]}},"allow-send-audio-data":{"identifier":"allow-send-audio-data","description":"Enables the send_audio_data command without any pre-configured scope.","commands":{"allow":["send_audio_data"],"deny":[]}},"allow-set-auth-bridge-enabled":{"identifier":"allow-set-auth-bridge-enabled","description":"Enables the set_auth_bridge_enabled command without any pre-configured scope.","commands":{"allow":["set_auth_bridge_enabled"],"deny":[]}},"allow-set-browser-view-enabled":{"identifier":"allow-set-browser-view-enabled","description":"Enables the set_browser_view_enabled command without any pre-configured scope.","commands":{"allow":["set_browser_view_enabled"],"deny":[]}},"allow-set-browser-view-match-window":{"identifier":"allow-set-browser-view-match-window","description":"Enables the set_browser_view_match_window command without any pre-configured scope.","commands":{"allow":["set_browser_view_match_window"],"deny":[]}},"allow-set-browser-view-popout-always-on-top":{"identifier":"allow-set-browser-view-popout-always-on-top","description":"Enables the set_browser_view_popout_always_on_top command without any pre-configured scope.","commands":{"allow":["set_browser_view_popout_always_on_top"],"deny":[]}},"allow-set-container-page-viewport":{"identifier":"allow-set-container-page-viewport","description":"Enables the set_container_page_viewport command without any pre-configured scope.","commands":{"allow":["set_container_page_viewport"],"deny":[]}},"allow-set-gateway-api-key":{"identifier":"allow-set-gateway-api-key","description":"Enables the set_gateway_api_key command without any pre-configured scope.","commands":{"allow":["set_gateway_api_key"],"deny":[]}},"allow-set-global-item-disabled":{"identifier":"allow-set-global-item-disabled","description":"Enables the set_global_item_disabled command without any pre-configured scope.","commands":{"allow":["set_global_item_disabled"],"deny":[]}},"allow-set-scheduled-task-enabled":{"identifier":"allow-set-scheduled-task-enabled","description":"Enables the set_scheduled_task_enabled command without any pre-configured scope.","commands":{"allow":["set_scheduled_task_enabled"],"deny":[]}},"allow-start-audio-bridge":{"identifier":"allow-start-audio-bridge","description":"Enables the start_audio_bridge command without any pre-configured scope.","commands":{"allow":["start_audio_bridge"],"deny":[]}},"allow-start-gateway":{"identifier":"allow-start-gateway","description":"Enables the start_gateway command without any pre-configured scope.","commands":{"allow":["start_gateway"],"deny":[]}},"allow-start-marketplace-gh-container-login":{"identifier":"allow-start-marketplace-gh-container-login","description":"Enables the start_marketplace_gh_container_login command without any pre-configured scope.","commands":{"allow":["start_marketplace_gh_container_login"],"deny":[]}},"allow-start-project-container":{"identifier":"allow-start-project-container","description":"Enables the start_project_container command without any pre-configured scope.","commands":{"allow":["start_project_container"],"deny":[]}},"allow-start-stt":{"identifier":"allow-start-stt","description":"Enables the start_stt command without any pre-configured scope.","commands":{"allow":["start_stt"],"deny":[]}},"allow-start-web-terminal":{"identifier":"allow-start-web-terminal","description":"Enables the start_web_terminal command without any pre-configured scope.","commands":{"allow":["start_web_terminal"],"deny":[]}},"allow-stop-audio-bridge":{"identifier":"allow-stop-audio-bridge","description":"Enables the stop_audio_bridge command without any pre-configured scope.","commands":{"allow":["stop_audio_bridge"],"deny":[]}},"allow-stop-gateway":{"identifier":"allow-stop-gateway","description":"Enables the stop_gateway command without any pre-configured scope.","commands":{"allow":["stop_gateway"],"deny":[]}},"allow-stop-project-container":{"identifier":"allow-stop-project-container","description":"Enables the stop_project_container command without any pre-configured scope.","commands":{"allow":["stop_project_container"],"deny":[]}},"allow-stop-stt":{"identifier":"allow-stop-stt","description":"Enables the stop_stt command without any pre-configured scope.","commands":{"allow":["stop_stt"],"deny":[]}},"allow-stop-web-terminal":{"identifier":"allow-stop-web-terminal","description":"Enables the stop_web_terminal command without any pre-configured scope.","commands":{"allow":["stop_web_terminal"],"deny":[]}},"allow-submit-claude-token-code":{"identifier":"allow-submit-claude-token-code","description":"Enables the submit_claude_token_code command without any pre-configured scope.","commands":{"allow":["submit_claude_token_code"],"deny":[]}},"allow-sweep-claude-token-snapshots":{"identifier":"allow-sweep-claude-token-snapshots","description":"Enables the sweep_claude_token_snapshots command without any pre-configured scope.","commands":{"allow":["sweep_claude_token_snapshots"],"deny":[]}},"allow-terminal-input":{"identifier":"allow-terminal-input","description":"Enables the terminal_input command without any pre-configured scope.","commands":{"allow":["terminal_input"],"deny":[]}},"allow-terminal-resize":{"identifier":"allow-terminal-resize","description":"Enables the terminal_resize command without any pre-configured scope.","commands":{"allow":["terminal_resize"],"deny":[]}},"allow-test-marketplace-account":{"identifier":"allow-test-marketplace-account","description":"Enables the test_marketplace_account command without any pre-configured scope.","commands":{"allow":["test_marketplace_account"],"deny":[]}},"allow-transcribe-audio":{"identifier":"allow-transcribe-audio","description":"Enables the transcribe_audio command without any pre-configured scope.","commands":{"allow":["transcribe_audio"],"deny":[]}},"allow-uninstall-marketplace-item":{"identifier":"allow-uninstall-marketplace-item","description":"Enables the uninstall_marketplace_item command without any pre-configured scope.","commands":{"allow":["uninstall_marketplace_item"],"deny":[]}},"allow-unlock-aws-state":{"identifier":"allow-unlock-aws-state","description":"Enables the unlock_aws_state command without any pre-configured scope.","commands":{"allow":["unlock_aws_state"],"deny":[]}},"allow-update-aws-connection":{"identifier":"allow-update-aws-connection","description":"Enables the update_aws_connection command without any pre-configured scope.","commands":{"allow":["update_aws_connection"],"deny":[]}},"allow-update-aws-environment":{"identifier":"allow-update-aws-environment","description":"Enables the update_aws_environment command without any pre-configured scope.","commands":{"allow":["update_aws_environment"],"deny":[]}},"allow-update-marketplace":{"identifier":"allow-update-marketplace","description":"Enables the update_marketplace command without any pre-configured scope.","commands":{"allow":["update_marketplace"],"deny":[]}},"allow-update-marketplace-item":{"identifier":"allow-update-marketplace-item","description":"Enables the update_marketplace_item command without any pre-configured scope.","commands":{"allow":["update_marketplace_item"],"deny":[]}},"allow-update-project":{"identifier":"allow-update-project","description":"Enables the update_project command without any pre-configured scope.","commands":{"allow":["update_project"],"deny":[]}},"allow-update-scheduled-task":{"identifier":"allow-update-scheduled-task","description":"Enables the update_scheduled_task command without any pre-configured scope.","commands":{"allow":["update_scheduled_task"],"deny":[]}},"allow-update-settings":{"identifier":"allow-update-settings","description":"Enables the update_settings command without any pre-configured scope.","commands":{"allow":["update_settings"],"deny":[]}},"allow-upload-files-to-container":{"identifier":"allow-upload-files-to-container","description":"Enables the upload_files_to_container command without any pre-configured scope.","commands":{"allow":["upload_files_to_container"],"deny":[]}},"allow-upload-host-file-to-terminal":{"identifier":"allow-upload-host-file-to-terminal","description":"Enables the upload_host_file_to_terminal command without any pre-configured scope.","commands":{"allow":["upload_host_file_to_terminal"],"deny":[]}},"allow-viewer-choose-file":{"identifier":"allow-viewer-choose-file","description":"Enables the viewer_choose_file command without any pre-configured scope.","commands":{"allow":["viewer_choose_file"],"deny":[]}},"allow-viewer-get-state":{"identifier":"allow-viewer-get-state","description":"Enables the viewer_get_state command without any pre-configured scope.","commands":{"allow":["viewer_get_state"],"deny":[]}},"allow-viewer-poll-file":{"identifier":"allow-viewer-poll-file","description":"Enables the viewer_poll_file command without any pre-configured scope.","commands":{"allow":["viewer_poll_file"],"deny":[]}},"allow-viewer-read-file":{"identifier":"allow-viewer-read-file","description":"Enables the viewer_read_file command without any pre-configured scope.","commands":{"allow":["viewer_read_file"],"deny":[]}},"allow-viewer-write-file":{"identifier":"allow-viewer-write-file","description":"Enables the viewer_write_file command without any pre-configured scope.","commands":{"allow":["viewer_write_file"],"deny":[]}},"deny-acquire-claude-token":{"identifier":"deny-acquire-claude-token","description":"Denies the acquire_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["acquire_claude_token"]}},"deny-add-aws-keys-connection":{"identifier":"deny-add-aws-keys-connection","description":"Denies the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["add_aws_keys_connection"]}},"deny-add-aws-profile-connection":{"identifier":"deny-add-aws-profile-connection","description":"Denies the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["add_aws_profile_connection"]}},"deny-add-marketplace":{"identifier":"deny-add-marketplace","description":"Denies the add_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace"]}},"deny-add-marketplace-gh-host-account":{"identifier":"deny-add-marketplace-gh-host-account","description":"Denies the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace_gh_host_account"]}},"deny-add-marketplace-token-account":{"identifier":"deny-add-marketplace-token-account","description":"Denies the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace_token_account"]}},"deny-add-project":{"identifier":"deny-add-project","description":"Denies the add_project command without any pre-configured scope.","commands":{"allow":[],"deny":["add_project"]}},"deny-add-scheduled-task":{"identifier":"deny-add-scheduled-task","description":"Denies the add_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["add_scheduled_task"]}},"deny-apply-marketplace-now":{"identifier":"deny-apply-marketplace-now","description":"Denies the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":[],"deny":["apply_marketplace_now"]}},"deny-apply-settings-import":{"identifier":"deny-apply-settings-import","description":"Denies the apply_settings_import command without any pre-configured scope.","commands":{"allow":[],"deny":["apply_settings_import"]}},"deny-aws-connection-identity":{"identifier":"deny-aws-connection-identity","description":"Denies the aws_connection_identity command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_connection_identity"]}},"deny-aws-connection-sso-login":{"identifier":"deny-aws-connection-sso-login","description":"Denies the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_connection_sso_login"]}},"deny-aws-cost-estimate":{"identifier":"deny-aws-cost-estimate","description":"Denies the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_cost_estimate"]}},"deny-aws-environment-max-hours":{"identifier":"deny-aws-environment-max-hours","description":"Denies the aws_environment_max_hours command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_environment_max_hours"]}},"deny-aws-policy-document":{"identifier":"deny-aws-policy-document","description":"Denies the aws_policy_document command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_policy_document"]}},"deny-aws-sso-refresh":{"identifier":"deny-aws-sso-refresh","description":"Denies the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_sso_refresh"]}},"deny-aws-task-log":{"identifier":"deny-aws-task-log","description":"Denies the aws_task_log command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_task_log"]}},"deny-aws-workspace-status":{"identifier":"deny-aws-workspace-status","description":"Denies the aws_workspace_status command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_workspace_status"]}},"deny-build-gateway-image":{"identifier":"deny-build-gateway-image","description":"Denies the build_gateway_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_gateway_image"]}},"deny-build-image":{"identifier":"deny-build-image","description":"Denies the build_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_image"]}},"deny-build-stt-image":{"identifier":"deny-build-stt-image","description":"Denies the build_stt_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_stt_image"]}},"deny-cancel-aws-deployment":{"identifier":"deny-cancel-aws-deployment","description":"Denies the cancel_aws_deployment command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_aws_deployment"]}},"deny-cancel-claude-token":{"identifier":"deny-cancel-claude-token","description":"Denies the cancel_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_claude_token"]}},"deny-cancel-marketplace-gh-login":{"identifier":"deny-cancel-marketplace-gh-login","description":"Denies the cancel_marketplace_gh_login command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_marketplace_gh_login"]}},"deny-check-aws-permissions":{"identifier":"deny-check-aws-permissions","description":"Denies the check_aws_permissions command without any pre-configured scope.","commands":{"allow":[],"deny":["check_aws_permissions"]}},"deny-check-browser-view-support":{"identifier":"deny-check-browser-view-support","description":"Denies the check_browser_view_support command without any pre-configured scope.","commands":{"allow":[],"deny":["check_browser_view_support"]}},"deny-check-docker":{"identifier":"deny-check-docker","description":"Denies the check_docker command without any pre-configured scope.","commands":{"allow":[],"deny":["check_docker"]}},"deny-check-for-updates":{"identifier":"deny-check-for-updates","description":"Denies the check_for_updates command without any pre-configured scope.","commands":{"allow":[],"deny":["check_for_updates"]}},"deny-check-gateway-health":{"identifier":"deny-check-gateway-health","description":"Denies the check_gateway_health command without any pre-configured scope.","commands":{"allow":[],"deny":["check_gateway_health"]}},"deny-check-image-exists":{"identifier":"deny-check-image-exists","description":"Denies the check_image_exists command without any pre-configured scope.","commands":{"allow":[],"deny":["check_image_exists"]}},"deny-check-image-update":{"identifier":"deny-check-image-update","description":"Denies the check_image_update command without any pre-configured scope.","commands":{"allow":[],"deny":["check_image_update"]}},"deny-check-unsaved-work":{"identifier":"deny-check-unsaved-work","description":"Denies the check_unsaved_work command without any pre-configured scope.","commands":{"allow":[],"deny":["check_unsaved_work"]}},"deny-clear-claude-token":{"identifier":"deny-clear-claude-token","description":"Denies the clear_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_claude_token"]}},"deny-clear-gateway-api-key":{"identifier":"deny-clear-gateway-api-key","description":"Denies the clear_gateway_api_key command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_gateway_api_key"]}},"deny-clear-scheduler-notifications":{"identifier":"deny-clear-scheduler-notifications","description":"Denies the clear_scheduler_notifications command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_scheduler_notifications"]}},"deny-close-browser-view-popout":{"identifier":"deny-close-browser-view-popout","description":"Denies the close_browser_view_popout command without any pre-configured scope.","commands":{"allow":[],"deny":["close_browser_view_popout"]}},"deny-close-container-page":{"identifier":"deny-close-container-page","description":"Denies the close_container_page command without any pre-configured scope.","commands":{"allow":[],"deny":["close_container_page"]}},"deny-close-terminal-session":{"identifier":"deny-close-terminal-session","description":"Denies the close_terminal_session command without any pre-configured scope.","commands":{"allow":[],"deny":["close_terminal_session"]}},"deny-confirm-migration":{"identifier":"deny-confirm-migration","description":"Denies the confirm_migration command without any pre-configured scope.","commands":{"allow":[],"deny":["confirm_migration"]}},"deny-create-container-directory":{"identifier":"deny-create-container-directory","description":"Denies the create_container_directory command without any pre-configured scope.","commands":{"allow":[],"deny":["create_container_directory"]}},"deny-delete-note":{"identifier":"deny-delete-note","description":"Denies the delete_note command without any pre-configured scope.","commands":{"allow":[],"deny":["delete_note"]}},"deny-deploy-aws-environment":{"identifier":"deny-deploy-aws-environment","description":"Denies the deploy_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["deploy_aws_environment"]}},"deny-deploy-aws-permissions-boundary":{"identifier":"deny-deploy-aws-permissions-boundary","description":"Denies the deploy_aws_permissions_boundary command without any pre-configured scope.","commands":{"allow":[],"deny":["deploy_aws_permissions_boundary"]}},"deny-destroy-incomplete-aws-environment":{"identifier":"deny-destroy-incomplete-aws-environment","description":"Denies the destroy_incomplete_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["destroy_incomplete_aws_environment"]}},"deny-detect-aws-config":{"identifier":"deny-detect-aws-config","description":"Denies the detect_aws_config command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_aws_config"]}},"deny-detect-aws-environments":{"identifier":"deny-detect-aws-environments","description":"Denies the detect_aws_environments command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_aws_environments"]}},"deny-detect-host-timezone":{"identifier":"deny-detect-host-timezone","description":"Denies the detect_host_timezone command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_host_timezone"]}},"deny-detect-install-options":{"identifier":"deny-detect-install-options","description":"Denies the detect_install_options command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_install_options"]}},"deny-download-container-backup":{"identifier":"deny-download-container-backup","description":"Denies the download_container_backup command without any pre-configured scope.","commands":{"allow":[],"deny":["download_container_backup"]}},"deny-download-container-file":{"identifier":"deny-download-container-file","description":"Denies the download_container_file command without any pre-configured scope.","commands":{"allow":[],"deny":["download_container_file"]}},"deny-export-settings":{"identifier":"deny-export-settings","description":"Denies the export_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["export_settings"]}},"deny-follow-aws-deployment":{"identifier":"deny-follow-aws-deployment","description":"Denies the follow_aws_deployment command without any pre-configured scope.","commands":{"allow":[],"deny":["follow_aws_deployment"]}},"deny-forget-marketplace-installs":{"identifier":"deny-forget-marketplace-installs","description":"Denies the forget_marketplace_installs command without any pre-configured scope.","commands":{"allow":[],"deny":["forget_marketplace_installs"]}},"deny-get-app-version":{"identifier":"deny-get-app-version","description":"Denies the get_app_version command without any pre-configured scope.","commands":{"allow":[],"deny":["get_app_version"]}},"deny-get-auth-bridge-status":{"identifier":"deny-get-auth-bridge-status","description":"Denies the get_auth_bridge_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_auth_bridge_status"]}},"deny-get-browser-view-match-window":{"identifier":"deny-get-browser-view-match-window","description":"Denies the get_browser_view_match_window command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_match_window"]}},"deny-get-browser-view-popout-state":{"identifier":"deny-get-browser-view-popout-state","description":"Denies the get_browser_view_popout_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_popout_state"]}},"deny-get-browser-view-status":{"identifier":"deny-get-browser-view-status","description":"Denies the get_browser_view_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_status"]}},"deny-get-container-info":{"identifier":"deny-get-container-info","description":"Denies the get_container_info command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_info"]}},"deny-get-container-page-state":{"identifier":"deny-get-container-page-state","description":"Denies the get_container_page_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_page_state"]}},"deny-get-container-staleness":{"identifier":"deny-get-container-staleness","description":"Denies the get_container_staleness command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_staleness"]}},"deny-get-gateway-auth-token":{"identifier":"deny-get-gateway-auth-token","description":"Denies the get_gateway_auth_token command without any pre-configured scope.","commands":{"allow":[],"deny":["get_gateway_auth_token"]}},"deny-get-gateway-status":{"identifier":"deny-get-gateway-status","description":"Denies the get_gateway_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_gateway_status"]}},"deny-get-help-content":{"identifier":"deny-get-help-content","description":"Denies the get_help_content command without any pre-configured scope.","commands":{"allow":[],"deny":["get_help_content"]}},"deny-get-marketplace-sync-report":{"identifier":"deny-get-marketplace-sync-report","description":"Denies the get_marketplace_sync_report command without any pre-configured scope.","commands":{"allow":[],"deny":["get_marketplace_sync_report"]}},"deny-get-migration-state":{"identifier":"deny-get-migration-state","description":"Denies the get_migration_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_migration_state"]}},"deny-get-scheduled-task-log":{"identifier":"deny-get-scheduled-task-log","description":"Denies the get_scheduled_task_log command without any pre-configured scope.","commands":{"allow":[],"deny":["get_scheduled_task_log"]}},"deny-get-scheduler-notifications":{"identifier":"deny-get-scheduler-notifications","description":"Denies the get_scheduler_notifications command without any pre-configured scope.","commands":{"allow":[],"deny":["get_scheduler_notifications"]}},"deny-get-settings":{"identifier":"deny-get-settings","description":"Denies the get_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["get_settings"]}},"deny-get-stt-status":{"identifier":"deny-get-stt-status","description":"Denies the get_stt_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_stt_status"]}},"deny-get-web-terminal-status":{"identifier":"deny-get-web-terminal-status","description":"Denies the get_web_terminal_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_web_terminal_status"]}},"deny-has-claude-token":{"identifier":"deny-has-claude-token","description":"Denies the has_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["has_claude_token"]}},"deny-inspect-ca-cert-path":{"identifier":"deny-inspect-ca-cert-path","description":"Denies the inspect_ca_cert_path command without any pre-configured scope.","commands":{"allow":[],"deny":["inspect_ca_cert_path"]}},"deny-install-browser-view-browser":{"identifier":"deny-install-browser-view-browser","description":"Denies the install_browser_view_browser command without any pre-configured scope.","commands":{"allow":[],"deny":["install_browser_view_browser"]}},"deny-install-browser-view-support":{"identifier":"deny-install-browser-view-support","description":"Denies the install_browser_view_support command without any pre-configured scope.","commands":{"allow":[],"deny":["install_browser_view_support"]}},"deny-install-marketplace-item":{"identifier":"deny-install-marketplace-item","description":"Denies the install_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["install_marketplace_item"]}},"deny-list-aws-profiles":{"identifier":"deny-list-aws-profiles","description":"Denies the list_aws_profiles command without any pre-configured scope.","commands":{"allow":[],"deny":["list_aws_profiles"]}},"deny-list-claude-sessions":{"identifier":"deny-list-claude-sessions","description":"Denies the list_claude_sessions command without any pre-configured scope.","commands":{"allow":[],"deny":["list_claude_sessions"]}},"deny-list-container-capabilities":{"identifier":"deny-list-container-capabilities","description":"Denies the list_container_capabilities command without any pre-configured scope.","commands":{"allow":[],"deny":["list_container_capabilities"]}},"deny-list-container-files":{"identifier":"deny-list-container-files","description":"Denies the list_container_files command without any pre-configured scope.","commands":{"allow":[],"deny":["list_container_files"]}},"deny-list-ec2-instance-types":{"identifier":"deny-list-ec2-instance-types","description":"Denies the list_ec2_instance_types command without any pre-configured scope.","commands":{"allow":[],"deny":["list_ec2_instance_types"]}},"deny-list-marketplace-snapshots":{"identifier":"deny-list-marketplace-snapshots","description":"Denies the list_marketplace_snapshots command without any pre-configured scope.","commands":{"allow":[],"deny":["list_marketplace_snapshots"]}},"deny-list-marketplace-updates":{"identifier":"deny-list-marketplace-updates","description":"Denies the list_marketplace_updates command without any pre-configured scope.","commands":{"allow":[],"deny":["list_marketplace_updates"]}},"deny-list-notes":{"identifier":"deny-list-notes","description":"Denies the list_notes command without any pre-configured scope.","commands":{"allow":[],"deny":["list_notes"]}},"deny-list-projects":{"identifier":"deny-list-projects","description":"Denies the list_projects command without any pre-configured scope.","commands":{"allow":[],"deny":["list_projects"]}},"deny-list-scheduled-tasks":{"identifier":"deny-list-scheduled-tasks","description":"Denies the list_scheduled_tasks command without any pre-configured scope.","commands":{"allow":[],"deny":["list_scheduled_tasks"]}},"deny-marketplace-gh-host-available":{"identifier":"deny-marketplace-gh-host-available","description":"Denies the marketplace_gh_host_available command without any pre-configured scope.","commands":{"allow":[],"deny":["marketplace_gh_host_available"]}},"deny-marketplace-item-diff":{"identifier":"deny-marketplace-item-diff","description":"Denies the marketplace_item_diff command without any pre-configured scope.","commands":{"allow":[],"deny":["marketplace_item_diff"]}},"deny-migrate-project-to-base":{"identifier":"deny-migrate-project-to-base","description":"Denies the migrate_project_to_base command without any pre-configured scope.","commands":{"allow":[],"deny":["migrate_project_to_base"]}},"deny-onboard-aws-user":{"identifier":"deny-onboard-aws-user","description":"Denies the onboard_aws_user command without any pre-configured scope.","commands":{"allow":[],"deny":["onboard_aws_user"]}},"deny-open-browser-view-popout":{"identifier":"deny-open-browser-view-popout","description":"Denies the open_browser_view_popout command without any pre-configured scope.","commands":{"allow":[],"deny":["open_browser_view_popout"]}},"deny-open-file-viewer":{"identifier":"deny-open-file-viewer","description":"Denies the open_file_viewer command without any pre-configured scope.","commands":{"allow":[],"deny":["open_file_viewer"]}},"deny-open-page-in-container-browser":{"identifier":"deny-open-page-in-container-browser","description":"Denies the open_page_in_container_browser command without any pre-configured scope.","commands":{"allow":[],"deny":["open_page_in_container_browser"]}},"deny-open-terminal-session":{"identifier":"deny-open-terminal-session","description":"Denies the open_terminal_session command without any pre-configured scope.","commands":{"allow":[],"deny":["open_terminal_session"]}},"deny-open-url-external":{"identifier":"deny-open-url-external","description":"Denies the open_url_external command without any pre-configured scope.","commands":{"allow":[],"deny":["open_url_external"]}},"deny-paste-image-to-terminal":{"identifier":"deny-paste-image-to-terminal","description":"Denies the paste_image_to_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["paste_image_to_terminal"]}},"deny-preview-settings-import":{"identifier":"deny-preview-settings-import","description":"Denies the preview_settings_import command without any pre-configured scope.","commands":{"allow":[],"deny":["preview_settings_import"]}},"deny-pull-gateway-image":{"identifier":"deny-pull-gateway-image","description":"Denies the pull_gateway_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_gateway_image"]}},"deny-pull-image":{"identifier":"deny-pull-image","description":"Denies the pull_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_image"]}},"deny-pull-stt-image":{"identifier":"deny-pull-stt-image","description":"Denies the pull_stt_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_stt_image"]}},"deny-push-aws-saved-state":{"identifier":"deny-push-aws-saved-state","description":"Denies the push_aws_saved_state command without any pre-configured scope.","commands":{"allow":[],"deny":["push_aws_saved_state"]}},"deny-read-container-file":{"identifier":"deny-read-container-file","description":"Denies the read_container_file command without any pre-configured scope.","commands":{"allow":[],"deny":["read_container_file"]}},"deny-rebuild-project-container":{"identifier":"deny-rebuild-project-container","description":"Denies the rebuild_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["rebuild_project_container"]}},"deny-reconcile-aws-projects":{"identifier":"deny-reconcile-aws-projects","description":"Denies the reconcile_aws_projects command without any pre-configured scope.","commands":{"allow":[],"deny":["reconcile_aws_projects"]}},"deny-reconcile-project-statuses":{"identifier":"deny-reconcile-project-statuses","description":"Denies the reconcile_project_statuses command without any pre-configured scope.","commands":{"allow":[],"deny":["reconcile_project_statuses"]}},"deny-refresh-marketplaces":{"identifier":"deny-refresh-marketplaces","description":"Denies the refresh_marketplaces command without any pre-configured scope.","commands":{"allow":[],"deny":["refresh_marketplaces"]}},"deny-regenerate-gateway-auth-token":{"identifier":"deny-regenerate-gateway-auth-token","description":"Denies the regenerate_gateway_auth_token command without any pre-configured scope.","commands":{"allow":[],"deny":["regenerate_gateway_auth_token"]}},"deny-regenerate-web-terminal-token":{"identifier":"deny-regenerate-web-terminal-token","description":"Denies the regenerate_web_terminal_token command without any pre-configured scope.","commands":{"allow":[],"deny":["regenerate_web_terminal_token"]}},"deny-remove-aws-resources":{"identifier":"deny-remove-aws-resources","description":"Denies the remove_aws_resources command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_aws_resources"]}},"deny-remove-host-connection":{"identifier":"deny-remove-host-connection","description":"Denies the remove_host_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_host_connection"]}},"deny-remove-marketplace":{"identifier":"deny-remove-marketplace","description":"Denies the remove_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_marketplace"]}},"deny-remove-marketplace-account":{"identifier":"deny-remove-marketplace-account","description":"Denies the remove_marketplace_account command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_marketplace_account"]}},"deny-remove-project":{"identifier":"deny-remove-project","description":"Denies the remove_project command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_project"]}},"deny-remove-scheduled-task":{"identifier":"deny-remove-scheduled-task","description":"Denies the remove_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_scheduled_task"]}},"deny-rename-container-path":{"identifier":"deny-rename-container-path","description":"Denies the rename_container_path command without any pre-configured scope.","commands":{"allow":[],"deny":["rename_container_path"]}},"deny-repair-aws-environment":{"identifier":"deny-repair-aws-environment","description":"Denies the repair_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["repair_aws_environment"]}},"deny-rollback-migration":{"identifier":"deny-rollback-migration","description":"Denies the rollback_migration command without any pre-configured scope.","commands":{"allow":[],"deny":["rollback_migration"]}},"deny-run-docker-install":{"identifier":"deny-run-docker-install","description":"Denies the run_docker_install command without any pre-configured scope.","commands":{"allow":[],"deny":["run_docker_install"]}},"deny-run-scheduled-task-now":{"identifier":"deny-run-scheduled-task-now","description":"Denies the run_scheduled_task_now command without any pre-configured scope.","commands":{"allow":[],"deny":["run_scheduled_task_now"]}},"deny-save-aws-admin-bundle":{"identifier":"deny-save-aws-admin-bundle","description":"Denies the save_aws_admin_bundle command without any pre-configured scope.","commands":{"allow":[],"deny":["save_aws_admin_bundle"]}},"deny-save-note":{"identifier":"deny-save-note","description":"Denies the save_note command without any pre-configured scope.","commands":{"allow":[],"deny":["save_note"]}},"deny-send-audio-data":{"identifier":"deny-send-audio-data","description":"Denies the send_audio_data command without any pre-configured scope.","commands":{"allow":[],"deny":["send_audio_data"]}},"deny-set-auth-bridge-enabled":{"identifier":"deny-set-auth-bridge-enabled","description":"Denies the set_auth_bridge_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_auth_bridge_enabled"]}},"deny-set-browser-view-enabled":{"identifier":"deny-set-browser-view-enabled","description":"Denies the set_browser_view_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_enabled"]}},"deny-set-browser-view-match-window":{"identifier":"deny-set-browser-view-match-window","description":"Denies the set_browser_view_match_window command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_match_window"]}},"deny-set-browser-view-popout-always-on-top":{"identifier":"deny-set-browser-view-popout-always-on-top","description":"Denies the set_browser_view_popout_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_popout_always_on_top"]}},"deny-set-container-page-viewport":{"identifier":"deny-set-container-page-viewport","description":"Denies the set_container_page_viewport command without any pre-configured scope.","commands":{"allow":[],"deny":["set_container_page_viewport"]}},"deny-set-gateway-api-key":{"identifier":"deny-set-gateway-api-key","description":"Denies the set_gateway_api_key command without any pre-configured scope.","commands":{"allow":[],"deny":["set_gateway_api_key"]}},"deny-set-global-item-disabled":{"identifier":"deny-set-global-item-disabled","description":"Denies the set_global_item_disabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_global_item_disabled"]}},"deny-set-scheduled-task-enabled":{"identifier":"deny-set-scheduled-task-enabled","description":"Denies the set_scheduled_task_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_scheduled_task_enabled"]}},"deny-start-audio-bridge":{"identifier":"deny-start-audio-bridge","description":"Denies the start_audio_bridge command without any pre-configured scope.","commands":{"allow":[],"deny":["start_audio_bridge"]}},"deny-start-gateway":{"identifier":"deny-start-gateway","description":"Denies the start_gateway command without any pre-configured scope.","commands":{"allow":[],"deny":["start_gateway"]}},"deny-start-marketplace-gh-container-login":{"identifier":"deny-start-marketplace-gh-container-login","description":"Denies the start_marketplace_gh_container_login command without any pre-configured scope.","commands":{"allow":[],"deny":["start_marketplace_gh_container_login"]}},"deny-start-project-container":{"identifier":"deny-start-project-container","description":"Denies the start_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["start_project_container"]}},"deny-start-stt":{"identifier":"deny-start-stt","description":"Denies the start_stt command without any pre-configured scope.","commands":{"allow":[],"deny":["start_stt"]}},"deny-start-web-terminal":{"identifier":"deny-start-web-terminal","description":"Denies the start_web_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["start_web_terminal"]}},"deny-stop-audio-bridge":{"identifier":"deny-stop-audio-bridge","description":"Denies the stop_audio_bridge command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_audio_bridge"]}},"deny-stop-gateway":{"identifier":"deny-stop-gateway","description":"Denies the stop_gateway command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_gateway"]}},"deny-stop-project-container":{"identifier":"deny-stop-project-container","description":"Denies the stop_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_project_container"]}},"deny-stop-stt":{"identifier":"deny-stop-stt","description":"Denies the stop_stt command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_stt"]}},"deny-stop-web-terminal":{"identifier":"deny-stop-web-terminal","description":"Denies the stop_web_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_web_terminal"]}},"deny-submit-claude-token-code":{"identifier":"deny-submit-claude-token-code","description":"Denies the submit_claude_token_code command without any pre-configured scope.","commands":{"allow":[],"deny":["submit_claude_token_code"]}},"deny-sweep-claude-token-snapshots":{"identifier":"deny-sweep-claude-token-snapshots","description":"Denies the sweep_claude_token_snapshots command without any pre-configured scope.","commands":{"allow":[],"deny":["sweep_claude_token_snapshots"]}},"deny-terminal-input":{"identifier":"deny-terminal-input","description":"Denies the terminal_input command without any pre-configured scope.","commands":{"allow":[],"deny":["terminal_input"]}},"deny-terminal-resize":{"identifier":"deny-terminal-resize","description":"Denies the terminal_resize command without any pre-configured scope.","commands":{"allow":[],"deny":["terminal_resize"]}},"deny-test-marketplace-account":{"identifier":"deny-test-marketplace-account","description":"Denies the test_marketplace_account command without any pre-configured scope.","commands":{"allow":[],"deny":["test_marketplace_account"]}},"deny-transcribe-audio":{"identifier":"deny-transcribe-audio","description":"Denies the transcribe_audio command without any pre-configured scope.","commands":{"allow":[],"deny":["transcribe_audio"]}},"deny-uninstall-marketplace-item":{"identifier":"deny-uninstall-marketplace-item","description":"Denies the uninstall_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["uninstall_marketplace_item"]}},"deny-unlock-aws-state":{"identifier":"deny-unlock-aws-state","description":"Denies the unlock_aws_state command without any pre-configured scope.","commands":{"allow":[],"deny":["unlock_aws_state"]}},"deny-update-aws-connection":{"identifier":"deny-update-aws-connection","description":"Denies the update_aws_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["update_aws_connection"]}},"deny-update-aws-environment":{"identifier":"deny-update-aws-environment","description":"Denies the update_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["update_aws_environment"]}},"deny-update-marketplace":{"identifier":"deny-update-marketplace","description":"Denies the update_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["update_marketplace"]}},"deny-update-marketplace-item":{"identifier":"deny-update-marketplace-item","description":"Denies the update_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["update_marketplace_item"]}},"deny-update-project":{"identifier":"deny-update-project","description":"Denies the update_project command without any pre-configured scope.","commands":{"allow":[],"deny":["update_project"]}},"deny-update-scheduled-task":{"identifier":"deny-update-scheduled-task","description":"Denies the update_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["update_scheduled_task"]}},"deny-update-settings":{"identifier":"deny-update-settings","description":"Denies the update_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["update_settings"]}},"deny-upload-files-to-container":{"identifier":"deny-upload-files-to-container","description":"Denies the upload_files_to_container command without any pre-configured scope.","commands":{"allow":[],"deny":["upload_files_to_container"]}},"deny-upload-host-file-to-terminal":{"identifier":"deny-upload-host-file-to-terminal","description":"Denies the upload_host_file_to_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["upload_host_file_to_terminal"]}},"deny-viewer-choose-file":{"identifier":"deny-viewer-choose-file","description":"Denies the viewer_choose_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_choose_file"]}},"deny-viewer-get-state":{"identifier":"deny-viewer-get-state","description":"Denies the viewer_get_state command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_get_state"]}},"deny-viewer-poll-file":{"identifier":"deny-viewer-poll-file","description":"Denies the viewer_poll_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_poll_file"]}},"deny-viewer-read-file":{"identifier":"deny-viewer-read-file","description":"Denies the viewer_read_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_read_file"]}},"deny-viewer-write-file":{"identifier":"deny-viewer-write-file","description":"Denies the viewer_write_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_write_file"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","commands":{"allow":["name"],"deny":[]}},"allow-register-listener":{"identifier":"allow-register-listener","description":"Enables the register_listener command without any pre-configured scope.","commands":{"allow":["register_listener"],"deny":[]}},"allow-remove-data-store":{"identifier":"allow-remove-data-store","description":"Enables the remove_data_store command without any pre-configured scope.","commands":{"allow":["remove_data_store"],"deny":[]}},"allow-remove-listener":{"identifier":"allow-remove-listener","description":"Enables the remove_listener command without any pre-configured scope.","commands":{"allow":["remove_listener"],"deny":[]}},"allow-set-app-theme":{"identifier":"allow-set-app-theme","description":"Enables the set_app_theme command without any pre-configured scope.","commands":{"allow":["set_app_theme"],"deny":[]}},"allow-set-dock-visibility":{"identifier":"allow-set-dock-visibility","description":"Enables the set_dock_visibility command without any pre-configured scope.","commands":{"allow":["set_dock_visibility"],"deny":[]}},"allow-supports-multiple-windows":{"identifier":"allow-supports-multiple-windows","description":"Enables the supports_multiple_windows command without any pre-configured scope.","commands":{"allow":["supports_multiple_windows"],"deny":[]}},"allow-tauri-version":{"identifier":"allow-tauri-version","description":"Enables the tauri_version command without any pre-configured scope.","commands":{"allow":["tauri_version"],"deny":[]}},"allow-version":{"identifier":"allow-version","description":"Enables the version command without any pre-configured scope.","commands":{"allow":["version"],"deny":[]}},"deny-app-hide":{"identifier":"deny-app-hide","description":"Denies the app_hide command without any pre-configured scope.","commands":{"allow":[],"deny":["app_hide"]}},"deny-app-show":{"identifier":"deny-app-show","description":"Denies the app_show command without any pre-configured scope.","commands":{"allow":[],"deny":["app_show"]}},"deny-bundle-type":{"identifier":"deny-bundle-type","description":"Denies the bundle_type command without any pre-configured scope.","commands":{"allow":[],"deny":["bundle_type"]}},"deny-default-window-icon":{"identifier":"deny-default-window-icon","description":"Denies the default_window_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["default_window_icon"]}},"deny-fetch-data-store-identifiers":{"identifier":"deny-fetch-data-store-identifiers","description":"Denies the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":[],"deny":["fetch_data_store_identifiers"]}},"deny-identifier":{"identifier":"deny-identifier","description":"Denies the identifier command without any pre-configured scope.","commands":{"allow":[],"deny":["identifier"]}},"deny-name":{"identifier":"deny-name","description":"Denies the name command without any pre-configured scope.","commands":{"allow":[],"deny":["name"]}},"deny-register-listener":{"identifier":"deny-register-listener","description":"Denies the register_listener command without any pre-configured scope.","commands":{"allow":[],"deny":["register_listener"]}},"deny-remove-data-store":{"identifier":"deny-remove-data-store","description":"Denies the remove_data_store command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_data_store"]}},"deny-remove-listener":{"identifier":"deny-remove-listener","description":"Denies the remove_listener command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_listener"]}},"deny-set-app-theme":{"identifier":"deny-set-app-theme","description":"Denies the set_app_theme command without any pre-configured scope.","commands":{"allow":[],"deny":["set_app_theme"]}},"deny-set-dock-visibility":{"identifier":"deny-set-dock-visibility","description":"Denies the set_dock_visibility command without any pre-configured scope.","commands":{"allow":[],"deny":["set_dock_visibility"]}},"deny-supports-multiple-windows":{"identifier":"deny-supports-multiple-windows","description":"Denies the supports_multiple_windows command without any pre-configured scope.","commands":{"allow":[],"deny":["supports_multiple_windows"]}},"deny-tauri-version":{"identifier":"deny-tauri-version","description":"Denies the tauri_version command without any pre-configured scope.","commands":{"allow":[],"deny":["tauri_version"]}},"deny-version":{"identifier":"deny-version","description":"Denies the version command without any pre-configured scope.","commands":{"allow":[],"deny":["version"]}}},"permission_sets":{},"global_scope_schema":null},"core:event":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-listen","allow-unlisten","allow-emit","allow-emit-to"]},"permissions":{"allow-emit":{"identifier":"allow-emit","description":"Enables the emit command without any pre-configured scope.","commands":{"allow":["emit"],"deny":[]}},"allow-emit-to":{"identifier":"allow-emit-to","description":"Enables the emit_to command without any pre-configured scope.","commands":{"allow":["emit_to"],"deny":[]}},"allow-listen":{"identifier":"allow-listen","description":"Enables the listen command without any pre-configured scope.","commands":{"allow":["listen"],"deny":[]}},"allow-unlisten":{"identifier":"allow-unlisten","description":"Enables the unlisten command without any pre-configured scope.","commands":{"allow":["unlisten"],"deny":[]}},"deny-emit":{"identifier":"deny-emit","description":"Denies the emit command without any pre-configured scope.","commands":{"allow":[],"deny":["emit"]}},"deny-emit-to":{"identifier":"deny-emit-to","description":"Denies the emit_to command without any pre-configured scope.","commands":{"allow":[],"deny":["emit_to"]}},"deny-listen":{"identifier":"deny-listen","description":"Denies the listen command without any pre-configured scope.","commands":{"allow":[],"deny":["listen"]}},"deny-unlisten":{"identifier":"deny-unlisten","description":"Denies the unlisten command without any pre-configured scope.","commands":{"allow":[],"deny":["unlisten"]}}},"permission_sets":{},"global_scope_schema":null},"core:image":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-from-bytes","allow-from-path","allow-rgba","allow-size"]},"permissions":{"allow-from-bytes":{"identifier":"allow-from-bytes","description":"Enables the from_bytes command without any pre-configured scope.","commands":{"allow":["from_bytes"],"deny":[]}},"allow-from-path":{"identifier":"allow-from-path","description":"Enables the from_path command without any pre-configured scope.","commands":{"allow":["from_path"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-rgba":{"identifier":"allow-rgba","description":"Enables the rgba command without any pre-configured scope.","commands":{"allow":["rgba"],"deny":[]}},"allow-size":{"identifier":"allow-size","description":"Enables the size command without any pre-configured scope.","commands":{"allow":["size"],"deny":[]}},"deny-from-bytes":{"identifier":"deny-from-bytes","description":"Denies the from_bytes command without any pre-configured scope.","commands":{"allow":[],"deny":["from_bytes"]}},"deny-from-path":{"identifier":"deny-from-path","description":"Denies the from_path command without any pre-configured scope.","commands":{"allow":[],"deny":["from_path"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-rgba":{"identifier":"deny-rgba","description":"Denies the rgba command without any pre-configured scope.","commands":{"allow":[],"deny":["rgba"]}},"deny-size":{"identifier":"deny-size","description":"Denies the size command without any pre-configured scope.","commands":{"allow":[],"deny":["size"]}}},"permission_sets":{},"global_scope_schema":null},"core:menu":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-append","allow-prepend","allow-insert","allow-remove","allow-remove-at","allow-items","allow-get","allow-popup","allow-create-default","allow-set-as-app-menu","allow-set-as-window-menu","allow-text","allow-set-text","allow-is-enabled","allow-set-enabled","allow-set-accelerator","allow-set-as-windows-menu-for-nsapp","allow-set-as-help-menu-for-nsapp","allow-is-checked","allow-set-checked","allow-set-icon"]},"permissions":{"allow-append":{"identifier":"allow-append","description":"Enables the append command without any pre-configured scope.","commands":{"allow":["append"],"deny":[]}},"allow-create-default":{"identifier":"allow-create-default","description":"Enables the create_default command without any pre-configured scope.","commands":{"allow":["create_default"],"deny":[]}},"allow-get":{"identifier":"allow-get","description":"Enables the get command without any pre-configured scope.","commands":{"allow":["get"],"deny":[]}},"allow-insert":{"identifier":"allow-insert","description":"Enables the insert command without any pre-configured scope.","commands":{"allow":["insert"],"deny":[]}},"allow-is-checked":{"identifier":"allow-is-checked","description":"Enables the is_checked command without any pre-configured scope.","commands":{"allow":["is_checked"],"deny":[]}},"allow-is-enabled":{"identifier":"allow-is-enabled","description":"Enables the is_enabled command without any pre-configured scope.","commands":{"allow":["is_enabled"],"deny":[]}},"allow-items":{"identifier":"allow-items","description":"Enables the items command without any pre-configured scope.","commands":{"allow":["items"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-popup":{"identifier":"allow-popup","description":"Enables the popup command without any pre-configured scope.","commands":{"allow":["popup"],"deny":[]}},"allow-prepend":{"identifier":"allow-prepend","description":"Enables the prepend command without any pre-configured scope.","commands":{"allow":["prepend"],"deny":[]}},"allow-remove":{"identifier":"allow-remove","description":"Enables the remove command without any pre-configured scope.","commands":{"allow":["remove"],"deny":[]}},"allow-remove-at":{"identifier":"allow-remove-at","description":"Enables the remove_at command without any pre-configured scope.","commands":{"allow":["remove_at"],"deny":[]}},"allow-set-accelerator":{"identifier":"allow-set-accelerator","description":"Enables the set_accelerator command without any pre-configured scope.","commands":{"allow":["set_accelerator"],"deny":[]}},"allow-set-as-app-menu":{"identifier":"allow-set-as-app-menu","description":"Enables the set_as_app_menu command without any pre-configured scope.","commands":{"allow":["set_as_app_menu"],"deny":[]}},"allow-set-as-help-menu-for-nsapp":{"identifier":"allow-set-as-help-menu-for-nsapp","description":"Enables the set_as_help_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":["set_as_help_menu_for_nsapp"],"deny":[]}},"allow-set-as-window-menu":{"identifier":"allow-set-as-window-menu","description":"Enables the set_as_window_menu command without any pre-configured scope.","commands":{"allow":["set_as_window_menu"],"deny":[]}},"allow-set-as-windows-menu-for-nsapp":{"identifier":"allow-set-as-windows-menu-for-nsapp","description":"Enables the set_as_windows_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":["set_as_windows_menu_for_nsapp"],"deny":[]}},"allow-set-checked":{"identifier":"allow-set-checked","description":"Enables the set_checked command without any pre-configured scope.","commands":{"allow":["set_checked"],"deny":[]}},"allow-set-enabled":{"identifier":"allow-set-enabled","description":"Enables the set_enabled command without any pre-configured scope.","commands":{"allow":["set_enabled"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-text":{"identifier":"allow-set-text","description":"Enables the set_text command without any pre-configured scope.","commands":{"allow":["set_text"],"deny":[]}},"allow-text":{"identifier":"allow-text","description":"Enables the text command without any pre-configured scope.","commands":{"allow":["text"],"deny":[]}},"deny-append":{"identifier":"deny-append","description":"Denies the append command without any pre-configured scope.","commands":{"allow":[],"deny":["append"]}},"deny-create-default":{"identifier":"deny-create-default","description":"Denies the create_default command without any pre-configured scope.","commands":{"allow":[],"deny":["create_default"]}},"deny-get":{"identifier":"deny-get","description":"Denies the get command without any pre-configured scope.","commands":{"allow":[],"deny":["get"]}},"deny-insert":{"identifier":"deny-insert","description":"Denies the insert command without any pre-configured scope.","commands":{"allow":[],"deny":["insert"]}},"deny-is-checked":{"identifier":"deny-is-checked","description":"Denies the is_checked command without any pre-configured scope.","commands":{"allow":[],"deny":["is_checked"]}},"deny-is-enabled":{"identifier":"deny-is-enabled","description":"Denies the is_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["is_enabled"]}},"deny-items":{"identifier":"deny-items","description":"Denies the items command without any pre-configured scope.","commands":{"allow":[],"deny":["items"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-popup":{"identifier":"deny-popup","description":"Denies the popup command without any pre-configured scope.","commands":{"allow":[],"deny":["popup"]}},"deny-prepend":{"identifier":"deny-prepend","description":"Denies the prepend command without any pre-configured scope.","commands":{"allow":[],"deny":["prepend"]}},"deny-remove":{"identifier":"deny-remove","description":"Denies the remove command without any pre-configured scope.","commands":{"allow":[],"deny":["remove"]}},"deny-remove-at":{"identifier":"deny-remove-at","description":"Denies the remove_at command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_at"]}},"deny-set-accelerator":{"identifier":"deny-set-accelerator","description":"Denies the set_accelerator command without any pre-configured scope.","commands":{"allow":[],"deny":["set_accelerator"]}},"deny-set-as-app-menu":{"identifier":"deny-set-as-app-menu","description":"Denies the set_as_app_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_app_menu"]}},"deny-set-as-help-menu-for-nsapp":{"identifier":"deny-set-as-help-menu-for-nsapp","description":"Denies the set_as_help_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_help_menu_for_nsapp"]}},"deny-set-as-window-menu":{"identifier":"deny-set-as-window-menu","description":"Denies the set_as_window_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_window_menu"]}},"deny-set-as-windows-menu-for-nsapp":{"identifier":"deny-set-as-windows-menu-for-nsapp","description":"Denies the set_as_windows_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_windows_menu_for_nsapp"]}},"deny-set-checked":{"identifier":"deny-set-checked","description":"Denies the set_checked command without any pre-configured scope.","commands":{"allow":[],"deny":["set_checked"]}},"deny-set-enabled":{"identifier":"deny-set-enabled","description":"Denies the set_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_enabled"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-text":{"identifier":"deny-set-text","description":"Denies the set_text command without any pre-configured scope.","commands":{"allow":[],"deny":["set_text"]}},"deny-text":{"identifier":"deny-text","description":"Denies the text command without any pre-configured scope.","commands":{"allow":[],"deny":["text"]}}},"permission_sets":{},"global_scope_schema":null},"core:path":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-resolve-directory","allow-resolve","allow-normalize","allow-join","allow-dirname","allow-extname","allow-basename","allow-is-absolute"]},"permissions":{"allow-basename":{"identifier":"allow-basename","description":"Enables the basename command without any pre-configured scope.","commands":{"allow":["basename"],"deny":[]}},"allow-dirname":{"identifier":"allow-dirname","description":"Enables the dirname command without any pre-configured scope.","commands":{"allow":["dirname"],"deny":[]}},"allow-extname":{"identifier":"allow-extname","description":"Enables the extname command without any pre-configured scope.","commands":{"allow":["extname"],"deny":[]}},"allow-is-absolute":{"identifier":"allow-is-absolute","description":"Enables the is_absolute command without any pre-configured scope.","commands":{"allow":["is_absolute"],"deny":[]}},"allow-join":{"identifier":"allow-join","description":"Enables the join command without any pre-configured scope.","commands":{"allow":["join"],"deny":[]}},"allow-normalize":{"identifier":"allow-normalize","description":"Enables the normalize command without any pre-configured scope.","commands":{"allow":["normalize"],"deny":[]}},"allow-resolve":{"identifier":"allow-resolve","description":"Enables the resolve command without any pre-configured scope.","commands":{"allow":["resolve"],"deny":[]}},"allow-resolve-directory":{"identifier":"allow-resolve-directory","description":"Enables the resolve_directory command without any pre-configured scope.","commands":{"allow":["resolve_directory"],"deny":[]}},"deny-basename":{"identifier":"deny-basename","description":"Denies the basename command without any pre-configured scope.","commands":{"allow":[],"deny":["basename"]}},"deny-dirname":{"identifier":"deny-dirname","description":"Denies the dirname command without any pre-configured scope.","commands":{"allow":[],"deny":["dirname"]}},"deny-extname":{"identifier":"deny-extname","description":"Denies the extname command without any pre-configured scope.","commands":{"allow":[],"deny":["extname"]}},"deny-is-absolute":{"identifier":"deny-is-absolute","description":"Denies the is_absolute command without any pre-configured scope.","commands":{"allow":[],"deny":["is_absolute"]}},"deny-join":{"identifier":"deny-join","description":"Denies the join command without any pre-configured scope.","commands":{"allow":[],"deny":["join"]}},"deny-normalize":{"identifier":"deny-normalize","description":"Denies the normalize command without any pre-configured scope.","commands":{"allow":[],"deny":["normalize"]}},"deny-resolve":{"identifier":"deny-resolve","description":"Denies the resolve command without any pre-configured scope.","commands":{"allow":[],"deny":["resolve"]}},"deny-resolve-directory":{"identifier":"deny-resolve-directory","description":"Denies the resolve_directory command without any pre-configured scope.","commands":{"allow":[],"deny":["resolve_directory"]}}},"permission_sets":{},"global_scope_schema":null},"core:resources":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-close"]},"permissions":{"allow-close":{"identifier":"allow-close","description":"Enables the close command without any pre-configured scope.","commands":{"allow":["close"],"deny":[]}},"deny-close":{"identifier":"deny-close","description":"Denies the close command without any pre-configured scope.","commands":{"allow":[],"deny":["close"]}}},"permission_sets":{},"global_scope_schema":null},"core:tray":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-get-by-id","allow-remove-by-id","allow-set-icon","allow-set-menu","allow-set-tooltip","allow-set-title","allow-set-visible","allow-set-temp-dir-path","allow-set-icon-as-template","allow-set-icon-with-as-template","allow-set-show-menu-on-left-click"]},"permissions":{"allow-get-by-id":{"identifier":"allow-get-by-id","description":"Enables the get_by_id command without any pre-configured scope.","commands":{"allow":["get_by_id"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-remove-by-id":{"identifier":"allow-remove-by-id","description":"Enables the remove_by_id command without any pre-configured scope.","commands":{"allow":["remove_by_id"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-icon-as-template":{"identifier":"allow-set-icon-as-template","description":"Enables the set_icon_as_template command without any pre-configured scope.","commands":{"allow":["set_icon_as_template"],"deny":[]}},"allow-set-icon-with-as-template":{"identifier":"allow-set-icon-with-as-template","description":"Enables the set_icon_with_as_template command without any pre-configured scope.","commands":{"allow":["set_icon_with_as_template"],"deny":[]}},"allow-set-menu":{"identifier":"allow-set-menu","description":"Enables the set_menu command without any pre-configured scope.","commands":{"allow":["set_menu"],"deny":[]}},"allow-set-show-menu-on-left-click":{"identifier":"allow-set-show-menu-on-left-click","description":"Enables the set_show_menu_on_left_click command without any pre-configured scope.","commands":{"allow":["set_show_menu_on_left_click"],"deny":[]}},"allow-set-temp-dir-path":{"identifier":"allow-set-temp-dir-path","description":"Enables the set_temp_dir_path command without any pre-configured scope.","commands":{"allow":["set_temp_dir_path"],"deny":[]}},"allow-set-title":{"identifier":"allow-set-title","description":"Enables the set_title command without any pre-configured scope.","commands":{"allow":["set_title"],"deny":[]}},"allow-set-tooltip":{"identifier":"allow-set-tooltip","description":"Enables the set_tooltip command without any pre-configured scope.","commands":{"allow":["set_tooltip"],"deny":[]}},"allow-set-visible":{"identifier":"allow-set-visible","description":"Enables the set_visible command without any pre-configured scope.","commands":{"allow":["set_visible"],"deny":[]}},"deny-get-by-id":{"identifier":"deny-get-by-id","description":"Denies the get_by_id command without any pre-configured scope.","commands":{"allow":[],"deny":["get_by_id"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-remove-by-id":{"identifier":"deny-remove-by-id","description":"Denies the remove_by_id command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_by_id"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-icon-as-template":{"identifier":"deny-set-icon-as-template","description":"Denies the set_icon_as_template command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon_as_template"]}},"deny-set-icon-with-as-template":{"identifier":"deny-set-icon-with-as-template","description":"Denies the set_icon_with_as_template command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon_with_as_template"]}},"deny-set-menu":{"identifier":"deny-set-menu","description":"Denies the set_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_menu"]}},"deny-set-show-menu-on-left-click":{"identifier":"deny-set-show-menu-on-left-click","description":"Denies the set_show_menu_on_left_click command without any pre-configured scope.","commands":{"allow":[],"deny":["set_show_menu_on_left_click"]}},"deny-set-temp-dir-path":{"identifier":"deny-set-temp-dir-path","description":"Denies the set_temp_dir_path command without any pre-configured scope.","commands":{"allow":[],"deny":["set_temp_dir_path"]}},"deny-set-title":{"identifier":"deny-set-title","description":"Denies the set_title command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title"]}},"deny-set-tooltip":{"identifier":"deny-set-tooltip","description":"Denies the set_tooltip command without any pre-configured scope.","commands":{"allow":[],"deny":["set_tooltip"]}},"deny-set-visible":{"identifier":"deny-set-visible","description":"Denies the set_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["set_visible"]}}},"permission_sets":{},"global_scope_schema":null},"core:webview":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-get-all-webviews","allow-webview-position","allow-webview-size","allow-internal-toggle-devtools"]},"permissions":{"allow-clear-all-browsing-data":{"identifier":"allow-clear-all-browsing-data","description":"Enables the clear_all_browsing_data command without any pre-configured scope.","commands":{"allow":["clear_all_browsing_data"],"deny":[]}},"allow-create-webview":{"identifier":"allow-create-webview","description":"Enables the create_webview command without any pre-configured scope.","commands":{"allow":["create_webview"],"deny":[]}},"allow-create-webview-window":{"identifier":"allow-create-webview-window","description":"Enables the create_webview_window command without any pre-configured scope.","commands":{"allow":["create_webview_window"],"deny":[]}},"allow-get-all-webviews":{"identifier":"allow-get-all-webviews","description":"Enables the get_all_webviews command without any pre-configured scope.","commands":{"allow":["get_all_webviews"],"deny":[]}},"allow-internal-toggle-devtools":{"identifier":"allow-internal-toggle-devtools","description":"Enables the internal_toggle_devtools command without any pre-configured scope.","commands":{"allow":["internal_toggle_devtools"],"deny":[]}},"allow-print":{"identifier":"allow-print","description":"Enables the print command without any pre-configured scope.","commands":{"allow":["print"],"deny":[]}},"allow-reparent":{"identifier":"allow-reparent","description":"Enables the reparent command without any pre-configured scope.","commands":{"allow":["reparent"],"deny":[]}},"allow-set-webview-auto-resize":{"identifier":"allow-set-webview-auto-resize","description":"Enables the set_webview_auto_resize command without any pre-configured scope.","commands":{"allow":["set_webview_auto_resize"],"deny":[]}},"allow-set-webview-background-color":{"identifier":"allow-set-webview-background-color","description":"Enables the set_webview_background_color command without any pre-configured scope.","commands":{"allow":["set_webview_background_color"],"deny":[]}},"allow-set-webview-focus":{"identifier":"allow-set-webview-focus","description":"Enables the set_webview_focus command without any pre-configured scope.","commands":{"allow":["set_webview_focus"],"deny":[]}},"allow-set-webview-position":{"identifier":"allow-set-webview-position","description":"Enables the set_webview_position command without any pre-configured scope.","commands":{"allow":["set_webview_position"],"deny":[]}},"allow-set-webview-size":{"identifier":"allow-set-webview-size","description":"Enables the set_webview_size command without any pre-configured scope.","commands":{"allow":["set_webview_size"],"deny":[]}},"allow-set-webview-zoom":{"identifier":"allow-set-webview-zoom","description":"Enables the set_webview_zoom command without any pre-configured scope.","commands":{"allow":["set_webview_zoom"],"deny":[]}},"allow-webview-close":{"identifier":"allow-webview-close","description":"Enables the webview_close command without any pre-configured scope.","commands":{"allow":["webview_close"],"deny":[]}},"allow-webview-hide":{"identifier":"allow-webview-hide","description":"Enables the webview_hide command without any pre-configured scope.","commands":{"allow":["webview_hide"],"deny":[]}},"allow-webview-position":{"identifier":"allow-webview-position","description":"Enables the webview_position command without any pre-configured scope.","commands":{"allow":["webview_position"],"deny":[]}},"allow-webview-show":{"identifier":"allow-webview-show","description":"Enables the webview_show command without any pre-configured scope.","commands":{"allow":["webview_show"],"deny":[]}},"allow-webview-size":{"identifier":"allow-webview-size","description":"Enables the webview_size command without any pre-configured scope.","commands":{"allow":["webview_size"],"deny":[]}},"deny-clear-all-browsing-data":{"identifier":"deny-clear-all-browsing-data","description":"Denies the clear_all_browsing_data command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_all_browsing_data"]}},"deny-create-webview":{"identifier":"deny-create-webview","description":"Denies the create_webview command without any pre-configured scope.","commands":{"allow":[],"deny":["create_webview"]}},"deny-create-webview-window":{"identifier":"deny-create-webview-window","description":"Denies the create_webview_window command without any pre-configured scope.","commands":{"allow":[],"deny":["create_webview_window"]}},"deny-get-all-webviews":{"identifier":"deny-get-all-webviews","description":"Denies the get_all_webviews command without any pre-configured scope.","commands":{"allow":[],"deny":["get_all_webviews"]}},"deny-internal-toggle-devtools":{"identifier":"deny-internal-toggle-devtools","description":"Denies the internal_toggle_devtools command without any pre-configured scope.","commands":{"allow":[],"deny":["internal_toggle_devtools"]}},"deny-print":{"identifier":"deny-print","description":"Denies the print command without any pre-configured scope.","commands":{"allow":[],"deny":["print"]}},"deny-reparent":{"identifier":"deny-reparent","description":"Denies the reparent command without any pre-configured scope.","commands":{"allow":[],"deny":["reparent"]}},"deny-set-webview-auto-resize":{"identifier":"deny-set-webview-auto-resize","description":"Denies the set_webview_auto_resize command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_auto_resize"]}},"deny-set-webview-background-color":{"identifier":"deny-set-webview-background-color","description":"Denies the set_webview_background_color command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_background_color"]}},"deny-set-webview-focus":{"identifier":"deny-set-webview-focus","description":"Denies the set_webview_focus command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_focus"]}},"deny-set-webview-position":{"identifier":"deny-set-webview-position","description":"Denies the set_webview_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_position"]}},"deny-set-webview-size":{"identifier":"deny-set-webview-size","description":"Denies the set_webview_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_size"]}},"deny-set-webview-zoom":{"identifier":"deny-set-webview-zoom","description":"Denies the set_webview_zoom command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_zoom"]}},"deny-webview-close":{"identifier":"deny-webview-close","description":"Denies the webview_close command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_close"]}},"deny-webview-hide":{"identifier":"deny-webview-hide","description":"Denies the webview_hide command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_hide"]}},"deny-webview-position":{"identifier":"deny-webview-position","description":"Denies the webview_position command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_position"]}},"deny-webview-show":{"identifier":"deny-webview-show","description":"Denies the webview_show command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_show"]}},"deny-webview-size":{"identifier":"deny-webview-size","description":"Denies the webview_size command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_size"]}}},"permission_sets":{},"global_scope_schema":null},"core:window":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-get-all-windows","allow-scale-factor","allow-inner-position","allow-outer-position","allow-inner-size","allow-outer-size","allow-is-fullscreen","allow-is-minimized","allow-is-maximized","allow-is-focused","allow-is-decorated","allow-is-resizable","allow-is-maximizable","allow-is-minimizable","allow-is-closable","allow-is-visible","allow-is-enabled","allow-title","allow-current-monitor","allow-primary-monitor","allow-monitor-from-point","allow-available-monitors","allow-cursor-position","allow-theme","allow-is-always-on-top","allow-activity-name","allow-scene-identifier","allow-internal-toggle-maximize"]},"permissions":{"allow-activity-name":{"identifier":"allow-activity-name","description":"Enables the activity_name command without any pre-configured scope.","commands":{"allow":["activity_name"],"deny":[]}},"allow-available-monitors":{"identifier":"allow-available-monitors","description":"Enables the available_monitors command without any pre-configured scope.","commands":{"allow":["available_monitors"],"deny":[]}},"allow-center":{"identifier":"allow-center","description":"Enables the center command without any pre-configured scope.","commands":{"allow":["center"],"deny":[]}},"allow-close":{"identifier":"allow-close","description":"Enables the close command without any pre-configured scope.","commands":{"allow":["close"],"deny":[]}},"allow-create":{"identifier":"allow-create","description":"Enables the create command without any pre-configured scope.","commands":{"allow":["create"],"deny":[]}},"allow-current-monitor":{"identifier":"allow-current-monitor","description":"Enables the current_monitor command without any pre-configured scope.","commands":{"allow":["current_monitor"],"deny":[]}},"allow-cursor-position":{"identifier":"allow-cursor-position","description":"Enables the cursor_position command without any pre-configured scope.","commands":{"allow":["cursor_position"],"deny":[]}},"allow-destroy":{"identifier":"allow-destroy","description":"Enables the destroy command without any pre-configured scope.","commands":{"allow":["destroy"],"deny":[]}},"allow-get-all-windows":{"identifier":"allow-get-all-windows","description":"Enables the get_all_windows command without any pre-configured scope.","commands":{"allow":["get_all_windows"],"deny":[]}},"allow-hide":{"identifier":"allow-hide","description":"Enables the hide command without any pre-configured scope.","commands":{"allow":["hide"],"deny":[]}},"allow-inner-position":{"identifier":"allow-inner-position","description":"Enables the inner_position command without any pre-configured scope.","commands":{"allow":["inner_position"],"deny":[]}},"allow-inner-size":{"identifier":"allow-inner-size","description":"Enables the inner_size command without any pre-configured scope.","commands":{"allow":["inner_size"],"deny":[]}},"allow-internal-toggle-maximize":{"identifier":"allow-internal-toggle-maximize","description":"Enables the internal_toggle_maximize command without any pre-configured scope.","commands":{"allow":["internal_toggle_maximize"],"deny":[]}},"allow-is-always-on-top":{"identifier":"allow-is-always-on-top","description":"Enables the is_always_on_top command without any pre-configured scope.","commands":{"allow":["is_always_on_top"],"deny":[]}},"allow-is-closable":{"identifier":"allow-is-closable","description":"Enables the is_closable command without any pre-configured scope.","commands":{"allow":["is_closable"],"deny":[]}},"allow-is-decorated":{"identifier":"allow-is-decorated","description":"Enables the is_decorated command without any pre-configured scope.","commands":{"allow":["is_decorated"],"deny":[]}},"allow-is-enabled":{"identifier":"allow-is-enabled","description":"Enables the is_enabled command without any pre-configured scope.","commands":{"allow":["is_enabled"],"deny":[]}},"allow-is-focused":{"identifier":"allow-is-focused","description":"Enables the is_focused command without any pre-configured scope.","commands":{"allow":["is_focused"],"deny":[]}},"allow-is-fullscreen":{"identifier":"allow-is-fullscreen","description":"Enables the is_fullscreen command without any pre-configured scope.","commands":{"allow":["is_fullscreen"],"deny":[]}},"allow-is-maximizable":{"identifier":"allow-is-maximizable","description":"Enables the is_maximizable command without any pre-configured scope.","commands":{"allow":["is_maximizable"],"deny":[]}},"allow-is-maximized":{"identifier":"allow-is-maximized","description":"Enables the is_maximized command without any pre-configured scope.","commands":{"allow":["is_maximized"],"deny":[]}},"allow-is-minimizable":{"identifier":"allow-is-minimizable","description":"Enables the is_minimizable command without any pre-configured scope.","commands":{"allow":["is_minimizable"],"deny":[]}},"allow-is-minimized":{"identifier":"allow-is-minimized","description":"Enables the is_minimized command without any pre-configured scope.","commands":{"allow":["is_minimized"],"deny":[]}},"allow-is-resizable":{"identifier":"allow-is-resizable","description":"Enables the is_resizable command without any pre-configured scope.","commands":{"allow":["is_resizable"],"deny":[]}},"allow-is-visible":{"identifier":"allow-is-visible","description":"Enables the is_visible command without any pre-configured scope.","commands":{"allow":["is_visible"],"deny":[]}},"allow-maximize":{"identifier":"allow-maximize","description":"Enables the maximize command without any pre-configured scope.","commands":{"allow":["maximize"],"deny":[]}},"allow-minimize":{"identifier":"allow-minimize","description":"Enables the minimize command without any pre-configured scope.","commands":{"allow":["minimize"],"deny":[]}},"allow-monitor-from-point":{"identifier":"allow-monitor-from-point","description":"Enables the monitor_from_point command without any pre-configured scope.","commands":{"allow":["monitor_from_point"],"deny":[]}},"allow-outer-position":{"identifier":"allow-outer-position","description":"Enables the outer_position command without any pre-configured scope.","commands":{"allow":["outer_position"],"deny":[]}},"allow-outer-size":{"identifier":"allow-outer-size","description":"Enables the outer_size command without any pre-configured scope.","commands":{"allow":["outer_size"],"deny":[]}},"allow-primary-monitor":{"identifier":"allow-primary-monitor","description":"Enables the primary_monitor command without any pre-configured scope.","commands":{"allow":["primary_monitor"],"deny":[]}},"allow-request-user-attention":{"identifier":"allow-request-user-attention","description":"Enables the request_user_attention command without any pre-configured scope.","commands":{"allow":["request_user_attention"],"deny":[]}},"allow-scale-factor":{"identifier":"allow-scale-factor","description":"Enables the scale_factor command without any pre-configured scope.","commands":{"allow":["scale_factor"],"deny":[]}},"allow-scene-identifier":{"identifier":"allow-scene-identifier","description":"Enables the scene_identifier command without any pre-configured scope.","commands":{"allow":["scene_identifier"],"deny":[]}},"allow-set-always-on-bottom":{"identifier":"allow-set-always-on-bottom","description":"Enables the set_always_on_bottom command without any pre-configured scope.","commands":{"allow":["set_always_on_bottom"],"deny":[]}},"allow-set-always-on-top":{"identifier":"allow-set-always-on-top","description":"Enables the set_always_on_top command without any pre-configured scope.","commands":{"allow":["set_always_on_top"],"deny":[]}},"allow-set-background-color":{"identifier":"allow-set-background-color","description":"Enables the set_background_color command without any pre-configured scope.","commands":{"allow":["set_background_color"],"deny":[]}},"allow-set-badge-count":{"identifier":"allow-set-badge-count","description":"Enables the set_badge_count command without any pre-configured scope.","commands":{"allow":["set_badge_count"],"deny":[]}},"allow-set-badge-label":{"identifier":"allow-set-badge-label","description":"Enables the set_badge_label command without any pre-configured scope.","commands":{"allow":["set_badge_label"],"deny":[]}},"allow-set-closable":{"identifier":"allow-set-closable","description":"Enables the set_closable command without any pre-configured scope.","commands":{"allow":["set_closable"],"deny":[]}},"allow-set-content-protected":{"identifier":"allow-set-content-protected","description":"Enables the set_content_protected command without any pre-configured scope.","commands":{"allow":["set_content_protected"],"deny":[]}},"allow-set-cursor-grab":{"identifier":"allow-set-cursor-grab","description":"Enables the set_cursor_grab command without any pre-configured scope.","commands":{"allow":["set_cursor_grab"],"deny":[]}},"allow-set-cursor-icon":{"identifier":"allow-set-cursor-icon","description":"Enables the set_cursor_icon command without any pre-configured scope.","commands":{"allow":["set_cursor_icon"],"deny":[]}},"allow-set-cursor-position":{"identifier":"allow-set-cursor-position","description":"Enables the set_cursor_position command without any pre-configured scope.","commands":{"allow":["set_cursor_position"],"deny":[]}},"allow-set-cursor-visible":{"identifier":"allow-set-cursor-visible","description":"Enables the set_cursor_visible command without any pre-configured scope.","commands":{"allow":["set_cursor_visible"],"deny":[]}},"allow-set-decorations":{"identifier":"allow-set-decorations","description":"Enables the set_decorations command without any pre-configured scope.","commands":{"allow":["set_decorations"],"deny":[]}},"allow-set-effects":{"identifier":"allow-set-effects","description":"Enables the set_effects command without any pre-configured scope.","commands":{"allow":["set_effects"],"deny":[]}},"allow-set-enabled":{"identifier":"allow-set-enabled","description":"Enables the set_enabled command without any pre-configured scope.","commands":{"allow":["set_enabled"],"deny":[]}},"allow-set-focus":{"identifier":"allow-set-focus","description":"Enables the set_focus command without any pre-configured scope.","commands":{"allow":["set_focus"],"deny":[]}},"allow-set-focusable":{"identifier":"allow-set-focusable","description":"Enables the set_focusable command without any pre-configured scope.","commands":{"allow":["set_focusable"],"deny":[]}},"allow-set-fullscreen":{"identifier":"allow-set-fullscreen","description":"Enables the set_fullscreen command without any pre-configured scope.","commands":{"allow":["set_fullscreen"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-ignore-cursor-events":{"identifier":"allow-set-ignore-cursor-events","description":"Enables the set_ignore_cursor_events command without any pre-configured scope.","commands":{"allow":["set_ignore_cursor_events"],"deny":[]}},"allow-set-max-size":{"identifier":"allow-set-max-size","description":"Enables the set_max_size command without any pre-configured scope.","commands":{"allow":["set_max_size"],"deny":[]}},"allow-set-maximizable":{"identifier":"allow-set-maximizable","description":"Enables the set_maximizable command without any pre-configured scope.","commands":{"allow":["set_maximizable"],"deny":[]}},"allow-set-min-size":{"identifier":"allow-set-min-size","description":"Enables the set_min_size command without any pre-configured scope.","commands":{"allow":["set_min_size"],"deny":[]}},"allow-set-minimizable":{"identifier":"allow-set-minimizable","description":"Enables the set_minimizable command without any pre-configured scope.","commands":{"allow":["set_minimizable"],"deny":[]}},"allow-set-overlay-icon":{"identifier":"allow-set-overlay-icon","description":"Enables the set_overlay_icon command without any pre-configured scope.","commands":{"allow":["set_overlay_icon"],"deny":[]}},"allow-set-position":{"identifier":"allow-set-position","description":"Enables the set_position command without any pre-configured scope.","commands":{"allow":["set_position"],"deny":[]}},"allow-set-progress-bar":{"identifier":"allow-set-progress-bar","description":"Enables the set_progress_bar command without any pre-configured scope.","commands":{"allow":["set_progress_bar"],"deny":[]}},"allow-set-resizable":{"identifier":"allow-set-resizable","description":"Enables the set_resizable command without any pre-configured scope.","commands":{"allow":["set_resizable"],"deny":[]}},"allow-set-shadow":{"identifier":"allow-set-shadow","description":"Enables the set_shadow command without any pre-configured scope.","commands":{"allow":["set_shadow"],"deny":[]}},"allow-set-simple-fullscreen":{"identifier":"allow-set-simple-fullscreen","description":"Enables the set_simple_fullscreen command without any pre-configured scope.","commands":{"allow":["set_simple_fullscreen"],"deny":[]}},"allow-set-size":{"identifier":"allow-set-size","description":"Enables the set_size command without any pre-configured scope.","commands":{"allow":["set_size"],"deny":[]}},"allow-set-size-constraints":{"identifier":"allow-set-size-constraints","description":"Enables the set_size_constraints command without any pre-configured scope.","commands":{"allow":["set_size_constraints"],"deny":[]}},"allow-set-skip-taskbar":{"identifier":"allow-set-skip-taskbar","description":"Enables the set_skip_taskbar command without any pre-configured scope.","commands":{"allow":["set_skip_taskbar"],"deny":[]}},"allow-set-theme":{"identifier":"allow-set-theme","description":"Enables the set_theme command without any pre-configured scope.","commands":{"allow":["set_theme"],"deny":[]}},"allow-set-title":{"identifier":"allow-set-title","description":"Enables the set_title command without any pre-configured scope.","commands":{"allow":["set_title"],"deny":[]}},"allow-set-title-bar-style":{"identifier":"allow-set-title-bar-style","description":"Enables the set_title_bar_style command without any pre-configured scope.","commands":{"allow":["set_title_bar_style"],"deny":[]}},"allow-set-visible-on-all-workspaces":{"identifier":"allow-set-visible-on-all-workspaces","description":"Enables the set_visible_on_all_workspaces command without any pre-configured scope.","commands":{"allow":["set_visible_on_all_workspaces"],"deny":[]}},"allow-show":{"identifier":"allow-show","description":"Enables the show command without any pre-configured scope.","commands":{"allow":["show"],"deny":[]}},"allow-start-dragging":{"identifier":"allow-start-dragging","description":"Enables the start_dragging command without any pre-configured scope.","commands":{"allow":["start_dragging"],"deny":[]}},"allow-start-resize-dragging":{"identifier":"allow-start-resize-dragging","description":"Enables the start_resize_dragging command without any pre-configured scope.","commands":{"allow":["start_resize_dragging"],"deny":[]}},"allow-theme":{"identifier":"allow-theme","description":"Enables the theme command without any pre-configured scope.","commands":{"allow":["theme"],"deny":[]}},"allow-title":{"identifier":"allow-title","description":"Enables the title command without any pre-configured scope.","commands":{"allow":["title"],"deny":[]}},"allow-toggle-maximize":{"identifier":"allow-toggle-maximize","description":"Enables the toggle_maximize command without any pre-configured scope.","commands":{"allow":["toggle_maximize"],"deny":[]}},"allow-unmaximize":{"identifier":"allow-unmaximize","description":"Enables the unmaximize command without any pre-configured scope.","commands":{"allow":["unmaximize"],"deny":[]}},"allow-unminimize":{"identifier":"allow-unminimize","description":"Enables the unminimize command without any pre-configured scope.","commands":{"allow":["unminimize"],"deny":[]}},"deny-activity-name":{"identifier":"deny-activity-name","description":"Denies the activity_name command without any pre-configured scope.","commands":{"allow":[],"deny":["activity_name"]}},"deny-available-monitors":{"identifier":"deny-available-monitors","description":"Denies the available_monitors command without any pre-configured scope.","commands":{"allow":[],"deny":["available_monitors"]}},"deny-center":{"identifier":"deny-center","description":"Denies the center command without any pre-configured scope.","commands":{"allow":[],"deny":["center"]}},"deny-close":{"identifier":"deny-close","description":"Denies the close command without any pre-configured scope.","commands":{"allow":[],"deny":["close"]}},"deny-create":{"identifier":"deny-create","description":"Denies the create command without any pre-configured scope.","commands":{"allow":[],"deny":["create"]}},"deny-current-monitor":{"identifier":"deny-current-monitor","description":"Denies the current_monitor command without any pre-configured scope.","commands":{"allow":[],"deny":["current_monitor"]}},"deny-cursor-position":{"identifier":"deny-cursor-position","description":"Denies the cursor_position command without any pre-configured scope.","commands":{"allow":[],"deny":["cursor_position"]}},"deny-destroy":{"identifier":"deny-destroy","description":"Denies the destroy command without any pre-configured scope.","commands":{"allow":[],"deny":["destroy"]}},"deny-get-all-windows":{"identifier":"deny-get-all-windows","description":"Denies the get_all_windows command without any pre-configured scope.","commands":{"allow":[],"deny":["get_all_windows"]}},"deny-hide":{"identifier":"deny-hide","description":"Denies the hide command without any pre-configured scope.","commands":{"allow":[],"deny":["hide"]}},"deny-inner-position":{"identifier":"deny-inner-position","description":"Denies the inner_position command without any pre-configured scope.","commands":{"allow":[],"deny":["inner_position"]}},"deny-inner-size":{"identifier":"deny-inner-size","description":"Denies the inner_size command without any pre-configured scope.","commands":{"allow":[],"deny":["inner_size"]}},"deny-internal-toggle-maximize":{"identifier":"deny-internal-toggle-maximize","description":"Denies the internal_toggle_maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["internal_toggle_maximize"]}},"deny-is-always-on-top":{"identifier":"deny-is-always-on-top","description":"Denies the is_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["is_always_on_top"]}},"deny-is-closable":{"identifier":"deny-is-closable","description":"Denies the is_closable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_closable"]}},"deny-is-decorated":{"identifier":"deny-is-decorated","description":"Denies the is_decorated command without any pre-configured scope.","commands":{"allow":[],"deny":["is_decorated"]}},"deny-is-enabled":{"identifier":"deny-is-enabled","description":"Denies the is_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["is_enabled"]}},"deny-is-focused":{"identifier":"deny-is-focused","description":"Denies the is_focused command without any pre-configured scope.","commands":{"allow":[],"deny":["is_focused"]}},"deny-is-fullscreen":{"identifier":"deny-is-fullscreen","description":"Denies the is_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["is_fullscreen"]}},"deny-is-maximizable":{"identifier":"deny-is-maximizable","description":"Denies the is_maximizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_maximizable"]}},"deny-is-maximized":{"identifier":"deny-is-maximized","description":"Denies the is_maximized command without any pre-configured scope.","commands":{"allow":[],"deny":["is_maximized"]}},"deny-is-minimizable":{"identifier":"deny-is-minimizable","description":"Denies the is_minimizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_minimizable"]}},"deny-is-minimized":{"identifier":"deny-is-minimized","description":"Denies the is_minimized command without any pre-configured scope.","commands":{"allow":[],"deny":["is_minimized"]}},"deny-is-resizable":{"identifier":"deny-is-resizable","description":"Denies the is_resizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_resizable"]}},"deny-is-visible":{"identifier":"deny-is-visible","description":"Denies the is_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["is_visible"]}},"deny-maximize":{"identifier":"deny-maximize","description":"Denies the maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["maximize"]}},"deny-minimize":{"identifier":"deny-minimize","description":"Denies the minimize command without any pre-configured scope.","commands":{"allow":[],"deny":["minimize"]}},"deny-monitor-from-point":{"identifier":"deny-monitor-from-point","description":"Denies the monitor_from_point command without any pre-configured scope.","commands":{"allow":[],"deny":["monitor_from_point"]}},"deny-outer-position":{"identifier":"deny-outer-position","description":"Denies the outer_position command without any pre-configured scope.","commands":{"allow":[],"deny":["outer_position"]}},"deny-outer-size":{"identifier":"deny-outer-size","description":"Denies the outer_size command without any pre-configured scope.","commands":{"allow":[],"deny":["outer_size"]}},"deny-primary-monitor":{"identifier":"deny-primary-monitor","description":"Denies the primary_monitor command without any pre-configured scope.","commands":{"allow":[],"deny":["primary_monitor"]}},"deny-request-user-attention":{"identifier":"deny-request-user-attention","description":"Denies the request_user_attention command without any pre-configured scope.","commands":{"allow":[],"deny":["request_user_attention"]}},"deny-scale-factor":{"identifier":"deny-scale-factor","description":"Denies the scale_factor command without any pre-configured scope.","commands":{"allow":[],"deny":["scale_factor"]}},"deny-scene-identifier":{"identifier":"deny-scene-identifier","description":"Denies the scene_identifier command without any pre-configured scope.","commands":{"allow":[],"deny":["scene_identifier"]}},"deny-set-always-on-bottom":{"identifier":"deny-set-always-on-bottom","description":"Denies the set_always_on_bottom command without any pre-configured scope.","commands":{"allow":[],"deny":["set_always_on_bottom"]}},"deny-set-always-on-top":{"identifier":"deny-set-always-on-top","description":"Denies the set_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["set_always_on_top"]}},"deny-set-background-color":{"identifier":"deny-set-background-color","description":"Denies the set_background_color command without any pre-configured scope.","commands":{"allow":[],"deny":["set_background_color"]}},"deny-set-badge-count":{"identifier":"deny-set-badge-count","description":"Denies the set_badge_count command without any pre-configured scope.","commands":{"allow":[],"deny":["set_badge_count"]}},"deny-set-badge-label":{"identifier":"deny-set-badge-label","description":"Denies the set_badge_label command without any pre-configured scope.","commands":{"allow":[],"deny":["set_badge_label"]}},"deny-set-closable":{"identifier":"deny-set-closable","description":"Denies the set_closable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_closable"]}},"deny-set-content-protected":{"identifier":"deny-set-content-protected","description":"Denies the set_content_protected command without any pre-configured scope.","commands":{"allow":[],"deny":["set_content_protected"]}},"deny-set-cursor-grab":{"identifier":"deny-set-cursor-grab","description":"Denies the set_cursor_grab command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_grab"]}},"deny-set-cursor-icon":{"identifier":"deny-set-cursor-icon","description":"Denies the set_cursor_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_icon"]}},"deny-set-cursor-position":{"identifier":"deny-set-cursor-position","description":"Denies the set_cursor_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_position"]}},"deny-set-cursor-visible":{"identifier":"deny-set-cursor-visible","description":"Denies the set_cursor_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_visible"]}},"deny-set-decorations":{"identifier":"deny-set-decorations","description":"Denies the set_decorations command without any pre-configured scope.","commands":{"allow":[],"deny":["set_decorations"]}},"deny-set-effects":{"identifier":"deny-set-effects","description":"Denies the set_effects command without any pre-configured scope.","commands":{"allow":[],"deny":["set_effects"]}},"deny-set-enabled":{"identifier":"deny-set-enabled","description":"Denies the set_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_enabled"]}},"deny-set-focus":{"identifier":"deny-set-focus","description":"Denies the set_focus command without any pre-configured scope.","commands":{"allow":[],"deny":["set_focus"]}},"deny-set-focusable":{"identifier":"deny-set-focusable","description":"Denies the set_focusable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_focusable"]}},"deny-set-fullscreen":{"identifier":"deny-set-fullscreen","description":"Denies the set_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["set_fullscreen"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-ignore-cursor-events":{"identifier":"deny-set-ignore-cursor-events","description":"Denies the set_ignore_cursor_events command without any pre-configured scope.","commands":{"allow":[],"deny":["set_ignore_cursor_events"]}},"deny-set-max-size":{"identifier":"deny-set-max-size","description":"Denies the set_max_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_max_size"]}},"deny-set-maximizable":{"identifier":"deny-set-maximizable","description":"Denies the set_maximizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_maximizable"]}},"deny-set-min-size":{"identifier":"deny-set-min-size","description":"Denies the set_min_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_min_size"]}},"deny-set-minimizable":{"identifier":"deny-set-minimizable","description":"Denies the set_minimizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_minimizable"]}},"deny-set-overlay-icon":{"identifier":"deny-set-overlay-icon","description":"Denies the set_overlay_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_overlay_icon"]}},"deny-set-position":{"identifier":"deny-set-position","description":"Denies the set_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_position"]}},"deny-set-progress-bar":{"identifier":"deny-set-progress-bar","description":"Denies the set_progress_bar command without any pre-configured scope.","commands":{"allow":[],"deny":["set_progress_bar"]}},"deny-set-resizable":{"identifier":"deny-set-resizable","description":"Denies the set_resizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_resizable"]}},"deny-set-shadow":{"identifier":"deny-set-shadow","description":"Denies the set_shadow command without any pre-configured scope.","commands":{"allow":[],"deny":["set_shadow"]}},"deny-set-simple-fullscreen":{"identifier":"deny-set-simple-fullscreen","description":"Denies the set_simple_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["set_simple_fullscreen"]}},"deny-set-size":{"identifier":"deny-set-size","description":"Denies the set_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_size"]}},"deny-set-size-constraints":{"identifier":"deny-set-size-constraints","description":"Denies the set_size_constraints command without any pre-configured scope.","commands":{"allow":[],"deny":["set_size_constraints"]}},"deny-set-skip-taskbar":{"identifier":"deny-set-skip-taskbar","description":"Denies the set_skip_taskbar command without any pre-configured scope.","commands":{"allow":[],"deny":["set_skip_taskbar"]}},"deny-set-theme":{"identifier":"deny-set-theme","description":"Denies the set_theme command without any pre-configured scope.","commands":{"allow":[],"deny":["set_theme"]}},"deny-set-title":{"identifier":"deny-set-title","description":"Denies the set_title command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title"]}},"deny-set-title-bar-style":{"identifier":"deny-set-title-bar-style","description":"Denies the set_title_bar_style command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title_bar_style"]}},"deny-set-visible-on-all-workspaces":{"identifier":"deny-set-visible-on-all-workspaces","description":"Denies the set_visible_on_all_workspaces command without any pre-configured scope.","commands":{"allow":[],"deny":["set_visible_on_all_workspaces"]}},"deny-show":{"identifier":"deny-show","description":"Denies the show command without any pre-configured scope.","commands":{"allow":[],"deny":["show"]}},"deny-start-dragging":{"identifier":"deny-start-dragging","description":"Denies the start_dragging command without any pre-configured scope.","commands":{"allow":[],"deny":["start_dragging"]}},"deny-start-resize-dragging":{"identifier":"deny-start-resize-dragging","description":"Denies the start_resize_dragging command without any pre-configured scope.","commands":{"allow":[],"deny":["start_resize_dragging"]}},"deny-theme":{"identifier":"deny-theme","description":"Denies the theme command without any pre-configured scope.","commands":{"allow":[],"deny":["theme"]}},"deny-title":{"identifier":"deny-title","description":"Denies the title command without any pre-configured scope.","commands":{"allow":[],"deny":["title"]}},"deny-toggle-maximize":{"identifier":"deny-toggle-maximize","description":"Denies the toggle_maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["toggle_maximize"]}},"deny-unmaximize":{"identifier":"deny-unmaximize","description":"Denies the unmaximize command without any pre-configured scope.","commands":{"allow":[],"deny":["unmaximize"]}},"deny-unminimize":{"identifier":"deny-unminimize","description":"Denies the unminimize command without any pre-configured scope.","commands":{"allow":[],"deny":["unminimize"]}}},"permission_sets":{},"global_scope_schema":null},"dialog":{"default_permission":{"identifier":"default","description":"This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n","permissions":["allow-message","allow-save","allow-open"]},"permissions":{"allow-ask":{"identifier":"allow-ask","description":"Enables the ask command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `allow-message` and will be removed in v3)","commands":{"allow":["message"],"deny":[]}},"allow-confirm":{"identifier":"allow-confirm","description":"Enables the confirm command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `allow-message` and will be removed in v3)","commands":{"allow":["message"],"deny":[]}},"allow-message":{"identifier":"allow-message","description":"Enables the message command without any pre-configured scope.","commands":{"allow":["message"],"deny":[]}},"allow-open":{"identifier":"allow-open","description":"Enables the open command without any pre-configured scope.","commands":{"allow":["open"],"deny":[]}},"allow-save":{"identifier":"allow-save","description":"Enables the save command without any pre-configured scope.","commands":{"allow":["save"],"deny":[]}},"deny-ask":{"identifier":"deny-ask","description":"Denies the ask command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `deny-message` and will be removed in v3)","commands":{"allow":[],"deny":["message"]}},"deny-confirm":{"identifier":"deny-confirm","description":"Denies the confirm command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `deny-message` and will be removed in v3)","commands":{"allow":[],"deny":["message"]}},"deny-message":{"identifier":"deny-message","description":"Denies the message command without any pre-configured scope.","commands":{"allow":[],"deny":["message"]}},"deny-open":{"identifier":"deny-open","description":"Denies the open command without any pre-configured scope.","commands":{"allow":[],"deny":["open"]}},"deny-save":{"identifier":"deny-save","description":"Denies the save command without any pre-configured scope.","commands":{"allow":[],"deny":["save"]}}},"permission_sets":{},"global_scope_schema":null},"opener":{"default_permission":{"identifier":"default","description":"This permission set allows opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application\nas well as reveal file in directories using default file explorer","permissions":["allow-open-url","allow-reveal-item-in-dir","allow-default-urls"]},"permissions":{"allow-default-urls":{"identifier":"allow-default-urls","description":"This enables opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application.","commands":{"allow":[],"deny":[]},"scope":{"allow":[{"url":"mailto:*"},{"url":"tel:*"},{"url":"http://*"},{"url":"https://*"}]}},"allow-open-path":{"identifier":"allow-open-path","description":"Enables the open_path command without any pre-configured scope.","commands":{"allow":["open_path"],"deny":[]}},"allow-open-url":{"identifier":"allow-open-url","description":"Enables the open_url command without any pre-configured scope.","commands":{"allow":["open_url"],"deny":[]}},"allow-reveal-item-in-dir":{"identifier":"allow-reveal-item-in-dir","description":"Enables the reveal_item_in_dir command without any pre-configured scope.","commands":{"allow":["reveal_item_in_dir"],"deny":[]}},"deny-open-path":{"identifier":"deny-open-path","description":"Denies the open_path command without any pre-configured scope.","commands":{"allow":[],"deny":["open_path"]}},"deny-open-url":{"identifier":"deny-open-url","description":"Denies the open_url command without any pre-configured scope.","commands":{"allow":[],"deny":["open_url"]}},"deny-reveal-item-in-dir":{"identifier":"deny-reveal-item-in-dir","description":"Denies the reveal_item_in_dir command without any pre-configured scope.","commands":{"allow":[],"deny":["reveal_item_in_dir"]}}},"permission_sets":{},"global_scope_schema":{"$schema":"http://json-schema.org/draft-07/schema#","anyOf":[{"properties":{"app":{"allOf":[{"$ref":"#/definitions/Application"}],"description":"An application to open this url with, for example: firefox."},"url":{"description":"A URL that can be opened by the webview when using the Opener APIs.\n\nWildcards can be used following the UNIX glob pattern.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"","type":"string"}},"required":["url"],"type":"object"},{"properties":{"app":{"allOf":[{"$ref":"#/definitions/Application"}],"description":"An application to open this path with, for example: xdg-open."},"path":{"description":"A path that can be opened by the webview when using the Opener APIs.\n\nThe pattern can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.","type":"string"}},"required":["path"],"type":"object"}],"definitions":{"Application":{"anyOf":[{"description":"Open in default application.","type":"null"},{"description":"If true, allow open with any application.","type":"boolean"},{"description":"Allow specific application to open with.","type":"string"}],"description":"Opener scope application."}},"description":"Opener scope entry.","title":"OpenerScopeEntry"}}} \ No newline at end of file diff --git a/app/src-tauri/gen/schemas/capabilities.json b/app/src-tauri/gen/schemas/capabilities.json index 1be6a10..4e459fa 100644 --- a/app/src-tauri/gen/schemas/capabilities.json +++ b/app/src-tauri/gen/schemas/capabilities.json @@ -1 +1 @@ -{"default":{"identifier":"default","description":"Default capabilities for Triple-C. Every entry here is an IPC command a compromised webview can call directly, so the set is an enumeration of what `app/src` actually invokes — plugin and core grants verified against tauri 2.11.0's `PLUGINS` table in tauri's own `build.rs` rather than assumed from a plugin's `default` set, app-command grants (the bare `allow-*` entries) cross-checked by this crate's `build.rs` against `generate_handler!`. `core:default` in particular is NOT used: it is an alias for `core:{path,event,window,webview,app,image,resources,menu,tray}:default`, and `core:image:default` carries `allow-from-path`, whose handler (`tauri-2.11.0/src/image/plugin.rs:41` → `src/image/mod.rs:96`) is a bare `std::fs::read(path)` with no scope mechanism of any kind. Nothing imports `@tauri-apps/api/image`, so the whole plugin is dropped rather than scoped — there is nothing to scope it with. `core:menu` and `core:tray` are dropped for the same reason (no menu, no tray icon); `core:window` and `core:path` because nothing imports them; `core:resources:allow-close` because no frontend value is a `Resource`; and `core:event`'s `allow-emit`/`allow-emit-to` because the frontend only ever *listens* — every emit in this app originates in Rust. Three notes on what is deliberately kept or accepted: (1) `core:webview:allow-internal-toggle-devtools` is not called by `app/src` at all — it is called by Tauri's own injected `toggle-devtools.js`, which binds Ctrl/Cmd+Shift+I. Both that script and the command behind it are `#[cfg(any(debug_assertions, feature = \"devtools\"))]`, so this grant is a `tauri dev` convenience that does not exist in a release bundle. (2) `opener:allow-open-url` is **gone**. It could not be narrowed by host — `TerminalView`'s `WebLinksAddon` opens links Claude printed inside the container, which are arbitrary by construction, so a host allowlist would have deleted the feature rather than bounded it — and it was carried here as an accepted residual risk: a compromised webview could make the OS open an attacker-chosen http(s) URL, an outbound channel. That risk is now closed rather than recorded. Every host-browser open in the app goes through the `open_url_external` command in `url_open.rs`, which exists because the AppImage environment leaks into a cold-launched browser on Linux (triple-c#34) and which re-validates the URL in Rust — scheme allowlist, no embedded credentials, no control characters, length cap, ASCII asserted before `execvp`. On macOS and Windows that command reaches the same plugin as before, via `OpenerExt::open_url`, whose desktop implementation calls `crate::open::open` directly and is therefore not gated by this file at all (`tauri-plugin-opener-2.5.3/src/lib.rs:60`). The plugin stays a dependency for exactly that reason; what is removed is the webview's ability to reach it without passing the Rust validation. (3) `drag:allow-start-drag` is **gone**, together with the OS drag-out it existed for. It could not be scoped — `tauri-plugin-drag` takes the item paths from the caller and has no scope mechanism, so a compromised webview could call `startDrag({ item: ['~/.ssh/id_rsa'] })` against any host path the user can read — and it was carried as an accepted residual risk for one gesture. Drag-out was held back for separate hardening (see branch `hold/disk-and-dragout`) and the plugin is no longer a dependency. Getting a file *out* of a container is either \"Back up container\" on the project's Overview tab, which archives a tree through the Docker API, or the Files tab's per-row \"Save to host…\", which copies one file; getting one *in* is a drop on the Terminal or the Files tab's \"Upload…\". None of the four touches this permission. The Files tab's two are worth separating out here, because they are the only host-path commands in the app whose dialog is opened by **Rust** rather than by the webview — `pick_save_path` and `pick_files_to_upload` in `commands/file_commands.rs` drive `tauri-plugin-dialog` from the backend, so a compromised webview can ask for a picker and nothing more: it cannot name a host path as an *input* to either command. Be precise about the limit of that claim — host paths do still travel outward in error text (`Failed to create /home/j/Documents/x.txt.triple-c-part-1a2b3c4d: Permission denied`), including canonicalized ones, which disclose symlink targets. That is accepted; the app already hands the webview the project paths. What is closed is the direction that mattered — the webview naming where bytes go. That is the shape an earlier revision of this file named as the honest one if the Files tab ever regained host I/O, and it is the shape it regained it in. The `dialog:allow-open` / `dialog:allow-save` grants below are therefore *not* what those two use; they remain for the frontend pickers in Add Project, the Config tab's workspace and access sections, the CA-certificate field and Backup. Two commands still take a host path over IPC as a string — the terminal drop and `download_container_backup` — and for those `validate_host_path` is the boundary rather than defence in depth. This file is the reviewed threat model of record, so keep this census accurate: a stale reference here is worse than none. Note that dragging files *into* the app is unaffected: `dragDropEnabled` and `onDragDropEvent` are core webview behaviour and need no grant. Historical note kept because it is easy to re-introduce: the `store:*` grants were removed — nothing in `app/src` uses `@tauri-apps/plugin-store`, and the plugin's `resolve_store_path` is a `PathBuf::push` against AppData, which `push` discards outright when handed an absolute path, so the grant was an arbitrary host-file read/write primitive (`plugin:store|load` + `set` + `save` on `~/.claude/settings.json` is host code execution). A second capability file, `file-viewer.json`, covers the `file-viewer-*` windows the terminal file viewer opens on `viewer.html`; it is the only other local-origin window, its grants are listed and justified there, and its one non-obvious grant (`core:window:allow-destroy`) exists because `onCloseRequested` cannot close a window without it. App commands are gated by this file too. `build.rs` declares a Tauri `AppManifest` listing every command in `generate_handler!`, which is what makes tauri 2.11.0 apply the ACL to app commands at all (`webview/mod.rs:1794` skips it when no app manifest exists), and the bare `allow-` entries below are the complete list of app commands the main window may call. `build.rs` refuses to build unless every registered command has exactly one such grant, in the file whose `windows` its name says it belongs to (`viewer_*` in `file-viewer.json`, everything else here), and unless every bare entry names a registered command — so a forgotten, misspelled, duplicated or misfiled grant is a failed `cargo check`, not a feature that dies at runtime with `not allowed by ACL`. `deny-*` is banned by the same check: in tauri 2.11.0 a deny matches regardless of window or origin, so a deny meant for the viewer would deny main too. Hand-written files under `permissions/` are refused for the same reason — they would be grants this census cannot see. Because the census can only vouch for what it reads, `build.rs` also refuses any capability it did not check: anything in `capabilities/` other than a top-level `*.json` file (tauri also loads `.toml`/`.json5` there, and subdirectories), a `webviews` or `remote` key in a capability file (either would extend grants beyond what `windows` says), `app.security.capabilities` declared inline in `tauri.conf.json`, any `tauri..conf.json`, or `TAURI_CONFIG`, and a tauri config in a format the census cannot parse (JSON5, TOML). OS/editor junk (`.DS_Store`, `Thumbs.db`, editor swap files) is recognised and skipped in `capabilities/` and `permissions/` rather than refused, since tauri never loads it either. Each failure names the check that failed (\"stray entry in capabilities/\", \"capabilities declared outside capabilities/\", \"hand-written permission\", …) rather than always reading as a grant/handler mismatch. Known gap: adding a new `tauri..conf.json` to a tree that has already been built once only takes effect on a clean build or in CI — cargo's incremental build has no reason to notice a file that did not exist on the previous build. The `*marketplace*` commands fetch user-configured https git repos on the host and push pinned files into containers; account tokens stay in the OS keychain and never cross IPC outward — the only inbound one is the token pasted into `add_marketplace_token_account`. The pop-out stays capability-less. The Rust label gates in `commands/file_viewer_commands.rs` remain, because the ACL says *which* window may call a command and the label says *whose* registry entry it acts on; they are not redundant. The rules live in `src/command_census.rs`, which is unit-tested, and `src/test/capabilities.test.ts` checks the other direction: that the code that runs in each window imports only the wrappers that window is granted. On the CSP side: `app.security.csp` in `tauri.conf.json` covers the shipped bundle, and there is deliberately no `devCsp`. `npm run tauri dev` loads the main document straight from Vite at `build.devUrl` (`http://localhost:1420`), and Tauri only attaches a CSP to documents it serves itself — `protocol/tauri.rs:217` sets the header on `tauri://` assets, and the dev server is proxied through that protocol only when `PROXY_DEV_SERVER`, which is `cfg!(all(dev, mobile))` and therefore false for every desktop build. A `devCsp` here would be inert config that reads as protection, which is worse than its absence. If a CSP in dev is wanted, the only place that can set one is the Vite dev server's own `server.headers` in `app/vite.config.ts`; it is not set today, and dev is not the shipped configuration.","local":true,"windows":["main"],"permissions":["core:event:allow-listen","core:event:allow-unlisten","core:webview:allow-internal-toggle-devtools","dialog:allow-open","dialog:allow-save","allow-check-docker","allow-check-image-exists","allow-build-image","allow-get-container-info","allow-list-projects","allow-add-project","allow-remove-project","allow-update-project","allow-start-project-container","allow-stop-project-container","allow-check-unsaved-work","allow-aws-task-log","allow-aws-workspace-status","allow-aws-environment-max-hours","allow-remove-aws-resources","allow-rebuild-project-container","allow-reconcile-project-statuses","allow-reconcile-aws-projects","allow-list-notes","allow-save-note","allow-delete-note","allow-get-container-staleness","allow-migrate-project-to-base","allow-confirm-migration","allow-rollback-migration","allow-get-migration-state","allow-set-auth-bridge-enabled","allow-get-auth-bridge-status","allow-set-browser-view-enabled","allow-get-browser-view-status","allow-check-browser-view-support","allow-install-browser-view-support","allow-install-browser-view-browser","allow-open-browser-view-popout","allow-close-browser-view-popout","allow-get-browser-view-popout-state","allow-set-browser-view-popout-always-on-top","allow-open-page-in-container-browser","allow-set-container-page-viewport","allow-get-container-page-state","allow-close-container-page","allow-set-browser-view-match-window","allow-get-browser-view-match-window","allow-acquire-claude-token","allow-submit-claude-token-code","allow-cancel-claude-token","allow-has-claude-token","allow-clear-claude-token","allow-sweep-claude-token-snapshots","allow-get-settings","allow-update-settings","allow-pull-image","allow-detect-aws-config","allow-inspect-ca-cert-path","allow-list-aws-profiles","allow-add-aws-profile-connection","allow-add-aws-keys-connection","allow-update-aws-connection","allow-remove-host-connection","allow-aws-connection-identity","allow-aws-connection-sso-login","allow-check-aws-permissions","allow-aws-policy-document","allow-aws-cost-estimate","allow-detect-aws-environments","allow-deploy-aws-environment","allow-update-aws-environment","allow-repair-aws-environment","allow-destroy-incomplete-aws-environment","allow-unlock-aws-state","allow-follow-aws-deployment","allow-cancel-aws-deployment","allow-push-aws-saved-state","allow-onboard-aws-user","allow-deploy-aws-permissions-boundary","allow-save-aws-admin-bundle","allow-detect-host-timezone","allow-export-settings","allow-preview-settings-import","allow-apply-settings-import","allow-open-terminal-session","allow-terminal-input","allow-terminal-resize","allow-close-terminal-session","allow-paste-image-to-terminal","allow-upload-host-file-to-terminal","allow-start-audio-bridge","allow-send-audio-data","allow-stop-audio-bridge","allow-list-container-files","allow-download-container-backup","allow-download-container-file","allow-upload-files-to-container","allow-read-container-file","allow-rename-container-path","allow-create-container-directory","allow-open-file-viewer","allow-aws-sso-refresh","allow-get-app-version","allow-check-for-updates","allow-check-image-update","allow-get-help-content","allow-open-url-external","allow-detect-install-options","allow-run-docker-install","allow-start-web-terminal","allow-stop-web-terminal","allow-get-web-terminal-status","allow-regenerate-web-terminal-token","allow-get-stt-status","allow-start-stt","allow-stop-stt","allow-build-stt-image","allow-pull-stt-image","allow-transcribe-audio","allow-get-gateway-status","allow-start-gateway","allow-stop-gateway","allow-check-gateway-health","allow-build-gateway-image","allow-pull-gateway-image","allow-set-gateway-api-key","allow-clear-gateway-api-key","allow-get-gateway-auth-token","allow-regenerate-gateway-auth-token","allow-list-claude-sessions","allow-list-container-capabilities","allow-list-scheduled-tasks","allow-add-scheduled-task","allow-update-scheduled-task","allow-get-scheduled-task-log","allow-set-scheduled-task-enabled","allow-run-scheduled-task-now","allow-remove-scheduled-task","allow-get-scheduler-notifications","allow-clear-scheduler-notifications","allow-list-marketplace-snapshots","allow-refresh-marketplaces","allow-add-marketplace","allow-update-marketplace","allow-remove-marketplace","allow-install-marketplace-item","allow-uninstall-marketplace-item","allow-set-global-item-disabled","allow-forget-marketplace-installs","allow-list-marketplace-updates","allow-marketplace-item-diff","allow-update-marketplace-item","allow-apply-marketplace-now","allow-get-marketplace-sync-report","allow-add-marketplace-token-account","allow-add-marketplace-gh-host-account","allow-start-marketplace-gh-container-login","allow-cancel-marketplace-gh-login","allow-test-marketplace-account","allow-remove-marketplace-account","allow-marketplace-gh-host-available"]},"file-viewer":{"identifier":"file-viewer","description":"The terminal file viewer windows (`file-viewer-`, opened by `open_file_viewer` on the app's own `viewer.html`). Same rules as `default.json`, including the layout checks: this file itself must stay a top-level `capabilities/*.json` with no `webviews` or `remote` key, or `build.rs` refuses the build rather than grant something the census cannot see. The five bare `allow-viewer-*` grants are the only app commands a viewer window can invoke: `build.rs` declares the AppManifest that makes tauri enforce that, and refuses any other bare grant in this file. The label gate inside `commands/file_viewer_commands.rs` is still what stops window A acting on window B's registry entry, because the ACL only decides which window may call. The rest of this file is the plugin-command surface a compromised viewer webview could reach, and it is the smallest one that lets the window work. `core:event:allow-listen`/`allow-unlisten` are for `file-viewer-goto` (Rust → this window; the viewer subscribes through `getCurrentWindow().listen`, because a bare `listen()` in *any* window receives an `emit_to`). `core:window:allow-destroy` is not optional: `getCurrentWindow().onCloseRequested` in @tauri-apps/api 2.11 makes Rust `prevent_close()` whenever a JS listener exists and then calls `destroy()` itself, so without this grant the window's X button does nothing once the unsaved-changes guard is installed. `allow-close` is deliberately absent — nothing calls it, and `destroy` is the only exit. No `set-title`/`set-focus`/`unminimize`: those are done from Rust when a second click targets an already-open file. `core:webview:allow-internal-toggle-devtools` is the same dev-only convenience `default.json` carries.","local":true,"windows":["file-viewer-*"],"permissions":["core:event:allow-listen","core:event:allow-unlisten","core:window:allow-destroy","core:webview:allow-internal-toggle-devtools","allow-viewer-get-state","allow-viewer-choose-file","allow-viewer-read-file","allow-viewer-poll-file","allow-viewer-write-file"]}} \ No newline at end of file +{"default":{"identifier":"default","description":"Default capabilities for Triple-C. Every entry here is an IPC command a compromised webview can call directly, so the set is an enumeration of what `app/src` actually invokes — plugin and core grants verified against tauri 2.11.0's `PLUGINS` table in tauri's own `build.rs` rather than assumed from a plugin's `default` set, app-command grants (the bare `allow-*` entries) cross-checked by this crate's `build.rs` against `generate_handler!`. `core:default` in particular is NOT used: it is an alias for `core:{path,event,window,webview,app,image,resources,menu,tray}:default`, and `core:image:default` carries `allow-from-path`, whose handler (`tauri-2.11.0/src/image/plugin.rs:41` → `src/image/mod.rs:96`) is a bare `std::fs::read(path)` with no scope mechanism of any kind. Nothing imports `@tauri-apps/api/image`, so the whole plugin is dropped rather than scoped — there is nothing to scope it with. `core:menu` and `core:tray` are dropped for the same reason (no menu, no tray icon); `core:window` and `core:path` because nothing imports them; `core:resources:allow-close` because no frontend value is a `Resource`; and `core:event`'s `allow-emit`/`allow-emit-to` because the frontend only ever *listens* — every emit in this app originates in Rust. Three notes on what is deliberately kept or accepted: (1) `core:webview:allow-internal-toggle-devtools` is not called by `app/src` at all — it is called by Tauri's own injected `toggle-devtools.js`, which binds Ctrl/Cmd+Shift+I. Both that script and the command behind it are `#[cfg(any(debug_assertions, feature = \"devtools\"))]`, so this grant is a `tauri dev` convenience that does not exist in a release bundle. (2) `opener:allow-open-url` is **gone**. It could not be narrowed by host — `TerminalView`'s `WebLinksAddon` opens links Claude printed inside the container, which are arbitrary by construction, so a host allowlist would have deleted the feature rather than bounded it — and it was carried here as an accepted residual risk: a compromised webview could make the OS open an attacker-chosen http(s) URL, an outbound channel. That risk is now closed rather than recorded. Every host-browser open in the app goes through the `open_url_external` command in `url_open.rs`, which exists because the AppImage environment leaks into a cold-launched browser on Linux (triple-c#34) and which re-validates the URL in Rust — scheme allowlist, no embedded credentials, no control characters, length cap, ASCII asserted before `execvp`. On macOS and Windows that command reaches the same plugin as before, via `OpenerExt::open_url`, whose desktop implementation calls `crate::open::open` directly and is therefore not gated by this file at all (`tauri-plugin-opener-2.5.3/src/lib.rs:60`). The plugin stays a dependency for exactly that reason; what is removed is the webview's ability to reach it without passing the Rust validation. (3) `drag:allow-start-drag` is **gone**, together with the OS drag-out it existed for. It could not be scoped — `tauri-plugin-drag` takes the item paths from the caller and has no scope mechanism, so a compromised webview could call `startDrag({ item: ['~/.ssh/id_rsa'] })` against any host path the user can read — and it was carried as an accepted residual risk for one gesture. Drag-out was held back for separate hardening (see branch `hold/disk-and-dragout`) and the plugin is no longer a dependency. Getting a file *out* of a container is either \"Back up container\" on the project's Overview tab, which archives a tree through the Docker API, or the Files tab's per-row \"Save to host…\", which copies one file; getting one *in* is a drop on the Terminal or the Files tab's \"Upload…\". None of the four touches this permission. The Files tab's two are worth separating out here, because they are the only host-path commands in the app whose dialog is opened by **Rust** rather than by the webview — `pick_save_path` and `pick_files_to_upload` in `commands/file_commands.rs` drive `tauri-plugin-dialog` from the backend, so a compromised webview can ask for a picker and nothing more: it cannot name a host path as an *input* to either command. Be precise about the limit of that claim — host paths do still travel outward in error text (`Failed to create /home/j/Documents/x.txt.triple-c-part-1a2b3c4d: Permission denied`), including canonicalized ones, which disclose symlink targets. That is accepted; the app already hands the webview the project paths. What is closed is the direction that mattered — the webview naming where bytes go. That is the shape an earlier revision of this file named as the honest one if the Files tab ever regained host I/O, and it is the shape it regained it in. The `dialog:allow-open` / `dialog:allow-save` grants below are therefore *not* what those two use; they remain for the frontend pickers in Add Project, the Config tab's workspace and access sections, the CA-certificate field and Backup. Two commands still take a host path over IPC as a string — the terminal drop and `download_container_backup` — and for those `validate_host_path` is the boundary rather than defence in depth. This file is the reviewed threat model of record, so keep this census accurate: a stale reference here is worse than none. Note that dragging files *into* the app is unaffected: `dragDropEnabled` and `onDragDropEvent` are core webview behaviour and need no grant. Historical note kept because it is easy to re-introduce: the `store:*` grants were removed — nothing in `app/src` uses `@tauri-apps/plugin-store`, and the plugin's `resolve_store_path` is a `PathBuf::push` against AppData, which `push` discards outright when handed an absolute path, so the grant was an arbitrary host-file read/write primitive (`plugin:store|load` + `set` + `save` on `~/.claude/settings.json` is host code execution). A second capability file, `file-viewer.json`, covers the `file-viewer-*` windows the terminal file viewer opens on `viewer.html`; it is the only other local-origin window, its grants are listed and justified there, and its one non-obvious grant (`core:window:allow-destroy`) exists because `onCloseRequested` cannot close a window without it. App commands are gated by this file too. `build.rs` declares a Tauri `AppManifest` listing every command in `generate_handler!`, which is what makes tauri 2.11.0 apply the ACL to app commands at all (`webview/mod.rs:1794` skips it when no app manifest exists), and the bare `allow-` entries below are the complete list of app commands the main window may call. `build.rs` refuses to build unless every registered command has exactly one such grant, in the file whose `windows` its name says it belongs to (`viewer_*` in `file-viewer.json`, everything else here), and unless every bare entry names a registered command — so a forgotten, misspelled, duplicated or misfiled grant is a failed `cargo check`, not a feature that dies at runtime with `not allowed by ACL`. `deny-*` is banned by the same check: in tauri 2.11.0 a deny matches regardless of window or origin, so a deny meant for the viewer would deny main too. Hand-written files under `permissions/` are refused for the same reason — they would be grants this census cannot see. Because the census can only vouch for what it reads, `build.rs` also refuses any capability it did not check: anything in `capabilities/` other than a top-level `*.json` file (tauri also loads `.toml`/`.json5` there, and subdirectories), a `webviews` or `remote` key in a capability file (either would extend grants beyond what `windows` says), `app.security.capabilities` declared inline in `tauri.conf.json`, any `tauri..conf.json`, or `TAURI_CONFIG`, and a tauri config in a format the census cannot parse (JSON5, TOML). OS/editor junk (`.DS_Store`, `Thumbs.db`, editor swap files) is recognised and skipped in `capabilities/` and `permissions/` rather than refused, since tauri never loads it either. Each failure names the check that failed (\"stray entry in capabilities/\", \"capabilities declared outside capabilities/\", \"hand-written permission\", …) rather than always reading as a grant/handler mismatch. Known gap: adding a new `tauri..conf.json` to a tree that has already been built once only takes effect on a clean build or in CI — cargo's incremental build has no reason to notice a file that did not exist on the previous build. The `*marketplace*` commands fetch user-configured https git repos on the host and push pinned files into containers; account tokens stay in the OS keychain and never cross IPC outward — the only inbound one is the token pasted into `add_marketplace_token_account`. The pop-out stays capability-less. The Rust label gates in `commands/file_viewer_commands.rs` remain, because the ACL says *which* window may call a command and the label says *whose* registry entry it acts on; they are not redundant. The rules live in `src/command_census.rs`, which is unit-tested, and `src/test/capabilities.test.ts` checks the other direction: that the code that runs in each window imports only the wrappers that window is granted. On the CSP side: `app.security.csp` in `tauri.conf.json` covers the shipped bundle, and there is deliberately no `devCsp`. `npm run tauri dev` loads the main document straight from Vite at `build.devUrl` (`http://localhost:1420`), and Tauri only attaches a CSP to documents it serves itself — `protocol/tauri.rs:217` sets the header on `tauri://` assets, and the dev server is proxied through that protocol only when `PROXY_DEV_SERVER`, which is `cfg!(all(dev, mobile))` and therefore false for every desktop build. A `devCsp` here would be inert config that reads as protection, which is worse than its absence. If a CSP in dev is wanted, the only place that can set one is the Vite dev server's own `server.headers` in `app/vite.config.ts`; it is not set today, and dev is not the shipped configuration.","local":true,"windows":["main"],"permissions":["core:event:allow-listen","core:event:allow-unlisten","core:webview:allow-internal-toggle-devtools","dialog:allow-open","dialog:allow-save","allow-check-docker","allow-check-image-exists","allow-build-image","allow-get-container-info","allow-list-projects","allow-add-project","allow-remove-project","allow-update-project","allow-start-project-container","allow-stop-project-container","allow-check-unsaved-work","allow-aws-task-log","allow-aws-workspace-status","allow-aws-environment-max-hours","allow-remove-aws-resources","allow-rebuild-project-container","allow-reconcile-project-statuses","allow-reconcile-aws-projects","allow-list-notes","allow-save-note","allow-delete-note","allow-get-container-staleness","allow-migrate-project-to-base","allow-confirm-migration","allow-rollback-migration","allow-get-migration-state","allow-set-auth-bridge-enabled","allow-get-auth-bridge-status","allow-set-browser-view-enabled","allow-get-browser-view-status","allow-check-browser-view-support","allow-install-browser-view-support","allow-install-browser-view-browser","allow-open-browser-view-popout","allow-close-browser-view-popout","allow-get-browser-view-popout-state","allow-set-browser-view-popout-always-on-top","allow-open-page-in-container-browser","allow-set-container-page-viewport","allow-get-container-page-state","allow-close-container-page","allow-set-browser-view-match-window","allow-get-browser-view-match-window","allow-acquire-claude-token","allow-submit-claude-token-code","allow-cancel-claude-token","allow-has-claude-token","allow-clear-claude-token","allow-sweep-claude-token-snapshots","allow-get-settings","allow-update-settings","allow-pull-image","allow-detect-aws-config","allow-inspect-ca-cert-path","allow-list-aws-profiles","allow-add-aws-profile-connection","allow-add-aws-keys-connection","allow-update-aws-connection","allow-remove-host-connection","allow-aws-connection-identity","allow-aws-connection-sso-login","allow-check-aws-permissions","allow-aws-policy-document","allow-aws-cost-estimate","allow-detect-aws-environments","allow-deploy-aws-environment","allow-update-aws-environment","allow-repair-aws-environment","allow-destroy-incomplete-aws-environment","allow-unlock-aws-state","allow-follow-aws-deployment","allow-cancel-aws-deployment","allow-push-aws-saved-state","allow-onboard-aws-user","allow-list-ec2-instance-types","allow-deploy-aws-permissions-boundary","allow-save-aws-admin-bundle","allow-detect-host-timezone","allow-export-settings","allow-preview-settings-import","allow-apply-settings-import","allow-open-terminal-session","allow-terminal-input","allow-terminal-resize","allow-close-terminal-session","allow-paste-image-to-terminal","allow-upload-host-file-to-terminal","allow-start-audio-bridge","allow-send-audio-data","allow-stop-audio-bridge","allow-list-container-files","allow-download-container-backup","allow-download-container-file","allow-upload-files-to-container","allow-read-container-file","allow-rename-container-path","allow-create-container-directory","allow-open-file-viewer","allow-aws-sso-refresh","allow-get-app-version","allow-check-for-updates","allow-check-image-update","allow-get-help-content","allow-open-url-external","allow-detect-install-options","allow-run-docker-install","allow-start-web-terminal","allow-stop-web-terminal","allow-get-web-terminal-status","allow-regenerate-web-terminal-token","allow-get-stt-status","allow-start-stt","allow-stop-stt","allow-build-stt-image","allow-pull-stt-image","allow-transcribe-audio","allow-get-gateway-status","allow-start-gateway","allow-stop-gateway","allow-check-gateway-health","allow-build-gateway-image","allow-pull-gateway-image","allow-set-gateway-api-key","allow-clear-gateway-api-key","allow-get-gateway-auth-token","allow-regenerate-gateway-auth-token","allow-list-claude-sessions","allow-list-container-capabilities","allow-list-scheduled-tasks","allow-add-scheduled-task","allow-update-scheduled-task","allow-get-scheduled-task-log","allow-set-scheduled-task-enabled","allow-run-scheduled-task-now","allow-remove-scheduled-task","allow-get-scheduler-notifications","allow-clear-scheduler-notifications","allow-list-marketplace-snapshots","allow-refresh-marketplaces","allow-add-marketplace","allow-update-marketplace","allow-remove-marketplace","allow-install-marketplace-item","allow-uninstall-marketplace-item","allow-set-global-item-disabled","allow-forget-marketplace-installs","allow-list-marketplace-updates","allow-marketplace-item-diff","allow-update-marketplace-item","allow-apply-marketplace-now","allow-get-marketplace-sync-report","allow-add-marketplace-token-account","allow-add-marketplace-gh-host-account","allow-start-marketplace-gh-container-login","allow-cancel-marketplace-gh-login","allow-test-marketplace-account","allow-remove-marketplace-account","allow-marketplace-gh-host-available"]},"file-viewer":{"identifier":"file-viewer","description":"The terminal file viewer windows (`file-viewer-`, opened by `open_file_viewer` on the app's own `viewer.html`). Same rules as `default.json`, including the layout checks: this file itself must stay a top-level `capabilities/*.json` with no `webviews` or `remote` key, or `build.rs` refuses the build rather than grant something the census cannot see. The five bare `allow-viewer-*` grants are the only app commands a viewer window can invoke: `build.rs` declares the AppManifest that makes tauri enforce that, and refuses any other bare grant in this file. The label gate inside `commands/file_viewer_commands.rs` is still what stops window A acting on window B's registry entry, because the ACL only decides which window may call. The rest of this file is the plugin-command surface a compromised viewer webview could reach, and it is the smallest one that lets the window work. `core:event:allow-listen`/`allow-unlisten` are for `file-viewer-goto` (Rust → this window; the viewer subscribes through `getCurrentWindow().listen`, because a bare `listen()` in *any* window receives an `emit_to`). `core:window:allow-destroy` is not optional: `getCurrentWindow().onCloseRequested` in @tauri-apps/api 2.11 makes Rust `prevent_close()` whenever a JS listener exists and then calls `destroy()` itself, so without this grant the window's X button does nothing once the unsaved-changes guard is installed. `allow-close` is deliberately absent — nothing calls it, and `destroy` is the only exit. No `set-title`/`set-focus`/`unminimize`: those are done from Rust when a second click targets an already-open file. `core:webview:allow-internal-toggle-devtools` is the same dev-only convenience `default.json` carries.","local":true,"windows":["file-viewer-*"],"permissions":["core:event:allow-listen","core:event:allow-unlisten","core:window:allow-destroy","core:webview:allow-internal-toggle-devtools","allow-viewer-get-state","allow-viewer-choose-file","allow-viewer-read-file","allow-viewer-poll-file","allow-viewer-write-file"]}} \ No newline at end of file diff --git a/app/src-tauri/gen/schemas/desktop-schema.json b/app/src-tauri/gen/schemas/desktop-schema.json index a9cf201..5bf0149 100644 --- a/app/src-tauri/gen/schemas/desktop-schema.json +++ b/app/src-tauri/gen/schemas/desktop-schema.json @@ -824,6 +824,12 @@ "const": "allow-list-container-files", "markdownDescription": "Enables the list_container_files command without any pre-configured scope." }, + { + "description": "Enables the list_ec2_instance_types command without any pre-configured scope.", + "type": "string", + "const": "allow-list-ec2-instance-types", + "markdownDescription": "Enables the list_ec2_instance_types command without any pre-configured scope." + }, { "description": "Enables the list_marketplace_snapshots command without any pre-configured scope.", "type": "string", @@ -1796,6 +1802,12 @@ "const": "deny-list-container-files", "markdownDescription": "Denies the list_container_files command without any pre-configured scope." }, + { + "description": "Denies the list_ec2_instance_types command without any pre-configured scope.", + "type": "string", + "const": "deny-list-ec2-instance-types", + "markdownDescription": "Denies the list_ec2_instance_types command without any pre-configured scope." + }, { "description": "Denies the list_marketplace_snapshots command without any pre-configured scope.", "type": "string", diff --git a/app/src-tauri/gen/schemas/linux-schema.json b/app/src-tauri/gen/schemas/linux-schema.json index a9cf201..5bf0149 100644 --- a/app/src-tauri/gen/schemas/linux-schema.json +++ b/app/src-tauri/gen/schemas/linux-schema.json @@ -824,6 +824,12 @@ "const": "allow-list-container-files", "markdownDescription": "Enables the list_container_files command without any pre-configured scope." }, + { + "description": "Enables the list_ec2_instance_types command without any pre-configured scope.", + "type": "string", + "const": "allow-list-ec2-instance-types", + "markdownDescription": "Enables the list_ec2_instance_types command without any pre-configured scope." + }, { "description": "Enables the list_marketplace_snapshots command without any pre-configured scope.", "type": "string", @@ -1796,6 +1802,12 @@ "const": "deny-list-container-files", "markdownDescription": "Denies the list_container_files command without any pre-configured scope." }, + { + "description": "Denies the list_ec2_instance_types command without any pre-configured scope.", + "type": "string", + "const": "deny-list-ec2-instance-types", + "markdownDescription": "Denies the list_ec2_instance_types command without any pre-configured scope." + }, { "description": "Denies the list_marketplace_snapshots command without any pre-configured scope.", "type": "string", diff --git a/app/src-tauri/src/aws/environments.rs b/app/src-tauri/src/aws/environments.rs index 72d09b3..95399fb 100644 --- a/app/src-tauri/src/aws/environments.rs +++ b/app/src-tauri/src/aws/environments.rs @@ -29,8 +29,9 @@ use serde_json::{json, Map, Value}; use super::error::{classify_sdk_error, AwsError}; use super::identity::CallerIdentity; use super::tofu_modules::{ - environment_parameter_name, owner_key, state_bucket_name, state_key, user_role_names, - validate_environment_name, Deployment, BOUNDARY_POLICY_NAME, + environment_parameter_name, owner_key, state_bucket_name, state_key, user_ec2_stem, + user_record_parameter_name, user_role_names, validate_ec2_user_tag, validate_environment_name, + Deployment, BOUNDARY_POLICY_NAME, EC2_MAX_INSTANCES, }; use crate::models::host_connection::validate_supported_region; @@ -309,15 +310,97 @@ pub enum EnvironmentAction { #[serde(tag = "state", rename_all = "snake_case")] pub enum OnboardingState { /// Their task role exists and, where the bucket is readable, their state - /// records a finished apply (its `onboarding_complete` output). - Joined, + /// records a finished apply (its `onboarding_complete` output). `ec2` is + /// their EC2 capacity, from their user record. + Joined { ec2: Option }, NotJoined, /// A local runner, or a recent lock. InProgress { lock: Option }, /// The last onboarding run didn't finish: a stale lock, a failed run on /// this machine, or a state without the completion output. Join is a - /// re-apply and finishes it. - Incomplete { lock: Option }, + /// re-apply and finishes it; `ec2` is what their record still holds, so + /// the re-apply can keep it. + Incomplete { + lock: Option, + ec2: Option, + }, +} + +impl OnboardingState { + fn with_ec2(self, compute: Option) -> Self { + match self { + OnboardingState::Joined { .. } => OnboardingState::Joined { ec2: compute }, + OnboardingState::Incomplete { lock, .. } => OnboardingState::Incomplete { lock, ec2: compute }, + other => other, + } + } +} + +/// A user's EC2 capacity in one environment: their validated user record +/// (`tofu_modules::user_record_parameter_name`). A missing record means no +/// NEW EC2 runs there, not that nothing runs (teardown removes it first). +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +pub struct UserCompute { + pub instance_type: String, + pub max_instances: u32, + /// The `triple-c-user` value the cluster is named after. + pub user_tag: String, + pub cluster_arn: String, + pub capacity_provider: String, +} + +/// Validate a user record read from `user_record_parameter_name(env, …)`: +/// schema 1, a type the app's table knows, 1 to `EC2_MAX_INSTANCES` +/// instances (absent in records written before the field: 1), a valid user +/// tag, and the cluster and capacity provider of exactly that tag's per-user +/// names in `account` and `region`. The error names the field, never its +/// value. +pub fn parse_user_record( + env: &str, + value: &str, + account: &str, + region: &str, +) -> Result { + if value.len() > MAX_UNTRUSTED_BYTES { + return Err("the record is larger than 4 KiB".into()); + } + let parsed: Value = + serde_json::from_str(value).map_err(|_| "the record is not JSON".to_string())?; + let obj = parsed + .as_object() + .ok_or_else(|| "the record is not a JSON object".to_string())?; + if field(obj, "schema")?.as_u64() != Some(RECORD_SCHEMA) { + return Err("schema is not 1".into()); + } + let instance_type = str_field(obj, "instance_type")?; + if crate::models::project::ec2_instance_spec(instance_type).is_none() { + return Err("instance_type is not a supported instance type".into()); + } + let max_instances = match obj.get("max_instances") { + None => 1, + Some(v) => v + .as_u64() + .and_then(|v| u32::try_from(v).ok()) + .filter(|v| (1..=EC2_MAX_INSTANCES).contains(v)) + .ok_or_else(|| format!("max_instances is not a number from 1 to {EC2_MAX_INSTANCES}"))?, + }; + let user_tag = validate_ec2_user_tag(str_field(obj, "user_tag")?) + .map_err(|_| "user_tag is not a valid triple-c-user value".to_string())?; + let stem = user_ec2_stem(env, &user_tag); + let cluster_arn = str_field(obj, "cluster_arn")?; + if cluster_arn != format!("arn:aws:ecs:{region}:{account}:cluster/{stem}") { + return Err("cluster_arn is not this user's cluster in this account and region".into()); + } + if str_field(obj, "capacity_provider")? != stem { + return Err("capacity_provider is not this user's capacity provider".into()); + } + Ok(UserCompute { + instance_type: instance_type.to_string(), + max_instances, + user_tag, + cluster_arn: cluster_arn.to_string(), + capacity_provider: stem, + }) } #[derive(Serialize, Clone, Debug, PartialEq)] @@ -565,9 +648,12 @@ fn onboarding_from_runs( Some(OnboardingState::InProgress { lock }) } else if lock.is_some() { actions.push(Unlock); - Some(OnboardingState::Incomplete { lock }) + Some(OnboardingState::Incomplete { lock, ec2: None }) } else if run.failed || run.errored_state { - Some(OnboardingState::Incomplete { lock: None }) + Some(OnboardingState::Incomplete { + lock: None, + ec2: None, + }) } else { None }; @@ -597,6 +683,12 @@ pub trait DetectApi: Send + Sync { account: &str, ) -> impl Future> + Send; fn role_exists(&self, name: &str) -> impl Future> + Send; + /// An SSM String parameter's value; `None` when it is missing or this + /// caller can't read it. + fn parameter( + &self, + name: &str, + ) -> impl Future, AwsError>> + Send; /// A state object's contents, capped; `None` when it is missing, can't /// be read or is too large. fn state_document( @@ -675,8 +767,13 @@ pub(crate) async fn scan_in_bucket( // role), which is not Joined. None if objects.as_ref().is_some_and(|o| o.has_state(&user_state)) => { match d.state_document(bucket, &user_state).await? { - Some(text) if onboarding_complete(&text) => OnboardingState::Joined, - _ => OnboardingState::Incomplete { lock: None }, + Some(text) if onboarding_complete(&text) => { + OnboardingState::Joined { ec2: None } + } + _ => OnboardingState::Incomplete { + lock: None, + ec2: None, + }, } } // Without a state here (a workspace user, who can't list the @@ -685,11 +782,20 @@ pub(crate) async fn scan_in_bucket( None => { let (task_role, _) = user_role_names(&env.name, &key); match d.role_exists(&task_role).await? { - Knowable::Yes => OnboardingState::Joined, + Knowable::Yes => OnboardingState::Joined { ec2: None }, Knowable::No | Knowable::Unknown => OnboardingState::NotJoined, } } }); + if let Some(state) = env.onboarding.take() { + let compute = match state { + OnboardingState::Joined { .. } | OnboardingState::Incomplete { .. } => { + user_compute(d, &env.name, &key, &who.account, region).await? + } + _ => None, + }; + env.onboarding = Some(state.with_ec2(compute)); + } } Ok(EnvironmentScan { @@ -703,6 +809,55 @@ pub(crate) async fn scan_in_bucket( }) } +/// The caller's EC2 capacity in `env` from their user record; `None` when +/// there is no record or it doesn't validate (logged, never echoed). +pub(crate) async fn user_compute( + d: &D, + env: &str, + owner_key: &str, + account: &str, + region: &str, +) -> Result, AwsError> { + let Some(text) = d.parameter(&user_record_parameter_name(env, owner_key)).await? else { + return Ok(None); + }; + match parse_user_record(env, &text, account, region) { + Ok(c) => Ok(Some(c)), + Err(reason) => { + log::warn!("Ignoring the EC2 user record for environment {env}: {reason}"); + Ok(None) + } + } +} + +/// Whether a per-user EC2 name (`tofu_modules::user_ec2_stem`) is in use: +/// (an ACTIVE ECS cluster of that name, an Auto Scaling group of that name). +/// Needs `ecs:DescribeClusters` and `autoscaling:DescribeAutoScalingGroups` +/// (the environment-admin tier has both; workspace users lack the second). +pub async fn ec2_names_in_use(cfg: &SdkConfig, stem: &str) -> Result<(bool, bool), AwsError> { + let clusters = aws_sdk_ecs::Client::new(cfg) + .describe_clusters() + .clusters(stem) + .send() + .await + .map_err(|e| classify_sdk_error("ecs:DescribeClusters", &e))?; + let cluster = clusters + .clusters() + .iter() + .any(|c| c.cluster_name() == Some(stem) && c.status() == Some("ACTIVE")); + let groups = aws_sdk_autoscaling::Client::new(cfg) + .describe_auto_scaling_groups() + .auto_scaling_group_names(stem) + .send() + .await + .map_err(|e| classify_sdk_error("autoscaling:DescribeAutoScalingGroups", &e))?; + let group = groups + .auto_scaling_groups() + .iter() + .any(|g| g.auto_scaling_group_name() == Some(stem)); + Ok((cluster, group)) +} + /// An OpenTofu state that manages nothing (what `tofu destroy` leaves): /// valid JSON whose `resources` is an empty list. Anything else, unreadable /// contents included, counts as a deployment. @@ -1015,6 +1170,27 @@ impl DetectApi for SdkDetectApi { knowable("iam:GetRole", res) } + async fn parameter(&self, name: &str) -> Result, AwsError> { + let res = self + .ssm + .get_parameter() + .name(name) + .with_decryption(false) + .send() + .await; + match res { + Ok(out) => Ok(out.parameter().and_then(|p| p.value()).map(str::to_string)), + Err(e) if e.as_service_error().is_some_and(|s| s.is_parameter_not_found()) => Ok(None), + Err(e) => { + let (code, status) = error_parts(&e); + match lookup_outcome(code.as_deref(), status) { + Lookup::Missing | Lookup::Denied => Ok(None), + Lookup::Error => Err(classify_sdk_error("ssm:GetParameter", &e)), + } + } + } + } + async fn state_document(&self, bucket: &str, key: &str) -> Result, AwsError> { const ACTION: &str = "s3:GetObject"; let res = self diff --git a/app/src-tauri/src/aws/environments/tests.rs b/app/src-tauri/src/aws/environments/tests.rs index 6b830b9..0e9bee0 100644 --- a/app/src-tauri/src/aws/environments/tests.rs +++ b/app/src-tauri/src/aws/environments/tests.rs @@ -494,6 +494,8 @@ struct FakeDetect { roles: HashMap, /// State objects' contents, by key. documents: HashMap, + /// SSM parameters (user records), by name. + parameters: HashMap, calls: Mutex>, } @@ -506,6 +508,7 @@ impl FakeDetect { boundary: Knowable::Yes, roles: HashMap::new(), documents: HashMap::new(), + parameters: HashMap::new(), calls: Mutex::new(Vec::new()), } } @@ -548,6 +551,10 @@ impl DetectApi for FakeDetect { self.log(format!("role {name}")); Ok(self.roles.get(name).cloned().unwrap_or(Knowable::No)) } + async fn parameter(&self, name: &str) -> Result, AwsError> { + self.log(format!("parameter {name}")); + Ok(self.parameters.get(name).cloned()) + } async fn state_document(&self, bucket: &str, key: &str) -> Result, AwsError> { self.log(format!("document {bucket} {key}")); Ok(self.documents.get(key).cloned()) @@ -612,8 +619,8 @@ fn onboarding_is_found_by_state_then_by_role() { assert_eq!(scan.owner_id, USER_ID); assert_eq!(scan.owner_key, owner_key(REGION, USER_ID)); let onboarding = |n: &str| find(&scan.environments, n).onboarding.clone(); - assert_eq!(onboarding("bystate"), Some(OnboardingState::Joined)); - assert_eq!(onboarding("byrole"), Some(OnboardingState::Joined)); + assert_eq!(onboarding("bystate"), Some(OnboardingState::Joined { ec2: None })); + assert_eq!(onboarding("byrole"), Some(OnboardingState::Joined { ec2: None })); assert_eq!(onboarding("denied"), Some(OnboardingState::NotJoined)); assert_eq!(onboarding("absent"), Some(OnboardingState::NotJoined)); assert!(matches!( @@ -662,7 +669,7 @@ fn onboarding_is_found_by_state_then_by_role() { assert_eq!(x.onboarding, Some(OnboardingState::InProgress { lock: None })); assert_eq!(x.onboarding_actions, vec![EnvironmentAction::Follow]); let y = find(&scan.environments, "y"); - let Some(OnboardingState::Incomplete { lock: Some(lock) }) = &y.onboarding else { + let Some(OnboardingState::Incomplete { lock: Some(lock), ec2: None }) = &y.onboarding else { panic!("{y:#?}"); }; assert!(!lock.local_process); @@ -982,12 +989,12 @@ fn a_failed_onboarding_is_incomplete_not_joined() { let scan = run_scan(&d, &local); let row = |n: &str| find(&scan.environments, n).clone(); - assert_eq!(row("done").onboarding, Some(OnboardingState::Joined)); + assert_eq!(row("done").onboarding, Some(OnboardingState::Joined { ec2: None })); for name in ["partial", "failedhere", "errored"] { let r = row(name); assert_eq!( r.onboarding, - Some(OnboardingState::Incomplete { lock: None }), + Some(OnboardingState::Incomplete { lock: None, ec2: None }), "{name}" ); // Join is kept: an idempotent re-apply finishes it. @@ -1107,3 +1114,152 @@ fn the_tls_statement_is_added_to_a_bucket_policy_never_replacing_it() { // Something that isn't a policy is never overwritten. assert!(state_bucket_policy_update(Some("not json"), &bucket).is_err()); } + +fn user_record(env: &str, tag: &str) -> Value { + let stem = crate::aws::tofu_modules::user_ec2_stem(env, tag); + json!({ + "schema": 1, + "instance_type": "m7g.large", + "cluster_arn": format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/{stem}"), + "capacity_provider": stem, + "user_tag": tag, + "max_instances": 3, + }) +} + +#[test] +fn a_user_record_reads_as_the_users_compute() { + let rec = user_record("dev", "alice"); + let c = parse_user_record("dev", &rec.to_string(), ACCOUNT, REGION).unwrap(); + assert_eq!( + c, + UserCompute { + instance_type: "m7g.large".into(), + max_instances: 3, + user_tag: "alice".into(), + cluster_arn: format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/triple-c-dev--u-alice"), + capacity_provider: "triple-c-dev--u-alice".into(), + } + ); + // A record written before max_instances existed: the module's default. + let mut old = rec.clone(); + old.as_object_mut().unwrap().remove("max_instances"); + let c = parse_user_record("dev", &old.to_string(), ACCOUNT, REGION).unwrap(); + assert_eq!(c.max_instances, 1); +} + +#[test] +fn a_user_record_is_untrusted() { + let bad = |field: &str, value: Value, why: &str| { + let mut rec = user_record("dev", "alice"); + rec[field] = value; + let err = parse_user_record("dev", &rec.to_string(), ACCOUNT, REGION).unwrap_err(); + assert!(err.contains(why), "{field}: {err}"); + assert!(!err.contains("evil"), "{err}"); + }; + bad("schema", json!(2), "schema"); + bad("instance_type", json!("p5.48xlarge"), "instance_type"); + bad("instance_type", json!(7), "instance_type"); + bad("max_instances", json!(0), "max_instances"); + bad("max_instances", json!(5), "max_instances"); + bad("max_instances", json!("2"), "max_instances"); + bad("user_tag", json!("evil--tag"), "user_tag"); + // Another user's cluster, or one in another account or region. + bad( + "cluster_arn", + json!(format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/triple-c-dev--u-bob")), + "cluster_arn", + ); + bad( + "cluster_arn", + json!(format!("arn:aws:ecs:us-east-1:{ACCOUNT}:cluster/triple-c-dev--u-alice")), + "cluster_arn", + ); + bad( + "cluster_arn", + json!(format!("arn:aws:ecs:{REGION}:999999999999:cluster/triple-c-dev--u-alice")), + "cluster_arn", + ); + bad("capacity_provider", json!("evil"), "capacity_provider"); + // Another environment's record. + let rec = user_record("prod", "alice").to_string(); + assert!(parse_user_record("dev", &rec, ACCOUNT, REGION).is_err()); + for text in ["", "not json", "[]", &"x".repeat(5000)] { + assert!(parse_user_record("dev", text, ACCOUNT, REGION).is_err()); + } +} + +fn compute_of(s: &OnboardingState) -> Option<&UserCompute> { + match s { + OnboardingState::Joined { ec2 } | OnboardingState::Incomplete { ec2, .. } => ec2.as_ref(), + _ => None, + } +} + +#[test] +fn onboarding_carries_the_users_compute_from_their_record() { + use crate::aws::tofu_modules::user_record_parameter_name; + let ok = owner_key(REGION, USER_ID); + let mut d = FakeDetect::new() + .with_record("joined", 1) + .with_record("fargate", 1) + .with_record("broken", 1) + .with_record("partial", 1) + .with_record("absent", 1); + d.roles.insert(task_role("joined"), Knowable::Yes); + d.roles.insert(task_role("fargate"), Knowable::Yes); + d.roles.insert(task_role("broken"), Knowable::Yes); + d.objects = Some(StateObjects { + states: vec![ + env_key("joined"), + env_key("fargate"), + env_key("broken"), + env_key("partial"), + env_key("absent"), + user_key("partial"), + ], + locks: vec![], + }); + d.documents.insert(user_key("partial"), "{\"resources\":[{}]}".into()); + for env in ["joined", "partial", "absent"] { + d.parameters.insert( + user_record_parameter_name(env, &ok), + user_record(env, "alice").to_string(), + ); + } + d.parameters.insert( + user_record_parameter_name("broken", &ok), + user_record("other", "alice").to_string(), + ); + // `joined`'s state is not readable here: found by role. + d.objects.as_mut().unwrap().states.retain(|k| *k != user_key("joined")); + + let scan = run_scan(&d, &nobody_local); + let onboarding = |n: &str| find(&scan.environments, n).onboarding.clone().unwrap(); + let joined = onboarding("joined"); + let compute = compute_of(&joined).expect("joined has compute"); + assert_eq!(compute.instance_type, "m7g.large"); + assert_eq!(compute.max_instances, 3); + assert_eq!(compute.user_tag, "alice"); + assert_eq!(onboarding("fargate"), OnboardingState::Joined { ec2: None }); + // A record that doesn't validate is no compute. + assert_eq!(onboarding("broken"), OnboardingState::Joined { ec2: None }); + // An incomplete onboarding keeps what its record still says. + let partial = onboarding("partial"); + assert!(matches!(partial, OnboardingState::Incomplete { .. }), "{partial:?}"); + assert_eq!(compute_of(&partial).map(|c| c.max_instances), Some(3)); + // Not joined: the record isn't even read. + assert_eq!(onboarding("absent"), OnboardingState::NotJoined); + assert!(!d + .calls() + .contains(&format!("parameter {}", user_record_parameter_name("absent", &ok)))); + + // Serialized for the UI: the state tag plus `ec2`. + let v = serde_json::to_value(&joined).unwrap(); + assert_eq!(v["state"], "joined"); + assert_eq!(v["ec2"]["capacity_provider"], "triple-c-joined--u-alice"); + assert_eq!( + serde_json::to_value(OnboardingState::Joined { ec2: None }).unwrap(), + json!({"state": "joined", "ec2": null}) + ); +} diff --git a/app/src-tauri/src/aws/live_tests.rs b/app/src-tauri/src/aws/live_tests.rs index 8d5a502..41d2ad9 100644 --- a/app/src-tauri/src/aws/live_tests.rs +++ b/app/src-tauri/src/aws/live_tests.rs @@ -1601,7 +1601,7 @@ mod environment { let found = t.scan(&cfg, &who).await; let env = found.environments.iter().find(|x| x.name == name).unwrap(); // Joined from the state's onboarding_complete output, not just the role. - assert_eq!(env.onboarding, Some(OnboardingState::Joined), "{env:#?}"); + assert_eq!(env.onboarding, Some(OnboardingState::Joined { ec2: None }), "{env:#?}"); assert_eq!(env.onboarded_users, Some(1), "{env:#?}"); let (task_role, exec_role) = user_role_names(&name, &okey); eprintln!("onboarded with region-scoped roles {task_role} / {exec_role}"); diff --git a/app/src-tauri/src/aws/tofu_modules.rs b/app/src-tauri/src/aws/tofu_modules.rs index 293fb0f..21fdfac 100644 --- a/app/src-tauri/src/aws/tofu_modules.rs +++ b/app/src-tauri/src/aws/tofu_modules.rs @@ -200,14 +200,17 @@ pub fn user_record_parameter_name(env: &str, owner_key: &str) -> String { /// The fields of a user's EC2 record, schema 1: `instance_type`, /// `cluster_arn` (the user's cluster, [`user_ec2_stem`]), /// `capacity_provider` (its one provider, the same name) and `user_tag` -/// (the `triple-c-user` value the cluster is named after). -#[allow(dead_code)] // the app reads it from Task 4 on -pub const USER_RECORD_FIELDS: [&str; 5] = [ +/// (the `triple-c-user` value the cluster is named after) and +/// `max_instances` (the group's maximum), so a re-apply can keep them. +/// `environments::parse_user_record` reads them; a test pins the HCL to it. +#[allow(dead_code)] +pub const USER_RECORD_FIELDS: [&str; 6] = [ "schema", "instance_type", "cluster_arn", "capacity_provider", "user_tag", + "max_instances", ]; /// The most instances a user's EC2 capacity may run at once. diff --git a/app/src-tauri/src/aws/tofu_modules/tests.rs b/app/src-tauri/src/aws/tofu_modules/tests.rs index 1f07ffb..e85274d 100644 --- a/app/src-tauri/src/aws/tofu_modules/tests.rs +++ b/app/src-tauri/src/aws/tofu_modules/tests.rs @@ -3230,6 +3230,7 @@ fn the_user_record_has_exactly_the_schema_fields() { "${aws_ecs_capacity_provider.ec2[0].name}" ); assert_eq!(value["user_tag"], "${var.ec2_user_tag}"); + assert_eq!(value["max_instances"], "${var.ec2_max_instances}"); assert_eq!( flat(attr(¶m.body, "depends_on").unwrap()), "[aws_ecs_cluster_capacity_providers.ec2]" diff --git a/app/src-tauri/src/commands/environment_commands.rs b/app/src-tauri/src/commands/environment_commands.rs index 79162c8..ce69822 100644 --- a/app/src-tauri/src/commands/environment_commands.rs +++ b/app/src-tauri/src/commands/environment_commands.rs @@ -30,7 +30,7 @@ use std::sync::{Mutex, OnceLock}; use std::time::Duration; use aws_config::SdkConfig; -use serde::Serialize; +use serde::{Deserialize, Serialize}; use serde_json::Value; use tauri::{AppHandle, Emitter, State}; @@ -38,9 +38,9 @@ use aws_sdk_s3::error::ProvideErrorMetadata; use tokio::sync::oneshot; use crate::aws::environments::{ - ensure_state_bucket, scan, state_bucket_policy, LIVE_LOCK_SECS, DetectedEnvironment, - EnvironmentAction, EnvironmentInfo, EnvironmentScan, EnvironmentState, Knowable, LocalRun, - OnboardingState, SdkDetectApi, + ec2_names_in_use, ensure_state_bucket, scan, state_bucket_policy, user_compute, + LIVE_LOCK_SECS, DetectedEnvironment, EnvironmentAction, EnvironmentInfo, EnvironmentScan, + EnvironmentState, Knowable, LocalRun, OnboardingState, SdkDetectApi, UserCompute, }; use crate::aws::tofu::{ self, backend_hcl, StartError, TofuEvent, TofuOp, TofuOutcome, Workdir, @@ -48,8 +48,9 @@ use crate::aws::tofu::{ use crate::aws::tofu_modules::{ boundary_vars, environment_vars, module_files, onboarding_vars, owner_key, state_bucket_name, state_key, user_ec2_stem, user_record_parameter_name, validate_ec2_user_tag, - validate_environment_name, Deployment, ModuleKind, NetworkChoice, + validate_environment_name, Deployment, Ec2Compute, ModuleKind, NetworkChoice, }; +use crate::models::project::{ec2_instance_types, Ec2InstanceType, DEFAULT_EC2_INSTANCE_TYPE}; use crate::aws::{caller_identity, sdk_config, AwsError, CallerIdentity}; use crate::models::{validate_supported_region, AwsAuth, HostConnection, HostKind}; use crate::storage::secure; @@ -273,7 +274,7 @@ pub(crate) fn onboarding_unlock_refusal( } let env = find(scan, name).ok_or_else(|| format!("No environment named \"{name}\" was found"))?; match &env.onboarding { - Some(OnboardingState::Incomplete { lock: Some(l) }) + Some(OnboardingState::Incomplete { lock: Some(l), .. }) if !l.local_process && env.onboarding_actions.contains(&EnvironmentAction::Unlock) => { Ok(()) @@ -300,6 +301,62 @@ pub(crate) fn onboard_refusal(scan: &EnvironmentScan, name: &str) -> Result<(), } /// `AlreadyRunning` is told apart before it becomes an `AwsError`. +/// The EC2 capacity an onboarding asks for: none (Fargate only), or EC2 +/// with these values. A command given no choice keeps what the user's +/// record holds ([`resolve_ec2`]). +#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)] +#[serde(tag = "kind", rename_all = "snake_case")] +pub enum Ec2Choice { + None, + Ec2(Ec2Compute), +} + +/// What an onboarding apply uses: the explicit choice, or with none given +/// the recorded capacity (a re-apply keeps it unless changed). +pub(crate) fn resolve_ec2( + choice: Option, + recorded: Option<&UserCompute>, +) -> Option { + match choice { + Some(Ec2Choice::None) => None, + Some(Ec2Choice::Ec2(c)) => Some(c), + None => recorded.map(|r| Ec2Compute { + instance_type: r.instance_type.clone(), + max_instances: r.max_instances, + user_tag: r.user_tag.clone(), + }), + } +} + +/// R3: an onboarding apply with EC2 capacity would adopt (or fail on) a +/// per-user cluster or Auto Scaling group named `stem` that already +/// exists, so it is allowed only when this owner's own record names that +/// cluster (a re-apply of their capacity). +pub(crate) fn ec2_collision_refusal( + stem: &str, + cluster_in_use: bool, + group_in_use: bool, + recorded: Option<&UserCompute>, +) -> Result<(), String> { + if !cluster_in_use && !group_in_use { + return Ok(()); + } + let suffix = format!(":cluster/{stem}"); + if recorded.is_some_and(|r| r.cluster_arn.ends_with(&suffix)) { + return Ok(()); + } + let what = match (cluster_in_use, group_in_use) { + (true, true) => "An ECS cluster and an Auto Scaling group named {stem} already belong", + (true, false) => "An ECS cluster named {stem} already belongs", + _ => "An Auto Scaling group named {stem} already belongs", + } + .replace("{stem}", stem); + Err(format!( + "{what} to another onboarding. The triple-c-user value is \ + probably wrong: use the value an admin set as your triple-c-user sign-in tag" + )) +} + pub(crate) fn start_error(e: StartError, label: &str) -> AwsError { match e { StartError::AlreadyRunning => other(format!( @@ -426,8 +483,7 @@ fn ec2_collision_step(env: &str, owner_key: &str, region: &str, user_tag: Option let stem = user_ec2_stem(env, user_tag.unwrap_or("")); let record = user_record_parameter_name(env, owner_key); format!( - " -EC2 capacity (only if ec2_instance_type is set) + "EC2 capacity (only if ec2_instance_type is set) ------------------------------------------------ ec2_user_tag must be the value of the user's triple-c-user principal tag. BEFORE tofu apply, check that the per-user EC2 names are not already in use @@ -441,6 +497,7 @@ If either of the first two prints {stem}, apply ONLY if the third (this user's record) succeeds and its cluster_arn ends in cluster/{stem}; otherwise the name belongs to someone else's onboarding: stop and choose the correct ec2_user_tag. (The app runs the same check before applying.) + " ) } @@ -535,7 +592,7 @@ AWS CLI v2 recent enough that create-bucket accepts Tags, e.g. 2.39): aws s3api put-public-access-block --bucket {bucket} --region {region} --expected-bucket-owner {account} --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true aws s3api put-bucket-policy --bucket {bucket} --region {region} --expected-bucket-owner {account} --policy '{policy}' -2. Deploy +{ec2_step}2. Deploy --------- From this folder: @@ -544,7 +601,7 @@ From this folder: (With Terraform: terraform init -backend-config=backend.hcl, then terraform apply.) -{ec2_step} + 3. Remove --------- From this folder, after tofu init: @@ -1363,12 +1420,15 @@ pub async fn cancel_aws_deployment( } /// Onboard the caller to `environment`, as the owner their own -/// `aws:userid` names. +/// `aws:userid` names, with the EC2 capacity `ec2` asks for (omitted: keep +/// what their user record holds, none without one). With EC2 capacity the +/// per-user names must be free or already theirs (R3). #[tauri::command] pub async fn onboard_aws_user( connection_id: String, region: String, environment: String, + ec2: Option, app: AppHandle, state: State<'_, AppState>, ) -> Result { @@ -1377,14 +1437,42 @@ pub async fn onboard_aws_user( let owner = validate_owner_id(&ctx.who.user_id).map_err(other)?; let found = detect(&ctx).await?; onboard_refusal(&found, &env).map_err(other)?; - let vars = onboarding_vars(&env, &ctx.region, &owner, None).map_err(other)?; + let okey = owner_key(&ctx.region, &owner); + let api = SdkDetectApi::new(&ctx.cfg, &ctx.who.account); + let recorded = user_compute(&api, &env, &okey, &ctx.who.account, &ctx.region).await?; + let compute = resolve_ec2(ec2, recorded.as_ref()); + let vars = onboarding_vars(&env, &ctx.region, &owner, compute.as_ref()).map_err(other)?; + if let Some(c) = &compute { + // R3: before any apply with EC2 capacity. The caller's own + // triple-c-user tag can't be read (session tags aren't visible to + // GetCallerIdentity); a wrong value fails later as access denied. + let stem = user_ec2_stem(&env, &c.user_tag); + let (cluster, group) = ec2_names_in_use(&ctx.cfg, &stem).await?; + ec2_collision_refusal(&stem, cluster, group, recorded.as_ref()).map_err(other)?; + } let key = DeploymentKey::User { - owner_key: owner_key(&ctx.region, &owner), + owner_key: okey, env, }; opened(launch(app, &ctx, &key, &vars, TofuOp::Apply).await) } +/// The EC2 instance types onboarding offers (the app's built-in table) and +/// the one it offers first. +#[derive(Serialize, Clone, Debug, PartialEq)] +pub struct Ec2InstanceTable { + pub default_type: &'static str, + pub types: Vec, +} + +#[tauri::command] +pub fn list_ec2_instance_types() -> Ec2InstanceTable { + Ec2InstanceTable { + default_type: DEFAULT_EC2_INSTANCE_TYPE, + types: ec2_instance_types(), + } +} + /// Deploy (or re-apply) the account's permissions boundary. Refused when /// the boundary exists but this region's bucket has no state for it. #[tauri::command] @@ -1424,8 +1512,10 @@ async fn pick_folder(window: &tauri::Window) -> Option { /// Write an admin bundle (D5) for `kind` into a folder the user picks: /// `environment` names the environment (environment and onboarding), /// `owner_id` the user to onboard (an `aws:userid`), `network` an -/// environment's network (public when omitted). `None` when the dialog was -/// dismissed; otherwise the folder written. +/// environment's network (public when omitted), `ec2` an onboarding's EC2 +/// capacity (none when omitted; the bundle's README has the admin check +/// its names first). `None` when the dialog was dismissed; otherwise the +/// folder written. #[allow(clippy::too_many_arguments)] #[tauri::command] pub async fn save_aws_admin_bundle( @@ -1436,6 +1526,7 @@ pub async fn save_aws_admin_bundle( owner_id: Option, network: Option, max_workspace_hours: Option, + ec2: Option, window: tauri::Window, state: State<'_, AppState>, ) -> Result, AwsError> { @@ -1466,7 +1557,7 @@ pub async fn save_aws_admin_bundle( .map(str::trim) .ok_or_else(|| other("The user's owner id (aws:userid) is required")) .and_then(|o| validate_owner_id(o).map_err(other))?; - let vars = onboarding_vars(&env, ®ion_ok, &owner, None).map_err(other)?; + let vars = onboarding_vars(&env, ®ion_ok, &owner, ec2.as_ref()).map_err(other)?; ( DeploymentKey::User { owner_key: owner_key(®ion_ok, &owner), diff --git a/app/src-tauri/src/commands/environment_commands/tests.rs b/app/src-tauri/src/commands/environment_commands/tests.rs index ad7553e..39f7007 100644 --- a/app/src-tauri/src/commands/environment_commands/tests.rs +++ b/app/src-tauri/src/commands/environment_commands/tests.rs @@ -6,7 +6,7 @@ use serde_json::json; use super::*; use crate::aws::tofu::Workdir; use crate::aws::environments::{ - EnvironmentState, Knowable, LockInfo, OnboardingState, + EnvironmentState, Knowable, LockInfo, OnboardingState, UserCompute, }; use crate::aws::tofu_modules::{ environment_vars, module_files, onboarding_vars, owner_key, state_key, ModuleKind, @@ -278,6 +278,10 @@ fn bundles_contain_the_module_backend_vars_and_readme() { assert!(readme_tagged.contains("--clusters triple-c-dev--u-alice "), "{readme_tagged}"); assert!(readme_tagged.contains("--auto-scaling-group-names triple-c-dev--u-alice ")); assert!(!readme_tagged.contains("")); + // The check comes before the apply it guards. + let check = readme.find("BEFORE tofu apply").unwrap(); + let apply = readme.find(" tofu apply").unwrap(); + assert!(check < apply, "{readme}"); // Not in the other bundles. let env_dir = tempfile::tempdir().unwrap(); let env_vars = environment_vars("dev", REGION, &NetworkChoice::Public, 0).unwrap(); @@ -539,12 +543,12 @@ fn destroy_is_refused_while_users_are_onboarded() { fn only_your_own_stale_onboarding_lock_can_be_removed() { use EnvironmentAction::*; let mut stale = env("dev", EnvironmentState::Ready, vec![Join]); - stale.onboarding = Some(OnboardingState::Incomplete { lock: Some(lock(9000, false)) }); + stale.onboarding = Some(OnboardingState::Incomplete { lock: Some(lock(9000, false)), ec2: None }); stale.onboarding_actions = vec![Unlock]; let mut live = env("live", EnvironmentState::Ready, vec![Join]); live.onboarding = Some(OnboardingState::InProgress { lock: Some(lock(10, false)) }); let mut none = env("none", EnvironmentState::Ready, vec![Join]); - none.onboarding = Some(OnboardingState::Incomplete { lock: None }); + none.onboarding = Some(OnboardingState::Incomplete { lock: None, ec2: None }); let s = scan(Knowable::Yes, vec![stale, live, none]); let mine = owner_key(REGION, USER_ID); assert!(onboarding_unlock_refusal(&s, "dev", &mine).is_ok()); @@ -663,3 +667,88 @@ fn ending_a_launch_never_clears_a_following_slot() { assert_eq!(slots.begin_launch(dir).unwrap_err(), SlotBusy::Following); slots.end_launch(Path::new("/w/env/none")); // nothing there: no-op } + +fn recorded(env: &str, tag: &str, max: u32) -> UserCompute { + let stem = crate::aws::tofu_modules::user_ec2_stem(env, tag); + UserCompute { + instance_type: "m7g.xlarge".into(), + max_instances: max, + user_tag: tag.into(), + cluster_arn: format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/{stem}"), + capacity_provider: stem, + } +} + +#[test] +fn a_reapply_keeps_the_recorded_compute_unless_changed() { + let rec = recorded("dev", "alice", 3); + let kept = Ec2Compute { + instance_type: "m7g.xlarge".into(), + max_instances: 3, + user_tag: "alice".into(), + }; + // Omitted: keep what the record says (or none without one). + assert_eq!(resolve_ec2(None, Some(&rec)), Some(kept.clone())); + assert_eq!(resolve_ec2(None, None), None); + // Explicitly none: the re-apply removes it. + assert_eq!(resolve_ec2(Some(Ec2Choice::None), Some(&rec)), None); + // A new choice wins. + let new = Ec2Compute { + instance_type: "m7i.large".into(), + max_instances: 1, + user_tag: "alice".into(), + }; + assert_eq!( + resolve_ec2(Some(Ec2Choice::Ec2(new.clone())), Some(&rec)), + Some(new.clone()) + ); + // The kept values reach the module's variables unchanged. + let vars = onboarding_vars("dev", REGION, USER_ID, resolve_ec2(None, Some(&rec)).as_ref()).unwrap(); + assert_eq!(vars["ec2_instance_type"], "m7g.xlarge"); + assert_eq!(vars["ec2_max_instances"], 3); + assert_eq!(vars["ec2_user_tag"], "alice"); + let vars = onboarding_vars("dev", REGION, USER_ID, Some(&new)).unwrap(); + assert_eq!(vars["ec2_instance_type"], "m7i.large"); + assert_eq!(vars["ec2_max_instances"], 1); + + // The UI's JSON for each choice. + let none: Ec2Choice = serde_json::from_value(json!({"kind": "none"})).unwrap(); + assert_eq!(none, Ec2Choice::None); + let ec2: Ec2Choice = serde_json::from_value(json!({ + "kind": "ec2", "instance_type": "m7i.large", "max_instances": 1, "user_tag": "alice" + })) + .unwrap(); + assert_eq!(ec2, Ec2Choice::Ec2(new)); +} + +#[test] +fn ec2_names_in_use_by_another_onboarding_are_refused() { + let stem = "triple-c-dev--u-alice"; + // Free names: fine, with or without a record. + assert!(ec2_collision_refusal(stem, false, false, None).is_ok()); + assert!(ec2_collision_refusal(stem, false, false, Some(&recorded("dev", "bob", 1))).is_ok()); + // Taken, and this owner's record names that cluster: their own re-apply. + let mine = recorded("dev", "alice", 2); + for (cluster, group) in [(true, false), (false, true), (true, true)] { + assert!(ec2_collision_refusal(stem, cluster, group, Some(&mine)).is_ok()); + // Taken with no record, or a record naming another cluster. + for other in [None, Some(recorded("dev", "bob", 1))] { + let e = ec2_collision_refusal(stem, cluster, group, other.as_ref()).unwrap_err(); + assert!(e.contains(stem), "{e}"); + assert!(e.contains("triple-c-user"), "{e}"); + } + } + // A cluster that merely ends in the same text is not the same cluster. + let mut lookalike = recorded("dev", "alice", 1); + lookalike.cluster_arn = format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/x{stem}"); + assert!(ec2_collision_refusal(stem, true, false, Some(&lookalike)).is_err()); +} + +#[test] +fn the_ui_gets_the_apps_instance_table() { + let table = list_ec2_instance_types(); + assert_eq!(table.types, crate::models::project::ec2_instance_types()); + assert_eq!(table.types.len(), 30); + assert_eq!(table.default_type, "m7i.large"); + assert!(table.types.iter().any(|t| t.instance_type == table.default_type)); +} diff --git a/app/src-tauri/src/lib.rs b/app/src-tauri/src/lib.rs index 0a77116..f99e53b 100644 --- a/app/src-tauri/src/lib.rs +++ b/app/src-tauri/src/lib.rs @@ -644,6 +644,7 @@ pub fn run() { commands::environment_commands::cancel_aws_deployment, commands::environment_commands::push_aws_saved_state, commands::environment_commands::onboard_aws_user, + commands::environment_commands::list_ec2_instance_types, commands::environment_commands::deploy_aws_permissions_boundary, commands::environment_commands::save_aws_admin_bundle, commands::settings_commands::detect_host_timezone, diff --git a/app/src-tauri/src/models/project.rs b/app/src-tauri/src/models/project.rs index 4af52e8..b9ee871 100644 --- a/app/src-tauri/src/models/project.rs +++ b/app/src-tauri/src/models/project.rs @@ -718,6 +718,47 @@ fn describe_sizes(sizes: &[u32]) -> String { pub const EC2_RESERVED_CPU_UNITS: u32 = 128; pub const EC2_RESERVED_MEMORY_MIB: u32 = 256; +/// The instance families the built-in table knows, in the order the app +/// lists them; a family ending in `g` is Graviton (ARM). +const EC2_FAMILIES: [&str; 8] = ["m7i", "c7i", "r7i", "t3", "m7g", "c7g", "r7g", "t4g"]; +const EC2_SIZES: [&str; 4] = ["large", "xlarge", "2xlarge", "4xlarge"]; + +/// The instance type onboarding offers first (x86; `m7g.large` is its ARM +/// counterpart). +pub const DEFAULT_EC2_INSTANCE_TYPE: &str = "m7i.large"; + +/// One row of the built-in instance table, for the onboarding UI. +#[derive(Debug, Clone, Serialize, PartialEq, Eq)] +pub struct Ec2InstanceType { + pub instance_type: String, + pub arch: Arch, + pub vcpu: u32, + pub memory_mib: u32, +} + +/// Every type [`ec2_instance_spec`] knows (x86 families first), so the UI's +/// list and the app's validation share one table. +pub fn ec2_instance_types() -> Vec { + EC2_FAMILIES + .iter() + .flat_map(|family| EC2_SIZES.iter().map(move |size| format!("{family}.{size}"))) + .filter_map(|instance_type| { + let (cpu, memory_mib) = ec2_instance_spec(&instance_type)?; + let arch = if instance_type.split('.').next()?.ends_with('g') { + Arch::Arm64 + } else { + Arch::X86_64 + }; + Some(Ec2InstanceType { + instance_type, + arch, + vcpu: cpu / 1024, + memory_mib, + }) + }) + .collect() +} + /// `(vcpu * 1024, memory MiB)` of a common EC2 instance type, or None when the /// type is not in the built-in table (m7i, m7g, c7i, c7g, r7i, r7g, t3, t4g). pub fn ec2_instance_spec(instance_type: &str) -> Option<(u32, u32)> { @@ -1563,6 +1604,32 @@ mod tests { assert!(validate_aws_workspace(&cfg(1500, 3000)).is_err()); } + #[test] + fn the_instance_type_list_is_the_table() { + let list = ec2_instance_types(); + assert_eq!(list.len(), 30); + for t in &list { + assert_eq!( + ec2_instance_spec(&t.instance_type), + Some((t.vcpu * 1024, t.memory_mib)), + "{}", + t.instance_type + ); + } + let arch = |name: &str| list.iter().find(|t| t.instance_type == name).unwrap().arch; + assert_eq!(arch("m7i.large"), Arch::X86_64); + assert_eq!(arch("t3.xlarge"), Arch::X86_64); + assert_eq!(arch("m7g.large"), Arch::Arm64); + assert_eq!(arch("t4g.2xlarge"), Arch::Arm64); + assert!(list.iter().any(|t| t.instance_type == DEFAULT_EC2_INSTANCE_TYPE)); + assert_eq!(arch(DEFAULT_EC2_INSTANCE_TYPE), Arch::X86_64); + let first = &list[0]; + assert_eq!( + serde_json::to_value(first).unwrap(), + serde_json::json!({"instance_type": "m7i.large", "arch": "x86_64", "vcpu": 2, "memory_mib": 8192}) + ); + } + #[test] fn instance_table_values() { assert_eq!(ec2_instance_spec("m7i.large"), Some((2048, 8192))); diff --git a/app/src/components/settings/hosts/AdminBundleModal.test.tsx b/app/src/components/settings/hosts/AdminBundleModal.test.tsx index 00228c4..7b62625 100644 --- a/app/src/components/settings/hosts/AdminBundleModal.test.tsx +++ b/app/src/components/settings/hosts/AdminBundleModal.test.tsx @@ -1,6 +1,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest"; import { fireEvent, render, screen, waitFor } from "@testing-library/react"; import AdminBundleModal from "./AdminBundleModal"; +import { instanceTable } from "./testkit"; const invoke = vi.fn(); vi.mock("@tauri-apps/api/core", () => ({ @@ -11,7 +12,9 @@ describe("AdminBundleModal", () => { beforeEach(() => vi.clearAllMocks()); it("saves the bundle and shows the folder and the two commands, with Copy", async () => { - invoke.mockResolvedValue("/home/me/triple-c-onboard-dev"); + invoke.mockImplementation(async (cmd: string) => + cmd === "list_ec2_instance_types" ? instanceTable : "/home/me/triple-c-onboard-dev", + ); const writeText = vi.fn().mockResolvedValue(undefined); Object.assign(navigator, { clipboard: { writeText } }); render( @@ -28,11 +31,47 @@ describe("AdminBundleModal", () => { environment: "dev", ownerId: "AIDAEXAMPLE", network: null, + ec2: null, }); const commands = "tofu init -backend-config=backend.hcl\ntofu apply"; expect(screen.getByText((_, el) => el?.tagName === "PRE" && el.textContent === commands)).toBeInTheDocument(); fireEvent.click(screen.getByRole("button", { name: "Copy commands" })); await waitFor(() => expect(writeText).toHaveBeenCalledWith(commands)); + expect(invoke.mock.calls.filter((c) => c[0] === "save_aws_admin_bundle")).toHaveLength(1); + }); + + it("an onboarding bundle carries the chosen EC2 capacity", async () => { + invoke.mockImplementation(async (cmd: string) => + cmd === "list_ec2_instance_types" ? instanceTable : "/tmp/onboard", + ); + render( + , + ); + fireEvent.click(screen.getByRole("radio", { name: "My own EC2 instances" })); + await waitFor(() => expect((screen.getByLabelText("Instance type") as HTMLSelectElement).value).toBe("m7i.large")); + const save = screen.getByRole("button", { name: "Save bundle to folder…" }); + // The triple-c-user value is required with EC2. + expect(save).toBeDisabled(); + fireEvent.change(screen.getByLabelText("Your triple-c-user value"), { target: { value: " bob " } }); + fireEvent.change(screen.getByLabelText("Maximum instances"), { target: { value: "4" } }); + fireEvent.click(save); + await waitFor(() => + expect(invoke).toHaveBeenCalledWith("save_aws_admin_bundle", { + connectionId: "h1", + region: "eu-west-1", + kind: "user_onboard", + environment: "dev", + ownerId: "AIDAEXAMPLE", + network: null, + ec2: { instance_type: "m7i.large", max_instances: 4, user_tag: "bob" }, + }), + ); + }); + + it("an environment bundle has no EC2 capacity", () => { + invoke.mockResolvedValue(instanceTable); + render(); + expect(screen.queryByRole("radio", { name: "My own EC2 instances" })).toBeNull(); }); it("shows nothing new when the folder picker is dismissed", async () => { diff --git a/app/src/components/settings/hosts/AdminBundleModal.tsx b/app/src/components/settings/hosts/AdminBundleModal.tsx index e6b372f..ffe4e0a 100644 --- a/app/src/components/settings/hosts/AdminBundleModal.tsx +++ b/app/src/components/settings/hosts/AdminBundleModal.tsx @@ -1,13 +1,22 @@ import { useState } from "react"; import { saveAwsAdminBundle } from "../../../lib/tauri-commands"; import { awsErrorMessage, toAwsError } from "../../../lib/aws-error"; -import type { AwsError, ModuleKind, NetworkChoice } from "../../../lib/types"; +import type { AwsError, ModuleKind, NetworkChoice, UserCompute } from "../../../lib/types"; import Button from "../../ui/Button"; import Field, { inputClass } from "../../ui/Field"; import Modal from "../../ui/Modal"; import LifetimeCapField, { parseCapHours } from "./LifetimeCapField"; +import Ec2CapacityFields from "./Ec2CapacityFields"; import NetworkFields from "./NetworkFields"; -import { DEFAULT_NETWORK, environmentNameError, networkFromDraft, type NetworkDraft } from "./environmentFormat"; +import { + DEFAULT_NETWORK, + ec2DraftFrom, + ec2FromDraft, + environmentNameError, + networkFromDraft, + type Ec2Draft, + type NetworkDraft, +} from "./environmentFormat"; const COMMANDS = "tofu init -backend-config=backend.hcl\ntofu apply"; @@ -29,6 +38,7 @@ export default function AdminBundleModal({ environment, ownerId, network, + recordedEc2, reason, onSaved, onClose, @@ -40,6 +50,8 @@ export default function AdminBundleModal({ environment?: string; ownerId?: string; network?: NetworkChoice; + /** An onboarding bundle's starting EC2 capacity: the user's recorded one, if any. */ + recordedEc2?: UserCompute | null; /** Why the bundle is needed (e.g. the refusal that led here). */ reason?: string; /** Called with the folder once a bundle was actually written. */ @@ -50,6 +62,7 @@ export default function AdminBundleModal({ const [name, setName] = useState("main"); const [draft, setDraft] = useState(DEFAULT_NETWORK); const [capText, setCapText] = useState("0"); + const [ec2Draft, setEc2Draft] = useState(() => ec2DraftFrom(recordedEc2)); const [saving, setSaving] = useState(false); const [saved, setSaved] = useState(null); const [error, setError] = useState(null); @@ -58,7 +71,13 @@ export default function AdminBundleModal({ const nameError = askEnvironment ? environmentNameError(name) : null; const picked = askEnvironment ? networkFromDraft(draft) : null; const capHours = parseCapHours(capText); - const ready = !nameError && (!picked || "network" in picked) && (!askEnvironment || capHours !== null); + const onboarding = kind === "user_onboard"; + const ec2 = onboarding ? ec2FromDraft(ec2Draft) : null; + const ready = + !nameError && + (!picked || "network" in picked) && + (!askEnvironment || capHours !== null) && + (!ec2 || "compute" in ec2); const save = async () => { setSaving(true); @@ -69,6 +88,7 @@ export default function AdminBundleModal({ ownerId, network: picked && "network" in picked ? picked.network : network, ...(askEnvironment && capHours !== null ? { maxWorkspaceHours: capHours } : {}), + ...(ec2 && "compute" in ec2 ? { ec2: ec2.compute } : {}), }); if (folder) { setSaved(folder); @@ -116,6 +136,7 @@ export default function AdminBundleModal({

Joining {environment} needs your own task role and file system, which an environment admin creates by applying this bundle. Send them the folder; once it's applied, Detect again shows you as joined. + With EC2 capacity, its README has the admin first check that your EC2 names aren't already taken.

)} {kind === "permissions_boundary" && ( @@ -125,6 +146,7 @@ export default function AdminBundleModal({

)}

The bundle works with OpenTofu or Terraform 1.10 and later. Its README lists every step.

+ {onboarding && } {askEnvironment && (
diff --git a/app/src/components/settings/hosts/Ec2CapacityFields.tsx b/app/src/components/settings/hosts/Ec2CapacityFields.tsx new file mode 100644 index 0000000..5e11387 --- /dev/null +++ b/app/src/components/settings/hosts/Ec2CapacityFields.tsx @@ -0,0 +1,141 @@ +import { useEffect, useState } from "react"; +import { listEc2InstanceTypes } from "../../../lib/tauri-commands"; +import type { Ec2InstanceTable, Ec2InstanceType } from "../../../lib/types"; +import Field, { monoInputClass, selectClass } from "../../ui/Field"; +import SegmentedControl from "../../ui/SegmentedControl"; +import { EC2_MAX_INSTANCES, userTagError, type Ec2Draft } from "./environmentFormat"; + +const label = (t: Ec2InstanceType) => `${t.instance_type} — ${t.vcpu} vCPU, ${t.memory_mib / 1024} GiB`; + +/** + * An onboarding's EC2 capacity (phase 7): none, or the user's own instances + * of one type from the app's table, up to a maximum, on the cluster named + * after their `triple-c-user` sign-in tag. Shared by self-onboarding and the + * onboarding bundle. + */ +export default function Ec2CapacityFields({ + value, + onChange, +}: { + value: Ec2Draft; + onChange: (next: Ec2Draft) => void; +}) { + const [table, setTable] = useState(null); + const [loadError, setLoadError] = useState(false); + const set = (patch: Partial) => onChange({ ...value, ...patch }); + + useEffect(() => { + let live = true; + listEc2InstanceTypes() + .then((t) => live && setTable(t)) + .catch(() => live && setLoadError(true)); + return () => { + live = false; + }; + }, []); + + // The table's default fills an empty choice once the table is known. + useEffect(() => { + if (table && !value.instanceType) onChange({ ...value, instanceType: table.default_type }); + }, [table, value, onChange]); + + const tagError = value.enabled && value.userTag ? userTagError(value.userTag.trim()) : null; + const x86 = table?.types.filter((t) => t.arch === "x86_64") ?? []; + const arm = table?.types.filter((t) => t.arch === "arm64") ?? []; + + return ( +
+
EC2 capacity
+ + label="EC2 capacity" + value={value.enabled ? "ec2" : "none"} + onChange={(v) => set({ enabled: v === "ec2" })} + segments={[ + { value: "none", label: "None (Fargate only)" }, + { value: "ec2", label: "My own EC2 instances" }, + ]} + /> +

+ {value.enabled + ? "Projects set to EC2 run on instances only you use. Instances scale to zero when none of your workspaces run; a start after idle takes 2–3 minutes longer. You pay the instance's hourly price while it runs." + : "Every project runs on Fargate. You can add EC2 capacity later by applying again."} +

+ {value.enabled && ( +
+ + {(id) => ( + + )} + + {loadError && ( +

+ Could not load the instance types. +

+ )} + + {(id) => ( + + )} + + + {(id) => ( + set({ userTag: e.target.value })} + /> + )} + +

+ Triple-C can't read your sign-in's tags to check this value. If it isn't exactly your triple-c-user tag, + EC2 workspaces fail to start with access denied. +

+
+ )} +
+ ); +} diff --git a/app/src/components/settings/hosts/EnvironmentsPanel.test.tsx b/app/src/components/settings/hosts/EnvironmentsPanel.test.tsx index 16ebc41..9486ba8 100644 --- a/app/src/components/settings/hosts/EnvironmentsPanel.test.tsx +++ b/app/src/components/settings/hosts/EnvironmentsPanel.test.tsx @@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest"; import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react"; import EnvironmentsPanel from "./EnvironmentsPanel"; import type { DeployProgress, EnvironmentScan } from "../../../lib/types"; -import { conn, env, info, progress, scan, tofuEvent } from "./testkit"; +import { compute, conn, env, info, instanceTable, progress, scan, tofuEvent } from "./testkit"; const invoke = vi.fn(); vi.mock("@tauri-apps/api/core", () => ({ @@ -72,7 +72,7 @@ describe("EnvironmentsPanel", () => { }); it("deploy is secondary when environments exist", async () => { - backend(() => scan({ environments: [env({ onboarding: { state: "joined" }, actions: [] })] })); + backend(() => scan({ environments: [env({ onboarding: { state: "joined", ec2: null }, actions: [] })] })); render(); await open(); const deploy = await screen.findByRole("button", { name: "Deploy a new environment" }); @@ -204,9 +204,10 @@ describe("EnvironmentsPanel", () => { backend( () => { detects += 1; - return scan({ environments: [env({ onboarding: detects > 1 ? { state: "joined" } : { state: "not_joined" } })] }); + return scan({ environments: [env({ onboarding: detects > 1 ? { state: "joined", ec2: null } : { state: "not_joined" } })] }); }, async (cmd) => { + if (cmd === "list_ec2_instance_types") return instanceTable; if (cmd === "onboard_aws_user") { // The backend can emit before the invoke resolves: an old follower's // line (another op) and this run's first line. @@ -220,9 +221,18 @@ describe("EnvironmentsPanel", () => { render(); await open(); fireEvent.click(await screen.findByRole("button", { name: "Join dev" })); + // The join dialog asks for EC2 capacity first; none is the default. + const dialog = screen.getByRole("dialog", { name: "Join dev" }); + fireEvent.click(within(dialog).getByRole("button", { name: "Join" })); expect(await screen.findByText("Planning")).toBeInTheDocument(); + expect(screen.queryByRole("dialog")).toBeNull(); expect(screen.queryByText("stale line")).toBeNull(); - expect(invoke).toHaveBeenCalledWith("onboard_aws_user", { connectionId: "h1", region: "eu-west-1", environment: "dev" }); + expect(invoke).toHaveBeenCalledWith("onboard_aws_user", { + connectionId: "h1", + region: "eu-west-1", + environment: "dev", + ec2: { kind: "none" }, + }); expect(screen.getByRole("button", { name: "Cancel deployment" })).toBeDisabled(); emit(progress({ op_id: "op1", state_key: key, events: [tofuEvent("Creating...", { resource: "aws_iam_role.task", action: "create" })] })); @@ -261,6 +271,7 @@ describe("EnvironmentsPanel", () => { environment: "dev", ownerId: "AIDAEXAMPLEEXAMPLE01", network: null, + ec2: null, }), ); expect(invoke.mock.calls.some((c) => c[0] === "onboard_aws_user")).toBe(false); @@ -268,6 +279,111 @@ describe("EnvironmentsPanel", () => { expect(within(screen.getByTestId("env-dev")).getByText("Waiting for an admin to onboard you")).toBeInTheDocument(); }); + it("an admin joins with EC2 capacity: a type from the table, max instances and their triple-c-user value", async () => { + backend( + () => scan({ environments: [env()] }), + (cmd) => { + if (cmd === "list_ec2_instance_types") return instanceTable; + if (cmd === "onboard_aws_user") return "op1"; + throw new Error(`unexpected ${cmd}`); + }, + ); + render(); + await open(); + fireEvent.click(await screen.findByRole("button", { name: "Join dev" })); + const dialog = screen.getByRole("dialog", { name: "Join dev" }); + fireEvent.click(within(dialog).getByRole("radio", { name: "My own EC2 instances" })); + const type = within(dialog).getByLabelText("Instance type") as HTMLSelectElement; + // The table's default, grouped by architecture. + await waitFor(() => expect(type.value).toBe("m7i.large")); + const groups = [...type.querySelectorAll("optgroup")].map((g) => g.label); + expect(groups).toEqual(["x86 (Intel)", "ARM (Graviton)"]); + expect(within(dialog).getByRole("option", { name: "m7g.large — 2 vCPU, 8 GiB" })).toBeInTheDocument(); + expect(within(dialog).getByText(/admin set as your triple-c-user sign-in tag/)).toBeInTheDocument(); + expect(within(dialog).getByText(/fail to start with access denied/)).toBeInTheDocument(); + // The value is required and validated. + const joinButton = within(dialog).getByRole("button", { name: "Join" }); + expect(joinButton).toBeDisabled(); + const tag = within(dialog).getByLabelText("Your triple-c-user value"); + fireEvent.change(tag, { target: { value: "al--ice" } }); + expect(within(dialog).getByText(/single hyphens/)).toBeInTheDocument(); + expect(joinButton).toBeDisabled(); + fireEvent.change(tag, { target: { value: "alice" } }); + fireEvent.change(type, { target: { value: "m7g.large" } }); + fireEvent.change(within(dialog).getByLabelText("Maximum instances"), { target: { value: "2" } }); + fireEvent.click(joinButton); + await waitFor(() => + expect(invoke).toHaveBeenCalledWith("onboard_aws_user", { + connectionId: "h1", + region: "eu-west-1", + environment: "dev", + ec2: { kind: "ec2", instance_type: "m7g.large", max_instances: 2, user_tag: "alice" }, + }), + ); + }); + + it("shows a joined user's compute, and a change starts from the recorded values", async () => { + backend( + () => + scan({ + environments: [ + env({ onboarding: { state: "joined", ec2: compute() } }), + env({ name: "plain", onboarding: { state: "joined", ec2: null } }), + ], + }), + (cmd) => { + if (cmd === "list_ec2_instance_types") return instanceTable; + if (cmd === "onboard_aws_user") return "op1"; + throw new Error(`unexpected ${cmd}`); + }, + ); + render(); + await open(); + expect(await screen.findByTestId("compute-dev")).toHaveTextContent( + "EC2 capacity: m7g.xlarge, up to 3 instances (triple-c-user alice)", + ); + expect(screen.getByTestId("compute-plain")).toHaveTextContent("EC2 capacity: none (Fargate only)"); + // Joined: no Join, but the capacity can be changed (a re-apply). + const row = screen.getByTestId("env-dev"); + expect(within(row).queryByRole("button", { name: "Join dev" })).toBeNull(); + fireEvent.click(within(row).getByRole("button", { name: "EC2 capacity in dev" })); + const dialog = screen.getByRole("dialog", { name: "EC2 capacity in dev" }); + expect((within(dialog).getByLabelText("Instance type") as HTMLSelectElement).value).toBe("m7g.xlarge"); + expect((within(dialog).getByLabelText("Maximum instances") as HTMLSelectElement).value).toBe("3"); + expect((within(dialog).getByLabelText("Your triple-c-user value") as HTMLInputElement).value).toBe("alice"); + fireEvent.click(within(dialog).getByRole("button", { name: "Apply" })); + await waitFor(() => + expect(invoke).toHaveBeenCalledWith("onboard_aws_user", { + connectionId: "h1", + region: "eu-west-1", + environment: "dev", + ec2: { kind: "ec2", instance_type: "m7g.xlarge", max_instances: 3, user_tag: "alice" }, + }), + ); + }); + + it("a joined workspace user's capacity change is a bundle starting from their record", async () => { + backend( + () => scan({ environments: [env({ onboarding: { state: "joined", ec2: compute({ max_instances: 1 }) } })] }), + (cmd) => { + if (cmd === "list_ec2_instance_types") return instanceTable; + if (cmd === "save_aws_admin_bundle") return "/home/me/onboard-dev"; + throw new Error(`unexpected ${cmd}`); + }, + ); + render(); + await open(); + fireEvent.click(await screen.findByRole("button", { name: "EC2 capacity in dev" })); + const dialog = screen.getByRole("dialog", { name: "Onboarding bundle" }); + fireEvent.click(within(dialog).getByRole("button", { name: "Save bundle to folder…" })); + await waitFor(() => + expect(invoke).toHaveBeenCalledWith( + "save_aws_admin_bundle", + expect.objectContaining({ ec2: { instance_type: "m7g.xlarge", max_instances: 1, user_tag: "alice" } }), + ), + ); + }); + it("follows a deployment running on this machine when opened, and cancels after confirming", async () => { const lock = { who: "me@here", created: "x", operation: "OperationTypeApply", age_secs: 60, local_process: true }; backend( @@ -303,7 +419,7 @@ describe("EnvironmentsPanel", () => { it("Update pre-fills the environment's recorded cap and sends what is shown", async () => { backend( - () => scan({ environments: [env({ state: { state: "update_available" }, actions: ["join", "update"], info: { ...info("dev"), max_workspace_hours: 24 }, onboarding: { state: "joined" } })] }), + () => scan({ environments: [env({ state: { state: "update_available" }, actions: ["join", "update"], info: { ...info("dev"), max_workspace_hours: 24 }, onboarding: { state: "joined", ec2: null } })] }), async (cmd) => { if (cmd === "update_aws_environment") return "u1"; throw new Error(`unexpected ${cmd}`); @@ -326,7 +442,7 @@ describe("EnvironmentsPanel", () => { it("shows a failed run's errors in full", async () => { backend( - () => scan({ environments: [env({ state: { state: "update_available" }, actions: ["join", "update"], onboarding: { state: "joined" } })] }), + () => scan({ environments: [env({ state: { state: "update_available" }, actions: ["join", "update"], onboarding: { state: "joined", ec2: null } })] }), async (cmd) => { if (cmd === "update_aws_environment") return "u1"; throw new Error(`unexpected ${cmd}`); @@ -383,7 +499,7 @@ describe("EnvironmentsPanel", () => { expect(screen.queryByRole("button", { name: "Destroy dev" })).toBeNull(); expect(screen.queryByRole("button", { name: "Deploy a new environment" })).toBeNull(); await act(async () => - resolveUs(scan({ region: "us-east-1", environments: [env({ state: { state: "update_available" }, actions: ["update"], onboarding: { state: "joined" } })] })), + resolveUs(scan({ region: "us-east-1", environments: [env({ state: { state: "update_available" }, actions: ["update"], onboarding: { state: "joined", ec2: null } })] })), ); fireEvent.click(await screen.findByRole("button", { name: "Update dev" })); fireEvent.click(within(screen.getByRole("dialog", { name: "Update dev" })).getByRole("button", { name: "Update" })); @@ -399,7 +515,7 @@ describe("EnvironmentsPanel", () => { invoke.mockImplementation(async (cmd: string) => { if (cmd !== "detect_aws_environments") throw new Error(`unexpected ${cmd}`); calls += 1; - const found = scan({ environments: [env({ actions: ["join", "update"], onboarding: { state: "joined" } })] }); + const found = scan({ environments: [env({ actions: ["join", "update"], onboarding: { state: "joined", ec2: null } })] }); if (calls === 1) return found; return new Promise((r) => (release = () => r(found))); }); @@ -414,7 +530,7 @@ describe("EnvironmentsPanel", () => { it("a done that arrives before the invoke resolves is shown and re-detects", async () => { backend( - () => scan({ environments: [env({ state: { state: "update_available" }, actions: ["update"], onboarding: { state: "joined" } })] }), + () => scan({ environments: [env({ state: { state: "update_available" }, actions: ["update"], onboarding: { state: "joined", ec2: null } })] }), async (cmd) => { if (cmd === "update_aws_environment") { emit(progress({ op_id: "u1", events: [tofuEvent("Refreshing state")] })); @@ -482,7 +598,7 @@ describe("EnvironmentsPanel", () => { backend( () => scan({ - environments: [env({ onboarding: { state: "incomplete", lock }, onboarding_actions: ["unlock"] })], + environments: [env({ onboarding: { state: "incomplete", lock, ec2: null }, onboarding_actions: ["unlock"] })], }), (cmd) => { if (cmd === "unlock_aws_state") return undefined; @@ -515,7 +631,7 @@ describe("EnvironmentsPanel", () => { scan({ environments: [ env({ name: "a", state: { state: "incomplete", lock: null }, actions: ["push_state"], info: null, onboarding: null }), - env({ name: "b", onboarding: { state: "incomplete", lock: null }, onboarding_actions: ["push_state"] }), + env({ name: "b", onboarding: { state: "incomplete", lock: null, ec2: null }, onboarding_actions: ["push_state"] }), ], }), (cmd) => { diff --git a/app/src/components/settings/hosts/EnvironmentsPanel.tsx b/app/src/components/settings/hosts/EnvironmentsPanel.tsx index 25956f9..48c34c2 100644 --- a/app/src/components/settings/hosts/EnvironmentsPanel.tsx +++ b/app/src/components/settings/hosts/EnvironmentsPanel.tsx @@ -14,6 +14,7 @@ import { awsErrorMessage, toAwsError } from "../../../lib/aws-error"; import type { AwsError, DetectedEnvironment, + Ec2Choice, EnvironmentScan, HostConnection, LockInfo, @@ -21,6 +22,7 @@ import type { NetworkChoice, PermissionSummary, PolicyFile, + UserCompute, } from "../../../lib/types"; import Button from "../../ui/Button"; import Field, { inputClass, selectClass } from "../../ui/Field"; @@ -29,10 +31,12 @@ import StatusIndicator from "../../ui/StatusIndicator"; import AdminBundleModal from "./AdminBundleModal"; import UpdateEnvironmentModal from "./UpdateEnvironmentModal"; import DeployEnvironmentModal from "./DeployEnvironmentModal"; +import JoinEnvironmentModal from "./JoinEnvironmentModal"; import DeployProgress, { runKey, useDeployRuns, type DeployRun } from "./DeployProgress"; import PolicyFiles from "./PolicyFiles"; import { COMMON_REGIONS, + computeLine, environmentStateKey, formatAge, lockLine, @@ -101,7 +105,19 @@ function TypedConfirmModal({ ); } -type Bundle = { kind: ModuleKind; region: string; environment?: string; ownerId?: string }; +type Bundle = { + kind: ModuleKind; + region: string; + environment?: string; + ownerId?: string; + recordedEc2?: UserCompute | null; +}; +/** A self-onboarding (or its re-apply) waiting for its EC2 choice. */ +type JoinOf = { region: string; name: string; stateKey: string; recorded: UserCompute | null; reapply: boolean }; + +/** The caller's recorded EC2 capacity in `e`, if any. */ +const recordedEc2 = (e: DetectedEnvironment): UserCompute | null => + e.onboarding && (e.onboarding.state === "joined" || e.onboarding.state === "incomplete") ? e.onboarding.ec2 : null; /** A row-level key: the same environment name can exist in every region. */ const rowKey = (region: string, name: string) => `${region}:${name}`; @@ -145,6 +161,7 @@ export default function EnvironmentsPanel({ onboarding: boolean; } | null>(null); const [bundle, setBundle] = useState(null); + const [joinOf, setJoinOf] = useState(null); const [copyNote, setCopyNote] = useState(null); const request = useRef(0); const followed = useRef(new Set()); @@ -241,15 +258,30 @@ export default function EnvironmentsPanel({ updateAwsEnvironment(connection.id, runRegion, name, hours), ); + // Join (or, once joined, a change of EC2 capacity): admins choose the + // capacity and apply it themselves; others get a bundle for an admin. const join = (found: EnvironmentScan, e: DetectedEnvironment) => { + const recorded = recordedEc2(e); if (isAdmin) { - void launch(found.region, e.name, onboardingStateKey(e.name, found.owner_key), `Joining ${e.name}`, () => - onboardAwsUser(connection.id, found.region, e.name), - ); + setJoinOf({ + region: found.region, + name: e.name, + stateKey: onboardingStateKey(e.name, found.owner_key), + recorded, + reapply: e.onboarding?.state === "joined", + }); } else { - setBundle({ kind: "user_onboard", region: found.region, environment: e.name, ownerId: found.owner_id }); + setBundle({ + kind: "user_onboard", + region: found.region, + environment: e.name, + ownerId: found.owner_id, + recordedEc2: recorded, + }); } }; + const runJoin = (j: JoinOf, ec2: Ec2Choice) => + launch(j.region, j.name, j.stateKey, `Joining ${j.name}`, () => onboardAwsUser(connection.id, j.region, j.name, ec2)); const rowRuns = (name: string) => Object.values(runs).filter((r) => r.region === current?.region && runEnvironment(r.stateKey) === name); @@ -343,6 +375,14 @@ export default function EnvironmentsPanel({ : "Your last onboarding didn't finish; Join again to finish it."}
)} + {(onboarding === "joined" || recordedEc2(e)) && ( +
+ EC2 capacity: {(() => { + const c = recordedEc2(e); + return c ? computeLine(c) : "none (Fargate only)"; + })()} +
+ )} {!isAdmin && isWaiting && onboarding !== "joined" && (
Waiting for an admin to onboard you
)} @@ -359,6 +399,16 @@ export default function EnvironmentsPanel({ {!isAdmin && isWaiting ? "Show onboarding bundle" : "Join"} )} + {has("join") && onboarding === "joined" && ( + + )} {mine("follow") && ( + + + } + > +
+ {!reapply &&

Joining creates your own task role and file system in {environment}.

} + {reapply && recorded && ( +

Stop your EC2 workspaces before removing EC2 capacity or changing your triple-c-user value: that change can't finish while one runs.

+ )} + + {error && ( +

+ {awsErrorMessage(error)} +

+ )} +
+ + ); +} diff --git a/app/src/components/settings/hosts/environmentFormat.ts b/app/src/components/settings/hosts/environmentFormat.ts index 3ed82c7..551d41e 100644 --- a/app/src/components/settings/hosts/environmentFormat.ts +++ b/app/src/components/settings/hosts/environmentFormat.ts @@ -1,6 +1,6 @@ // Pure helpers shared by the environments UI. The name and id rules mirror // `aws/tofu_modules.rs`; the server re-validates everything. -import type { EnvironmentState, LockInfo, NetworkChoice } from "../../../lib/types"; +import type { Ec2Compute, EnvironmentState, LockInfo, NetworkChoice, UserCompute } from "../../../lib/types"; import type { StatusTone } from "../../ui/StatusIndicator"; export const COMMON_REGIONS = [ @@ -97,3 +97,47 @@ export function stateStatus(s: EnvironmentState): { tone: StatusTone; label: str export function stateLock(s: EnvironmentState): LockInfo | null { return s.state === "deploying" || s.state === "incomplete" ? s.lock : null; } + +/** The most instances a user's EC2 capacity may run at once (`EC2_MAX_INSTANCES`). */ +export const EC2_MAX_INSTANCES = 4; + +/** The EC2 capacity picker's fields. An empty `instanceType` means the table's default. */ +export interface Ec2Draft { + enabled: boolean; + instanceType: string; + maxInstances: number; + userTag: string; +} + +/** The picker's start: the recorded capacity (a re-apply keeps it), or none. */ +export function ec2DraftFrom(recorded: UserCompute | null | undefined): Ec2Draft { + return recorded + ? { enabled: true, instanceType: recorded.instance_type, maxInstances: recorded.max_instances, userTag: recorded.user_tag } + : { enabled: false, instanceType: "", maxInstances: 1, userTag: "" }; +} + +/** `validate_ec2_user_tag`: null when valid, else why not. */ +export function userTagError(tag: string): string | null { + if (!tag) return "Enter your triple-c-user value."; + const ok = /^[A-Za-z0-9-]{1,32}$/.test(tag) && !tag.startsWith("-") && !tag.endsWith("-") && !tag.includes("--"); + return ok ? null : "Use 1 to 32 letters, digits and single hyphens, not starting or ending with a hyphen."; +} + +/** The capacity a draft asks for (null = none), or why it can't be used yet. */ +export function ec2FromDraft(d: Ec2Draft): { compute: Ec2Compute | null } | { error: string } { + if (!d.enabled) return { compute: null }; + if (!d.instanceType) return { error: "Choose an instance type." }; + if (!Number.isInteger(d.maxInstances) || d.maxInstances < 1 || d.maxInstances > EC2_MAX_INSTANCES) { + return { error: `Choose 1 to ${EC2_MAX_INSTANCES} instances.` }; + } + const tag = d.userTag.trim(); + const tagError = userTagError(tag); + if (tagError) return { error: tagError }; + return { compute: { instance_type: d.instanceType, max_instances: d.maxInstances, user_tag: tag } }; +} + +/** "m7g.large, up to 3 instances (triple-c-user alice)". */ +export function computeLine(c: UserCompute): string { + const n = c.max_instances === 1 ? "1 instance" : `up to ${c.max_instances} instances`; + return `${c.instance_type}, ${n} (triple-c-user ${c.user_tag})`; +} diff --git a/app/src/components/settings/hosts/testkit.ts b/app/src/components/settings/hosts/testkit.ts index 72c1329..5336746 100644 --- a/app/src/components/settings/hosts/testkit.ts +++ b/app/src/components/settings/hosts/testkit.ts @@ -2,10 +2,12 @@ import type { DeployProgress, DetectedEnvironment, + Ec2InstanceTable, EnvironmentInfo, EnvironmentScan, HostConnection, TofuEvent, + UserCompute, } from "../../../lib/types"; export const conn: HostConnection = { @@ -65,3 +67,26 @@ export function tofuEvent(message: string, over: Partial = {}): TofuE export function progress(over: Partial): DeployProgress { return { op_id: "op1", state_key: "environments/dev/terraform.tfstate", events: [], done: false, cancellable: true, ...over }; } + +/** A slice of `list_ec2_instance_types`'s answer: x86 and ARM rows. */ +export const instanceTable: Ec2InstanceTable = { + default_type: "m7i.large", + types: [ + { instance_type: "m7i.large", arch: "x86_64", vcpu: 2, memory_mib: 8192 }, + { instance_type: "m7i.xlarge", arch: "x86_64", vcpu: 4, memory_mib: 16384 }, + { instance_type: "m7g.large", arch: "arm64", vcpu: 2, memory_mib: 8192 }, + { instance_type: "m7g.xlarge", arch: "arm64", vcpu: 4, memory_mib: 16384 }, + ], +}; + +export function compute(over: Partial = {}): UserCompute { + const tag = over.user_tag ?? "alice"; + return { + instance_type: "m7g.xlarge", + max_instances: 3, + user_tag: tag, + cluster_arn: `arn:aws:ecs:eu-west-1:123456789012:cluster/triple-c-dev--u-${tag}`, + capacity_provider: `triple-c-dev--u-${tag}`, + ...over, + }; +} diff --git a/app/src/lib/tauri-commands.ts b/app/src/lib/tauri-commands.ts index cba180c..0b312e8 100644 --- a/app/src/lib/tauri-commands.ts +++ b/app/src/lib/tauri-commands.ts @@ -1,5 +1,5 @@ import { invoke } from "@tauri-apps/api/core"; -import type { Project, ProjectPath, NewProjectHost, RemoveProjectOptions, WipChoice, UnsavedWork, WorkspaceStatus, ProjectRemovalReport, ProjectResetOutcome, ContainerInfo, AppSettings, SettingsImportPreview, SettingsImportOutcome, UpdateInfo, ImageUpdateInfo, FileEntry, FileContents, WebTerminalInfo, SttStatus, GatewayStatus, InstallOptions, ClaudeSession, ContainerCapabilities, ScheduledTask, ScheduledTaskInput, SchedulerNotification, AuthBridgeStatus, BrowserViewStatus, BrowserViewPopoutState, BrowserPageState, PlaywrightDetection, BrowserSetupOutcome, BrowserInstallTarget, ContainerStaleness, MigrationOptions, MigrationReport, MigrationState, ClearTokenOutcome, CaCertInfo, UploadOutcome, Note, ViewerFile, ViewerPoll, ViewerSaved, ViewerState, FileDiff, InstallScope, ItemUpdate, Marketplace, MarketplaceAccount, MarketplaceItemRef, MarketplaceSnapshot, ProjectSyncResult, SyncReport, HostConnection, CallerIdentity, PermissionReport, PolicyFile, HourlyEstimate, AwsWorkspaceConfig, Tier, EnvironmentScan, NetworkChoice, ModuleKind } from "./types"; +import type { Project, ProjectPath, NewProjectHost, RemoveProjectOptions, WipChoice, UnsavedWork, WorkspaceStatus, ProjectRemovalReport, ProjectResetOutcome, ContainerInfo, AppSettings, SettingsImportPreview, SettingsImportOutcome, UpdateInfo, ImageUpdateInfo, FileEntry, FileContents, WebTerminalInfo, SttStatus, GatewayStatus, InstallOptions, ClaudeSession, ContainerCapabilities, ScheduledTask, ScheduledTaskInput, SchedulerNotification, AuthBridgeStatus, BrowserViewStatus, BrowserViewPopoutState, BrowserPageState, PlaywrightDetection, BrowserSetupOutcome, BrowserInstallTarget, ContainerStaleness, MigrationOptions, MigrationReport, MigrationState, ClearTokenOutcome, CaCertInfo, UploadOutcome, Note, ViewerFile, ViewerPoll, ViewerSaved, ViewerState, FileDiff, InstallScope, ItemUpdate, Marketplace, MarketplaceAccount, MarketplaceItemRef, MarketplaceSnapshot, ProjectSyncResult, SyncReport, HostConnection, CallerIdentity, PermissionReport, PolicyFile, HourlyEstimate, AwsWorkspaceConfig, Tier, EnvironmentScan, NetworkChoice, ModuleKind, Ec2Choice, Ec2Compute, Ec2InstanceTable } from "./types"; // Docker export const checkDocker = () => invoke("check_docker"); @@ -163,8 +163,13 @@ export const cancelAwsDeployment = (connectionId: string, region: string, stateK /** Push `errored.tfstate` (a failed run's unsaved state) back to the bucket; resolves to an op id like a deploy. */ export const pushAwsSavedState = (connectionId: string, region: string, stateKey: string) => invoke("push_aws_saved_state", { connectionId, region, stateKey }); -export const onboardAwsUser = (connectionId: string, region: string, environment: string) => - invoke("onboard_aws_user", { connectionId, region, environment }); +/** Omit `ec2` to keep the caller's recorded EC2 capacity (none without a record). */ +export const onboardAwsUser = (connectionId: string, region: string, environment: string, ec2?: Ec2Choice) => + invoke( + "onboard_aws_user", + ec2 === undefined ? { connectionId, region, environment } : { connectionId, region, environment, ec2 }, + ); +export const listEc2InstanceTypes = () => invoke("list_ec2_instance_types"); export const deployAwsPermissionsBoundary = (connectionId: string, region: string) => invoke("deploy_aws_permissions_boundary", { connectionId, region }); /** Opens a folder picker in Rust; resolves to the folder written, or null if dismissed. */ @@ -172,7 +177,14 @@ export const saveAwsAdminBundle = ( connectionId: string, region: string, kind: ModuleKind, - options: { environment?: string; ownerId?: string; network?: NetworkChoice; maxWorkspaceHours?: number } = {}, + options: { + environment?: string; + ownerId?: string; + network?: NetworkChoice; + maxWorkspaceHours?: number; + /** An onboarding bundle's EC2 capacity; null = none. */ + ec2?: Ec2Compute | null; + } = {}, ) => invoke("save_aws_admin_bundle", { connectionId, @@ -182,6 +194,7 @@ export const saveAwsAdminBundle = ( ownerId: options.ownerId ?? null, network: options.network ?? null, ...(options.maxWorkspaceHours === undefined ? {} : { maxWorkspaceHours: options.maxWorkspaceHours }), + ...(options.ec2 === undefined ? {} : { ec2: options.ec2 }), }); /** Check a corporate CA path and report what would be installed. Never * rejects for a bad path — the reason comes back in `error`. */ diff --git a/app/src/lib/types.ts b/app/src/lib/types.ts index 091a454..6104f99 100644 --- a/app/src/lib/types.ts +++ b/app/src/lib/types.ts @@ -1356,12 +1356,47 @@ export type EnvironmentState = /** `push_state`: push the state a failed run on this machine couldn't save (`errored.tfstate`) back to the bucket. */ export type EnvironmentAction = "join" | "update" | "repair" | "destroy" | "follow" | "unlock" | "push_state"; -/** `incomplete`: the last onboarding run didn't finish (Join re-applies and finishes it). */ +/** A user's EC2 capacity in an environment: their validated user record (`aws::environments::UserCompute`). */ +export interface UserCompute { + instance_type: string; + max_instances: number; + /** The `triple-c-user` value the cluster is named after. */ + user_tag: string; + cluster_arn: string; + capacity_provider: string; +} + +/** `incomplete`: the last onboarding run didn't finish (Join re-applies and finishes it). `ec2`: the caller's recorded EC2 capacity, null for none. */ export type OnboardingState = - | { state: "joined" } + | { state: "joined"; ec2: UserCompute | null } | { state: "not_joined" } | { state: "in_progress"; lock: LockInfo | null } - | { state: "incomplete"; lock: LockInfo | null }; + | { state: "incomplete"; lock: LockInfo | null; ec2: UserCompute | null }; + +/** EC2 capacity as the onboarding module takes it (`aws::tofu_modules::Ec2Compute`). */ +export interface Ec2Compute { + instance_type: string; + /** 1 to 4. */ + max_instances: number; + /** The user's `triple-c-user` sign-in tag value. */ + user_tag: string; +} + +/** An onboarding's EC2 choice (`environment_commands::Ec2Choice`). */ +export type Ec2Choice = { kind: "none" } | ({ kind: "ec2" } & Ec2Compute); + +/** One row of the app's built-in instance table (`models::project::Ec2InstanceType`). */ +export interface Ec2InstanceType { + instance_type: string; + arch: Arch; + vcpu: number; + memory_mib: number; +} + +export interface Ec2InstanceTable { + default_type: string; + types: Ec2InstanceType[]; +} export type Knowable = "yes" | "no" | "unknown"; diff --git a/app/src/test/awsFixtures.ts b/app/src/test/awsFixtures.ts index 5748412..2dadb45 100644 --- a/app/src/test/awsFixtures.ts +++ b/app/src/test/awsFixtures.ts @@ -69,7 +69,7 @@ export function environment( state: { state } as DetectedEnvironment["state"], actions: [], info: null, - onboarding: joined ? { state: "joined" } : { state: "not_joined" }, + onboarding: joined ? { state: "joined", ec2: null } : { state: "not_joined" }, onboarding_actions: [], onboarded_users: 1, }; diff --git a/aws/terraform/user-onboard/ec2.tf b/aws/terraform/user-onboard/ec2.tf index b29b55e..e5c26ec 100644 --- a/aws/terraform/user-onboard/ec2.tf +++ b/aws/terraform/user-onboard/ec2.tf @@ -310,6 +310,7 @@ resource "aws_ssm_parameter" "user" { cluster_arn = aws_ecs_cluster.ec2[0].arn capacity_provider = aws_ecs_capacity_provider.ec2[0].name user_tag = var.ec2_user_tag + max_instances = var.ec2_max_instances }) depends_on = [aws_ecs_cluster_capacity_providers.ec2] -- 2.52.0 From 98e330060e3b56c565bc86845a3989e7a9a9ec9c Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 14:31:30 -0800 Subject: [PATCH 10/29] fix(aws): EC2 name check by owner tag; keep unusable records; bundle warning The pre-apply check now decides ownership by the resources' triple-c:owner tag (record as fallback), so a failed apply of one's own capacity can be re-applied; any cluster status but INACTIVE holds the name. An onboarding seam (OnboardApi) makes the record read and the name lookups testable, and prepare_onboarding settles everything before launch. With no choice given, an unreadable or invalid record is refused instead of removing capacity. Bundles warn when their cluster name looks taken; the README check prints owner tags. The UI keeps the recorded type when the instance list fails and says when an apply removes EC2 capacity. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/environments.rs | 270 ++++++++++++---- app/src-tauri/src/aws/environments/tests.rs | 23 +- .../src/commands/environment_commands.rs | 223 ++++++++++---- .../commands/environment_commands/tests.rs | 287 ++++++++++++++++-- app/src-tauri/src/models/project.rs | 14 + .../settings/hosts/AdminBundleModal.test.tsx | 42 ++- .../settings/hosts/AdminBundleModal.tsx | 15 +- .../hosts/DeployEnvironmentModal.test.tsx | 4 +- .../settings/hosts/Ec2CapacityFields.tsx | 3 +- .../settings/hosts/EnvironmentsPanel.test.tsx | 22 +- .../settings/hosts/JoinEnvironmentModal.tsx | 7 +- app/src/lib/tauri-commands.ts | 6 +- app/src/lib/types.ts | 7 + 13 files changed, 759 insertions(+), 164 deletions(-) diff --git a/app/src-tauri/src/aws/environments.rs b/app/src-tauri/src/aws/environments.rs index 95399fb..f5f3967 100644 --- a/app/src-tauri/src/aws/environments.rs +++ b/app/src-tauri/src/aws/environments.rs @@ -683,12 +683,8 @@ pub trait DetectApi: Send + Sync { account: &str, ) -> impl Future> + Send; fn role_exists(&self, name: &str) -> impl Future> + Send; - /// An SSM String parameter's value; `None` when it is missing or this - /// caller can't read it. - fn parameter( - &self, - name: &str, - ) -> impl Future, AwsError>> + Send; + /// An SSM String parameter (a user record). + fn parameter(&self, name: &str) -> impl Future> + Send; /// A state object's contents, capped; `None` when it is missing, can't /// be read or is too large. fn state_document( @@ -809,8 +805,46 @@ pub(crate) async fn scan_in_bucket( }) } +/// An SSM parameter read: its value, missing, or this caller can't read it. +#[derive(Clone, Debug, PartialEq)] +pub enum Param { + Value(String), + Missing, + Denied, +} + +/// A user record as read: none, valid, or present but unusable (unreadable +/// or failing validation; the reason names a field, never a value). +#[derive(Clone, Debug, PartialEq)] +pub enum UserRecord { + Absent, + Valid(UserCompute), + Unusable(String), +} + +impl UserRecord { + pub fn valid(&self) -> Option<&UserCompute> { + match self { + UserRecord::Valid(c) => Some(c), + _ => None, + } + } +} + +/// [`UserRecord`] from a read of `user_record_parameter_name(env, …)`. +pub fn user_record_from(read: Param, env: &str, account: &str, region: &str) -> UserRecord { + match read { + Param::Missing => UserRecord::Absent, + Param::Denied => UserRecord::Unusable("it can't be read with these credentials".into()), + Param::Value(text) => match parse_user_record(env, &text, account, region) { + Ok(c) => UserRecord::Valid(c), + Err(reason) => UserRecord::Unusable(reason), + }, + } +} + /// The caller's EC2 capacity in `env` from their user record; `None` when -/// there is no record or it doesn't validate (logged, never echoed). +/// there is no usable record (an unusable one is logged, never echoed). pub(crate) async fn user_compute( d: &D, env: &str, @@ -818,44 +852,185 @@ pub(crate) async fn user_compute( account: &str, region: &str, ) -> Result, AwsError> { - let Some(text) = d.parameter(&user_record_parameter_name(env, owner_key)).await? else { - return Ok(None); - }; - match parse_user_record(env, &text, account, region) { - Ok(c) => Ok(Some(c)), - Err(reason) => { + let read = d.parameter(&user_record_parameter_name(env, owner_key)).await?; + match user_record_from(read, env, account, region) { + UserRecord::Valid(c) => Ok(Some(c)), + UserRecord::Absent => Ok(None), + UserRecord::Unusable(reason) => { log::warn!("Ignoring the EC2 user record for environment {env}: {reason}"); Ok(None) } } } -/// Whether a per-user EC2 name (`tofu_modules::user_ec2_stem`) is in use: -/// (an ACTIVE ECS cluster of that name, an Auto Scaling group of that name). -/// Needs `ecs:DescribeClusters` and `autoscaling:DescribeAutoScalingGroups` -/// (the environment-admin tier has both; workspace users lack the second). -pub async fn ec2_names_in_use(cfg: &SdkConfig, stem: &str) -> Result<(bool, bool), AwsError> { - let clusters = aws_sdk_ecs::Client::new(cfg) - .describe_clusters() - .clusters(stem) - .send() - .await - .map_err(|e| classify_sdk_error("ecs:DescribeClusters", &e))?; - let cluster = clusters - .clusters() +/// Who holds a per-user EC2 name (`tofu_modules::user_ec2_stem`): an ECS +/// cluster or Auto Scaling group of that name and its `triple-c:owner` tag. +#[derive(Clone, Debug, PartialEq)] +pub struct NameHolder { + /// "ECS cluster" or "Auto Scaling group". + pub kind: &'static str, + pub owner: Option, +} + +/// An ECS cluster or Auto Scaling group found by name: its status (clusters +/// only) and tags. +#[derive(Clone, Debug, PartialEq, Default)] +pub struct NamedResource { + pub status: Option, + pub tags: Vec<(String, String)>, +} + +/// What an onboarding apply asks AWS before it starts (R3): the caller's +/// user record and whether the per-user EC2 names are taken. The cluster +/// read needs `ecs:DescribeClusters` (tags included); the group read +/// `autoscaling:DescribeAutoScalingGroups`, which only the environment-admin +/// tier has. +pub trait OnboardApi: Send + Sync { + fn parameter(&self, name: &str) -> impl Future> + Send; + fn cluster( + &self, + name: &str, + ) -> impl Future, AwsError>> + Send; + fn group( + &self, + name: &str, + ) -> impl Future, AwsError>> + Send; +} + +const OWNER_TAG: &str = "triple-c:owner"; + +fn owner_of(r: &NamedResource) -> Option { + r.tags .iter() - .any(|c| c.cluster_name() == Some(stem) && c.status() == Some("ACTIVE")); - let groups = aws_sdk_autoscaling::Client::new(cfg) - .describe_auto_scaling_groups() - .auto_scaling_group_names(stem) + .find(|(k, _)| k == OWNER_TAG) + .map(|(_, v)| v.clone()) +} + +/// The cluster holding `stem`, if any. Every status but INACTIVE (a deleted +/// cluster) holds the name: PROVISIONING, DEPROVISIONING and FAILED too. +pub async fn cluster_holder( + api: &A, + stem: &str, +) -> Result, AwsError> { + Ok(api + .cluster(stem) + .await? + .filter(|c| c.status.as_deref() != Some("INACTIVE")) + .map(|c| NameHolder { + kind: "ECS cluster", + owner: owner_of(&c), + })) +} + +/// Everything holding `stem`: its cluster and its Auto Scaling group. +pub async fn ec2_name_holders( + api: &A, + stem: &str, +) -> Result, AwsError> { + let mut out: Vec = cluster_holder(api, stem).await?.into_iter().collect(); + if let Some(g) = api.group(stem).await? { + out.push(NameHolder { + kind: "Auto Scaling group", + owner: owner_of(&g), + }); + } + Ok(out) +} + +/// `ssm:GetParameter` as a [`Param`]. +async fn get_parameter(ssm: &aws_sdk_ssm::Client, name: &str) -> Result { + let res = ssm + .get_parameter() + .name(name) + .with_decryption(false) .send() - .await - .map_err(|e| classify_sdk_error("autoscaling:DescribeAutoScalingGroups", &e))?; - let group = groups - .auto_scaling_groups() - .iter() - .any(|g| g.auto_scaling_group_name() == Some(stem)); - Ok((cluster, group)) + .await; + match res { + Ok(out) => Ok(out + .parameter() + .and_then(|p| p.value()) + .map_or(Param::Missing, |v| Param::Value(v.to_string()))), + Err(e) if e.as_service_error().is_some_and(|s| s.is_parameter_not_found()) => { + Ok(Param::Missing) + } + Err(e) => { + let (code, status) = error_parts(&e); + match lookup_outcome(code.as_deref(), status) { + Lookup::Missing => Ok(Param::Missing), + Lookup::Denied => Ok(Param::Denied), + Lookup::Error => Err(classify_sdk_error("ssm:GetParameter", &e)), + } + } + } +} + +/// The real [`OnboardApi`], from a connection's `SdkConfig`. +pub struct SdkOnboardApi { + ssm: aws_sdk_ssm::Client, + ecs: aws_sdk_ecs::Client, + autoscaling: aws_sdk_autoscaling::Client, +} + +impl SdkOnboardApi { + pub fn new(cfg: &SdkConfig) -> Self { + SdkOnboardApi { + ssm: aws_sdk_ssm::Client::new(cfg), + ecs: aws_sdk_ecs::Client::new(cfg), + autoscaling: aws_sdk_autoscaling::Client::new(cfg), + } + } +} + +impl OnboardApi for SdkOnboardApi { + async fn parameter(&self, name: &str) -> Result { + get_parameter(&self.ssm, name).await + } + + async fn cluster(&self, name: &str) -> Result, AwsError> { + // A missing name is a `failures` entry, not an error. + let out = self + .ecs + .describe_clusters() + .clusters(name) + .include(aws_sdk_ecs::types::ClusterField::Tags) + .send() + .await + .map_err(|e| classify_sdk_error("ecs:DescribeClusters", &e))?; + Ok(out + .clusters() + .iter() + .find(|c| c.cluster_name() == Some(name)) + .map(|c| NamedResource { + status: c.status().map(str::to_string), + tags: c + .tags() + .iter() + .filter_map(|t| Some((t.key()?.to_string(), t.value()?.to_string()))) + .collect(), + })) + } + + async fn group(&self, name: &str) -> Result, AwsError> { + let out = self + .autoscaling + .describe_auto_scaling_groups() + .auto_scaling_group_names(name) + .send() + .await + .map_err(|e| classify_sdk_error("autoscaling:DescribeAutoScalingGroups", &e))?; + Ok(out + .auto_scaling_groups() + .iter() + .find(|g| g.auto_scaling_group_name() == Some(name)) + .map(|g| NamedResource { + status: None, + tags: g + .tags() + .iter() + .filter_map(|t| Some((t.key()?.to_string(), t.value()?.to_string()))) + .collect(), + })) + } } /// An OpenTofu state that manages nothing (what `tofu destroy` leaves): @@ -1170,25 +1345,8 @@ impl DetectApi for SdkDetectApi { knowable("iam:GetRole", res) } - async fn parameter(&self, name: &str) -> Result, AwsError> { - let res = self - .ssm - .get_parameter() - .name(name) - .with_decryption(false) - .send() - .await; - match res { - Ok(out) => Ok(out.parameter().and_then(|p| p.value()).map(str::to_string)), - Err(e) if e.as_service_error().is_some_and(|s| s.is_parameter_not_found()) => Ok(None), - Err(e) => { - let (code, status) = error_parts(&e); - match lookup_outcome(code.as_deref(), status) { - Lookup::Missing | Lookup::Denied => Ok(None), - Lookup::Error => Err(classify_sdk_error("ssm:GetParameter", &e)), - } - } - } + async fn parameter(&self, name: &str) -> Result { + get_parameter(&self.ssm, name).await } async fn state_document(&self, bucket: &str, key: &str) -> Result, AwsError> { diff --git a/app/src-tauri/src/aws/environments/tests.rs b/app/src-tauri/src/aws/environments/tests.rs index 0e9bee0..0a17347 100644 --- a/app/src-tauri/src/aws/environments/tests.rs +++ b/app/src-tauri/src/aws/environments/tests.rs @@ -551,9 +551,9 @@ impl DetectApi for FakeDetect { self.log(format!("role {name}")); Ok(self.roles.get(name).cloned().unwrap_or(Knowable::No)) } - async fn parameter(&self, name: &str) -> Result, AwsError> { + async fn parameter(&self, name: &str) -> Result { self.log(format!("parameter {name}")); - Ok(self.parameters.get(name).cloned()) + Ok(self.parameters.get(name).cloned().map_or(Param::Missing, Param::Value)) } async fn state_document(&self, bucket: &str, key: &str) -> Result, AwsError> { self.log(format!("document {bucket} {key}")); @@ -1263,3 +1263,22 @@ fn onboarding_carries_the_users_compute_from_their_record() { json!({"state": "joined", "ec2": null}) ); } + +#[test] +fn a_user_record_read_is_absent_valid_or_unusable() { + let ok = user_record("dev", "alice").to_string(); + assert_eq!(user_record_from(Param::Missing, "dev", ACCOUNT, REGION), UserRecord::Absent); + assert!(matches!( + user_record_from(Param::Value(ok), "dev", ACCOUNT, REGION), + UserRecord::Valid(_) + )); + // Denied or invalid: there may be capacity, so it is not "absent". + assert!(matches!( + user_record_from(Param::Denied, "dev", ACCOUNT, REGION), + UserRecord::Unusable(_) + )); + assert!(matches!( + user_record_from(Param::Value("{}".into()), "dev", ACCOUNT, REGION), + UserRecord::Unusable(_) + )); +} diff --git a/app/src-tauri/src/commands/environment_commands.rs b/app/src-tauri/src/commands/environment_commands.rs index ce69822..a1db5e9 100644 --- a/app/src-tauri/src/commands/environment_commands.rs +++ b/app/src-tauri/src/commands/environment_commands.rs @@ -38,9 +38,10 @@ use aws_sdk_s3::error::ProvideErrorMetadata; use tokio::sync::oneshot; use crate::aws::environments::{ - ec2_names_in_use, ensure_state_bucket, scan, state_bucket_policy, user_compute, - LIVE_LOCK_SECS, DetectedEnvironment, EnvironmentAction, EnvironmentInfo, EnvironmentScan, - EnvironmentState, Knowable, LocalRun, OnboardingState, SdkDetectApi, UserCompute, + cluster_holder, ec2_name_holders, ensure_state_bucket, scan, state_bucket_policy, + user_record_from, DetectedEnvironment, EnvironmentAction, EnvironmentInfo, EnvironmentScan, + EnvironmentState, Knowable, LocalRun, NameHolder, OnboardApi, OnboardingState, SdkDetectApi, + SdkOnboardApi, UserCompute, UserRecord, LIVE_LOCK_SECS, }; use crate::aws::tofu::{ self, backend_hcl, StartError, TofuEvent, TofuOp, TofuOutcome, Workdir, @@ -300,7 +301,6 @@ pub(crate) fn onboard_refusal(scan: &EnvironmentScan, name: &str) -> Result<(), Ok(()) } -/// `AlreadyRunning` is told apart before it becomes an `AwsError`. /// The EC2 capacity an onboarding asks for: none (Fargate only), or EC2 /// with these values. A command given no choice keeps what the user's /// record holds ([`resolve_ec2`]). @@ -312,51 +312,126 @@ pub enum Ec2Choice { } /// What an onboarding apply uses: the explicit choice, or with none given -/// the recorded capacity (a re-apply keeps it unless changed). +/// the recorded capacity (a re-apply keeps it unless changed). With none +/// given and a record that exists but can't be used, it refuses rather than +/// apply without EC2, which would tear the capacity down. pub(crate) fn resolve_ec2( choice: Option, - recorded: Option<&UserCompute>, -) -> Option { - match choice { - Some(Ec2Choice::None) => None, - Some(Ec2Choice::Ec2(c)) => Some(c), - None => recorded.map(|r| Ec2Compute { + record: &UserRecord, +) -> Result, String> { + match (choice, record) { + (Some(Ec2Choice::None), _) => Ok(None), + (Some(Ec2Choice::Ec2(c)), _) => Ok(Some(c)), + (None, UserRecord::Absent) => Ok(None), + (None, UserRecord::Valid(r)) => Ok(Some(Ec2Compute { instance_type: r.instance_type.clone(), max_instances: r.max_instances, user_tag: r.user_tag.clone(), - }), + })), + (None, UserRecord::Unusable(reason)) => Err(format!( + "Your EC2 record can't be used ({reason}), so Triple-C can't keep your EC2 capacity \ + as it is; choose the EC2 capacity explicitly" + )), } } -/// R3: an onboarding apply with EC2 capacity would adopt (or fail on) a -/// per-user cluster or Auto Scaling group named `stem` that already -/// exists, so it is allowed only when this owner's own record names that -/// cluster (a re-apply of their capacity). +/// R3 (amended): an apply with EC2 capacity would adopt (or fail on) a +/// per-user cluster or Auto Scaling group named `stem` that already exists. +/// Each one found must be the caller's: its `triple-c:owner` tag (the +/// module's default tags) is `owner_id`, or, failing that, the caller's +/// record names the cluster. A half-built capacity of the caller's own (a +/// failed apply that wrote no record yet) is therefore re-applied; one +/// owned by someone else, or untagged, is refused. pub(crate) fn ec2_collision_refusal( stem: &str, - cluster_in_use: bool, - group_in_use: bool, + holders: &[NameHolder], + owner_id: &str, recorded: Option<&UserCompute>, ) -> Result<(), String> { - if !cluster_in_use && !group_in_use { - return Ok(()); - } let suffix = format!(":cluster/{stem}"); - if recorded.is_some_and(|r| r.cluster_arn.ends_with(&suffix)) { - return Ok(()); + let recorded_here = recorded.is_some_and(|r| r.cluster_arn.ends_with(&suffix)); + for h in holders { + if h.owner.as_deref() == Some(owner_id) || recorded_here { + continue; + } + let whose = if h.owner.is_some() { + "belongs to another onboarding" + } else { + "exists but isn't tagged as any Triple-C user's" + }; + return Err(format!( + "An {} named {stem} already {whose}. The triple-c-user value is probably wrong: use \ + the value an admin set as your triple-c-user sign-in tag", + h.kind + )); } - let what = match (cluster_in_use, group_in_use) { - (true, true) => "An ECS cluster and an Auto Scaling group named {stem} already belong", - (true, false) => "An ECS cluster named {stem} already belongs", - _ => "An Auto Scaling group named {stem} already belongs", - } - .replace("{stem}", stem); - Err(format!( - "{what} to another onboarding. The triple-c-user value is \ - probably wrong: use the value an admin set as your triple-c-user sign-in tag" - )) + Ok(()) } +/// Everything a self-onboarding apply needs settled before it starts: the +/// caller's record, the capacity ([`resolve_ec2`]), the module variables +/// and, with EC2 capacity, the name check ([`ec2_collision_refusal`]). +/// Check-then-apply leaves a narrow race (another admin creating the same +/// names in between); only admins apply, and the module would then fail on +/// create rather than adopt. +pub(crate) async fn prepare_onboarding( + api: &A, + env: &str, + region: &str, + account: &str, + owner_id: &str, + choice: Option, +) -> Result { + let okey = owner_key(region, owner_id); + let read = api.parameter(&user_record_parameter_name(env, &okey)).await?; + let record = user_record_from(read, env, account, region); + let compute = resolve_ec2(choice, &record).map_err(other)?; + let vars = onboarding_vars(env, region, owner_id, compute.as_ref()).map_err(other)?; + if let Some(c) = &compute { + // The caller's own triple-c-user tag can't be read (session tags + // aren't visible to GetCallerIdentity); a wrong value fails later + // as access denied. + let stem = user_ec2_stem(env, &c.user_tag); + let holders = ec2_name_holders(api, &stem).await?; + ec2_collision_refusal(&stem, &holders, owner_id, record.valid()).map_err(other)?; + } + Ok(vars) +} + +/// The bundle's version of the check, with what a workspace user can read +/// (the cluster, via `ecs:Describe*`, and the record; not the Auto Scaling +/// group): a warning to show, never a refusal. The admin runs the full +/// check from the README. +pub(crate) async fn bundle_ec2_warning( + api: &A, + env: &str, + region: &str, + account: &str, + owner_id: &str, + compute: &Ec2Compute, +) -> Option { + let stem = user_ec2_stem(env, &compute.user_tag); + let checked = async { + let holder = cluster_holder(api, &stem).await?; + let read = api + .parameter(&user_record_parameter_name(env, &owner_key(region, owner_id))) + .await?; + let record = user_record_from(read, env, account, region); + Ok::<_, AwsError>( + ec2_collision_refusal(&stem, &holder.into_iter().collect::>(), owner_id, record.valid()) + .err(), + ) + }; + match checked.await { + Ok(warning) => warning, + Err(_) => Some(format!( + "Triple-C couldn't check whether the EC2 name {stem} is already in use; the README has \ + the admin check it" + )), + } +} + +/// `AlreadyRunning` is told apart before it becomes an `AwsError`. pub(crate) fn start_error(e: StartError, label: &str) -> AwsError { match e { StartError::AlreadyRunning => other(format!( @@ -476,10 +551,18 @@ const TFVARS: &str = "terraform.tfvars.json"; /// The onboarding bundle's EC2 step: before applying with EC2 capacity, the /// admin checks that the per-user names are free or already this user's /// (the module can't: a name taken by someone else's onboarding would be -/// adopted by neither, and a collision only fails at create). `user_tag` is -/// the bundle's `ec2_user_tag` when set and valid; otherwise the commands -/// show `` for the admin to fill in. -fn ec2_collision_step(env: &str, owner_key: &str, region: &str, user_tag: Option<&str>) -> String { +/// adopted, and a collision only fails at create). Ownership is the +/// resources' `triple-c:owner` tag, or failing that the user's record, as +/// in [`ec2_collision_refusal`]. `user_tag` is the bundle's `ec2_user_tag` +/// when set and valid; otherwise the commands show `` for the admin to +/// fill in. +fn ec2_collision_step( + env: &str, + owner_key: &str, + owner_id: &str, + region: &str, + user_tag: Option<&str>, +) -> String { let stem = user_ec2_stem(env, user_tag.unwrap_or("")); let record = user_record_parameter_name(env, owner_key); format!( @@ -489,14 +572,17 @@ ec2_user_tag must be the value of the user's triple-c-user principal tag. BEFORE tofu apply, check that the per-user EC2 names are not already in use by another onboarding. Run: - aws ecs describe-clusters --region {region} --clusters {stem} --query 'clusters[?status==`ACTIVE`].clusterName' --output text - aws autoscaling describe-auto-scaling-groups --region {region} --auto-scaling-group-names {stem} --query 'AutoScalingGroups[].AutoScalingGroupName' --output text + aws ecs describe-clusters --region {region} --clusters {stem} --include TAGS --query 'clusters[?status!=`INACTIVE`].[clusterName,tags[?key==`triple-c:owner`].value|[0]]' --output text + aws autoscaling describe-auto-scaling-groups --region {region} --auto-scaling-group-names {stem} --query 'AutoScalingGroups[].[AutoScalingGroupName,Tags[?Key==`triple-c:owner`].Value|[0]]' --output text aws ssm get-parameter --region {region} --name {record} --query Parameter.Value --output text -If either of the first two prints {stem}, apply ONLY if the third (this -user's record) succeeds and its cluster_arn ends in cluster/{stem}; -otherwise the name belongs to someone else's onboarding: stop and choose -the correct ec2_user_tag. (The app runs the same check before applying.) +If either of the first two prints {stem}, apply ONLY if the owner printed +next to it is this user's owner_id ({owner_id}) or the third (this user's +record) succeeds and its cluster_arn ends in cluster/{stem}; otherwise the +name belongs to someone else's onboarding (or to nobody's): stop and +choose the correct ec2_user_tag. (The app runs the same check before +applying; run the check right before the apply, since nothing holds the +name in between.) " ) @@ -541,7 +627,8 @@ fn bundle_readme( let tag = vars["ec2_user_tag"] .as_str() .filter(|t| validate_ec2_user_tag(t).is_ok()); - ec2_collision_step(env, owner_key, region, tag) + let owner_id = vars["owner_id"].as_str().unwrap_or(""); + ec2_collision_step(env, owner_key, owner_id, region, tag) } _ => String::new(), }; @@ -1437,21 +1524,17 @@ pub async fn onboard_aws_user( let owner = validate_owner_id(&ctx.who.user_id).map_err(other)?; let found = detect(&ctx).await?; onboard_refusal(&found, &env).map_err(other)?; - let okey = owner_key(&ctx.region, &owner); - let api = SdkDetectApi::new(&ctx.cfg, &ctx.who.account); - let recorded = user_compute(&api, &env, &okey, &ctx.who.account, &ctx.region).await?; - let compute = resolve_ec2(ec2, recorded.as_ref()); - let vars = onboarding_vars(&env, &ctx.region, &owner, compute.as_ref()).map_err(other)?; - if let Some(c) = &compute { - // R3: before any apply with EC2 capacity. The caller's own - // triple-c-user tag can't be read (session tags aren't visible to - // GetCallerIdentity); a wrong value fails later as access denied. - let stem = user_ec2_stem(&env, &c.user_tag); - let (cluster, group) = ec2_names_in_use(&ctx.cfg, &stem).await?; - ec2_collision_refusal(&stem, cluster, group, recorded.as_ref()).map_err(other)?; - } + let vars = prepare_onboarding( + &SdkOnboardApi::new(&ctx.cfg), + &env, + &ctx.region, + &ctx.who.account, + &owner, + ec2, + ) + .await?; let key = DeploymentKey::User { - owner_key: okey, + owner_key: owner_key(&ctx.region, &owner), env, }; opened(launch(app, &ctx, &key, &vars, TofuOp::Apply).await) @@ -1515,7 +1598,7 @@ async fn pick_folder(window: &tauri::Window) -> Option { /// environment's network (public when omitted), `ec2` an onboarding's EC2 /// capacity (none when omitted; the bundle's README has the admin check /// its names first). `None` when the dialog was dismissed; otherwise the -/// folder written. +/// folder written and any warning. #[allow(clippy::too_many_arguments)] #[tauri::command] pub async fn save_aws_admin_bundle( @@ -1529,7 +1612,7 @@ pub async fn save_aws_admin_bundle( ec2: Option, window: tauri::Window, state: State<'_, AppState>, -) -> Result, AwsError> { +) -> Result, AwsError> { let need_env = || { environment .as_deref() @@ -1569,11 +1652,29 @@ pub async fn save_aws_admin_bundle( ModuleKind::PermissionsBoundary => (DeploymentKey::Boundary, boundary_vars(®ion_ok)), }; let ctx = context(&state, &connection_id, ®ion).await?; + let warning = match (&key, &ec2, &owner_id) { + (DeploymentKey::User { env, .. }, Some(c), Some(owner)) => { + let api = SdkOnboardApi::new(&ctx.cfg); + bundle_ec2_warning(&api, env, &ctx.region, &ctx.who.account, owner.trim(), c).await + } + _ => None, + }; let Some(dir) = pick_folder(&window).await else { return Ok(None); }; write_bundle(&dir, key.deployment(), &ctx.who.account, &ctx.region, &vars).map_err(other)?; - Ok(Some(dir.to_string_lossy().into_owned())) + Ok(Some(SavedBundle { + folder: dir.to_string_lossy().into_owned(), + warning, + })) +} + +/// A bundle written: its folder and, for an onboarding with EC2 capacity, +/// a warning when its EC2 name looks taken ([`bundle_ec2_warning`]). +#[derive(Serialize, Clone, Debug, PartialEq)] +pub struct SavedBundle { + pub folder: String, + pub warning: Option, } #[cfg(test)] diff --git a/app/src-tauri/src/commands/environment_commands/tests.rs b/app/src-tauri/src/commands/environment_commands/tests.rs index 39f7007..a3d404f 100644 --- a/app/src-tauri/src/commands/environment_commands/tests.rs +++ b/app/src-tauri/src/commands/environment_commands/tests.rs @@ -6,7 +6,7 @@ use serde_json::json; use super::*; use crate::aws::tofu::Workdir; use crate::aws::environments::{ - EnvironmentState, Knowable, LockInfo, OnboardingState, UserCompute, + EnvironmentState, Knowable, LockInfo, NamedResource, OnboardingState, Param, UserCompute, }; use crate::aws::tofu_modules::{ environment_vars, module_files, onboarding_vars, owner_key, state_key, ModuleKind, @@ -265,6 +265,9 @@ fn bundles_contain_the_module_backend_vars_and_readme() { ), &format!("aws ssm get-parameter --region {REGION} --name {record}"), "cluster/triple-c-dev--u-", + "--include TAGS", + "triple-c:owner", + &format!("owner_id ({USER_ID})"), ] { assert!(readme.contains(needle), "README lacks {needle:?}:\n{readme}"); } @@ -681,17 +684,17 @@ fn recorded(env: &str, tag: &str, max: u32) -> UserCompute { #[test] fn a_reapply_keeps_the_recorded_compute_unless_changed() { - let rec = recorded("dev", "alice", 3); + let rec = UserRecord::Valid(recorded("dev", "alice", 3)); let kept = Ec2Compute { instance_type: "m7g.xlarge".into(), max_instances: 3, user_tag: "alice".into(), }; // Omitted: keep what the record says (or none without one). - assert_eq!(resolve_ec2(None, Some(&rec)), Some(kept.clone())); - assert_eq!(resolve_ec2(None, None), None); + assert_eq!(resolve_ec2(None, &rec), Ok(Some(kept.clone()))); + assert_eq!(resolve_ec2(None, &UserRecord::Absent), Ok(None)); // Explicitly none: the re-apply removes it. - assert_eq!(resolve_ec2(Some(Ec2Choice::None), Some(&rec)), None); + assert_eq!(resolve_ec2(Some(Ec2Choice::None), &rec), Ok(None)); // A new choice wins. let new = Ec2Compute { instance_type: "m7i.large".into(), @@ -699,17 +702,21 @@ fn a_reapply_keeps_the_recorded_compute_unless_changed() { user_tag: "alice".into(), }; assert_eq!( - resolve_ec2(Some(Ec2Choice::Ec2(new.clone())), Some(&rec)), - Some(new.clone()) + resolve_ec2(Some(Ec2Choice::Ec2(new.clone())), &rec), + Ok(Some(new.clone())) ); + // A record that exists but can't be used is never read as "none" (that + // would tear the capacity down); an explicit choice still goes. + let bad = UserRecord::Unusable("schema is not 1".into()); + let e = resolve_ec2(None, &bad).unwrap_err(); + assert!(e.contains("schema is not 1") && e.contains("explicitly"), "{e}"); + assert_eq!(resolve_ec2(Some(Ec2Choice::None), &bad), Ok(None)); + assert_eq!(resolve_ec2(Some(Ec2Choice::Ec2(new.clone())), &bad), Ok(Some(new.clone()))); // The kept values reach the module's variables unchanged. - let vars = onboarding_vars("dev", REGION, USER_ID, resolve_ec2(None, Some(&rec)).as_ref()).unwrap(); + let vars = onboarding_vars("dev", REGION, USER_ID, resolve_ec2(None, &rec).unwrap().as_ref()).unwrap(); assert_eq!(vars["ec2_instance_type"], "m7g.xlarge"); assert_eq!(vars["ec2_max_instances"], 3); assert_eq!(vars["ec2_user_tag"], "alice"); - let vars = onboarding_vars("dev", REGION, USER_ID, Some(&new)).unwrap(); - assert_eq!(vars["ec2_instance_type"], "m7i.large"); - assert_eq!(vars["ec2_max_instances"], 1); // The UI's JSON for each choice. let none: Ec2Choice = serde_json::from_value(json!({"kind": "none"})).unwrap(); @@ -721,27 +728,251 @@ fn a_reapply_keeps_the_recorded_compute_unless_changed() { assert_eq!(ec2, Ec2Choice::Ec2(new)); } -#[test] -fn ec2_names_in_use_by_another_onboarding_are_refused() { - let stem = "triple-c-dev--u-alice"; - // Free names: fine, with or without a record. - assert!(ec2_collision_refusal(stem, false, false, None).is_ok()); - assert!(ec2_collision_refusal(stem, false, false, Some(&recorded("dev", "bob", 1))).is_ok()); - // Taken, and this owner's record names that cluster: their own re-apply. - let mine = recorded("dev", "alice", 2); - for (cluster, group) in [(true, false), (false, true), (true, true)] { - assert!(ec2_collision_refusal(stem, cluster, group, Some(&mine)).is_ok()); - // Taken with no record, or a record naming another cluster. - for other in [None, Some(recorded("dev", "bob", 1))] { - let e = ec2_collision_refusal(stem, cluster, group, other.as_ref()).unwrap_err(); - assert!(e.contains(stem), "{e}"); - assert!(e.contains("triple-c-user"), "{e}"); - } +fn held(kind: &'static str, owner: Option<&str>) -> NameHolder { + NameHolder { + kind, + owner: owner.map(String::from), } +} + +#[test] +fn ec2_names_held_by_another_owner_are_refused() { + let stem = "triple-c-dev--u-alice"; + let me = USER_ID; + // Free names: fine, with or without a record. + assert!(ec2_collision_refusal(stem, &[], me, None).is_ok()); + assert!(ec2_collision_refusal(stem, &[], me, Some(&recorded("dev", "bob", 1))).is_ok()); + let cluster = |o| held("ECS cluster", o); + let group = |o| held("Auto Scaling group", o); + // Tagged as mine: a half-built capacity (no record yet) is re-applied. + assert!(ec2_collision_refusal(stem, &[cluster(Some(me)), group(Some(me))], me, None).is_ok()); + // Another owner's, or untagged: refused, naming the resource. + let e = ec2_collision_refusal(stem, &[cluster(Some("AROAOTHER:bob"))], me, None).unwrap_err(); + assert!(e.contains("ECS cluster") && e.contains(stem) && e.contains("another onboarding"), "{e}"); + assert!(e.contains("triple-c-user"), "{e}"); + let e = ec2_collision_refusal(stem, &[cluster(Some(me)), group(None)], me, None).unwrap_err(); + assert!(e.contains("Auto Scaling group") && e.contains("isn't tagged"), "{e}"); + // The record naming the cluster is the fallback for an untagged or + // differently tagged one. + let mine = recorded("dev", "alice", 2); + assert!(ec2_collision_refusal(stem, &[cluster(None), group(Some("x"))], me, Some(&mine)).is_ok()); + // A record naming another cluster doesn't help. + assert!(ec2_collision_refusal(stem, &[cluster(None)], me, Some(&recorded("dev", "bob", 1))).is_err()); // A cluster that merely ends in the same text is not the same cluster. let mut lookalike = recorded("dev", "alice", 1); lookalike.cluster_arn = format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/x{stem}"); - assert!(ec2_collision_refusal(stem, true, false, Some(&lookalike)).is_err()); + assert!(ec2_collision_refusal(stem, &[cluster(None)], me, Some(&lookalike)).is_err()); +} + +/// An `OnboardApi` answering from fixed data, recording what it was asked. +#[derive(Default)] +struct FakeOnboard { + record: Option, + record_denied: bool, + cluster: Option, + group: Option, + group_denied: bool, + calls: std::sync::Mutex>, +} + +impl FakeOnboard { + fn calls(&self) -> Vec { + self.calls.lock().unwrap().clone() + } +} + +impl OnboardApi for FakeOnboard { + async fn parameter(&self, name: &str) -> Result { + self.calls.lock().unwrap().push(format!("parameter {name}")); + Ok(match (&self.record, self.record_denied) { + (_, true) => Param::Denied, + (Some(v), _) => Param::Value(v.clone()), + (None, _) => Param::Missing, + }) + } + async fn cluster(&self, name: &str) -> Result, AwsError> { + self.calls.lock().unwrap().push(format!("cluster {name}")); + Ok(self.cluster.clone()) + } + async fn group(&self, name: &str) -> Result, AwsError> { + self.calls.lock().unwrap().push(format!("group {name}")); + if self.group_denied { + return Err(AwsError::AccessDenied { + action: "autoscaling:DescribeAutoScalingGroups".into(), + message: "denied".into(), + }); + } + Ok(self.group.clone()) + } +} + +fn named(status: Option<&str>, owner: Option<&str>) -> NamedResource { + NamedResource { + status: status.map(String::from), + tags: owner + .map(|o| vec![("triple-c:owner".to_string(), o.to_string())]) + .unwrap_or_default(), + } +} + +fn record_json(env: &str, tag: &str) -> String { + let r = recorded(env, tag, 2); + json!({ + "schema": 1, "instance_type": r.instance_type, "cluster_arn": r.cluster_arn, + "capacity_provider": r.capacity_provider, "user_tag": r.user_tag, "max_instances": 2, + }) + .to_string() +} + +fn prepare(api: &FakeOnboard, choice: Option) -> Result { + tokio::runtime::Builder::new_current_thread() + .build() + .unwrap() + .block_on(prepare_onboarding(api, "dev", REGION, ACCOUNT, USER_ID, choice)) +} + +fn alice() -> Option { + Some(Ec2Choice::Ec2(Ec2Compute { + instance_type: "m7i.large".into(), + max_instances: 1, + user_tag: "alice".into(), + })) +} + +#[test] +fn onboarding_checks_the_ec2_names_before_it_applies() { + let stem = "triple-c-dev--u-alice"; + // Fargate only: no name lookups at all. + let api = FakeOnboard::default(); + let vars = prepare(&api, Some(Ec2Choice::None)).unwrap(); + assert_eq!(vars["ec2_instance_type"], ""); + assert!(api.calls().iter().all(|c| c.starts_with("parameter ")), "{:?}", api.calls()); + + // Free names: the vars come back. + let api = FakeOnboard::default(); + let vars = prepare(&api, alice()).unwrap(); + assert_eq!(vars["ec2_user_tag"], "alice"); + assert!(api.calls().contains(&format!("cluster {stem}"))); + assert!(api.calls().contains(&format!("group {stem}"))); + + // Another owner's cluster: refused, so nothing is launched. + let api = FakeOnboard { + cluster: Some(named(Some("ACTIVE"), Some("AROAOTHER:bob"))), + ..Default::default() + }; + let e = prepare(&api, alice()).unwrap_err(); + assert!(format!("{e:?}").contains("another onboarding"), "{e:?}"); + + // My own half-built cluster and group (a failed apply, no record yet). + let api = FakeOnboard { + cluster: Some(named(Some("PROVISIONING"), Some(USER_ID))), + group: Some(named(None, Some(USER_ID))), + ..Default::default() + }; + assert!(prepare(&api, alice()).is_ok()); + + // Untagged: refused unless my record names it. + let untagged = || FakeOnboard { + cluster: Some(named(Some("ACTIVE"), None)), + ..Default::default() + }; + assert!(prepare(&untagged(), alice()).is_err()); + let api = FakeOnboard { + record: Some(record_json("dev", "alice")), + ..untagged() + }; + assert!(prepare(&api, alice()).is_ok()); + + // A deleted (INACTIVE) cluster doesn't hold the name; every other + // status does. + let api = FakeOnboard { + cluster: Some(named(Some("INACTIVE"), None)), + ..Default::default() + }; + assert!(prepare(&api, alice()).is_ok()); + for status in ["ACTIVE", "PROVISIONING", "DEPROVISIONING", "FAILED"] { + let api = FakeOnboard { + cluster: Some(named(Some(status), Some("AROAOTHER:bob"))), + ..Default::default() + }; + assert!(prepare(&api, alice()).is_err(), "{status}"); + } + + // An Auto Scaling group alone is enough to refuse. + let api = FakeOnboard { + group: Some(named(None, Some("AROAOTHER:bob"))), + ..Default::default() + }; + assert!(prepare(&api, alice()).is_err()); + + // A denied group lookup is an error, never "free". + let api = FakeOnboard { + group_denied: true, + ..Default::default() + }; + assert!(prepare(&api, alice()).is_err()); +} + +#[test] +fn capacity_kept_from_the_record_is_checked_too() { + let stem = "triple-c-dev--u-alice"; + // Omitted choice + a record: the record's capacity, and its names are + // checked (here another owner's group appeared under it). + let api = FakeOnboard { + record: Some(record_json("dev", "alice")), + cluster: Some(named(Some("ACTIVE"), Some(USER_ID))), + group: Some(named(None, Some(USER_ID))), + ..Default::default() + }; + let vars = prepare(&api, None).unwrap(); + assert_eq!(vars["ec2_instance_type"], "m7g.xlarge"); + assert_eq!(vars["ec2_max_instances"], 2); + assert!(api.calls().contains(&format!("group {stem}"))); + + // A record that can't be used (unreadable or invalid) and no choice: + // refused before any name lookup or launch. + for api in [ + FakeOnboard { + record_denied: true, + ..Default::default() + }, + FakeOnboard { + record: Some("{\"schema\": 9}".into()), + ..Default::default() + }, + ] { + let e = prepare(&api, None).unwrap_err(); + assert!(format!("{e:?}").contains("explicitly"), "{e:?}"); + assert!(api.calls().iter().all(|c| c.starts_with("parameter "))); + } +} + +#[test] +fn a_bundle_warns_when_its_cluster_name_looks_taken() { + let run = |api: &FakeOnboard| { + let c = Ec2Compute { + instance_type: "m7i.large".into(), + max_instances: 1, + user_tag: "alice".into(), + }; + tokio::runtime::Builder::new_current_thread() + .build() + .unwrap() + .block_on(bundle_ec2_warning(api, "dev", REGION, ACCOUNT, USER_ID, &c)) + }; + assert_eq!(run(&FakeOnboard::default()), None); + let api = FakeOnboard { + cluster: Some(named(Some("ACTIVE"), Some("AROAOTHER:bob"))), + ..Default::default() + }; + assert!(run(&api).unwrap().contains("another onboarding")); + // Only the cluster half: a workspace user can't read Auto Scaling. + assert!(!api.calls().iter().any(|c| c.starts_with("group "))); + let api = FakeOnboard { + cluster: Some(named(Some("ACTIVE"), Some(USER_ID))), + ..Default::default() + }; + assert_eq!(run(&api), None); } #[test] diff --git a/app/src-tauri/src/models/project.rs b/app/src-tauri/src/models/project.rs index b9ee871..000f91f 100644 --- a/app/src-tauri/src/models/project.rs +++ b/app/src-tauri/src/models/project.rs @@ -1616,6 +1616,20 @@ mod tests { t.instance_type ); } + // And the other way: every type the spec table sizes is listed (a + // family added to one but not the other fails here). + let families = [ + "m7i", "m7g", "m7a", "m6i", "c7i", "c7g", "c7a", "r7i", "r7g", "r7a", "t3", "t3a", + "t4g", "p5", "g6", + ]; + for family in families { + for size in ["medium", "large", "xlarge", "2xlarge", "4xlarge", "8xlarge", "metal"] { + let t = format!("{family}.{size}"); + if ec2_instance_spec(&t).is_some() { + assert!(list.iter().any(|row| row.instance_type == t), "{t} missing"); + } + } + } let arch = |name: &str| list.iter().find(|t| t.instance_type == name).unwrap().arch; assert_eq!(arch("m7i.large"), Arch::X86_64); assert_eq!(arch("t3.xlarge"), Arch::X86_64); diff --git a/app/src/components/settings/hosts/AdminBundleModal.test.tsx b/app/src/components/settings/hosts/AdminBundleModal.test.tsx index 7b62625..7f0e8f1 100644 --- a/app/src/components/settings/hosts/AdminBundleModal.test.tsx +++ b/app/src/components/settings/hosts/AdminBundleModal.test.tsx @@ -13,7 +13,7 @@ describe("AdminBundleModal", () => { it("saves the bundle and shows the folder and the two commands, with Copy", async () => { invoke.mockImplementation(async (cmd: string) => - cmd === "list_ec2_instance_types" ? instanceTable : "/home/me/triple-c-onboard-dev", + cmd === "list_ec2_instance_types" ? instanceTable : { folder: "/home/me/triple-c-onboard-dev", warning: null }, ); const writeText = vi.fn().mockResolvedValue(undefined); Object.assign(navigator, { clipboard: { writeText } }); @@ -42,7 +42,7 @@ describe("AdminBundleModal", () => { it("an onboarding bundle carries the chosen EC2 capacity", async () => { invoke.mockImplementation(async (cmd: string) => - cmd === "list_ec2_instance_types" ? instanceTable : "/tmp/onboard", + cmd === "list_ec2_instance_types" ? instanceTable : { folder: "/tmp/onboard", warning: "An ECS cluster named triple-c-dev--u-bob already belongs to another onboarding." }, ); render( , @@ -66,6 +66,40 @@ describe("AdminBundleModal", () => { ec2: { instance_type: "m7i.large", max_instances: 4, user_tag: "bob" }, }), ); + // The app's partial check of the name (cluster only) warns, never refuses. + expect(await screen.findByText(/already belongs to another onboarding/)).toBeInTheDocument(); + expect(screen.getByText("/tmp/onboard")).toBeInTheDocument(); + }); + + it("keeps the recorded instance type, read-only, when the list can't load", async () => { + invoke.mockImplementation(async (cmd: string) => { + if (cmd === "list_ec2_instance_types") throw new Error("boom"); + return null; + }); + render( + , + ); + expect(await screen.findByText(/Could not load the instance types/)).toBeInTheDocument(); + const type = screen.getByLabelText("Instance type") as HTMLSelectElement; + expect(type).toBeDisabled(); + expect(type.value).toBe("r7g.2xlarge"); + expect(screen.getByText(/keeping r7g.2xlarge/)).toBeInTheDocument(); + // The kept values can still be saved. + expect(screen.getByRole("button", { name: "Save bundle to folder…" })).toBeEnabled(); }); it("an environment bundle has no EC2 capacity", () => { @@ -83,7 +117,7 @@ describe("AdminBundleModal", () => { }); it("an environment bundle asks for the name and network", async () => { - invoke.mockResolvedValue("/tmp/env"); + invoke.mockResolvedValue({ folder: "/tmp/env", warning: null }); render(); fireEvent.change(screen.getByLabelText("Name"), { target: { value: "team" } }); fireEvent.click(screen.getByRole("radio", { name: "Private + NAT" })); @@ -102,7 +136,7 @@ describe("AdminBundleModal", () => { }); it("an environment bundle carries the lifetime cap", async () => { - invoke.mockResolvedValue("/tmp/env"); + invoke.mockResolvedValue({ folder: "/tmp/env", warning: null }); render(); fireEvent.change(screen.getByLabelText("Maximum workspace lifetime (hours, 0 = none)"), { target: { value: "24" } }); fireEvent.click(screen.getByRole("button", { name: "Save bundle to folder…" })); diff --git a/app/src/components/settings/hosts/AdminBundleModal.tsx b/app/src/components/settings/hosts/AdminBundleModal.tsx index ffe4e0a..59719e4 100644 --- a/app/src/components/settings/hosts/AdminBundleModal.tsx +++ b/app/src/components/settings/hosts/AdminBundleModal.tsx @@ -65,6 +65,7 @@ export default function AdminBundleModal({ const [ec2Draft, setEc2Draft] = useState(() => ec2DraftFrom(recordedEc2)); const [saving, setSaving] = useState(false); const [saved, setSaved] = useState(null); + const [warning, setWarning] = useState(null); const [error, setError] = useState(null); const [copyNote, setCopyNote] = useState(null); @@ -83,16 +84,17 @@ export default function AdminBundleModal({ setSaving(true); setError(null); try { - const folder = await saveAwsAdminBundle(connectionId, region, kind, { + const result = await saveAwsAdminBundle(connectionId, region, kind, { environment: askEnvironment ? name : environment, ownerId, network: picked && "network" in picked ? picked.network : network, ...(askEnvironment && capHours !== null ? { maxWorkspaceHours: capHours } : {}), ...(ec2 && "compute" in ec2 ? { ec2: ec2.compute } : {}), }); - if (folder) { - setSaved(folder); - onSaved?.(folder); + if (result) { + setSaved(result.folder); + setWarning(result.warning); + onSaved?.(result.folder); } } catch (e) { setError(toAwsError(e)); @@ -166,6 +168,11 @@ export default function AdminBundleModal({ )} {saved && (
+ {warning && ( +

+ {warning} +

+ )}

Saved to {saved}

diff --git a/app/src/components/settings/hosts/DeployEnvironmentModal.test.tsx b/app/src/components/settings/hosts/DeployEnvironmentModal.test.tsx index 6258919..af5df4c 100644 --- a/app/src/components/settings/hosts/DeployEnvironmentModal.test.tsx +++ b/app/src/components/settings/hosts/DeployEnvironmentModal.test.tsx @@ -144,7 +144,7 @@ describe("DeployEnvironmentModal", () => { it("offers the boundary bundle when the boundary run fails, with its summary as the reason", async () => { invoke.mockImplementation(async (cmd: string) => { if (cmd === "deploy_aws_permissions_boundary") return "b1"; - if (cmd === "save_aws_admin_bundle") return "/tmp/b"; + if (cmd === "save_aws_admin_bundle") return { folder: "/tmp/b", warning: null }; throw new Error(`unexpected ${cmd}`); }); const props = renderModal({ scan: scan({ boundary: "no" }) }); @@ -166,7 +166,7 @@ describe("DeployEnvironmentModal", () => { it("opens the boundary bundle when the boundary command itself is denied", async () => { invoke.mockImplementation(async (cmd: string) => { if (cmd === "deploy_aws_permissions_boundary") throw { kind: "access_denied", action: "iam:CreatePolicy", message: "denied iam:CreatePolicy" }; - if (cmd === "save_aws_admin_bundle") return "/tmp/b"; + if (cmd === "save_aws_admin_bundle") return { folder: "/tmp/b", warning: null }; throw new Error(`unexpected ${cmd}`); }); renderModal({ scan: scan({ boundary: "no" }) }); diff --git a/app/src/components/settings/hosts/Ec2CapacityFields.tsx b/app/src/components/settings/hosts/Ec2CapacityFields.tsx index 5e11387..e2951b0 100644 --- a/app/src/components/settings/hosts/Ec2CapacityFields.tsx +++ b/app/src/components/settings/hosts/Ec2CapacityFields.tsx @@ -95,7 +95,8 @@ export default function Ec2CapacityFields({ {loadError && (

- Could not load the instance types. + Could not load the instance types + {value.instanceType ? `; keeping ${value.instanceType}.` : "; detect again to choose one."}

)} diff --git a/app/src/components/settings/hosts/EnvironmentsPanel.test.tsx b/app/src/components/settings/hosts/EnvironmentsPanel.test.tsx index 9486ba8..d972966 100644 --- a/app/src/components/settings/hosts/EnvironmentsPanel.test.tsx +++ b/app/src/components/settings/hosts/EnvironmentsPanel.test.tsx @@ -251,7 +251,7 @@ describe("EnvironmentsPanel", () => { backend( () => scan({ environments: [env()] }), (cmd) => { - if (cmd === "save_aws_admin_bundle") return "/home/me/onboard-dev"; + if (cmd === "save_aws_admin_bundle") return { folder: "/home/me/onboard-dev", warning: null }; throw new Error(`unexpected ${cmd}`); }, ); @@ -362,12 +362,30 @@ describe("EnvironmentsPanel", () => { ); }); + it("finishing an incomplete onboarding starts from its record and says when it removes EC2", async () => { + backend( + () => scan({ environments: [env({ onboarding: { state: "incomplete", lock: null, ec2: compute() } })] }), + (cmd) => { + if (cmd === "list_ec2_instance_types") return instanceTable; + throw new Error(`unexpected ${cmd}`); + }, + ); + render(); + await open(); + fireEvent.click(await screen.findByRole("button", { name: "Join dev" })); + const dialog = screen.getByRole("dialog", { name: "Join dev" }); + expect((within(dialog).getByLabelText("Your triple-c-user value") as HTMLInputElement).value).toBe("alice"); + expect(within(dialog).queryByText(/This removes your EC2 capacity/)).toBeNull(); + fireEvent.click(within(dialog).getByRole("radio", { name: "None (Fargate only)" })); + expect(within(dialog).getByText("This removes your EC2 capacity (m7g.xlarge) in dev.")).toBeInTheDocument(); + }); + it("a joined workspace user's capacity change is a bundle starting from their record", async () => { backend( () => scan({ environments: [env({ onboarding: { state: "joined", ec2: compute({ max_instances: 1 }) } })] }), (cmd) => { if (cmd === "list_ec2_instance_types") return instanceTable; - if (cmd === "save_aws_admin_bundle") return "/home/me/onboard-dev"; + if (cmd === "save_aws_admin_bundle") return { folder: "/home/me/onboard-dev", warning: null }; throw new Error(`unexpected ${cmd}`); }, ); diff --git a/app/src/components/settings/hosts/JoinEnvironmentModal.tsx b/app/src/components/settings/hosts/JoinEnvironmentModal.tsx index 29aa2a6..15fb042 100644 --- a/app/src/components/settings/hosts/JoinEnvironmentModal.tsx +++ b/app/src/components/settings/hosts/JoinEnvironmentModal.tsx @@ -65,10 +65,15 @@ export default function JoinEnvironmentModal({ >
{!reapply &&

Joining creates your own task role and file system in {environment}.

} - {reapply && recorded && ( + {recorded && (

Stop your EC2 workspaces before removing EC2 capacity or changing your triple-c-user value: that change can't finish while one runs.

)} + {recorded && !draft.enabled && ( +

+ This removes your EC2 capacity ({recorded.instance_type}) in {environment}. +

+ )} {error && (

{awsErrorMessage(error)} diff --git a/app/src/lib/tauri-commands.ts b/app/src/lib/tauri-commands.ts index 0b312e8..894051b 100644 --- a/app/src/lib/tauri-commands.ts +++ b/app/src/lib/tauri-commands.ts @@ -1,5 +1,5 @@ import { invoke } from "@tauri-apps/api/core"; -import type { Project, ProjectPath, NewProjectHost, RemoveProjectOptions, WipChoice, UnsavedWork, WorkspaceStatus, ProjectRemovalReport, ProjectResetOutcome, ContainerInfo, AppSettings, SettingsImportPreview, SettingsImportOutcome, UpdateInfo, ImageUpdateInfo, FileEntry, FileContents, WebTerminalInfo, SttStatus, GatewayStatus, InstallOptions, ClaudeSession, ContainerCapabilities, ScheduledTask, ScheduledTaskInput, SchedulerNotification, AuthBridgeStatus, BrowserViewStatus, BrowserViewPopoutState, BrowserPageState, PlaywrightDetection, BrowserSetupOutcome, BrowserInstallTarget, ContainerStaleness, MigrationOptions, MigrationReport, MigrationState, ClearTokenOutcome, CaCertInfo, UploadOutcome, Note, ViewerFile, ViewerPoll, ViewerSaved, ViewerState, FileDiff, InstallScope, ItemUpdate, Marketplace, MarketplaceAccount, MarketplaceItemRef, MarketplaceSnapshot, ProjectSyncResult, SyncReport, HostConnection, CallerIdentity, PermissionReport, PolicyFile, HourlyEstimate, AwsWorkspaceConfig, Tier, EnvironmentScan, NetworkChoice, ModuleKind, Ec2Choice, Ec2Compute, Ec2InstanceTable } from "./types"; +import type { Project, ProjectPath, NewProjectHost, RemoveProjectOptions, WipChoice, UnsavedWork, WorkspaceStatus, ProjectRemovalReport, ProjectResetOutcome, ContainerInfo, AppSettings, SettingsImportPreview, SettingsImportOutcome, UpdateInfo, ImageUpdateInfo, FileEntry, FileContents, WebTerminalInfo, SttStatus, GatewayStatus, InstallOptions, ClaudeSession, ContainerCapabilities, ScheduledTask, ScheduledTaskInput, SchedulerNotification, AuthBridgeStatus, BrowserViewStatus, BrowserViewPopoutState, BrowserPageState, PlaywrightDetection, BrowserSetupOutcome, BrowserInstallTarget, ContainerStaleness, MigrationOptions, MigrationReport, MigrationState, ClearTokenOutcome, CaCertInfo, UploadOutcome, Note, ViewerFile, ViewerPoll, ViewerSaved, ViewerState, FileDiff, InstallScope, ItemUpdate, Marketplace, MarketplaceAccount, MarketplaceItemRef, MarketplaceSnapshot, ProjectSyncResult, SyncReport, HostConnection, CallerIdentity, PermissionReport, PolicyFile, HourlyEstimate, AwsWorkspaceConfig, Tier, EnvironmentScan, NetworkChoice, ModuleKind, Ec2Choice, Ec2Compute, Ec2InstanceTable, SavedBundle } from "./types"; // Docker export const checkDocker = () => invoke("check_docker"); @@ -172,7 +172,7 @@ export const onboardAwsUser = (connectionId: string, region: string, environment export const listEc2InstanceTypes = () => invoke("list_ec2_instance_types"); export const deployAwsPermissionsBoundary = (connectionId: string, region: string) => invoke("deploy_aws_permissions_boundary", { connectionId, region }); -/** Opens a folder picker in Rust; resolves to the folder written, or null if dismissed. */ +/** Opens a folder picker in Rust; resolves to the folder written (and, for an onboarding with EC2, a warning when its cluster name looks taken), or null if dismissed. */ export const saveAwsAdminBundle = ( connectionId: string, region: string, @@ -186,7 +186,7 @@ export const saveAwsAdminBundle = ( ec2?: Ec2Compute | null; } = {}, ) => - invoke("save_aws_admin_bundle", { + invoke("save_aws_admin_bundle", { connectionId, region, kind, diff --git a/app/src/lib/types.ts b/app/src/lib/types.ts index 6104f99..fb0a25d 100644 --- a/app/src/lib/types.ts +++ b/app/src/lib/types.ts @@ -1393,6 +1393,13 @@ export interface Ec2InstanceType { memory_mib: number; } +/** `environment_commands::SavedBundle`. */ +export interface SavedBundle { + folder: string; + /** An onboarding bundle's EC2 name looks taken (a warning; the README has the admin check). */ + warning: string | null; +} + export interface Ec2InstanceTable { default_type: string; types: Ec2InstanceType[]; -- 2.52.0 From d6ef6a5fd2714184a75734dd79994af1f8b87754 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 14:46:06 -0800 Subject: [PATCH 11/29] feat(aws): run projects on per-user EC2 capacity EC2 projects register an EC2/bridge task definition (no runtime platform or ephemeral storage; task-level reservations checked against the user's instance type with a 10% memory margin), with the instance's Docker socket and the Docker VPN pieces (NET_ADMIN, /dev/net/tun, src_valid_mark) when enabled, and run on the user's cluster through their capacity provider. The start reads the user record, waits up to 10 minutes with "Starting an instance" progress, and maps RunTask access denied to the triple-c-user mismatch. Stop, reconcile, removal and the watch follow the task's own cluster, so a running EC2 task outlives its record. The sandbox stays on for EC2; the gateway sidecar is refused there for now. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/environments.rs | 2 +- app/src-tauri/src/aws/runtime.rs | 83 +++++- app/src-tauri/src/aws/runtime/tests.rs | 140 ++++++++- app/src-tauri/src/aws/tasks.rs | 127 +++++++- app/src-tauri/src/aws/tasks/tests.rs | 145 ++++++++- app/src-tauri/src/aws/tofu_modules.rs | 9 +- app/src-tauri/src/aws/workspace.rs | 216 ++++++++++++-- app/src-tauri/src/aws/workspace/tests.rs | 249 +++++++++++++++- .../src/commands/project_commands.rs | 13 + app/src-tauri/src/docker/container.rs | 31 ++ app/src-tauri/src/host/aws_host.rs | 279 +++++++++++++++--- app/src-tauri/src/host/aws_host/tests.rs | 279 +++++++++++++++++- app/src-tauri/src/models/project.rs | 33 ++- 13 files changed, 1474 insertions(+), 132 deletions(-) diff --git a/app/src-tauri/src/aws/environments.rs b/app/src-tauri/src/aws/environments.rs index f5f3967..0b79753 100644 --- a/app/src-tauri/src/aws/environments.rs +++ b/app/src-tauri/src/aws/environments.rs @@ -938,7 +938,7 @@ pub async fn ec2_name_holders( } /// `ssm:GetParameter` as a [`Param`]. -async fn get_parameter(ssm: &aws_sdk_ssm::Client, name: &str) -> Result { +pub(crate) async fn get_parameter(ssm: &aws_sdk_ssm::Client, name: &str) -> Result { let res = ssm .get_parameter() .name(name) diff --git a/app/src-tauri/src/aws/runtime.rs b/app/src-tauri/src/aws/runtime.rs index 8dc313b..8ec989a 100644 --- a/app/src-tauri/src/aws/runtime.rs +++ b/app/src-tauri/src/aws/runtime.rs @@ -14,12 +14,15 @@ use std::time::Duration; use aws_config::SdkConfig; use aws_sdk_secretsmanager::error::ProvideErrorMetadata; -use super::environments::{knowable, parse_environment_record, EnvironmentInfo, Knowable}; +use super::environments::{ + get_parameter, knowable, parse_environment_record, user_record_from, EnvironmentInfo, Knowable, + Param, UserRecord, +}; use super::error::{classify_sdk_error, AwsError}; use super::tasks::{find_project_task, TaskApi, STOP_REASON}; use super::tofu_modules::{ access_point_root, workspace_access_point_root, environment_cluster_name, environment_parameter_name, project_secret_name, task_family, - user_file_system_token, user_role_names, + is_user_ec2_cluster, user_file_system_token, user_record_parameter_name, user_role_names, }; use super::workspace::WorkspaceApi; @@ -40,6 +43,13 @@ pub trait RuntimeApi: Send + Sync { &self, env: &str, ) -> impl Future, AwsError>> + Send; + /// `ssm:GetParameter` of the caller's EC2 record in `env` + /// (`user_record_parameter_name`). + fn user_record( + &self, + env: &str, + owner_key: &str, + ) -> impl Future> + Send; /// `iam:GetRole`. fn role_exists(&self, name: &str) -> impl Future> + Send; /// `secretsmanager:GetSecretValue`'s `SecretString`. @@ -80,6 +90,28 @@ pub async fn read_environment( }) } +/// The caller's EC2 record in `env`, validated (untrusted: `parse_user_record`). +/// Absent = no EC2 capacity for NEW runs; a task already running on the +/// user's cluster may outlive the record (teardown removes it first). +pub async fn read_user_record( + rt: &R, + env: &str, + owner_key: &str, + account: &str, + region: &str, +) -> Result { + Ok(user_record_from(rt.user_record(env, owner_key).await?, env, account, region)) +} + +/// The per-user EC2 cluster (ARN) a stored task ARN names, when it is one of +/// `env`'s: where a project that ran on EC2 is still looked for after its +/// user record is gone. +pub fn ec2_cluster_of_task(env: &str, task_arn: &str) -> Option { + cluster_of_task(task_arn) + .filter(|c| is_user_ec2_cluster(env, c)) + .and_then(|_| cluster_arn_of_task(task_arn)) +} + /// Whether the caller's task role exists in the environment: the onboarding /// signal a workspace user can read. A denied lookup is not an answer, so /// it is let through (RunTask will say what is wrong). @@ -237,6 +269,9 @@ pub struct RemoveRequest<'a> { /// The EFS-mode `/workspace` access point the store has (kept after a /// switch to Hybrid or Ephemeral, Q1). pub stored_workspace_access_point_id: Option<&'a str>, + /// The user's EC2 cluster (their record's), looked in too: a project + /// may have run there. + pub ec2_cluster: Option<&'a str>, /// Delete the EFS access points, home and `/workspace` (ruling R9). The /// files stay on the user's own file system (only their task role can /// read it) until offboarding destroys it; a later start of the same @@ -258,17 +293,39 @@ pub async fn remove_workspace_resources = live.into_iter().map(|t| t.arn).collect(); - if let Some(arn) = req.stored_task_arn { - if cluster_of_task(arn) == Some(cluster.as_str()) && !to_stop.iter().any(|a| a == arn) { - to_stop.push(arn.to_string()); + // 1. The task: in the environment's cluster, the user's EC2 cluster (the + // record's, and the stored task's when that is a per-user cluster of + // this environment — the record may be gone). + let mut clusters = vec![cluster.clone()]; + for c in [ + req.ec2_cluster.map(str::to_string), + req.stored_task_arn.and_then(|a| ec2_cluster_of_task(req.env, a)), + ] + .into_iter() + .flatten() + { + if !clusters.contains(&c) { + clusters.push(c); } } - for arn in &to_stop { - tasks.stop_task(&cluster, arn, STOP_REASON).await?; + let mut to_stop: Vec<(String, String)> = Vec::new(); + for c in &clusters { + if let Some(t) = + find_project_task(tasks, c, &family, req.owner_user_id, req.project_id).await? + { + to_stop.push((c.clone(), t.arn)); + } + } + if let Some(arn) = req.stored_task_arn { + let ours = cluster_of_task(arn) == Some(cluster.as_str()) + || ec2_cluster_of_task(req.env, arn).is_some(); + if ours && !to_stop.iter().any(|(_, a)| a == arn) { + let c = cluster_of_task(arn).map_or_else(|| cluster.clone(), str::to_string); + to_stop.push((c, arn.to_string())); + } + } + for (c, arn) in &to_stop { + tasks.stop_task(c, arn, STOP_REASON).await?; } let mut failures: Vec = Vec::new(); @@ -385,6 +442,10 @@ impl RuntimeApi for SdkRuntimeApi { } } + async fn user_record(&self, env: &str, owner_key: &str) -> Result { + get_parameter(&self.ssm, &user_record_parameter_name(env, owner_key)).await + } + async fn role_exists(&self, name: &str) -> Result { let res = self.iam.get_role().role_name(name).send().await; knowable("iam:GetRole", res) diff --git a/app/src-tauri/src/aws/runtime/tests.rs b/app/src-tauri/src/aws/runtime/tests.rs index dc39a8b..be73910 100644 --- a/app/src-tauri/src/aws/runtime/tests.rs +++ b/app/src-tauri/src/aws/runtime/tests.rs @@ -36,6 +36,8 @@ struct Fake { revisions: Vec, access_points: Vec, fail_secret_delete: bool, + /// The clusters ListTasks was asked about, by name. + lists: Mutex>, } impl Fake { @@ -52,6 +54,10 @@ impl RuntimeApi for Fake { self.log(format!("record {env}")); Ok(self.record.clone()) } + async fn user_record(&self, env: &str, owner_key: &str) -> Result { + self.log(format!("user-record {env} {owner_key}")); + Ok(crate::aws::environments::Param::Missing) + } async fn role_exists(&self, name: &str) -> Result { self.log(format!("role {name}")); Ok(self.role.clone().unwrap_or(Knowable::Yes)) @@ -85,8 +91,16 @@ impl TaskApi for Fake { async fn describe(&self, _c: &str, arns: &[String]) -> Result, AwsError> { Ok(self.live_tasks.iter().filter(|t| arns.contains(&t.arn)).cloned().collect()) } - async fn list_project_tasks(&self, _c: &str, _f: &str) -> Result, AwsError> { - Ok(self.live_tasks.iter().map(|t| t.arn.clone()).collect()) + async fn list_project_tasks(&self, c: &str, _f: &str) -> Result, AwsError> { + // By cluster name or ARN, like ECS. + let name = c.rsplit_once(":cluster/").map_or(c, |(_, n)| n); + self.lists.lock().unwrap().push(name.to_string()); + Ok(self + .live_tasks + .iter() + .filter(|t| cluster_of_task(&t.arn) == Some(name)) + .map(|t| t.arn.clone()) + .collect()) } async fn stop_task(&self, cluster: &str, arn: &str, reason: &str) -> Result<(), AwsError> { self.log(format!("stop {cluster} {arn} {reason}")); @@ -262,6 +276,7 @@ fn live(id: &str) -> TaskInfo { family() ), runtime_id: None, + container_instance_arn: None, exec_agent_running: false, exit_code: None, owner: Some(USER.into()), @@ -305,6 +320,7 @@ async fn removal_stops_the_task_leaves_the_revisions_and_schedules_the_secret() stored_task_arn: Some(&t0), stored_access_point_id: Some("fsap-stored"), stored_workspace_access_point_id: None, + ec2_cluster: None, discard_data: false, }; remove_workspace_resources(&fake, &fake, &fake, &r).await.unwrap(); @@ -341,6 +357,7 @@ async fn a_failed_step_is_reported_but_the_rest_still_runs() { stored_task_arn: None, stored_access_point_id: Some("fsap-1"), stored_workspace_access_point_id: None, + ec2_cluster: None, discard_data: true, }; let e = remove_workspace_resources(&fake, &fake, &fake, &r).await.unwrap_err(); @@ -381,6 +398,7 @@ async fn removal_with_discard_deletes_both_access_points_and_without_keeps_both( stored_access_point_id: Some("fsap-home"), // Kept in the store after switching EFS -> Hybrid. stored_workspace_access_point_id: Some("fsap-ws-stored"), + ec2_cluster: None, discard_data: false, }; let keep = Fake { access_points: points.clone(), ..Default::default() }; @@ -402,3 +420,121 @@ async fn removal_with_discard_deletes_both_access_points_and_without_keeps_both( deleted.sort(); assert_eq!(deleted, vec!["fsap-home", "fsap-ws", "fsap-ws-stored"]); } + +// ------------------------------------------------------------- EC2 (phase 7) + +fn ec2_task_arn(id: &str) -> String { + format!("arn:aws:ecs:{REGION}:{ACCOUNT}:task/triple-c-dev--u-alice/{id}") +} + +#[test] +fn a_stored_task_on_a_per_user_cluster_names_that_cluster() { + assert_eq!( + ec2_cluster_of_task("dev", &ec2_task_arn("t")).as_deref(), + Some(format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/triple-c-dev--u-alice").as_str()) + ); + // The environment's own cluster, another environment's per-user + // cluster and anything else are not. + assert_eq!(ec2_cluster_of_task("dev", &task_arn("t")), None); + assert_eq!(ec2_cluster_of_task("prod", &ec2_task_arn("t")), None); + let odd = format!("arn:aws:ecs:{REGION}:{ACCOUNT}:task/triple-c-dev--u-a--b/t"); + assert_eq!(ec2_cluster_of_task("dev", &odd), None); + assert_eq!(ec2_cluster_of_task("dev", "not-an-arn"), None); +} + +#[tokio::test] +async fn the_user_record_is_read_and_validated() { + struct Rec(Param); + impl Rec { + async fn read(&self) -> UserRecord { + let fake = RecFake(self.0.clone(), Mutex::new(Vec::new())); + let r = read_user_record(&fake, "dev", &ok(), ACCOUNT, REGION).await.unwrap(); + assert_eq!(*fake.1.lock().unwrap(), vec![format!("dev {}", ok())]); + r + } + } + let valid = serde_json::json!({ + "schema": 1, "instance_type": "m7i.large", "max_instances": 2, "user_tag": "alice", + "cluster_arn": format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/triple-c-dev--u-alice"), + "capacity_provider": "triple-c-dev--u-alice", + }) + .to_string(); + let UserRecord::Valid(c) = Rec(Param::Value(valid)).read().await else { panic!() }; + assert_eq!((c.instance_type.as_str(), c.max_instances), ("m7i.large", 2)); + assert_eq!(Rec(Param::Missing).read().await, UserRecord::Absent); + assert!(matches!(Rec(Param::Denied).read().await, UserRecord::Unusable(_))); + assert!(matches!(Rec(Param::Value("{}".into())).read().await, UserRecord::Unusable(_))); +} + +/// Only `user_record` is asked of it. +struct RecFake(Param, Mutex>); + +impl RuntimeApi for RecFake { + async fn environment_record(&self, _env: &str) -> Result, AwsError> { + unreachable!() + } + async fn user_record(&self, env: &str, owner_key: &str) -> Result { + self.1.lock().unwrap().push(format!("{env} {owner_key}")); + Ok(self.0.clone()) + } + async fn role_exists(&self, _name: &str) -> Result { + unreachable!() + } + async fn secret_string(&self, _name: &str) -> Result { + unreachable!() + } + async fn access_point_state(&self, _id: &str) -> Result, AwsError> { + unreachable!() + } + async fn delete_secret(&self, _name: &str) -> Result<(), AwsError> { + unreachable!() + } + async fn delete_access_point(&self, _id: &str) -> Result<(), AwsError> { + unreachable!() + } +} + +#[tokio::test] +async fn removal_finds_and_stops_a_task_on_the_users_ec2_cluster() { + let key = ok(); + let user_cluster = format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/triple-c-dev--u-alice"); + let base = RemoveRequest { + env: "dev", + region: REGION, + owner_user_id: USER, + owner_key: &key, + project_id: PROJECT, + stored_task_arn: None, + stored_access_point_id: None, + stored_workspace_access_point_id: None, + ec2_cluster: Some(&user_cluster), + discard_data: false, + }; + // Found through the record's cluster. + let mut t = live("e1"); + t.arn = ec2_task_arn("e1"); + let fake = Fake { live_tasks: vec![t.clone()], ..Default::default() }; + remove_workspace_resources(&fake, &fake, &fake, &base).await.unwrap(); + assert_eq!(*fake.lists.lock().unwrap(), ["triple-c-dev", "triple-c-dev--u-alice"]); + let calls = fake.calls(); + assert!( + calls.contains(&format!("stop {user_cluster} {} {STOP_REASON}", ec2_task_arn("e1"))), + "{calls:?}" + ); + + // The record is gone: the stored ARN still leads to its cluster. + let stored = ec2_task_arn("e1"); + let fake = Fake { live_tasks: vec![t], ..Default::default() }; + let r = RemoveRequest { ec2_cluster: None, stored_task_arn: Some(&stored), ..base }; + remove_workspace_resources(&fake, &fake, &fake, &r).await.unwrap(); + let stops: Vec = fake.calls().into_iter().filter(|c| c.starts_with("stop")).collect(); + assert_eq!(stops.len(), 1, "{stops:?}"); + assert!(stops[0].contains(&ec2_task_arn("e1")), "{stops:?}"); + + // A stored ARN on someone else's kind of cluster is not stopped. + let foreign = format!("arn:aws:ecs:{REGION}:{ACCOUNT}:task/other-cluster/x"); + let fake = Fake::default(); + let r = RemoveRequest { ec2_cluster: None, stored_task_arn: Some(&foreign), ..base }; + remove_workspace_resources(&fake, &fake, &fake, &r).await.unwrap(); + assert!(!fake.calls().iter().any(|c| c.starts_with("stop"))); +} diff --git a/app/src-tauri/src/aws/tasks.rs b/app/src-tauri/src/aws/tasks.rs index 1f69219..b65db02 100644 --- a/app/src-tauri/src/aws/tasks.rs +++ b/app/src-tauri/src/aws/tasks.rs @@ -25,7 +25,7 @@ use aws_sdk_ecs::types::{ ManagedAgentName, NetworkConfiguration, Tag, Task, TaskField, }; -use super::environments::EnvironmentInfo; +use super::environments::{EnvironmentInfo, UserCompute}; use super::error::{classify_sdk_error, AwsError}; pub use super::tofu_modules::task_log_stream; use super::workspace::{workspace_tags, CONTAINER_NAME, TAG_OWNER, TAG_PROJECT}; @@ -62,6 +62,9 @@ pub struct TaskInfo { pub task_definition_arn: String, /// The `workspace` container's runtime id (needed for an SSM target). pub runtime_id: Option, + /// The EC2 container instance the task was placed on; `None` on Fargate, + /// and on EC2 until an instance has room for it. + pub container_instance_arn: Option, /// The `workspace` container's ExecuteCommandAgent is RUNNING. pub exec_agent_running: bool, /// The `workspace` container's exit code, once it has one. @@ -112,6 +115,7 @@ pub(crate) fn task_info(t: &Task) -> TaskInfo { stopped_reason: t.stopped_reason().map(str::to_string), task_definition_arn: t.task_definition_arn().unwrap_or_default().to_string(), runtime_id: workspace.and_then(|c| c.runtime_id()).map(str::to_string), + container_instance_arn: t.container_instance_arn().map(str::to_string), exec_agent_running: workspace.is_some_and(|c| { c.managed_agents().iter().any(|a| { a.name() == Some(&ManagedAgentName::ExecuteCommandAgent) @@ -216,6 +220,65 @@ pub fn run_task_request( req.build().expect(BUILT) } +/// Where a new task runs. +#[derive(Debug, Clone, Copy)] +pub enum RunOn<'a> { + /// The environment's cluster, Fargate (or `FARGATE_SPOT`). + Fargate { spot: bool }, + /// The user's own cluster and capacity provider (phase 7), from their + /// record. + Ec2(&'a UserCompute), +} + +impl RunOn<'_> { + /// The cluster a task runs on, and is looked for in. + pub fn cluster<'e>(&'e self, env: &'e EnvironmentInfo) -> &'e str { + match self { + RunOn::Fargate { .. } => &env.cluster_arn, + RunOn::Ec2(c) => &c.cluster_arn, + } + } +} + +/// The RunTask request on the user's EC2 capacity: the exact revision, on +/// their cluster, placed by their capacity provider (weight 1). No launch +/// type (exclusive with a strategy) and no network configuration: EC2 tasks +/// use `bridge` networking (ruling R2). ECS Exec, tags, the client token and +/// no overrides as on Fargate (P1). +pub fn ec2_run_task_request( + compute: &UserCompute, + task_def_arn: &str, + tags: &[(String, String)], +) -> RunTaskInput { + const BUILT: &str = "every required field is set"; + RunTaskInput::builder() + .cluster(&compute.cluster_arn) + .task_definition(task_def_arn) + .count(1) + .enable_execute_command(true) + .capacity_provider_strategy( + CapacityProviderStrategyItem::builder() + .capacity_provider(&compute.capacity_provider) + .weight(1) + .build() + .expect(BUILT), + ) + .set_tags(Some( + tags.iter() + .map(|(k, v)| Tag::builder().key(k).value(v).build()) + .collect(), + )) + .client_token(uuid::Uuid::new_v4().to_string()) + .build() + .expect(BUILT) +} + +/// RunTask refused on a per-user cluster: the workspace policy lets a caller +/// run tasks only on the cluster named after their own `triple-c-user` +/// principal tag. +pub const EC2_TAG_MISMATCH: &str = "This EC2 capacity belongs to a different triple-c-user value \ + than your sign-in's (or your sign-in has no triple-c-user tag). Ask an admin."; + /// The family of `arn:...:task-definition/:`, when the /// revision is a number. `None` for a bare family or anything else. pub fn revision_family(arn: &str) -> Option<&str> { @@ -271,14 +334,15 @@ pub struct TaskStart { } /// The project's live task if there is one (Review Focus 2: never a second -/// task for a project), else RunTask with the exact `task_def_arn`. +/// task for a project), else RunTask with the exact `task_def_arn` where +/// `run_on` says. pub async fn find_or_run( api: &A, env: &EnvironmentInfo, owner_user_id: &str, project_id: &str, task_def_arn: &str, - spot: bool, + run_on: RunOn<'_>, ) -> Result { let family = revision_family(task_def_arn).ok_or_else(|| { other(format!( @@ -291,20 +355,43 @@ pub async fn find_or_run( ))); } if let Some(task) = - find_project_task(api, &env.cluster_arn, family, owner_user_id, project_id).await? + find_project_task(api, run_on.cluster(env), family, owner_user_id, project_id).await? { return Ok(TaskStart { task, reused: true }); } let tags = workspace_tags(owner_user_id, project_id, &env.name); - let task = api - .run_task(run_task_request(env, task_def_arn, spot, &tags)) - .await?; + let task = match run_on { + RunOn::Fargate { spot } => { + api.run_task(run_task_request(env, task_def_arn, spot, &tags)).await? + } + RunOn::Ec2(compute) => api + .run_task(ec2_run_task_request(compute, task_def_arn, &tags)) + .await + .map_err(ec2_run_error)?, + }; Ok(TaskStart { task, reused: false, }) } +/// A RunTask error on the user's EC2 capacity, in its terms: access denied is +/// the `triple-c-user` mismatch ([`EC2_TAG_MISMATCH`]); a placement failure +/// (`RESOURCE:CPU`/`RESOURCE:MEMORY`) means no instance can take the task. +pub fn ec2_run_error(e: AwsError) -> AwsError { + match e { + AwsError::AccessDenied { action, message } => AwsError::AccessDenied { + action, + message: format!("{EC2_TAG_MISMATCH} (AWS said: {message})"), + }, + AwsError::Other { message } if message.contains("RESOURCE:") => other(format!( + "{message}. No instance of your EC2 capacity has room for this task: lower its CPU \ + or memory reservation, or stop another EC2 workspace." + )), + e => e, + } +} + // ------------------------------------------------------------------ quotas /// Whether an AWS message says an account limit or quota was hit. @@ -386,6 +473,30 @@ impl Default for WaitTiming { } } +impl WaitTiming { + /// An EC2 task's wait: a cold start (capacity scaled to zero) launches + /// an instance and pulls the image before the task can run. + pub fn ec2() -> Self { + WaitTiming { + timeout: Duration::from_secs(10 * 60), + ..Self::default() + } + } +} + +/// An EC2 task still waiting for an instance with room: ECS keeps it +/// PROVISIONING (or PENDING) with no container instance while the capacity +/// provider's managed scaling launches one. (A Fargate task never has a +/// container instance, so ask this only of EC2 tasks.) +pub fn waiting_for_instance(t: &TaskInfo) -> bool { + t.container_instance_arn.is_none() + && t.desired_status == "RUNNING" + && matches!(t.last_status.as_str(), "PROVISIONING" | "PENDING") +} + +/// How a [`wait_ready`] timeout begins. +pub const WAIT_TIMED_OUT: &str = "The task did not become ready within"; + /// Where a project's task logs go: the environment's log group and the /// project's `awslogs-stream-prefix` (Task 4's `log_stream_prefix`). #[derive(Debug, Clone, PartialEq, Eq)] @@ -440,7 +551,7 @@ pub async fn wait_ready( } if tokio::time::Instant::now() + timing.interval > deadline { return Err(other(format!( - "The task did not become ready within {} (last status {}{}). It may still \ + "{WAIT_TIMED_OUT} {} (last status {}{}). It may still \ be starting; check the ECS console, or stop the project and start it again.", describe_timeout(timing.timeout), t.last_status, diff --git a/app/src-tauri/src/aws/tasks/tests.rs b/app/src-tauri/src/aws/tasks/tests.rs index 31284f3..23c321b 100644 --- a/app/src-tauri/src/aws/tasks/tests.rs +++ b/app/src-tauri/src/aws/tasks/tests.rs @@ -64,6 +64,7 @@ fn info(id: &str, last: &str) -> TaskInfo { stopped_reason: None, task_definition_arn: td_arn(3), runtime_id: None, + container_instance_arn: None, exec_agent_running: false, exit_code: None, owner: Some(USER.into()), @@ -230,7 +231,7 @@ async fn an_existing_running_task_is_reused_and_nothing_is_run() { ..Default::default() } .describing(vec![vec![ready("t1")]]); - let got = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(4), false) + let got = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(4), RunOn::Fargate { spot: false }) .await .unwrap(); assert!(got.reused); @@ -246,7 +247,7 @@ async fn a_pending_task_is_reused_too() { ..Default::default() } .describing(vec![vec![info("t1", "PENDING")]]); - let got = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(3), false) + let got = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(3), RunOn::Fargate { spot: false }) .await .unwrap(); assert!(got.reused); @@ -272,7 +273,7 @@ async fn a_task_of_another_owner_or_project_in_the_family_is_never_reused() { ..Default::default() } .describing(vec![vec![foreign, other_project, untagged]]); - let got = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(3), false) + let got = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(3), RunOn::Fargate { spot: false }) .await .unwrap(); assert!(!got.reused); @@ -289,7 +290,7 @@ async fn a_task_already_stopping_is_not_reused() { ..Default::default() } .describing(vec![vec![stopping, info("t2", "DEPROVISIONING")]]); - let got = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(3), false) + let got = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(3), RunOn::Fargate { spot: false }) .await .unwrap(); assert!(!got.reused); @@ -312,7 +313,7 @@ async fn a_running_task_is_preferred_over_a_pending_one() { #[tokio::test] async fn nothing_listed_means_no_describe_and_a_run_with_the_exact_revision_and_tags() { let api = Fake::default(); - let got = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(7), true) + let got = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(7), RunOn::Fargate { spot: true }) .await .unwrap(); assert!(!got.reused); @@ -345,7 +346,7 @@ async fn a_bare_family_or_foreign_arn_is_refused_before_any_call() { format!("arn:aws:ecs:{REGION}:{ACCOUNT}:task-definition/{FAMILY}:latest"), "arn:aws:ecs:eu-west-1:1:task-definition/someone-else:1".to_string(), ] { - let err = find_or_run(&api, &env_info(), USER, PROJECT_ID, &bad, false) + let err = find_or_run(&api, &env_info(), USER, PROJECT_ID, &bad, RunOn::Fargate { spot: false }) .await .unwrap_err(); assert!(matches!(err, AwsError::Other { .. }), "{bad}: {err:?}"); @@ -358,7 +359,7 @@ async fn a_quota_refusal_is_reported_once_without_retrying() { let api = Fake::default().running(Err(quota_error( "You've reached the limit on the number of vCPUs you can run concurrently", ))); - let err = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(3), false) + let err = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(3), RunOn::Fargate { spot: false }) .await .unwrap_err(); assert!(is_quota_error(&err)); @@ -748,3 +749,133 @@ fn task_info_reads_the_workspace_container_and_its_exec_agent() { assert_eq!(bare.exit_code, None); assert_eq!(bare.owner, None); } + +// ------------------------------------------------------------- EC2 (phase 7) + +fn user_cluster() -> String { + format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/triple-c-dev--u-alice") +} + +fn compute() -> UserCompute { + UserCompute { + instance_type: "m7i.large".into(), + max_instances: 2, + user_tag: "alice".into(), + cluster_arn: user_cluster(), + capacity_provider: "triple-c-dev--u-alice".into(), + } +} + +#[test] +fn an_ec2_run_uses_the_users_cluster_and_capacity_provider_and_no_network() { + let c = compute(); + let req = ec2_run_task_request(&c, &td_arn(3), &tags()); + assert_eq!(req.cluster(), Some(user_cluster().as_str())); + assert_eq!(req.task_definition(), Some(td_arn(3).as_str())); + assert_eq!(req.launch_type(), None, "exclusive with a capacity provider strategy"); + let strategy = req.capacity_provider_strategy(); + assert_eq!(strategy.len(), 1); + assert_eq!(strategy[0].capacity_provider(), "triple-c-dev--u-alice"); + assert_eq!(strategy[0].weight(), 1); + assert!(req.network_configuration().is_none(), "bridge networking (R2)"); + assert_eq!(req.enable_execute_command(), Some(true)); + assert_eq!(req.count(), Some(1)); + assert!(req.client_token().is_some_and(|t| !t.is_empty())); + let got: Vec<(String, String)> = req + .tags() + .iter() + .map(|t| (t.key().unwrap().to_string(), t.value().unwrap().to_string())) + .collect(); + assert_eq!(got, tags()); + assert!(req.overrides().is_none()); + assert!(req.propagate_tags().is_none()); + assert!(req.enable_ecs_managed_tags().is_none()); +} + +#[tokio::test] +async fn an_ec2_find_or_run_looks_and_runs_on_the_users_cluster() { + let api = Fake::default(); + let c = compute(); + let got = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(3), RunOn::Ec2(&c)) + .await + .unwrap(); + assert!(!got.reused); + assert_eq!(api.calls(), vec![format!("list {} {FAMILY}", user_cluster()), "run".to_string()]); + let req = &api.run_requests.lock().unwrap()[0]; + assert_eq!(req.cluster(), Some(user_cluster().as_str())); + assert_eq!(req.capacity_provider_strategy()[0].capacity_provider(), "triple-c-dev--u-alice"); + assert_eq!(RunOn::Ec2(&c).cluster(&env_info()), user_cluster()); + assert_eq!(RunOn::Fargate { spot: true }.cluster(&env_info()), cluster()); +} + +#[tokio::test] +async fn access_denied_on_the_users_cluster_says_the_triple_c_user_value_is_wrong() { + let api = Fake::default().running(Err(AwsError::AccessDenied { + action: "ecs:RunTask".into(), + message: "not authorized to perform ecs:RunTask on cluster/triple-c-dev--u-alice".into(), + })); + let c = compute(); + let e = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(3), RunOn::Ec2(&c)) + .await + .unwrap_err(); + let AwsError::AccessDenied { action, message } = &e else { panic!("{e:?}") }; + assert_eq!(action, "ecs:RunTask"); + assert!(message.starts_with(EC2_TAG_MISMATCH), "{message}"); + assert!(message.contains("not authorized"), "AWS's words are kept: {message}"); + assert!(EC2_TAG_MISMATCH.contains("different triple-c-user value")); + assert!(EC2_TAG_MISMATCH.contains("Ask an admin")); + + // The same refusal on Fargate is left as it is. + let api = Fake::default().running(Err(AwsError::AccessDenied { + action: "ecs:RunTask".into(), + message: "nope".into(), + })); + let e = find_or_run(&api, &env_info(), USER, PROJECT_ID, &td_arn(3), RunOn::Fargate { spot: false }) + .await + .unwrap_err(); + assert_eq!(e, AwsError::AccessDenied { action: "ecs:RunTask".into(), message: "nope".into() }); +} + +#[test] +fn a_placement_failure_on_ec2_says_no_instance_has_room() { + let e = ec2_run_error( + run_task_outcome(Vec::new(), vec![(Some("RESOURCE:MEMORY".into()), None)]).unwrap_err(), + ); + assert!(e.to_string().contains("RESOURCE:MEMORY"), "{e}"); + assert!(e.to_string().contains("No instance of your EC2 capacity has room"), "{e}"); + // Anything else passes through. + let q = quota_error("limit"); + assert_eq!(ec2_run_error(q.clone()), q); +} + +#[test] +fn an_ec2_task_without_an_instance_is_waiting_for_one() { + let provisioning = info("t", "PROVISIONING"); + assert!(waiting_for_instance(&provisioning)); + assert!(waiting_for_instance(&info("t", "PENDING"))); + let placed = TaskInfo { + container_instance_arn: Some(format!( + "arn:aws:ecs:{REGION}:{ACCOUNT}:container-instance/triple-c-dev--u-alice/abc" + )), + ..info("t", "PENDING") + }; + assert!(!waiting_for_instance(&placed)); + assert!(!waiting_for_instance(&info("t", "RUNNING"))); + assert!(!waiting_for_instance(&info("t", "STOPPED"))); + // The EC2 wait leaves room for an instance launch and an image pull. + assert_eq!(WaitTiming::ec2().timeout, Duration::from_secs(600)); + assert_eq!(WaitTiming::ec2().interval, WaitTiming::default().interval); +} + +#[test] +fn task_info_reads_the_container_instance() { + let t = Task::builder() + .task_arn(task_arn("t")) + .container_instance_arn("arn:aws:ecs:eu-west-1:111122223333:container-instance/c/1") + .build(); + assert_eq!( + task_info(&t).container_instance_arn.as_deref(), + Some("arn:aws:ecs:eu-west-1:111122223333:container-instance/c/1") + ); + assert_eq!(task_info(&Task::builder().build()).container_instance_arn, None); +} diff --git a/app/src-tauri/src/aws/tofu_modules.rs b/app/src-tauri/src/aws/tofu_modules.rs index 21fdfac..e2d92f4 100644 --- a/app/src-tauri/src/aws/tofu_modules.rs +++ b/app/src-tauri/src/aws/tofu_modules.rs @@ -173,11 +173,18 @@ pub fn validate_ec2_user_tag(tag: &str) -> Result { /// characters). Environment names and user tags never contain `--`, so the /// workspace policy's `cluster/triple-c-*--u-*` matches exactly the /// per-user clusters, and `triple-c-*--u-` exactly that user's. -#[allow(dead_code)] // the onboarding module builds it; the app's EC2 runs (Task 5) will pub fn user_ec2_stem(env: &str, user_tag: &str) -> String { format!("triple-c-{env}--u-{user_tag}") } +/// Whether `cluster` (a cluster *name*) is one of `env`'s per-user EC2 +/// clusters ([`user_ec2_stem`] of a valid tag). +pub fn is_user_ec2_cluster(env: &str, cluster: &str) -> bool { + cluster + .strip_prefix(&format!("{}--u-", environment_cluster_name(env))) + .is_some_and(|tag| validate_ec2_user_tag(tag).is_ok()) +} + /// A user's EC2 instance role (and instance profile): named by owner key, /// not the user tag, because role names are account-global and at most 64 /// characters (this is at most 51). The admin's PassRole to EC2 names diff --git a/app/src-tauri/src/aws/workspace.rs b/app/src-tauri/src/aws/workspace.rs index f41fa67..d7d5638 100644 --- a/app/src-tauri/src/aws/workspace.rs +++ b/app/src-tauri/src/aws/workspace.rs @@ -27,10 +27,11 @@ use std::future::Future; use aws_config::SdkConfig; use aws_sdk_ecs::operation::register_task_definition::RegisterTaskDefinitionInput; use aws_sdk_ecs::types::{ - Compatibility, ContainerDefinition, CpuArchitecture, EfsAuthorizationConfig, - EfsAuthorizationConfigIam, EfsTransitEncryption, EfsVolumeConfiguration, EphemeralStorage, - HealthCheck, KernelCapabilities, KeyValuePair, LinuxParameters, LogConfiguration, LogDriver, - MountPoint, NetworkMode, OsFamily, RuntimePlatform, Secret, SortOrder, Tag, + Compatibility, ContainerDefinition, CpuArchitecture, Device, DeviceCgroupPermission, + EfsAuthorizationConfig, EfsAuthorizationConfigIam, EfsTransitEncryption, + EfsVolumeConfiguration, EphemeralStorage, HealthCheck, HostVolumeProperties, + KernelCapabilities, KeyValuePair, LinuxParameters, LogConfiguration, LogDriver, MountPoint, + NetworkMode, OsFamily, RuntimePlatform, Secret, SortOrder, SystemControl, Tag, TaskDefinitionField, TaskDefinitionStatus, Volume, }; use aws_sdk_secretsmanager::error::ProvideErrorMetadata; @@ -39,7 +40,7 @@ use rand::RngCore; use serde::Serialize; use sha2::{Digest, Sha256}; -use super::environments::EnvironmentInfo; +use super::environments::{EnvironmentInfo, UserCompute}; use super::error::{classify_sdk_error, AwsError}; use super::identity::CallerIdentity; use super::tofu_modules::{ @@ -47,7 +48,10 @@ use super::tofu_modules::{ user_file_system_token, user_role_names, workspace_access_point_root, }; use crate::host::ssm::AGENT_PORT; -use crate::models::project::{validate_aws_workspace, Arch, RepoSource, SecretsDelivery, StorageMode}; +use crate::models::project::{ + fits_instance, validate_aws_workspace, Arch, Fit, LaunchType, RepoSource, + SecretsDelivery, StorageMode, +}; use crate::models::Project; pub const TAG_OWNER: &str = "triple-c:owner"; @@ -103,6 +107,11 @@ pub const MAX_GATEWAY_CONFIG_BYTES: usize = 8_192; /// Seconds ECS waits after SIGTERM before SIGKILL (Fargate allows 2–120). pub const STOP_TIMEOUT_SECS: i32 = 120; +/// The instance's Docker socket, mounted at the same path in an EC2 task +/// with Docker access (E6). +pub const DOCKER_SOCKET_PATH: &str = "/var/run/docker.sock"; +const DOCKER_SOCKET_VOLUME: &str = "docker-socket"; + /// The task definition's whole `environment` (R2): constants, no project data. const FIXED_ENVIRONMENT: [(&str, &str); 2] = [("TRIPLEC_HOST", "aws"), ("COLORTERM", "truecolor")]; @@ -205,6 +214,12 @@ pub fn gateway_sidecar_problem( if !project.aws.as_ref().is_some_and(|a| a.gateway_sidecar) { return None; } + if project.aws.as_ref().is_some_and(|a| a.launch_type == LaunchType::Ec2) { + // EC2 tasks use `bridge` networking (ruling R2): the containers of a + // task don't share a loopback, and the sidecar must never listen + // beyond it. Not offered on EC2 yet. + return Some(EC2_NO_SIDECAR.into()); + } if project.backend != crate::models::project::Backend::OpenAiCompatible { return Some( "The LLM gateway sidecar needs the OpenAI Compatible backend: choose it in the \ @@ -222,6 +237,10 @@ pub fn gateway_sidecar_problem( None } +/// Why an EC2 project can't run the gateway sidecar (yet). +pub const EC2_NO_SIDECAR: &str = "The LLM gateway sidecar is not available on EC2 yet: turn it \ + off, or run the project on Fargate"; + /// `workspace_env`'s fingerprint of the custom variables' values. const CUSTOM_ENV_FINGERPRINT: &str = "TRIPLE_C_CUSTOM_ENV"; @@ -473,6 +492,21 @@ pub struct WorkspacePlan { /// The gateway sidecar's image (Q7) when the project runs it; `None` /// leaves the request exactly as it was before the sidecar existed. pub gateway_image: Option, + /// Run on the user's own EC2 instances (phase 7) rather than Fargate; + /// `None` leaves the request exactly as it was before EC2 existed. + pub ec2: Option, +} + +/// What an EC2 task definition adds (E6, E7). `cpu`/`memory` are the task's +/// reservations on the instance; arch and ephemeral storage don't apply (the +/// instance decides both). +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] +pub struct Ec2Plan { + /// Mount the instance's Docker socket (`allow_docker_access`, E6). + pub docker_socket: bool, + /// What a VPN client needs (`vpn_support_enabled`, E7): `NET_ADMIN`, + /// `/dev/net/tun`, `net.ipv4.conf.all.src_valid_mark=1`. + pub vpn: bool, } /// sha256 (hex) over the task definition `plan` produces, minus the label @@ -583,12 +617,7 @@ fn build_request(plan: &WorkspacePlan) -> RegisterTaskDefinitionInput { .build() .expect(BUILT), ) - .linux_parameters( - LinuxParameters::builder() - .init_process_enabled(true) - .capabilities(KernelCapabilities::builder().add("SYS_PTRACE").build()) - .build(), - ) + .linux_parameters(linux_parameters(plan.ec2)) .log_configuration( LogConfiguration::builder() .log_driver(LogDriver::Awslogs) @@ -616,29 +645,64 @@ fn build_request(plan: &WorkspacePlan) -> RegisterTaskDefinitionInput { .build(), ); } + let docker_socket = plan.ec2.is_some_and(|e| e.docker_socket); + if docker_socket { + container = container.mount_points( + MountPoint::builder() + .source_volume(DOCKER_SOCKET_VOLUME) + .container_path(DOCKER_SOCKET_PATH) + .read_only(false) + .build(), + ); + } + if plan.ec2.is_some_and(|e| e.vpn) { + // Namespaced `net.*` sysctls are allowed in `bridge` mode: each + // container has its own network namespace, so this sets the + // workspace's, never the instance's (ECS warns only for `host`, and + // for several containers of one `awsvpc` task). + for (key, value) in crate::docker::container::vpn_requirements().sysctls { + container = container + .system_controls(SystemControl::builder().namespace(key).value(value).build()); + } + } let mut req = RegisterTaskDefinitionInput::builder() .family(&plan.family) .task_role_arn(&plan.task_role_arn) - .execution_role_arn(&plan.exec_role_arn) - .network_mode(NetworkMode::Awsvpc) - .requires_compatibilities(Compatibility::Fargate) - .cpu(plan.cpu.to_string()) - .memory(plan.memory.to_string()) - .runtime_platform( - RuntimePlatform::builder() - .cpu_architecture(match plan.arch { - Arch::X86_64 => CpuArchitecture::X8664, - Arch::Arm64 => CpuArchitecture::Arm64, - }) - .operating_system_family(OsFamily::Linux) - .build(), - ) - .ephemeral_storage( - EphemeralStorage::builder() - .size_in_gib(plan.ephemeral_gib as i32) - .build(), - ) + .execution_role_arn(&plan.exec_role_arn); + req = match plan.ec2 { + // Fargate: exactly the request from before EC2 existed (pinned). + None => req + .network_mode(NetworkMode::Awsvpc) + .requires_compatibilities(Compatibility::Fargate) + .cpu(plan.cpu.to_string()) + .memory(plan.memory.to_string()) + .runtime_platform( + RuntimePlatform::builder() + .cpu_architecture(match plan.arch { + Arch::X86_64 => CpuArchitecture::X8664, + Arch::Arm64 => CpuArchitecture::Arm64, + }) + .operating_system_family(OsFamily::Linux) + .build(), + ) + .ephemeral_storage( + EphemeralStorage::builder() + .size_in_gib(plan.ephemeral_gib as i32) + .build(), + ), + // EC2 (ruling R2: `bridge`, the instance is the user's alone). No + // runtime platform — the instance's architecture decides and the + // image is multi-arch — and no ephemeral storage (the instance's + // disk). Task-level cpu/memory are the reservations `fits_instance` + // checked against the user's instance type. + Some(_) => req + .network_mode(NetworkMode::Bridge) + .requires_compatibilities(Compatibility::Ec2) + .cpu(plan.cpu.to_string()) + .memory(plan.memory.to_string()), + }; + let mut req = req .container_definitions(container.build()) .set_tags(Some( plan.tags @@ -655,9 +719,45 @@ fn build_request(plan: &WorkspacePlan) -> RegisterTaskDefinitionInput { { req = req.volumes(efs_volume(name, fs, ap)); } + if docker_socket { + req = req.volumes( + Volume::builder() + .name(DOCKER_SOCKET_VOLUME) + .host(HostVolumeProperties::builder().source_path(DOCKER_SOCKET_PATH).build()) + .build(), + ); + } req.build().expect(BUILT) } +/// The workspace container's Linux parameters: docker-init and `SYS_PTRACE` +/// always; on EC2 with VPN support, [`vpn_requirements`]' capability and +/// device too (Fargate allows neither). +/// +/// [`vpn_requirements`]: crate::docker::container::vpn_requirements +fn linux_parameters(ec2: Option) -> LinuxParameters { + let mut caps = KernelCapabilities::builder().add("SYS_PTRACE"); + let mut lp = LinuxParameters::builder().init_process_enabled(true); + if ec2.is_some_and(|e| e.vpn) { + let vpn = crate::docker::container::vpn_requirements(); + for cap in vpn.capabilities { + caps = caps.add(cap); + } + for (host, container, perms) in vpn.devices { + let mut device = Device::builder().host_path(host).container_path(container); + for p in perms.chars() { + device = device.permissions(match p { + 'r' => DeviceCgroupPermission::Read, + 'w' => DeviceCgroupPermission::Write, + _ => DeviceCgroupPermission::Mknod, + }); + } + lp = lp.devices(device.build().expect("every required field is set")); + } + } + lp.capabilities(caps.build()).build() +} + /// `secrets` entries for `keys`, each by `valueFrom: :::`. fn secrets<'k>(plan: &WorkspacePlan, keys: impl Iterator) -> Vec { keys.map(|k| { @@ -902,9 +1002,58 @@ pub struct PreparedWorkspace { pub secret_arn: String, } +/// Why an EC2 project can't start on `compute` (the user's record, `None` +/// when they have none), or what its task definition adds. A Fargate project +/// gets `Ok(None)` whatever `compute` is. +pub fn ec2_plan( + project: &Project, + env: &str, + compute: Option<&UserCompute>, +) -> Result, String> { + let Some(cfg) = project.aws.as_ref().filter(|c| c.launch_type == LaunchType::Ec2) else { + return Ok(None); + }; + if cfg.gateway_sidecar { + return Err(EC2_NO_SIDECAR.into()); + } + let compute = compute.ok_or_else(|| no_ec2_capacity(env))?; + match fits_instance(cfg, &compute.instance_type) { + Fit::Ok => {} + Fit::TooBig { available_cpu, available_memory_mib } => { + return Err(format!( + "This project reserves {} CPU units and {} MiB of memory, more than your EC2 \ + instance type {} has for a workspace ({available_cpu} CPU units, \ + {available_memory_mib} MiB). Lower the reservations in the project's Host \ + settings, or ask an admin for a larger instance type.", + cfg.cpu, cfg.memory_mib, compute.instance_type + )) + } + // The record is validated against the same table, so this is a + // newer app's type: let ECS decide. + Fit::UnknownType => log::warn!( + "Project {}: instance type {} is not in the app's table; its fit is unchecked", + project.id, + compute.instance_type + ), + } + Ok(Some(Ec2Plan { + docker_socket: project.allow_docker_access, + vpn: project.vpn_support_enabled, + })) +} + +/// The user has no EC2 record in `env` (none was added, or it was removed). +pub fn no_ec2_capacity(env: &str) -> String { + format!( + "You have no EC2 capacity in {env}; ask an admin to add it to your onboarding (or run \ + the project on Fargate)." + ) +} + /// Make the project's secret, access points (Hybrid, EFS) and task definition /// ready. Everything that can be checked locally — placement, sizes, the -/// payload's size and names — is checked before the first write. +/// payload's size and names, an EC2 project's fit on `compute` — is checked +/// before the first write. #[allow(clippy::too_many_arguments)] pub async fn prepare_workspace( api: &W, @@ -916,6 +1065,7 @@ pub async fn prepare_workspace( custom_env_keys: &[String], image: &str, gateway: Option>, + compute: Option<&UserCompute>, ) -> Result { let (Some(placement), Some(cfg)) = (project.aws_placement.as_ref(), project.aws.as_ref()) else { @@ -940,6 +1090,7 @@ pub async fn prepare_workspace( ))); } validate_aws_workspace(cfg).map_err(other)?; + let ec2 = ec2_plan(project, &env.name, compute).map_err(other)?; if image.trim().is_empty() { return Err(other("No container image is set for AWS")); } @@ -1100,6 +1251,7 @@ pub async fn prepare_workspace( workspace_access_point_id: workspace_access_point_id.clone(), tags, gateway_image: gateway.map(|_| crate::docker::gateway::registry_image_ref()), + ec2, }; let fingerprint = workspace_fingerprint(&plan); let task_definition_arn = diff --git a/app/src-tauri/src/aws/workspace/tests.rs b/app/src-tauri/src/aws/workspace/tests.rs index 46cd135..6d5e98c 100644 --- a/app/src-tauri/src/aws/workspace/tests.rs +++ b/app/src-tauri/src/aws/workspace/tests.rs @@ -102,6 +102,7 @@ fn sample_plan(storage: StorageMode) -> WorkspacePlan { .then(|| "fsap-4567efab".to_string()), tags: workspace_tags(USER, PROJECT_ID, "dev"), gateway_image: None, + ec2: None, } } @@ -962,7 +963,7 @@ async fn prepare( p: &Project, env: &[(String, String)], ) -> Result { - prepare_workspace(fake, &who(), &env_info(), p, env, &[], &[], IMAGE, None).await + prepare_workspace(fake, &who(), &env_info(), p, env, &[], &[], IMAGE, None, None).await } #[tokio::test] @@ -972,7 +973,7 @@ async fn prepare_puts_the_setup_script_and_the_environments_cap_in_the_secret() p.aws.as_mut().unwrap().setup_script = Some("sudo apt-get install -y jq".into()); let mut env = env_info(); env.max_workspace_hours = 12; - prepare_workspace(&fake, &who(), &env, &p, &[], &[], &[], IMAGE, None).await.unwrap(); + prepare_workspace(&fake, &who(), &env, &p, &[], &[], &[], IMAGE, None, None).await.unwrap(); let m = payload_map(&fake.secrets.lock().unwrap()[0].2); assert_eq!(m["TRIPLEC_SETUP_SCRIPT"], "sudo apt-get install -y jq"); assert_eq!(m["TRIPLEC_MAX_LIFETIME_MINUTES"], "720"); @@ -1397,6 +1398,7 @@ async fn files_travel_in_the_secret_only() { &[], IMAGE, None, + None, ) .await .unwrap(); @@ -1638,7 +1640,7 @@ async fn prepare_leaves_the_credentials_out_of_a_copy_at_connect_secret() { p.aws.as_mut().unwrap().secrets_delivery = crate::models::project::SecretsDelivery::CopyAtConnect; let files = vec![("ssh/id_ed25519".to_string(), b"PRIVATE KEY".to_vec())]; let env = pairs(&[("GIT_TOKEN", "ghp_secret"), ("MINE", "x"), ("TZ", "UTC")]); - prepare_workspace(&fake, &who(), &env_info(), &p, &env, &files, &["MINE".to_string()], IMAGE, None) + prepare_workspace(&fake, &who(), &env_info(), &p, &env, &files, &["MINE".to_string()], IMAGE, None, None) .await .unwrap(); let m = payload_map(&fake.secrets.lock().unwrap()[0].2); @@ -1662,7 +1664,7 @@ async fn switching_to_copy_at_connect_replaces_a_secret_that_held_credentials() Some(r#"{"GIT_TOKEN":"ghp_old","TRIPLEC_AGENT_TOKEN":"t","TZ":"UTC"}"#.into()); *fake.pending_puts.lock().unwrap() = 2; // AWS still finishing the delete let env = pairs(&[("GIT_TOKEN", "ghp_new"), ("TZ", "UTC")]); - prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None) + prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None, None) .await .unwrap(); assert_eq!(*fake.secret_reads.lock().unwrap(), 1, "read only once it exists"); @@ -1675,7 +1677,7 @@ async fn switching_to_copy_at_connect_replaces_a_secret_that_held_credentials() *fake.existing_secret.lock().unwrap() = Some( r#"{"TRIPLEC_AGENT_TOKEN":"t","TRIPLEC_CREDENTIALS":"connect","TZ":"UTC","TRIPLEC_REPOS":"[]"}"#.into(), ); - prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None) + prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None, None) .await .unwrap(); assert!(fake.deleted_secrets.lock().unwrap().is_empty()); @@ -1684,7 +1686,7 @@ async fn switching_to_copy_at_connect_replaces_a_secret_that_held_credentials() // No secret yet (a first start): created, never read — a read of a // secret that doesn't exist may be refused — nothing deleted. let fake = Fake::onboarded(); - prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None) + prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None, None) .await .unwrap(); assert_eq!(*fake.creates.lock().unwrap(), 1); @@ -1737,7 +1739,7 @@ async fn the_start_after_a_timed_out_replace_retries_the_create() { let env = pairs(&[("TZ", "UTC")]); let fake = Fake::onboarded(); *fake.pending_puts.lock().unwrap() = 3; - prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None) + prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None, None) .await .unwrap(); assert_eq!(fake.secrets.lock().unwrap().len(), 1, "made once the name is free"); @@ -1752,7 +1754,7 @@ async fn the_start_after_a_timed_out_replace_retries_the_create() { // Still taken past the limit: try again in a minute, never "restore". let fake = Fake::onboarded(); *fake.pending_puts.lock().unwrap() = 1000; - let e = prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None) + let e = prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None, None) .await .unwrap_err() .to_string(); @@ -1770,7 +1772,7 @@ async fn a_copy_at_connect_read_of_a_secret_being_deleted_is_retried() { r#"{"TRIPLEC_AGENT_TOKEN":"t","TRIPLEC_CREDENTIALS":"connect","TZ":"UTC","TRIPLEC_REPOS":"[]"}"#.into(), ); *fake.pending_reads.lock().unwrap() = 3; - prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None) + prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None, None) .await .unwrap(); assert_eq!(*fake.secret_reads.lock().unwrap(), 4); @@ -1780,7 +1782,7 @@ async fn a_copy_at_connect_read_of_a_secret_being_deleted_is_retried() { let fake = Fake::onboarded(); *fake.existing_secret.lock().unwrap() = Some(r#"{"TZ":"UTC"}"#.into()); *fake.pending_reads.lock().unwrap() = 1000; - let e = prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None) + let e = prepare_workspace(&fake, &who(), &env_info(), ©_at_connect_project(), &env, &[], &[], IMAGE, None, None) .await .unwrap_err() .to_string(); @@ -1985,7 +1987,7 @@ fn sidecar_project() -> Project { async fn prepare_registers_the_sidecar_only_when_the_project_runs_it() { let fake = Fake::onboarded(); let p = sidecar_project(); - prepare_workspace(&fake, &who(), &env_info(), &p, &[], &[], &[], IMAGE, Some(gw())) + prepare_workspace(&fake, &who(), &env_info(), &p, &[], &[], &[], IMAGE, Some(gw()), None) .await .unwrap(); assert_eq!(fake.registered.lock().unwrap()[0].container_definitions().len(), 2); @@ -1994,7 +1996,7 @@ async fn prepare_registers_the_sidecar_only_when_the_project_runs_it() { // Toggle off: a payload handed in anyway is ignored. let fake = Fake::onboarded(); - prepare_workspace(&fake, &who(), &env_info(), &project(StorageMode::Ephemeral), &[], &[], &[], IMAGE, Some(gw())) + prepare_workspace(&fake, &who(), &env_info(), &project(StorageMode::Ephemeral), &[], &[], &[], IMAGE, Some(gw()), None) .await .unwrap(); assert_eq!(fake.registered.lock().unwrap()[0].container_definitions().len(), 1); @@ -2006,7 +2008,7 @@ async fn prepare_registers_the_sidecar_only_when_the_project_runs_it() { async fn prepare_refuses_a_sidecar_without_its_payload_or_with_an_oversized_config() { let fake = Fake::onboarded(); let p = sidecar_project(); - let e = prepare_workspace(&fake, &who(), &env_info(), &p, &[], &[], &[], IMAGE, None) + let e = prepare_workspace(&fake, &who(), &env_info(), &p, &[], &[], &[], IMAGE, None, None) .await .unwrap_err(); assert!(e.to_string().contains("gateway"), "{e}"); @@ -2021,6 +2023,7 @@ async fn prepare_refuses_a_sidecar_without_its_payload_or_with_an_oversized_conf &[], IMAGE, Some(GatewayPayload { config: &big, ..gw() }), + None, ) .await .unwrap_err(); @@ -2035,6 +2038,7 @@ async fn prepare_refuses_a_sidecar_without_its_payload_or_with_an_oversized_conf &[], IMAGE, Some(GatewayPayload { api_key: " ", ..gw() }), + None, ) .await .unwrap_err(); @@ -2084,3 +2088,222 @@ fn the_sidecars_token_is_not_a_leftover_credential_but_a_dropped_provider_key_is [("TRIPLEC_AGENT_TOKEN", "t")].iter().map(|(k, v)| (k.to_string(), v.to_string())).collect(); assert!(holds(sidecar_old, &off)); } + +// ------------------------------------------------------------- EC2 (phase 7) + +fn ec2_sample(storage: StorageMode, docker_socket: bool, vpn: bool) -> WorkspacePlan { + WorkspacePlan { ec2: Some(Ec2Plan { docker_socket, vpn }), ..sample_plan(storage) } +} + +fn compute(instance_type: &str) -> UserCompute { + UserCompute { + instance_type: instance_type.into(), + max_instances: 2, + user_tag: "alice".into(), + cluster_arn: format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/triple-c-dev--u-alice"), + capacity_provider: "triple-c-dev--u-alice".into(), + } +} + +fn ec2_project(storage: StorageMode, cpu: u32, memory_mib: u32) -> Project { + let mut p = project(storage); + let a = p.aws.as_mut().unwrap(); + a.launch_type = crate::models::LaunchType::Ec2; + a.cpu = cpu; + a.memory_mib = memory_mib; + p +} + +#[test] +fn an_ec2_request_is_bridge_mode_with_the_reservations_and_no_fargate_fields() { + for storage in [StorageMode::Ephemeral, StorageMode::Hybrid, StorageMode::Efs] { + let plan = ec2_sample(storage, false, false); + let req = task_definition_request(&plan); + assert_eq!(req.requires_compatibilities(), &[aws_sdk_ecs::types::Compatibility::Ec2]); + assert_eq!(req.network_mode(), Some(&aws_sdk_ecs::types::NetworkMode::Bridge)); + assert_eq!((req.cpu(), req.memory()), (Some("1024"), Some("4096"))); + assert!(req.runtime_platform().is_none(), "the instance's architecture decides"); + assert!(req.ephemeral_storage().is_none(), "the instance's disk"); + // Everything else as on Fargate: roles, tags, health check, stop + // timeout, init, logs, the EFS volumes and the fingerprint label. + let fargate = task_definition_request(&sample_plan(storage)); + assert_eq!(req.task_role_arn(), fargate.task_role_arn()); + assert_eq!(req.execution_role_arn(), fargate.execution_role_arn()); + assert_eq!(req.tags(), fargate.tags()); + assert_eq!(req.volumes(), fargate.volumes()); + let (c, f) = (&req.container_definitions()[0], &fargate.container_definitions()[0]); + assert_eq!(c.health_check(), f.health_check()); + assert_eq!(c.stop_timeout(), Some(STOP_TIMEOUT_SECS)); + assert_eq!(c.mount_points(), f.mount_points()); + assert_eq!(c.secrets(), f.secrets()); + assert_eq!(c.environment(), f.environment()); + assert_eq!(c.log_configuration(), f.log_configuration()); + assert_eq!(c.linux_parameters(), f.linux_parameters(), "SYS_PTRACE and init only"); + assert!(c.system_controls().is_empty()); + assert!(c.port_mappings().is_empty()); + assert_eq!( + c.docker_labels().unwrap().get(FINGERPRINT_LABEL), + Some(&workspace_fingerprint(&plan)) + ); + assert_ne!(workspace_fingerprint(&plan), workspace_fingerprint(&sample_plan(storage))); + } +} + +#[test] +fn an_ec2_request_for_each_toggle_combination() { + let mut fingerprints = std::collections::BTreeSet::new(); + for (docker, vpn) in [(false, false), (true, false), (false, true), (true, true)] { + let plan = ec2_sample(StorageMode::Hybrid, docker, vpn); + let req = task_definition_request(&plan); + fingerprints.insert(workspace_fingerprint(&plan)); + let c = &req.container_definitions()[0]; + let lp = c.linux_parameters().unwrap(); + assert_eq!(lp.init_process_enabled(), Some(true)); + + // E6: the instance's Docker socket at the same path. + let socket_volume: Vec<_> = + req.volumes().iter().filter(|v| v.name() == Some("docker-socket")).collect(); + let socket_mount: Vec<_> = c + .mount_points() + .iter() + .filter(|m| m.container_path() == Some(DOCKER_SOCKET_PATH)) + .collect(); + if docker { + assert_eq!(socket_volume.len(), 1); + assert_eq!( + socket_volume[0].host().and_then(|h| h.source_path()), + Some("/var/run/docker.sock") + ); + assert!(socket_volume[0].efs_volume_configuration().is_none()); + assert_eq!(socket_mount.len(), 1); + assert_eq!(socket_mount[0].source_volume(), Some("docker-socket")); + } else { + assert!(socket_volume.is_empty() && socket_mount.is_empty()); + } + // The home access point is mounted either way. + assert!(c.mount_points().iter().any(|m| m.container_path() == Some(HOME_MOUNT_PATH))); + + // E7: the three VPN pieces, all or none, plus SYS_PTRACE as always. + let caps = lp.capabilities().unwrap().add(); + let sysctls: Vec<(&str, &str)> = c + .system_controls() + .iter() + .map(|s| (s.namespace().unwrap(), s.value().unwrap())) + .collect(); + if vpn { + assert_eq!(caps, ["SYS_PTRACE".to_string(), "NET_ADMIN".to_string()]); + assert_eq!(lp.devices().len(), 1); + let d = &lp.devices()[0]; + assert_eq!((d.host_path(), d.container_path()), ("/dev/net/tun", Some("/dev/net/tun"))); + use aws_sdk_ecs::types::DeviceCgroupPermission as P; + assert_eq!(d.permissions(), [P::Read, P::Write, P::Mknod]); + assert_eq!(sysctls, [("net.ipv4.conf.all.src_valid_mark", "1")]); + } else { + assert_eq!(caps, ["SYS_PTRACE".to_string()]); + assert!(lp.devices().is_empty() && sysctls.is_empty()); + } + } + assert_eq!(fingerprints.len(), 4, "every combination is its own revision"); +} + +/// The VPN pieces are Docker's own (`vpn_host_config`), not a second list. +#[test] +fn the_ec2_vpn_pieces_are_the_docker_ones() { + let vpn = crate::docker::container::vpn_requirements(); + assert_eq!(vpn.capabilities, ["NET_ADMIN"]); + assert_eq!( + vpn.devices, + [("/dev/net/tun".to_string(), "/dev/net/tun".to_string(), "rwm".to_string())] + ); + assert_eq!(vpn.sysctls, [("net.ipv4.conf.all.src_valid_mark".to_string(), "1".to_string())]); +} + +#[test] +fn ec2_plan_checks_the_record_and_the_fit_and_carries_the_toggles() { + // Fargate: nothing, whatever the record says. + let fargate = project(StorageMode::Hybrid); + assert_eq!(ec2_plan(&fargate, "dev", None), Ok(None)); + assert_eq!(ec2_plan(&fargate, "dev", Some(&compute("m7i.large"))), Ok(None)); + + // No record: the onboarding has no EC2 capacity (or it was removed). + let mut p = ec2_project(StorageMode::Hybrid, 1024, 4096); + let e = ec2_plan(&p, "dev", None).unwrap_err(); + assert_eq!( + e, + "You have no EC2 capacity in dev; ask an admin to add it to your onboarding (or run the \ + project on Fargate)." + ); + + // Fits: the toggles ride along. + p.allow_docker_access = true; + assert_eq!( + ec2_plan(&p, "dev", Some(&compute("m7i.large"))), + Ok(Some(Ec2Plan { docker_socket: true, vpn: false })) + ); + p.vpn_support_enabled = true; + assert_eq!( + ec2_plan(&p, "dev", Some(&compute("m7i.large"))), + Ok(Some(Ec2Plan { docker_socket: true, vpn: true })) + ); + + // Too big: names what the instance has for a workspace (10 % memory + // margin: ECS registers less than the nominal 8 GiB). + let big = ec2_project(StorageMode::Hybrid, 2048, 8192); + let e = ec2_plan(&big, "dev", Some(&compute("m7i.large"))).unwrap_err(); + assert!(e.contains("m7i.large"), "{e}"); + assert!(e.contains("1920 CPU units, 7373 MiB"), "{e}"); + assert!(ec2_plan(&big, "dev", Some(&compute("m7i.xlarge"))).is_ok()); + + // The gateway sidecar is not offered on EC2 (bridge networking). + let mut gw_on = ec2_project(StorageMode::Hybrid, 1024, 4096); + gw_on.aws.as_mut().unwrap().gateway_sidecar = true; + assert_eq!(ec2_plan(&gw_on, "dev", Some(&compute("m7i.large"))).unwrap_err(), EC2_NO_SIDECAR); +} + +#[test] +fn the_sidecar_is_refused_on_ec2() { + use crate::models::gateway_settings::{GatewayModel, GatewaySettings}; + let models = GatewaySettings { + models: vec![GatewayModel { name: "gpt".into(), model_id: "gpt-5".into() }], + ..Default::default() + }; + let mut p = ec2_project(StorageMode::Hybrid, 1024, 4096); + p.backend = crate::models::project::Backend::OpenAiCompatible; + p.aws.as_mut().unwrap().gateway_sidecar = true; + assert_eq!(gateway_sidecar_problem(&p, &models).as_deref(), Some(EC2_NO_SIDECAR)); + p.aws.as_mut().unwrap().gateway_sidecar = false; + assert_eq!(gateway_sidecar_problem(&p, &models), None); +} + +#[tokio::test] +async fn an_ec2_project_registers_an_ec2_revision_on_the_users_instance() { + let fake = Fake::onboarded(); + let mut p = ec2_project(StorageMode::Hybrid, 1024, 4096); + p.allow_docker_access = true; + let c = compute("m7i.large"); + prepare_workspace(&fake, &who(), &env_info(), &p, &[], &[], &[], IMAGE, None, Some(&c)) + .await + .unwrap(); + let reg = fake.registered.lock().unwrap(); + assert_eq!(reg.len(), 1); + assert_eq!(reg[0].requires_compatibilities(), &[aws_sdk_ecs::types::Compatibility::Ec2]); + assert_eq!(reg[0].network_mode(), Some(&aws_sdk_ecs::types::NetworkMode::Bridge)); + assert!(reg[0].volumes().iter().any(|v| v.name() == Some("docker-socket"))); +} + +#[tokio::test] +async fn an_ec2_project_without_capacity_or_room_fails_before_any_write() { + let p = ec2_project(StorageMode::Hybrid, 1024, 4096); + let fake = Fake::onboarded(); + let e = prepare_workspace(&fake, &who(), &env_info(), &p, &[], &[], &[], IMAGE, None, None) + .await + .unwrap_err(); + assert!(e.to_string().contains("no EC2 capacity in dev"), "{e}"); + let big = ec2_project(StorageMode::Hybrid, 2048, 8192); + let c = compute("m7i.large"); + let e = prepare_workspace(&fake, &who(), &env_info(), &big, &[], &[], &[], IMAGE, None, Some(&c)) + .await + .unwrap_err(); + assert!(e.to_string().contains("more than your EC2 instance type"), "{e}"); + assert_eq!(fake.writes(), 0); +} diff --git a/app/src-tauri/src/commands/project_commands.rs b/app/src-tauri/src/commands/project_commands.rs index 01236a5..4b38340 100644 --- a/app/src-tauri/src/commands/project_commands.rs +++ b/app/src-tauri/src/commands/project_commands.rs @@ -1225,6 +1225,10 @@ fn validate_gateway_sidecar_update( let Some(problem) = crate::aws::workspace::gateway_sidecar_problem(project, gateway) else { return Ok(()); }; + // Not on EC2 at all (bridge networking): refused whatever was stored. + if problem == crate::aws::workspace::EC2_NO_SIDECAR { + return Err(problem); + } let was_on = stored.aws.as_ref().is_some_and(|a| a.gateway_sidecar); if was_on && project.backend == crate::models::project::Backend::OpenAiCompatible { return Ok(()); @@ -2903,6 +2907,15 @@ mod tests { assert!(validate_gateway_sidecar_update(&on, &on, &half).is_ok()); // Off: nothing to check. assert!(validate_gateway_sidecar_update(&off, &off, &half).is_ok()); + + // EC2 (bridge networking): refused even when it was already on. + let mut ec2 = on.clone(); + ec2.aws.as_mut().unwrap().launch_type = crate::models::LaunchType::Ec2; + let e = validate_gateway_sidecar_update(&on, &ec2, &with_models).unwrap_err(); + assert_eq!(e, crate::aws::workspace::EC2_NO_SIDECAR); + assert!(validate_gateway_sidecar_update(&ec2, &ec2, &with_models).is_err()); + ec2.aws.as_mut().unwrap().gateway_sidecar = false; + assert!(validate_gateway_sidecar_update(&on, &ec2, &with_models).is_ok()); } #[test] diff --git a/app/src-tauri/src/docker/container.rs b/app/src-tauri/src/docker/container.rs index ffeb841..036ec67 100644 --- a/app/src-tauri/src/docker/container.rs +++ b/app/src-tauri/src/docker/container.rs @@ -1112,6 +1112,37 @@ fn vpn_host_config(enabled: bool) -> VpnHostConfigParts { ) } +/// What a VPN client needs, as plain data, for hosts that aren't Docker (an +/// AWS EC2 task definition): the capabilities, the devices as +/// `(host path, container path, cgroup permissions)`, and the sysctls, +/// sorted. Derived from [`vpn_host_config`] so the two can't drift. +pub(crate) struct VpnRequirements { + pub capabilities: Vec, + pub devices: Vec<(String, String, String)>, + pub sysctls: Vec<(String, String)>, +} + +pub(crate) fn vpn_requirements() -> VpnRequirements { + let (caps, devices, sysctls) = vpn_host_config(true); + let mut sysctls: Vec<(String, String)> = sysctls.unwrap_or_default().into_iter().collect(); + sysctls.sort(); + VpnRequirements { + capabilities: caps.unwrap_or_default(), + devices: devices + .unwrap_or_default() + .into_iter() + .map(|d| { + ( + d.path_on_host.unwrap_or_default(), + d.path_in_container.unwrap_or_default(), + d.cgroup_permissions.unwrap_or_default(), + ) + }) + .collect(), + sysctls, + } +} + /// Turn the daemon's device-passthrough failure into an explanation. /// /// **This fires on `start`, not `create`.** Verified against Docker 29.7: diff --git a/app/src-tauri/src/host/aws_host.rs b/app/src-tauri/src/host/aws_host.rs index 5d55760..cf01982 100644 --- a/app/src-tauri/src/host/aws_host.rs +++ b/app/src-tauri/src/host/aws_host.rs @@ -1,6 +1,9 @@ -//! `ProjectHost::Aws`: a project's container is an ECS Fargate task in one -//! of the account's environments, reached through an SSM port-forward to -//! the in-task agent (`ssm.rs`, `agent.rs`). +//! `ProjectHost::Aws`: a project's container is an ECS task in one of the +//! account's environments — Fargate on the environment's cluster, or (phase +//! 7, `LaunchType::Ec2`) on the user's own EC2 capacity, their per-user +//! cluster from their record — reached through an SSM port-forward to the +//! in-task agent (`ssm.rs`, `agent.rs`). A task's cluster is always read +//! back from its ARN, so stop, reconcile and the watch need no record. //! //! Start: connection → `SdkConfig` → caller identity → environment record → //! onboarding → the project's live task, if there is one (its token is read @@ -27,27 +30,30 @@ use super::tunnels::{self, LiveTunnel, TunnelHandle}; use super::watch::{AwsTaskLookup, TaskGroup, WatchedTask}; use super::ContainerTarget; use crate::aws::environments::EnvironmentInfo; +use crate::aws::environments::UserRecord; use crate::aws::runtime::{ - check_onboarded, cluster_arn_of_task, cluster_of_task, ensure_agent_token, read_agent_token, - read_environment, + check_onboarded, cluster_arn_of_task, cluster_of_task, ec2_cluster_of_task, + ensure_agent_token, read_agent_token, read_environment, read_user_record, remove_workspace_resources, wait_access_point, PollTiming, RemoveRequest, RuntimeApi, SdkRuntimeApi, }; use crate::aws::tasks::{ - find_or_run, find_project_task, stopped_among, task_log_stream, wait_ready, SdkTaskApi, - StopKind, TaskApi, TaskInfo, TaskLogs, WaitTiming, LOG_TAIL_LINES, STOP_REASON, + find_or_run, find_project_task, stopped_among, task_log_stream, wait_ready, + waiting_for_instance, WAIT_TIMED_OUT, RunOn, SdkTaskApi, StopKind, TaskApi, TaskInfo, TaskLogs, WaitTiming, + LOG_TAIL_LINES, STOP_REASON, }; use crate::aws::tofu_modules::{ environment_cluster_name, log_stream_prefix, owner_key, task_family, }; use crate::aws::workspace::{ - gateway_sidecar_problem, new_agent_token, prepare_workspace, GatewayPayload, SdkWorkspaceApi, - WorkspaceApi, + gateway_sidecar_problem, new_agent_token, no_ec2_capacity, prepare_workspace, GatewayPayload, + SdkWorkspaceApi, WorkspaceApi, }; use crate::aws::{caller_identity, sdk_config, CallerIdentity}; use crate::docker::ca_certs::{container_cert_name, ResolvedCa}; use crate::models::app_settings::ImageSource; use crate::models::container_config::REGISTRY_IMAGE; +use crate::models::project::LaunchType; use crate::models::{AppSettings, Project, ProjectStatus}; use crate::storage::projects_store::ProjectsStore; use crate::storage::settings_store::SettingsStore; @@ -58,6 +64,8 @@ pub const PROGRESS_READING: &str = "Reading environment…"; pub const PROGRESS_PREPARING: &str = "Preparing workspace…"; pub const PROGRESS_STARTING: &str = "Starting task…"; pub const PROGRESS_WAITING: &str = "Waiting for the task (about 2 minutes)…"; +/// An EC2 task waiting for an instance with room (capacity scaled to zero). +pub const PROGRESS_INSTANCE: &str = "Starting an instance (about 3 minutes)…"; pub const PROGRESS_CONNECTING: &str = "Connecting…"; /// A concurrent start won the RunTask race: the secret now holds a token @@ -137,16 +145,24 @@ fn is_registry_reference(name: &str) -> bool { /// [`aws_env`]'s answer: the pairs, and the resolved CA whose files ship too. pub type AwsEnv = (Vec<(String, String)>, Option); +/// Whether Claude Code's sandbox (bubblewrap) may run where `project`'s task +/// runs — the one place this is decided. Not on Fargate (P9: it can't create +/// namespaces there, verified live); allowed on the user's EC2 instances +/// (E8: the ECS-optimized AMI permits user namespaces; the live test checks). +pub fn sandbox_allowed(project: &Project) -> bool { + project.aws.as_ref().is_some_and(|a| a.launch_type == LaunchType::Ec2) +} + /// The environment pairs an AWS task gets: [`workspace_env`] with the same -/// inputs Docker resolves, and Claude Code's sandbox forced off (R4: Fargate -/// support for bubblewrap is unverified). Returns the resolved CA too. +/// inputs Docker resolves, and Claude Code's sandbox forced off where +/// [`sandbox_allowed`] says no. Returns the resolved CA too. /// /// [`workspace_env`]: crate::docker::workspace_env::workspace_env pub fn aws_env(project: &Project, settings: &AppSettings) -> Result { let mut p = project.clone(); - if p.sandbox_mode_enabled { + if p.sandbox_mode_enabled && !sandbox_allowed(project) { log::info!( - "Project {}: Claude Code's sandbox is turned off on AWS (not yet supported on Fargate)", + "Project {}: Claude Code's sandbox is turned off on AWS (not supported on Fargate)", project.id ); p.sandbox_mode_enabled = false; @@ -410,6 +426,9 @@ pub struct StartInputs<'a> { /// attaching to a running one never needs the provider key or models. pub gateway: &'a (dyn Fn() -> Result, String> + Send + Sync), pub wait: WaitTiming, + /// The wait for a task on the user's EC2 capacity (an instance may have + /// to launch first: [`WaitTiming::ec2`]). + pub ec2_wait: WaitTiming, pub access_point_wait: PollTiming, /// Called as soon as the project has a task (found, or RunTask /// returned) so the store holds its ARN before the long wait — a crash @@ -468,6 +487,75 @@ async fn stop_created(api: &T, cluster: &str, arn: &str) -> bool { } } +/// Wait for `arn` on `cluster`, telling the user when an EC2 task is waiting +/// for an instance ([`PROGRESS_INSTANCE`], then [`PROGRESS_WAITING`] again +/// once one has room). An EC2 task that never got an instance fails with +/// what to check rather than ECS's last status. +#[allow(clippy::too_many_arguments)] +async fn wait_task( + tasks: &T, + cluster: &str, + arn: &str, + logs: &TaskLogs, + timing: WaitTiming, + ec2: Option, + progress: &(dyn Fn(&str) + Send + Sync), +) -> Result { + let waiting = std::sync::atomic::AtomicBool::new(false); + let r = wait_ready(tasks, cluster, arn, logs, timing, |t| { + if ec2.is_none() { + return; + } + let now = waiting_for_instance(t); + if now != waiting.swap(now, std::sync::atomic::Ordering::Relaxed) { + progress(if now { PROGRESS_INSTANCE } else { PROGRESS_WAITING }); + } + }) + .await; + match r { + Ok(t) => Ok(t), + Err(e) + if waiting.load(std::sync::atomic::Ordering::Relaxed) + && e.to_string().starts_with(WAIT_TIMED_OUT) => + { + let max = ec2.unwrap_or(1); + Err(format!( + "No EC2 instance had room for the task within {} minutes. Your capacity may \ + already be running its maximum of {max} instance{} (stop another EC2 \ + workspace), or its Auto Scaling group could not launch one (an admin can see \ + why in the group's activity in the EC2 console).", + timing.timeout.as_secs() / 60, + if max == 1 { "" } else { "s" } + )) + } + Err(e) => Err(e.to_string()), + } +} + +/// Where a project's task may be: the environment's cluster, the user's EC2 +/// cluster from their record, and the per-user cluster a stored task ARN +/// names (the record may be gone while that task runs), without repeats. +fn task_clusters(env: &EnvironmentInfo, record: Option<&UserRecord>, stored: Option<&str>) -> Vec { + let mut out = vec![env.cluster_arn.clone()]; + for c in [ + record.and_then(UserRecord::valid).map(|c| c.cluster_arn.clone()), + stored.and_then(|a| ec2_cluster_of_task(&env.name, a)), + ] + .into_iter() + .flatten() + { + if !out.contains(&c) { + out.push(c); + } + } + out +} + +/// The cluster (ARN) a task runs on, from its ARN. +fn task_cluster(env: &EnvironmentInfo, task_arn: &str) -> String { + cluster_arn_of_task(task_arn).unwrap_or_else(|| env.cluster_arn.clone()) +} + /// The start sequence; see the module docs. pub async fn start_core( tasks: &T, @@ -496,9 +584,35 @@ pub async fn start_core| if ec2.is_some() { inp.ec2_wait } else { inp.wait }; + + let stored = cfg.task_arn.as_deref(); + let mut existing = None; + for cluster in task_clusters(&env, record.as_ref(), stored) { + existing = find_project_task(tasks, &cluster, &family, &inp.who.user_id, &project.id) + .await + .map_err(s)?; + if existing.is_some() { + break; + } + } let (task, token, access_point_id, workspace_access_point_id, created) = if let Some(task) = existing { // Attach: never rotate a running task's token (P2). @@ -511,12 +625,28 @@ pub async fn start_core t, - Err(e) => return Err(with_log_tail(tasks, &logs, &task.arn, e.to_string()).await), + Err(e) => return Err(with_log_tail(tasks, &logs, &task.arn, e).await), }; (task, token, None, None, false) } else { + // Where the new task runs; an EC2 project without usable capacity + // fails here, before anything is written. + let run_on = match &record { + None => RunOn::Fargate { spot: cfg.spot }, + Some(UserRecord::Valid(c)) => RunOn::Ec2(c), + Some(UserRecord::Absent) => return Err(no_ec2_capacity(&env.name)), + Some(UserRecord::Unusable(why)) => { + return Err(format!( + "Your EC2 capacity record in {} can't be used ({why}); ask an admin to \ + re-apply your onboarding.", + env.name + )) + } + }; progress(PROGRESS_PREPARING); let sidecar = (inp.gateway)()?; let prepared = prepare_workspace( @@ -529,6 +659,7 @@ pub async fn start_core Some(c.max_instances), + RunOn::Fargate { .. } => None, + }; + let task = match wait_task(tasks, &cluster, &arn, &logs, timing_of(ec2), ec2, progress).await { Ok(t) => t, Err(e) => { - let msg = with_log_tail(tasks, &logs, &arn, e.to_string()).await; - if stop_created(tasks, &env.cluster_arn, &arn).await { + let msg = with_log_tail(tasks, &logs, &arn, e).await; + if stop_created(tasks, &cluster, &arn).await { (inp.on_task)(None); } return Err(msg); @@ -617,7 +753,7 @@ pub async fn start_core { - if created && stop_created(tasks, &env.cluster_arn, &task.arn).await { + if created && stop_created(tasks, &task_cluster(&env, &task.arn), &task.arn).await { (inp.on_task)(None); } Err(e) @@ -730,6 +866,7 @@ pub async fn ensure_started_with( image: &image, gateway: &sidecar, wait: WaitTiming::default(), + ec2_wait: WaitTiming::ec2(), access_point_wait: PollTiming::default(), on_task: &on_task, }, @@ -756,7 +893,7 @@ pub async fn ensure_started_with( LiveTunnel { task: ecs, task_arn: started.task.arn.clone(), - cluster_arn: started.env.cluster_arn.clone(), + cluster_arn: task_cluster(&started.env, &started.task.arn), connection_id, region, sdk, @@ -903,22 +1040,36 @@ pub async fn stop_endpoint(ep: &AgentEndpoint) -> Option> { /// Where to look for a project's live task when no ARN is stored (a crash /// before the store write, or a store from an older build). pub struct FindTask { - pub cluster: String, + /// The environment's cluster, then the user's EC2 cluster when known. + pub clusters: Vec, pub family: String, pub owner_user_id: String, pub project_id: String, } impl FindTask { - fn new(project: &Project, region: &str, owner_user_id: &str) -> Self { + /// `ec2_cluster`: the user's EC2 cluster from their record, if they + /// have one ([`user_ec2_cluster`]); the stored task's per-user cluster + /// is added either way. + fn new(project: &Project, region: &str, owner_user_id: &str, ec2_cluster: Option) -> Self { let env = project .aws_placement .as_ref() .map(|p| p.environment.clone()) .unwrap_or_default(); let ok = owner_key(region, owner_user_id); + let mut clusters = vec![environment_cluster_name(&env)]; + let stored = project.aws.as_ref().and_then(|a| a.task_arn.as_deref()); + for c in [ec2_cluster, stored.and_then(|a| ec2_cluster_of_task(&env, a))] + .into_iter() + .flatten() + { + if !clusters.contains(&c) { + clusters.push(c); + } + } FindTask { - cluster: environment_cluster_name(&env), + clusters, family: task_family(&env, &ok, &project.id), owner_user_id: owner_user_id.to_string(), project_id: project.id.clone(), @@ -926,6 +1077,43 @@ impl FindTask { } } +/// The project's live task in any of `find`'s clusters. +async fn find_in_clusters(api: &T, find: &FindTask) -> Result, String> { + for cluster in &find.clusters { + if let Some(t) = + find_project_task(api, cluster, &find.family, &find.owner_user_id, &find.project_id) + .await + .map_err(s)? + { + return Ok(Some(t)); + } + } + Ok(None) +} + +/// The user's EC2 cluster (ARN) for an EC2 project, from their record; `None` +/// for a Fargate project, or when there is no usable record (best effort: +/// only used to look for a task no ARN was stored for). +pub async fn user_ec2_cluster( + rt: &R, + project: &Project, + who: &CallerIdentity, + region: &str, +) -> Option { + if !project.aws.as_ref().is_some_and(|a| a.launch_type == LaunchType::Ec2) { + return None; + } + let env = &project.aws_placement.as_ref()?.environment; + match read_user_record(rt, env, &owner_key(region, &who.user_id), &who.account, region).await { + Ok(UserRecord::Valid(c)) => Some(c.cluster_arn), + Ok(_) => None, + Err(e) => { + log::warn!("Project {}: could not read the EC2 record ({e})", project.id); + None + } + } +} + /// The project's task ARN: the stored one, else its live task's. async fn task_arn_or_find( api: &T, @@ -935,12 +1123,7 @@ async fn task_arn_or_find( if let Some(a) = stored { return Ok(Some(a.to_string())); } - Ok( - find_project_task(api, &find.cluster, &find.family, &find.owner_user_id, &find.project_id) - .await - .map_err(s)? - .map(|t| t.arn), - ) + Ok(find_in_clusters(api, find).await?.map(|t| t.arn)) } /// Stop an AWS project's task: through its tunnel when there is one, else @@ -960,7 +1143,8 @@ pub async fn stop_project(project: &Project, settings: &AppSettings) -> Result<( Some(a) => Some(a), None => { let who = caller_identity(&sdk).await.map_err(s)?; - task_arn_or_find(&api, None, &FindTask::new(project, ®ion, &who.user_id)).await? + let ec2 = user_ec2_cluster(&SdkRuntimeApi::new(&sdk), project, &who, ®ion).await; + task_arn_or_find(&api, None, &FindTask::new(project, ®ion, &who.user_id, ec2)).await? } }; if let Some(arn) = arn { @@ -987,10 +1171,12 @@ pub async fn remove_resources( let ok = owner_key(®ion, &who.user_id); let env = project.aws_placement.as_ref().map(|p| p.environment.clone()).unwrap_or_default(); let aws = project.aws.as_ref(); + let rt = SdkRuntimeApi::new(&sdk); + let ec2_cluster = user_ec2_cluster(&rt, project, &who, ®ion).await; remove_workspace_resources( &SdkTaskApi::new(&sdk), &SdkWorkspaceApi::new(&sdk), - &SdkRuntimeApi::new(&sdk), + &rt, &RemoveRequest { env: &env, region: ®ion, @@ -1001,6 +1187,7 @@ pub async fn remove_resources( stored_access_point_id: aws.and_then(|a| a.access_point_id.as_deref()), stored_workspace_access_point_id: aws .and_then(|a| a.workspace_access_point_id.as_deref()), + ec2_cluster: ec2_cluster.as_deref(), discard_data, }, ) @@ -1041,11 +1228,9 @@ pub async fn reconcile_task( // or a crash before the store write) may have left the project a newer // one: look before calling it Gone (m3). if task_arn.is_some() { - if let Some(t) = - find_project_task(api, &find.cluster, &find.family, &find.owner_user_id, &find.project_id) - .await - .map_err(s)? - .filter(|t| t.arn != arn && is_live(t)) + if let Some(t) = find_in_clusters(api, find) + .await? + .filter(|t| t.arn != arn && is_live(t)) { return Ok(Reconciled::Live(Box::new(t))); } @@ -1155,7 +1340,8 @@ pub async fn reconcile( } }; let api = SdkTaskApi::new(&sdk); - let find = FindTask::new(project, ®ion, &who.user_id); + let ec2 = user_ec2_cluster(&SdkRuntimeApi::new(&sdk), project, &who, ®ion).await; + let find = FindTask::new(project, ®ion, &who.user_id, ec2); match reconcile_project(&api, &store, project, &find).await { Ok(Reconciled::Live(task)) => { let generation = tunnels::begin_reattach(&project.id); @@ -1227,14 +1413,21 @@ async fn reattach( .map_err(s)?; let token = read_agent_token(&rt, &env.name, &ok, &project.id).await.map_err(s)?; let logs = TaskLogs { group: env.log_group.clone(), stream_prefix: log_stream_prefix(&ok, &project.id) }; - let task = wait_ready(&api, &env.cluster_arn, &task.arn, &logs, WaitTiming::default(), |_| {}) + // An EC2 task may still be waiting for its instance after a restart. + let cluster = task_cluster(&env, &task.arn); + let timing = if ec2_cluster_of_task(&env.name, &task.arn).is_some() { + WaitTiming::ec2() + } else { + WaitTiming::default() + }; + let task = wait_ready(&api, &cluster, &task.arn, &logs, timing, |_| {}) .await .map_err(s)?; let (forward, endpoint) = SsmConnector { sdk: ctx.sdk.clone() }.connect(&task, &token).await?; let tunnel = LiveTunnel { task: ecs_task(&task)?, task_arn: task.arn.clone(), - cluster_arn: env.cluster_arn.clone(), + cluster_arn: cluster, connection_id: ctx.connection_id, region: ctx.region, sdk: ctx.sdk, diff --git a/app/src-tauri/src/host/aws_host/tests.rs b/app/src-tauri/src/host/aws_host/tests.rs index 48c19f0..09bba46 100644 --- a/app/src-tauri/src/host/aws_host/tests.rs +++ b/app/src-tauri/src/host/aws_host/tests.rs @@ -56,6 +56,7 @@ fn task(p: &Project, id: &str, last: &str, ready: bool) -> TaskInfo { stopped_reason: (last == "STOPPED").then(|| "Essential container exited".into()), task_definition_arn: format!("arn:aws:ecs:{REGION}:{ACCOUNT}:task-definition/{}:1", family(p)), runtime_id: ready.then(|| "rt-1".into()), + container_instance_arn: None, exec_agent_running: ready, exit_code: None, owner: Some(USER.into()), @@ -98,6 +99,19 @@ struct Fake { recorded: Mutex>>, /// `group stream limit` of each log read. log_reads: Mutex>, + /// The caller's EC2 record (absent by default). + user_record: Option, + /// RunTask requests, in order. + run_requests: Mutex>, + /// The clusters ListTasks / StopTask / DescribeTasks were asked about. + list_clusters: Mutex>, + stop_clusters: Mutex>, + describe_clusters: Mutex>, + /// When set, ListTasks answers per cluster (empty for any other). + listed_by_cluster: Option>>, + /// Successive states of the run task, one per DescribeTasks (the last + /// repeats); overrides `tasks` for that ARN. + script: Mutex>, } impl Fake { @@ -117,23 +131,39 @@ impl Fake { } impl TaskApi for Fake { - async fn run_task(&self, _req: RunTaskInput) -> Result { + async fn run_task(&self, req: RunTaskInput) -> Result { self.log("run"); + self.run_requests.lock().unwrap().push(req); let t = self.run.clone().expect("a run was expected"); self.tasks.lock().unwrap().insert(t.arn.clone(), t.clone()); Ok(t) } - async fn describe(&self, _c: &str, arns: &[String]) -> Result, AwsError> { + async fn describe(&self, c: &str, arns: &[String]) -> Result, AwsError> { + self.describe_clusters.lock().unwrap().push(c.into()); + { + let mut script = self.script.lock().unwrap(); + if let Some(first) = script.first().cloned().filter(|t| arns.contains(&t.arn)) { + if script.len() > 1 { + script.remove(0); + } + return Ok(vec![first]); + } + } let t = self.tasks.lock().unwrap(); Ok(arns.iter().filter_map(|a| t.get(a).cloned()).collect()) } - async fn list_project_tasks(&self, _c: &str, _f: &str) -> Result, AwsError> { + async fn list_project_tasks(&self, c: &str, _f: &str) -> Result, AwsError> { self.log("list"); + self.list_clusters.lock().unwrap().push(c.into()); + if let Some(by) = &self.listed_by_cluster { + return Ok(by.get(c).cloned().unwrap_or_default()); + } let mut l = self.listed.lock().unwrap(); Ok(if l.len() > 1 { l.remove(0) } else { l.first().cloned().unwrap_or_default() }) } - async fn stop_task(&self, _c: &str, arn: &str, reason: &str) -> Result<(), AwsError> { + async fn stop_task(&self, c: &str, arn: &str, reason: &str) -> Result<(), AwsError> { self.log(format!("stop {arn} {reason}")); + self.stop_clusters.lock().unwrap().push(c.into()); if self.stop_fails { return Err(AwsError::Other { message: "ExpiredToken".into() }); } @@ -213,6 +243,10 @@ impl RuntimeApi for Fake { self.log(format!("record {env}")); Ok(Some(record())) } + async fn user_record(&self, env: &str, _owner_key: &str) -> Result { + self.log(format!("user-record {env}")); + Ok(self.user_record.clone().unwrap_or(crate::aws::environments::Param::Missing)) + } async fn role_exists(&self, _name: &str) -> Result { self.log("role"); Ok(self.role.clone().unwrap_or(Knowable::Yes)) @@ -284,6 +318,10 @@ fn inputs<'a>( interval: Duration::from_millis(1), timeout: Duration::from_millis(30), }, + ec2_wait: WaitTiming { + interval: Duration::from_millis(1), + timeout: Duration::from_millis(30), + }, access_point_wait: PollTiming { interval: Duration::from_millis(1), timeout: Duration::from_millis(30), @@ -561,6 +599,20 @@ fn the_sandbox_is_forced_off_on_aws() { let settings = &pairs.iter().find(|(k, _)| k == "CLAUDE_CODE_SETTINGS_JSON").unwrap().1; let v: serde_json::Value = serde_json::from_str(settings).unwrap(); assert_eq!(v["sandbox"]["enabled"], false, "{settings}"); + assert!(!sandbox_allowed(&p)); +} + +/// E8: on the user's own EC2 instance the sandbox is left as the project +/// says (bubblewrap's user namespaces work on the ECS-optimized AMI). +#[test] +fn the_sandbox_stays_on_for_an_ec2_project() { + let mut p = ec2_project(); + p.sandbox_mode_enabled = true; + assert!(sandbox_allowed(&p)); + let (pairs, _) = aws_env(&p, &AppSettings::default()).unwrap(); + let settings = &pairs.iter().find(|(k, _)| k == "CLAUDE_CODE_SETTINGS_JSON").unwrap().1; + let v: serde_json::Value = serde_json::from_str(settings).unwrap(); + assert_eq!(v["sandbox"]["enabled"], true, "{settings}"); } #[test] @@ -636,7 +688,7 @@ async fn an_aws_projects_target_is_its_registered_tunnel() { } fn find(p: &Project) -> FindTask { - FindTask::new(p, REGION, USER) + FindTask::new(p, REGION, USER, None) } fn store_with(p: &Project) -> (tempfile::TempDir, ProjectsStore) { @@ -1241,3 +1293,220 @@ mod gateway_sidecar_inputs { } } + +// ------------------------------------------------------------- EC2 (phase 7) + +const USER_CLUSTER: &str = "triple-c-dev--u-alice"; + +fn user_cluster_arn() -> String { + format!("arn:aws:ecs:{REGION}:{ACCOUNT}:cluster/{USER_CLUSTER}") +} + +fn ec2_task_arn(id: &str) -> String { + format!("arn:aws:ecs:{REGION}:{ACCOUNT}:task/{USER_CLUSTER}/{id}") +} + +fn ec2_project() -> Project { + let mut p = aws_project(StorageMode::Ephemeral); + let a = p.aws.as_mut().unwrap(); + a.launch_type = LaunchType::Ec2; + a.cpu = 1024; + a.memory_mib = 4096; + p +} + +fn ec2_task(p: &Project, id: &str, last: &str, ready: bool, placed: bool) -> TaskInfo { + TaskInfo { + arn: ec2_task_arn(id), + container_instance_arn: placed.then(|| { + format!("arn:aws:ecs:{REGION}:{ACCOUNT}:container-instance/{USER_CLUSTER}/ci-1") + }), + ..task(p, id, last, ready) + } +} + +fn user_record_param() -> crate::aws::environments::Param { + crate::aws::environments::Param::Value( + serde_json::json!({ + "schema": 1, "instance_type": "m7i.large", "max_instances": 2, "user_tag": "alice", + "cluster_arn": user_cluster_arn(), + "capacity_provider": USER_CLUSTER, + }) + .to_string(), + ) +} + +#[tokio::test] +async fn an_ec2_start_runs_on_the_users_capacity_and_says_when_it_waits_for_an_instance() { + let p = ec2_project(); + let fake = Fake { + user_record: Some(user_record_param()), + run: Some(ec2_task(&p, "e1", "PROVISIONING", false, false)), + ..Default::default() + }; + // Cold start: no instance, then one is placed, then the task is up. + *fake.script.lock().unwrap() = vec![ + ec2_task(&p, "e1", "PROVISIONING", false, false), + ec2_task(&p, "e1", "PROVISIONING", false, false), + ec2_task(&p, "e1", "PENDING", false, true), + ec2_task(&p, "e1", "RUNNING", true, true), + ]; + let (r, steps) = start(&fake, &p).await; + let started = r.unwrap(); + assert!(started.created); + assert_eq!(started.task.arn, ec2_task_arn("e1")); + assert_eq!( + steps, + vec![ + PROGRESS_READING, + PROGRESS_PREPARING, + PROGRESS_STARTING, + PROGRESS_WAITING, + PROGRESS_INSTANCE, + PROGRESS_WAITING, + PROGRESS_CONNECTING + ] + ); + assert_eq!(PROGRESS_INSTANCE, "Starting an instance (about 3 minutes)…"); + // The record is read before anything is written; the project's task is + // looked for in both clusters, then once more where it will run. + let calls = fake.calls(); + let pos = |c: &str| calls.iter().position(|x| x == c).unwrap(); + assert!(pos("user-record dev") < pos("put-secret"), "{calls:?}"); + assert_eq!( + *fake.list_clusters.lock().unwrap(), + [cluster_arn(), user_cluster_arn(), user_cluster_arn()] + ); + let req = &fake.run_requests.lock().unwrap()[0]; + assert_eq!(req.cluster(), Some(user_cluster_arn().as_str())); + assert_eq!(req.capacity_provider_strategy()[0].capacity_provider(), USER_CLUSTER); + assert!(req.network_configuration().is_none() && req.launch_type().is_none()); + assert!(fake.describe_clusters.lock().unwrap().iter().all(|c| *c == user_cluster_arn())); +} + +#[tokio::test] +async fn a_fargate_start_never_reads_the_ec2_record() { + let p = aws_project(StorageMode::Ephemeral); + let fake = Fake { + user_record: Some(user_record_param()), + run: Some(task(&p, "f1", "RUNNING", true)), + ..Default::default() + }; + let (r, _) = start(&fake, &p).await; + r.unwrap(); + assert!(!fake.called("user-record")); + assert_eq!(*fake.list_clusters.lock().unwrap(), [cluster_arn(), cluster_arn()]); +} + +#[tokio::test] +async fn an_ec2_start_without_capacity_says_so_before_anything_is_written() { + let p = ec2_project(); + let fake = Fake::default(); + let (r, _) = start(&fake, &p).await; + let e = r.err().unwrap(); + assert_eq!( + e, + "You have no EC2 capacity in dev; ask an admin to add it to your onboarding (or run the \ + project on Fargate)." + ); + assert!(!fake.called("put-secret") && !fake.called("register") && !fake.called("run")); + + // A record that can't be used is not mistaken for none. + let fake = Fake { + user_record: Some(crate::aws::environments::Param::Value("{}".into())), + ..Default::default() + }; + let (r, _) = start(&fake, &p).await; + let e = r.err().unwrap(); + assert!(e.contains("can't be used") && e.contains("re-apply your onboarding"), "{e}"); + assert!(!fake.called("put-secret")); +} + +#[tokio::test] +async fn an_ec2_task_that_never_gets_an_instance_is_stopped_with_what_to_check() { + let p = ec2_project(); + let fake = Fake { + user_record: Some(user_record_param()), + run: Some(ec2_task(&p, "e2", "PROVISIONING", false, false)), + ..Default::default() + }; + let (r, steps) = start(&fake, &p).await; + let e = r.err().unwrap(); + assert!(e.contains("No EC2 instance had room"), "{e}"); + assert!(e.contains("maximum of 2 instances"), "{e}"); + assert!(steps.contains(&PROGRESS_INSTANCE.to_string())); + assert!(fake.calls().contains(&format!("stop {} {STOP_REASON}", ec2_task_arn("e2")))); + assert_eq!(*fake.stop_clusters.lock().unwrap(), [user_cluster_arn()]); + assert_eq!(*fake.recorded.lock().unwrap(), vec![Some(ec2_task_arn("e2")), None]); +} + +/// The record is gone (capacity removed) while the task still runs: the +/// stored ARN leads to it, and attaching needs no record. +#[tokio::test] +async fn a_running_ec2_task_is_attached_to_even_after_the_record_is_gone() { + let mut p = ec2_project(); + p.aws.as_mut().unwrap().task_arn = Some(ec2_task_arn("e3")); + let live = ec2_task(&p, "e3", "RUNNING", true, true); + let fake = Fake { + listed_by_cluster: Some(HashMap::from([(user_cluster_arn(), vec![live.arn.clone()])])), + ..Default::default() + } + .with_task(live); + let (r, _) = start(&fake, &p).await; + let started = r.unwrap(); + assert!(!started.created); + assert_eq!(started.task.arn, ec2_task_arn("e3")); + assert!(!fake.called("run") && !fake.called("put-secret")); + assert_eq!(*fake.list_clusters.lock().unwrap(), [cluster_arn(), user_cluster_arn()]); + assert!(fake.describe_clusters.lock().unwrap().iter().all(|c| *c == user_cluster_arn())); +} + +#[tokio::test] +async fn an_ec2_projects_task_is_found_and_watched_on_the_users_cluster() { + // FindTask: the environment's cluster, the record's, and the stored + // task's per-user cluster, without repeats. + let mut p = ec2_project(); + let f = FindTask::new(&p, REGION, USER, Some(user_cluster_arn())); + assert_eq!(f.clusters, ["triple-c-dev".to_string(), user_cluster_arn()]); + p.aws.as_mut().unwrap().task_arn = Some(ec2_task_arn("e4")); + assert_eq!(find(&p).clusters, ["triple-c-dev".to_string(), user_cluster_arn()]); + let f = FindTask::new(&p, REGION, USER, Some(user_cluster_arn())); + assert_eq!(f.clusters.len(), 2); + + // Reconcile with no ARN stored finds the task on the user's cluster. + let mut orphan = ec2_project(); + orphan.status = ProjectStatus::Running; + let live = ec2_task(&orphan, "e5", "RUNNING", true, true); + let fake = Fake { + listed_by_cluster: Some(HashMap::from([(user_cluster_arn(), vec![live.arn.clone()])])), + ..Default::default() + } + .with_task(live); + let (_d, store) = store_with(&orphan); + let find = FindTask::new(&orphan, REGION, USER, Some(user_cluster_arn())); + assert!(matches!( + reconcile_project(&fake, &store, &orphan, &find).await.unwrap(), + Reconciled::Live(_) + )); + assert_eq!(store.get(&orphan.id).unwrap().aws.unwrap().task_arn, Some(ec2_task_arn("e5"))); + + // The watch groups by the task's own cluster. + let mut running = ec2_project(); + running.status = ProjectStatus::Running; + running.container_id = Some("http://127.0.0.1:61301/".into()); + running.aws.as_mut().unwrap().task_arn = Some(ec2_task_arn("e6")); + let w = watched_task(&running).expect("watched"); + assert_eq!(w.group.cluster_arn, user_cluster_arn()); + let mut fargate = aws_project(StorageMode::Ephemeral); + fargate.status = ProjectStatus::Running; + fargate.container_id = Some("http://127.0.0.1:61302/".into()); + fargate.aws.as_mut().unwrap().task_arn = Some(task_arn("f6")); + assert_ne!(watched_task(&fargate).unwrap().group, w.group); +} + +#[tokio::test] +async fn stopping_an_ec2_task_by_its_arn_uses_its_cluster() { + let fake = Fake::default(); + stop_task_arn(&fake, &ec2_task_arn("e7")).await.unwrap(); + assert_eq!(*fake.stop_clusters.lock().unwrap(), [USER_CLUSTER]); +} diff --git a/app/src-tauri/src/models/project.rs b/app/src-tauri/src/models/project.rs index 000f91f..e35b311 100644 --- a/app/src-tauri/src/models/project.rs +++ b/app/src-tauri/src/models/project.rs @@ -801,13 +801,23 @@ pub enum Fit { UnknownType, } +/// Memory (MiB) an instance of `memory_mib` nominal memory keeps from tasks +/// in [`fits_instance`]: a tenth of it (what ECS doesn't register, with +/// room to spare), and never less than [`EC2_RESERVED_MEMORY_MIB`]. +pub fn ec2_memory_reserve_mib(memory_mib: u32) -> u32 { + (memory_mib / 10).max(EC2_RESERVED_MEMORY_MIB) +} + /// Check an EC2 config's reservations against `instance_type`, less the agent /// and OS reserve. A Fargate config always fits (no instance involved). /// -/// Nominal sizes only: ECS registers less memory than the instance's nominal -/// (the ECS-optimized AMI reserves some, e.g. ~7.5 GiB on an 8 GiB type), so a -/// later task should leave headroom or use the container instance's -/// registered memory. +/// Nominal sizes only, so memory keeps a margin: ECS registers less memory +/// than the instance's nominal (the ECS-optimized AMI and kernel keep some — +/// about 7.5 GiB of an 8 GiB type is registered), and a task asking for more +/// than the registered amount stays PROVISIONING with nothing able to place +/// it. The registered figure can't be read before an instance exists (scale +/// to zero), so the reserve is [`ec2_memory_reserve_mib`]: 10 % of the +/// nominal memory, at least [`EC2_RESERVED_MEMORY_MIB`]. pub fn fits_instance(cfg: &AwsWorkspaceConfig, instance_type: &str) -> Fit { if cfg.launch_type != LaunchType::Ec2 { return Fit::Ok; @@ -816,7 +826,7 @@ pub fn fits_instance(cfg: &AwsWorkspaceConfig, instance_type: &str) -> Fit { return Fit::UnknownType; }; let available_cpu = cpu - EC2_RESERVED_CPU_UNITS; - let available_memory_mib = mem - EC2_RESERVED_MEMORY_MIB; + let available_memory_mib = mem - ec2_memory_reserve_mib(mem); if cfg.cpu > available_cpu || cfg.memory_mib > available_memory_mib { Fit::TooBig { available_cpu, available_memory_mib } } else { @@ -1659,13 +1669,18 @@ mod tests { #[test] fn fit_checks_reserve_for_the_agent() { - // m7i.large: 2048 / 8192 less 128 / 256. - assert_eq!(fits_instance(&ec2(1920, 7936), "m7i.large"), Fit::Ok); + // m7i.large: 2048 / 8192 less 128 CPU units and 10 % of the memory + // (819 MiB: ECS registers less than the nominal 8 GiB). + assert_eq!(fits_instance(&ec2(1920, 7373), "m7i.large"), Fit::Ok); assert_eq!( fits_instance(&ec2(1921, 4096), "m7i.large"), - Fit::TooBig { available_cpu: 1920, available_memory_mib: 7936 } + Fit::TooBig { available_cpu: 1920, available_memory_mib: 7373 } ); - assert!(matches!(fits_instance(&ec2(1024, 7937), "m7i.large"), Fit::TooBig { .. })); + assert!(matches!(fits_instance(&ec2(1024, 7374), "m7i.large"), Fit::TooBig { .. })); + // The reserve is never under the agent's 256 MiB, and grows with + // the instance (r7i.4xlarge: 128 GiB nominal). + assert_eq!(ec2_memory_reserve_mib(2048), 256); + assert_eq!(ec2_memory_reserve_mib(131072), 13107); assert_eq!(fits_instance(&ec2(1024, 2048), "z9.huge"), Fit::UnknownType); // Fargate configs have no instance to fit. assert_eq!(fits_instance(&cfg(16384, 122880), "m7i.large"), Fit::Ok); -- 2.52.0 From 9e1a63cde56e38fcc5eb6ca69523dd4a27217380 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 15:03:57 -0800 Subject: [PATCH 12/29] feat(aws): EC2 projects in the UI, Docker access and VPN Host settings get the launch-type control (Fargate | EC2 with the user's instance type, disabled with the reason when their onboarding has no EC2 capacity), switching through launchTypePatch, which now also clears the gateway sidecar and Spot for EC2 and snaps sizes per side. EC2 projects size CPU/memory reservations checked by Rust's fit rule (ec2_fit_problem, new command) against the user's record (aws_ec2_capacity, new command); no ephemeral size, Spot or architecture; notes for scale-to-zero, Docker access as root on the instance and no sidecar. The sandbox follows the project on EC2. The cost estimate prices an EC2 project as its instance type's AmazonEC2 on-demand Linux shared-tenancy price (recorded fixture), cached per region and type with the Fargate cache's rules. The entrypoint's Docker-socket group step now runs in aws mode when the socket exists; the VPN skill follows VPN_SUPPORT_ENABLED there as on Docker. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 3 + app/src-tauri/capabilities/default.json | 2 + app/src-tauri/gen/schemas/acl-manifests.json | 2 +- app/src-tauri/gen/schemas/capabilities.json | 2 +- app/src-tauri/gen/schemas/desktop-schema.json | 24 ++ app/src-tauri/gen/schemas/linux-schema.json | 24 ++ app/src-tauri/src/aws/live_tests.rs | 6 + app/src-tauri/src/aws/pricing.rs | 301 +++++++++++++++--- .../fixtures/ec2-get-products-us-west-2.json | 7 + app/src-tauri/src/aws/pricing/tests.rs | 200 +++++++++++- app/src-tauri/src/aws/workspace.rs | 14 +- app/src-tauri/src/commands/host_commands.rs | 96 +++++- .../src/commands/project_commands.rs | 23 ++ app/src-tauri/src/docker/aws_mode_tests.rs | 88 +++++ app/src-tauri/src/host/aws_host.rs | 54 ++++ app/src-tauri/src/host/aws_host/tests.rs | 48 +++ app/src-tauri/src/lib.rs | 2 + app/src-tauri/src/models/project.rs | 45 ++- .../projects/home/AwsCostEstimate.test.tsx | 41 ++- .../projects/home/AwsCostEstimate.tsx | 26 +- .../components/projects/home/OverviewTab.tsx | 7 + .../projects/home/config/AwsConfig.test.tsx | 175 +++++++++- .../projects/home/config/HostSection.tsx | 195 +++++++++++- .../projects/home/config/RuntimeSection.tsx | 23 +- .../settings/hosts/EnvironmentsPanel.tsx | 4 + .../components/ui/SegmentedControl.test.tsx | 45 +++ app/src/components/ui/SegmentedControl.tsx | 19 +- app/src/lib/awsWorkspace.test.ts | 48 ++- app/src/lib/awsWorkspace.ts | 55 +++- app/src/lib/ec2Capacity.test.ts | 56 ++++ app/src/lib/ec2Capacity.ts | 73 +++++ app/src/lib/tauri-commands.ts | 16 +- app/src/lib/types.ts | 17 + container/entrypoint.sh | 8 +- 34 files changed, 1630 insertions(+), 119 deletions(-) create mode 100644 app/src-tauri/src/aws/pricing/fixtures/ec2-get-products-us-west-2.json create mode 100644 app/src/components/ui/SegmentedControl.test.tsx create mode 100644 app/src/lib/ec2Capacity.test.ts create mode 100644 app/src/lib/ec2Capacity.ts diff --git a/CLAUDE.md b/CLAUDE.md index c3a047c..72413c0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -384,6 +384,9 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li `FILTERS`) → per-region x86/ARM rates cached at `/triple-c/aws-pricing/.json` for 24 h; `aws_cost_estimate(connection_id, region, config)` never errors — denied/offline/slow (8 s) is `None` ("Estimate unavailable"), a failed region isn't re-asked for 5 min, a stale cache still answers. + 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 `--ec2-.json` + with the same rules — the instance's price, not the reservations. **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/` record, owner key — `sha256(":")`, diff --git a/app/src-tauri/capabilities/default.json b/app/src-tauri/capabilities/default.json index 4dfe397..2d613db 100644 --- a/app/src-tauri/capabilities/default.json +++ b/app/src-tauri/capabilities/default.json @@ -22,6 +22,8 @@ "allow-aws-task-log", "allow-aws-workspace-status", "allow-aws-environment-max-hours", + "allow-aws-ec2-capacity", + "allow-ec2-fit-problem", "allow-remove-aws-resources", "allow-rebuild-project-container", "allow-reconcile-project-statuses", diff --git a/app/src-tauri/gen/schemas/acl-manifests.json b/app/src-tauri/gen/schemas/acl-manifests.json index 8956c25..f370332 100644 --- a/app/src-tauri/gen/schemas/acl-manifests.json +++ b/app/src-tauri/gen/schemas/acl-manifests.json @@ -1 +1 @@ -{"__app-acl__":{"default_permission":null,"permissions":{"allow-acquire-claude-token":{"identifier":"allow-acquire-claude-token","description":"Enables the acquire_claude_token command without any pre-configured scope.","commands":{"allow":["acquire_claude_token"],"deny":[]}},"allow-add-aws-keys-connection":{"identifier":"allow-add-aws-keys-connection","description":"Enables the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":["add_aws_keys_connection"],"deny":[]}},"allow-add-aws-profile-connection":{"identifier":"allow-add-aws-profile-connection","description":"Enables the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":["add_aws_profile_connection"],"deny":[]}},"allow-add-marketplace":{"identifier":"allow-add-marketplace","description":"Enables the add_marketplace command without any pre-configured scope.","commands":{"allow":["add_marketplace"],"deny":[]}},"allow-add-marketplace-gh-host-account":{"identifier":"allow-add-marketplace-gh-host-account","description":"Enables the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_gh_host_account"],"deny":[]}},"allow-add-marketplace-token-account":{"identifier":"allow-add-marketplace-token-account","description":"Enables the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_token_account"],"deny":[]}},"allow-add-project":{"identifier":"allow-add-project","description":"Enables the add_project command without any pre-configured scope.","commands":{"allow":["add_project"],"deny":[]}},"allow-add-scheduled-task":{"identifier":"allow-add-scheduled-task","description":"Enables the add_scheduled_task command without any pre-configured scope.","commands":{"allow":["add_scheduled_task"],"deny":[]}},"allow-apply-marketplace-now":{"identifier":"allow-apply-marketplace-now","description":"Enables the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":["apply_marketplace_now"],"deny":[]}},"allow-apply-settings-import":{"identifier":"allow-apply-settings-import","description":"Enables the apply_settings_import command without any pre-configured scope.","commands":{"allow":["apply_settings_import"],"deny":[]}},"allow-aws-connection-identity":{"identifier":"allow-aws-connection-identity","description":"Enables the aws_connection_identity command without any pre-configured scope.","commands":{"allow":["aws_connection_identity"],"deny":[]}},"allow-aws-connection-sso-login":{"identifier":"allow-aws-connection-sso-login","description":"Enables the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":["aws_connection_sso_login"],"deny":[]}},"allow-aws-cost-estimate":{"identifier":"allow-aws-cost-estimate","description":"Enables the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":["aws_cost_estimate"],"deny":[]}},"allow-aws-environment-max-hours":{"identifier":"allow-aws-environment-max-hours","description":"Enables the aws_environment_max_hours command without any pre-configured scope.","commands":{"allow":["aws_environment_max_hours"],"deny":[]}},"allow-aws-policy-document":{"identifier":"allow-aws-policy-document","description":"Enables the aws_policy_document command without any pre-configured scope.","commands":{"allow":["aws_policy_document"],"deny":[]}},"allow-aws-sso-refresh":{"identifier":"allow-aws-sso-refresh","description":"Enables the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":["aws_sso_refresh"],"deny":[]}},"allow-aws-task-log":{"identifier":"allow-aws-task-log","description":"Enables the aws_task_log command without any pre-configured scope.","commands":{"allow":["aws_task_log"],"deny":[]}},"allow-aws-workspace-status":{"identifier":"allow-aws-workspace-status","description":"Enables the aws_workspace_status command without any pre-configured scope.","commands":{"allow":["aws_workspace_status"],"deny":[]}},"allow-build-gateway-image":{"identifier":"allow-build-gateway-image","description":"Enables the build_gateway_image command without any pre-configured scope.","commands":{"allow":["build_gateway_image"],"deny":[]}},"allow-build-image":{"identifier":"allow-build-image","description":"Enables the build_image command without any pre-configured scope.","commands":{"allow":["build_image"],"deny":[]}},"allow-build-stt-image":{"identifier":"allow-build-stt-image","description":"Enables the build_stt_image command without any pre-configured scope.","commands":{"allow":["build_stt_image"],"deny":[]}},"allow-cancel-aws-deployment":{"identifier":"allow-cancel-aws-deployment","description":"Enables the cancel_aws_deployment command without any pre-configured scope.","commands":{"allow":["cancel_aws_deployment"],"deny":[]}},"allow-cancel-claude-token":{"identifier":"allow-cancel-claude-token","description":"Enables the cancel_claude_token command without any pre-configured scope.","commands":{"allow":["cancel_claude_token"],"deny":[]}},"allow-cancel-marketplace-gh-login":{"identifier":"allow-cancel-marketplace-gh-login","description":"Enables the cancel_marketplace_gh_login command without any pre-configured scope.","commands":{"allow":["cancel_marketplace_gh_login"],"deny":[]}},"allow-check-aws-permissions":{"identifier":"allow-check-aws-permissions","description":"Enables the check_aws_permissions command without any pre-configured scope.","commands":{"allow":["check_aws_permissions"],"deny":[]}},"allow-check-browser-view-support":{"identifier":"allow-check-browser-view-support","description":"Enables the check_browser_view_support command without any pre-configured scope.","commands":{"allow":["check_browser_view_support"],"deny":[]}},"allow-check-docker":{"identifier":"allow-check-docker","description":"Enables the check_docker command without any pre-configured scope.","commands":{"allow":["check_docker"],"deny":[]}},"allow-check-for-updates":{"identifier":"allow-check-for-updates","description":"Enables the check_for_updates command without any pre-configured scope.","commands":{"allow":["check_for_updates"],"deny":[]}},"allow-check-gateway-health":{"identifier":"allow-check-gateway-health","description":"Enables the check_gateway_health command without any pre-configured scope.","commands":{"allow":["check_gateway_health"],"deny":[]}},"allow-check-image-exists":{"identifier":"allow-check-image-exists","description":"Enables the check_image_exists command without any pre-configured scope.","commands":{"allow":["check_image_exists"],"deny":[]}},"allow-check-image-update":{"identifier":"allow-check-image-update","description":"Enables the check_image_update command without any pre-configured scope.","commands":{"allow":["check_image_update"],"deny":[]}},"allow-check-unsaved-work":{"identifier":"allow-check-unsaved-work","description":"Enables the check_unsaved_work command without any pre-configured scope.","commands":{"allow":["check_unsaved_work"],"deny":[]}},"allow-clear-claude-token":{"identifier":"allow-clear-claude-token","description":"Enables the clear_claude_token command without any pre-configured scope.","commands":{"allow":["clear_claude_token"],"deny":[]}},"allow-clear-gateway-api-key":{"identifier":"allow-clear-gateway-api-key","description":"Enables the clear_gateway_api_key command without any pre-configured scope.","commands":{"allow":["clear_gateway_api_key"],"deny":[]}},"allow-clear-scheduler-notifications":{"identifier":"allow-clear-scheduler-notifications","description":"Enables the clear_scheduler_notifications command without any pre-configured scope.","commands":{"allow":["clear_scheduler_notifications"],"deny":[]}},"allow-close-browser-view-popout":{"identifier":"allow-close-browser-view-popout","description":"Enables the close_browser_view_popout command without any pre-configured scope.","commands":{"allow":["close_browser_view_popout"],"deny":[]}},"allow-close-container-page":{"identifier":"allow-close-container-page","description":"Enables the close_container_page command without any pre-configured scope.","commands":{"allow":["close_container_page"],"deny":[]}},"allow-close-terminal-session":{"identifier":"allow-close-terminal-session","description":"Enables the close_terminal_session command without any pre-configured scope.","commands":{"allow":["close_terminal_session"],"deny":[]}},"allow-confirm-migration":{"identifier":"allow-confirm-migration","description":"Enables the confirm_migration command without any pre-configured scope.","commands":{"allow":["confirm_migration"],"deny":[]}},"allow-create-container-directory":{"identifier":"allow-create-container-directory","description":"Enables the create_container_directory command without any pre-configured scope.","commands":{"allow":["create_container_directory"],"deny":[]}},"allow-delete-note":{"identifier":"allow-delete-note","description":"Enables the delete_note command without any pre-configured scope.","commands":{"allow":["delete_note"],"deny":[]}},"allow-deploy-aws-environment":{"identifier":"allow-deploy-aws-environment","description":"Enables the deploy_aws_environment command without any pre-configured scope.","commands":{"allow":["deploy_aws_environment"],"deny":[]}},"allow-deploy-aws-permissions-boundary":{"identifier":"allow-deploy-aws-permissions-boundary","description":"Enables the deploy_aws_permissions_boundary command without any pre-configured scope.","commands":{"allow":["deploy_aws_permissions_boundary"],"deny":[]}},"allow-destroy-incomplete-aws-environment":{"identifier":"allow-destroy-incomplete-aws-environment","description":"Enables the destroy_incomplete_aws_environment command without any pre-configured scope.","commands":{"allow":["destroy_incomplete_aws_environment"],"deny":[]}},"allow-detect-aws-config":{"identifier":"allow-detect-aws-config","description":"Enables the detect_aws_config command without any pre-configured scope.","commands":{"allow":["detect_aws_config"],"deny":[]}},"allow-detect-aws-environments":{"identifier":"allow-detect-aws-environments","description":"Enables the detect_aws_environments command without any pre-configured scope.","commands":{"allow":["detect_aws_environments"],"deny":[]}},"allow-detect-host-timezone":{"identifier":"allow-detect-host-timezone","description":"Enables the detect_host_timezone command without any pre-configured scope.","commands":{"allow":["detect_host_timezone"],"deny":[]}},"allow-detect-install-options":{"identifier":"allow-detect-install-options","description":"Enables the detect_install_options command without any pre-configured scope.","commands":{"allow":["detect_install_options"],"deny":[]}},"allow-download-container-backup":{"identifier":"allow-download-container-backup","description":"Enables the download_container_backup command without any pre-configured scope.","commands":{"allow":["download_container_backup"],"deny":[]}},"allow-download-container-file":{"identifier":"allow-download-container-file","description":"Enables the download_container_file command without any pre-configured scope.","commands":{"allow":["download_container_file"],"deny":[]}},"allow-export-settings":{"identifier":"allow-export-settings","description":"Enables the export_settings command without any pre-configured scope.","commands":{"allow":["export_settings"],"deny":[]}},"allow-follow-aws-deployment":{"identifier":"allow-follow-aws-deployment","description":"Enables the follow_aws_deployment command without any pre-configured scope.","commands":{"allow":["follow_aws_deployment"],"deny":[]}},"allow-forget-marketplace-installs":{"identifier":"allow-forget-marketplace-installs","description":"Enables the forget_marketplace_installs command without any pre-configured scope.","commands":{"allow":["forget_marketplace_installs"],"deny":[]}},"allow-get-app-version":{"identifier":"allow-get-app-version","description":"Enables the get_app_version command without any pre-configured scope.","commands":{"allow":["get_app_version"],"deny":[]}},"allow-get-auth-bridge-status":{"identifier":"allow-get-auth-bridge-status","description":"Enables the get_auth_bridge_status command without any pre-configured scope.","commands":{"allow":["get_auth_bridge_status"],"deny":[]}},"allow-get-browser-view-match-window":{"identifier":"allow-get-browser-view-match-window","description":"Enables the get_browser_view_match_window command without any pre-configured scope.","commands":{"allow":["get_browser_view_match_window"],"deny":[]}},"allow-get-browser-view-popout-state":{"identifier":"allow-get-browser-view-popout-state","description":"Enables the get_browser_view_popout_state command without any pre-configured scope.","commands":{"allow":["get_browser_view_popout_state"],"deny":[]}},"allow-get-browser-view-status":{"identifier":"allow-get-browser-view-status","description":"Enables the get_browser_view_status command without any pre-configured scope.","commands":{"allow":["get_browser_view_status"],"deny":[]}},"allow-get-container-info":{"identifier":"allow-get-container-info","description":"Enables the get_container_info command without any pre-configured scope.","commands":{"allow":["get_container_info"],"deny":[]}},"allow-get-container-page-state":{"identifier":"allow-get-container-page-state","description":"Enables the get_container_page_state command without any pre-configured scope.","commands":{"allow":["get_container_page_state"],"deny":[]}},"allow-get-container-staleness":{"identifier":"allow-get-container-staleness","description":"Enables the get_container_staleness command without any pre-configured scope.","commands":{"allow":["get_container_staleness"],"deny":[]}},"allow-get-gateway-auth-token":{"identifier":"allow-get-gateway-auth-token","description":"Enables the get_gateway_auth_token command without any pre-configured scope.","commands":{"allow":["get_gateway_auth_token"],"deny":[]}},"allow-get-gateway-status":{"identifier":"allow-get-gateway-status","description":"Enables the get_gateway_status command without any pre-configured scope.","commands":{"allow":["get_gateway_status"],"deny":[]}},"allow-get-help-content":{"identifier":"allow-get-help-content","description":"Enables the get_help_content command without any pre-configured scope.","commands":{"allow":["get_help_content"],"deny":[]}},"allow-get-marketplace-sync-report":{"identifier":"allow-get-marketplace-sync-report","description":"Enables the get_marketplace_sync_report command without any pre-configured scope.","commands":{"allow":["get_marketplace_sync_report"],"deny":[]}},"allow-get-migration-state":{"identifier":"allow-get-migration-state","description":"Enables the get_migration_state command without any pre-configured scope.","commands":{"allow":["get_migration_state"],"deny":[]}},"allow-get-scheduled-task-log":{"identifier":"allow-get-scheduled-task-log","description":"Enables the get_scheduled_task_log command without any pre-configured scope.","commands":{"allow":["get_scheduled_task_log"],"deny":[]}},"allow-get-scheduler-notifications":{"identifier":"allow-get-scheduler-notifications","description":"Enables the get_scheduler_notifications command without any pre-configured scope.","commands":{"allow":["get_scheduler_notifications"],"deny":[]}},"allow-get-settings":{"identifier":"allow-get-settings","description":"Enables the get_settings command without any pre-configured scope.","commands":{"allow":["get_settings"],"deny":[]}},"allow-get-stt-status":{"identifier":"allow-get-stt-status","description":"Enables the get_stt_status command without any pre-configured scope.","commands":{"allow":["get_stt_status"],"deny":[]}},"allow-get-web-terminal-status":{"identifier":"allow-get-web-terminal-status","description":"Enables the get_web_terminal_status command without any pre-configured scope.","commands":{"allow":["get_web_terminal_status"],"deny":[]}},"allow-has-claude-token":{"identifier":"allow-has-claude-token","description":"Enables the has_claude_token command without any pre-configured scope.","commands":{"allow":["has_claude_token"],"deny":[]}},"allow-inspect-ca-cert-path":{"identifier":"allow-inspect-ca-cert-path","description":"Enables the inspect_ca_cert_path command without any pre-configured scope.","commands":{"allow":["inspect_ca_cert_path"],"deny":[]}},"allow-install-browser-view-browser":{"identifier":"allow-install-browser-view-browser","description":"Enables the install_browser_view_browser command without any pre-configured scope.","commands":{"allow":["install_browser_view_browser"],"deny":[]}},"allow-install-browser-view-support":{"identifier":"allow-install-browser-view-support","description":"Enables the install_browser_view_support command without any pre-configured scope.","commands":{"allow":["install_browser_view_support"],"deny":[]}},"allow-install-marketplace-item":{"identifier":"allow-install-marketplace-item","description":"Enables the install_marketplace_item command without any pre-configured scope.","commands":{"allow":["install_marketplace_item"],"deny":[]}},"allow-list-aws-profiles":{"identifier":"allow-list-aws-profiles","description":"Enables the list_aws_profiles command without any pre-configured scope.","commands":{"allow":["list_aws_profiles"],"deny":[]}},"allow-list-claude-sessions":{"identifier":"allow-list-claude-sessions","description":"Enables the list_claude_sessions command without any pre-configured scope.","commands":{"allow":["list_claude_sessions"],"deny":[]}},"allow-list-container-capabilities":{"identifier":"allow-list-container-capabilities","description":"Enables the list_container_capabilities command without any pre-configured scope.","commands":{"allow":["list_container_capabilities"],"deny":[]}},"allow-list-container-files":{"identifier":"allow-list-container-files","description":"Enables the list_container_files command without any pre-configured scope.","commands":{"allow":["list_container_files"],"deny":[]}},"allow-list-ec2-instance-types":{"identifier":"allow-list-ec2-instance-types","description":"Enables the list_ec2_instance_types command without any pre-configured scope.","commands":{"allow":["list_ec2_instance_types"],"deny":[]}},"allow-list-marketplace-snapshots":{"identifier":"allow-list-marketplace-snapshots","description":"Enables the list_marketplace_snapshots command without any pre-configured scope.","commands":{"allow":["list_marketplace_snapshots"],"deny":[]}},"allow-list-marketplace-updates":{"identifier":"allow-list-marketplace-updates","description":"Enables the list_marketplace_updates command without any pre-configured scope.","commands":{"allow":["list_marketplace_updates"],"deny":[]}},"allow-list-notes":{"identifier":"allow-list-notes","description":"Enables the list_notes command without any pre-configured scope.","commands":{"allow":["list_notes"],"deny":[]}},"allow-list-projects":{"identifier":"allow-list-projects","description":"Enables the list_projects command without any pre-configured scope.","commands":{"allow":["list_projects"],"deny":[]}},"allow-list-scheduled-tasks":{"identifier":"allow-list-scheduled-tasks","description":"Enables the list_scheduled_tasks command without any pre-configured scope.","commands":{"allow":["list_scheduled_tasks"],"deny":[]}},"allow-marketplace-gh-host-available":{"identifier":"allow-marketplace-gh-host-available","description":"Enables the marketplace_gh_host_available command without any pre-configured scope.","commands":{"allow":["marketplace_gh_host_available"],"deny":[]}},"allow-marketplace-item-diff":{"identifier":"allow-marketplace-item-diff","description":"Enables the marketplace_item_diff command without any pre-configured scope.","commands":{"allow":["marketplace_item_diff"],"deny":[]}},"allow-migrate-project-to-base":{"identifier":"allow-migrate-project-to-base","description":"Enables the migrate_project_to_base command without any pre-configured scope.","commands":{"allow":["migrate_project_to_base"],"deny":[]}},"allow-onboard-aws-user":{"identifier":"allow-onboard-aws-user","description":"Enables the onboard_aws_user command without any pre-configured scope.","commands":{"allow":["onboard_aws_user"],"deny":[]}},"allow-open-browser-view-popout":{"identifier":"allow-open-browser-view-popout","description":"Enables the open_browser_view_popout command without any pre-configured scope.","commands":{"allow":["open_browser_view_popout"],"deny":[]}},"allow-open-file-viewer":{"identifier":"allow-open-file-viewer","description":"Enables the open_file_viewer command without any pre-configured scope.","commands":{"allow":["open_file_viewer"],"deny":[]}},"allow-open-page-in-container-browser":{"identifier":"allow-open-page-in-container-browser","description":"Enables the open_page_in_container_browser command without any pre-configured scope.","commands":{"allow":["open_page_in_container_browser"],"deny":[]}},"allow-open-terminal-session":{"identifier":"allow-open-terminal-session","description":"Enables the open_terminal_session command without any pre-configured scope.","commands":{"allow":["open_terminal_session"],"deny":[]}},"allow-open-url-external":{"identifier":"allow-open-url-external","description":"Enables the open_url_external command without any pre-configured scope.","commands":{"allow":["open_url_external"],"deny":[]}},"allow-paste-image-to-terminal":{"identifier":"allow-paste-image-to-terminal","description":"Enables the paste_image_to_terminal command without any pre-configured scope.","commands":{"allow":["paste_image_to_terminal"],"deny":[]}},"allow-preview-settings-import":{"identifier":"allow-preview-settings-import","description":"Enables the preview_settings_import command without any pre-configured scope.","commands":{"allow":["preview_settings_import"],"deny":[]}},"allow-pull-gateway-image":{"identifier":"allow-pull-gateway-image","description":"Enables the pull_gateway_image command without any pre-configured scope.","commands":{"allow":["pull_gateway_image"],"deny":[]}},"allow-pull-image":{"identifier":"allow-pull-image","description":"Enables the pull_image command without any pre-configured scope.","commands":{"allow":["pull_image"],"deny":[]}},"allow-pull-stt-image":{"identifier":"allow-pull-stt-image","description":"Enables the pull_stt_image command without any pre-configured scope.","commands":{"allow":["pull_stt_image"],"deny":[]}},"allow-push-aws-saved-state":{"identifier":"allow-push-aws-saved-state","description":"Enables the push_aws_saved_state command without any pre-configured scope.","commands":{"allow":["push_aws_saved_state"],"deny":[]}},"allow-read-container-file":{"identifier":"allow-read-container-file","description":"Enables the read_container_file command without any pre-configured scope.","commands":{"allow":["read_container_file"],"deny":[]}},"allow-rebuild-project-container":{"identifier":"allow-rebuild-project-container","description":"Enables the rebuild_project_container command without any pre-configured scope.","commands":{"allow":["rebuild_project_container"],"deny":[]}},"allow-reconcile-aws-projects":{"identifier":"allow-reconcile-aws-projects","description":"Enables the reconcile_aws_projects command without any pre-configured scope.","commands":{"allow":["reconcile_aws_projects"],"deny":[]}},"allow-reconcile-project-statuses":{"identifier":"allow-reconcile-project-statuses","description":"Enables the reconcile_project_statuses command without any pre-configured scope.","commands":{"allow":["reconcile_project_statuses"],"deny":[]}},"allow-refresh-marketplaces":{"identifier":"allow-refresh-marketplaces","description":"Enables the refresh_marketplaces command without any pre-configured scope.","commands":{"allow":["refresh_marketplaces"],"deny":[]}},"allow-regenerate-gateway-auth-token":{"identifier":"allow-regenerate-gateway-auth-token","description":"Enables the regenerate_gateway_auth_token command without any pre-configured scope.","commands":{"allow":["regenerate_gateway_auth_token"],"deny":[]}},"allow-regenerate-web-terminal-token":{"identifier":"allow-regenerate-web-terminal-token","description":"Enables the regenerate_web_terminal_token command without any pre-configured scope.","commands":{"allow":["regenerate_web_terminal_token"],"deny":[]}},"allow-remove-aws-resources":{"identifier":"allow-remove-aws-resources","description":"Enables the remove_aws_resources command without any pre-configured scope.","commands":{"allow":["remove_aws_resources"],"deny":[]}},"allow-remove-host-connection":{"identifier":"allow-remove-host-connection","description":"Enables the remove_host_connection command without any pre-configured scope.","commands":{"allow":["remove_host_connection"],"deny":[]}},"allow-remove-marketplace":{"identifier":"allow-remove-marketplace","description":"Enables the remove_marketplace command without any pre-configured scope.","commands":{"allow":["remove_marketplace"],"deny":[]}},"allow-remove-marketplace-account":{"identifier":"allow-remove-marketplace-account","description":"Enables the remove_marketplace_account command without any pre-configured scope.","commands":{"allow":["remove_marketplace_account"],"deny":[]}},"allow-remove-project":{"identifier":"allow-remove-project","description":"Enables the remove_project command without any pre-configured scope.","commands":{"allow":["remove_project"],"deny":[]}},"allow-remove-scheduled-task":{"identifier":"allow-remove-scheduled-task","description":"Enables the remove_scheduled_task command without any pre-configured scope.","commands":{"allow":["remove_scheduled_task"],"deny":[]}},"allow-rename-container-path":{"identifier":"allow-rename-container-path","description":"Enables the rename_container_path command without any pre-configured scope.","commands":{"allow":["rename_container_path"],"deny":[]}},"allow-repair-aws-environment":{"identifier":"allow-repair-aws-environment","description":"Enables the repair_aws_environment command without any pre-configured scope.","commands":{"allow":["repair_aws_environment"],"deny":[]}},"allow-rollback-migration":{"identifier":"allow-rollback-migration","description":"Enables the rollback_migration command without any pre-configured scope.","commands":{"allow":["rollback_migration"],"deny":[]}},"allow-run-docker-install":{"identifier":"allow-run-docker-install","description":"Enables the run_docker_install command without any pre-configured scope.","commands":{"allow":["run_docker_install"],"deny":[]}},"allow-run-scheduled-task-now":{"identifier":"allow-run-scheduled-task-now","description":"Enables the run_scheduled_task_now command without any pre-configured scope.","commands":{"allow":["run_scheduled_task_now"],"deny":[]}},"allow-save-aws-admin-bundle":{"identifier":"allow-save-aws-admin-bundle","description":"Enables the save_aws_admin_bundle command without any pre-configured scope.","commands":{"allow":["save_aws_admin_bundle"],"deny":[]}},"allow-save-note":{"identifier":"allow-save-note","description":"Enables the save_note command without any pre-configured scope.","commands":{"allow":["save_note"],"deny":[]}},"allow-send-audio-data":{"identifier":"allow-send-audio-data","description":"Enables the send_audio_data command without any pre-configured scope.","commands":{"allow":["send_audio_data"],"deny":[]}},"allow-set-auth-bridge-enabled":{"identifier":"allow-set-auth-bridge-enabled","description":"Enables the set_auth_bridge_enabled command without any pre-configured scope.","commands":{"allow":["set_auth_bridge_enabled"],"deny":[]}},"allow-set-browser-view-enabled":{"identifier":"allow-set-browser-view-enabled","description":"Enables the set_browser_view_enabled command without any pre-configured scope.","commands":{"allow":["set_browser_view_enabled"],"deny":[]}},"allow-set-browser-view-match-window":{"identifier":"allow-set-browser-view-match-window","description":"Enables the set_browser_view_match_window command without any pre-configured scope.","commands":{"allow":["set_browser_view_match_window"],"deny":[]}},"allow-set-browser-view-popout-always-on-top":{"identifier":"allow-set-browser-view-popout-always-on-top","description":"Enables the set_browser_view_popout_always_on_top command without any pre-configured scope.","commands":{"allow":["set_browser_view_popout_always_on_top"],"deny":[]}},"allow-set-container-page-viewport":{"identifier":"allow-set-container-page-viewport","description":"Enables the set_container_page_viewport command without any pre-configured scope.","commands":{"allow":["set_container_page_viewport"],"deny":[]}},"allow-set-gateway-api-key":{"identifier":"allow-set-gateway-api-key","description":"Enables the set_gateway_api_key command without any pre-configured scope.","commands":{"allow":["set_gateway_api_key"],"deny":[]}},"allow-set-global-item-disabled":{"identifier":"allow-set-global-item-disabled","description":"Enables the set_global_item_disabled command without any pre-configured scope.","commands":{"allow":["set_global_item_disabled"],"deny":[]}},"allow-set-scheduled-task-enabled":{"identifier":"allow-set-scheduled-task-enabled","description":"Enables the set_scheduled_task_enabled command without any pre-configured scope.","commands":{"allow":["set_scheduled_task_enabled"],"deny":[]}},"allow-start-audio-bridge":{"identifier":"allow-start-audio-bridge","description":"Enables the start_audio_bridge command without any pre-configured scope.","commands":{"allow":["start_audio_bridge"],"deny":[]}},"allow-start-gateway":{"identifier":"allow-start-gateway","description":"Enables the start_gateway command without any pre-configured scope.","commands":{"allow":["start_gateway"],"deny":[]}},"allow-start-marketplace-gh-container-login":{"identifier":"allow-start-marketplace-gh-container-login","description":"Enables the start_marketplace_gh_container_login command without any pre-configured scope.","commands":{"allow":["start_marketplace_gh_container_login"],"deny":[]}},"allow-start-project-container":{"identifier":"allow-start-project-container","description":"Enables the start_project_container command without any pre-configured scope.","commands":{"allow":["start_project_container"],"deny":[]}},"allow-start-stt":{"identifier":"allow-start-stt","description":"Enables the start_stt command without any pre-configured scope.","commands":{"allow":["start_stt"],"deny":[]}},"allow-start-web-terminal":{"identifier":"allow-start-web-terminal","description":"Enables the start_web_terminal command without any pre-configured scope.","commands":{"allow":["start_web_terminal"],"deny":[]}},"allow-stop-audio-bridge":{"identifier":"allow-stop-audio-bridge","description":"Enables the stop_audio_bridge command without any pre-configured scope.","commands":{"allow":["stop_audio_bridge"],"deny":[]}},"allow-stop-gateway":{"identifier":"allow-stop-gateway","description":"Enables the stop_gateway command without any pre-configured scope.","commands":{"allow":["stop_gateway"],"deny":[]}},"allow-stop-project-container":{"identifier":"allow-stop-project-container","description":"Enables the stop_project_container command without any pre-configured scope.","commands":{"allow":["stop_project_container"],"deny":[]}},"allow-stop-stt":{"identifier":"allow-stop-stt","description":"Enables the stop_stt command without any pre-configured scope.","commands":{"allow":["stop_stt"],"deny":[]}},"allow-stop-web-terminal":{"identifier":"allow-stop-web-terminal","description":"Enables the stop_web_terminal command without any pre-configured scope.","commands":{"allow":["stop_web_terminal"],"deny":[]}},"allow-submit-claude-token-code":{"identifier":"allow-submit-claude-token-code","description":"Enables the submit_claude_token_code command without any pre-configured scope.","commands":{"allow":["submit_claude_token_code"],"deny":[]}},"allow-sweep-claude-token-snapshots":{"identifier":"allow-sweep-claude-token-snapshots","description":"Enables the sweep_claude_token_snapshots command without any pre-configured scope.","commands":{"allow":["sweep_claude_token_snapshots"],"deny":[]}},"allow-terminal-input":{"identifier":"allow-terminal-input","description":"Enables the terminal_input command without any pre-configured scope.","commands":{"allow":["terminal_input"],"deny":[]}},"allow-terminal-resize":{"identifier":"allow-terminal-resize","description":"Enables the terminal_resize command without any pre-configured scope.","commands":{"allow":["terminal_resize"],"deny":[]}},"allow-test-marketplace-account":{"identifier":"allow-test-marketplace-account","description":"Enables the test_marketplace_account command without any pre-configured scope.","commands":{"allow":["test_marketplace_account"],"deny":[]}},"allow-transcribe-audio":{"identifier":"allow-transcribe-audio","description":"Enables the transcribe_audio command without any pre-configured scope.","commands":{"allow":["transcribe_audio"],"deny":[]}},"allow-uninstall-marketplace-item":{"identifier":"allow-uninstall-marketplace-item","description":"Enables the uninstall_marketplace_item command without any pre-configured scope.","commands":{"allow":["uninstall_marketplace_item"],"deny":[]}},"allow-unlock-aws-state":{"identifier":"allow-unlock-aws-state","description":"Enables the unlock_aws_state command without any pre-configured scope.","commands":{"allow":["unlock_aws_state"],"deny":[]}},"allow-update-aws-connection":{"identifier":"allow-update-aws-connection","description":"Enables the update_aws_connection command without any pre-configured scope.","commands":{"allow":["update_aws_connection"],"deny":[]}},"allow-update-aws-environment":{"identifier":"allow-update-aws-environment","description":"Enables the update_aws_environment command without any pre-configured scope.","commands":{"allow":["update_aws_environment"],"deny":[]}},"allow-update-marketplace":{"identifier":"allow-update-marketplace","description":"Enables the update_marketplace command without any pre-configured scope.","commands":{"allow":["update_marketplace"],"deny":[]}},"allow-update-marketplace-item":{"identifier":"allow-update-marketplace-item","description":"Enables the update_marketplace_item command without any pre-configured scope.","commands":{"allow":["update_marketplace_item"],"deny":[]}},"allow-update-project":{"identifier":"allow-update-project","description":"Enables the update_project command without any pre-configured scope.","commands":{"allow":["update_project"],"deny":[]}},"allow-update-scheduled-task":{"identifier":"allow-update-scheduled-task","description":"Enables the update_scheduled_task command without any pre-configured scope.","commands":{"allow":["update_scheduled_task"],"deny":[]}},"allow-update-settings":{"identifier":"allow-update-settings","description":"Enables the update_settings command without any pre-configured scope.","commands":{"allow":["update_settings"],"deny":[]}},"allow-upload-files-to-container":{"identifier":"allow-upload-files-to-container","description":"Enables the upload_files_to_container command without any pre-configured scope.","commands":{"allow":["upload_files_to_container"],"deny":[]}},"allow-upload-host-file-to-terminal":{"identifier":"allow-upload-host-file-to-terminal","description":"Enables the upload_host_file_to_terminal command without any pre-configured scope.","commands":{"allow":["upload_host_file_to_terminal"],"deny":[]}},"allow-viewer-choose-file":{"identifier":"allow-viewer-choose-file","description":"Enables the viewer_choose_file command without any pre-configured scope.","commands":{"allow":["viewer_choose_file"],"deny":[]}},"allow-viewer-get-state":{"identifier":"allow-viewer-get-state","description":"Enables the viewer_get_state command without any pre-configured scope.","commands":{"allow":["viewer_get_state"],"deny":[]}},"allow-viewer-poll-file":{"identifier":"allow-viewer-poll-file","description":"Enables the viewer_poll_file command without any pre-configured scope.","commands":{"allow":["viewer_poll_file"],"deny":[]}},"allow-viewer-read-file":{"identifier":"allow-viewer-read-file","description":"Enables the viewer_read_file command without any pre-configured scope.","commands":{"allow":["viewer_read_file"],"deny":[]}},"allow-viewer-write-file":{"identifier":"allow-viewer-write-file","description":"Enables the viewer_write_file command without any pre-configured scope.","commands":{"allow":["viewer_write_file"],"deny":[]}},"deny-acquire-claude-token":{"identifier":"deny-acquire-claude-token","description":"Denies the acquire_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["acquire_claude_token"]}},"deny-add-aws-keys-connection":{"identifier":"deny-add-aws-keys-connection","description":"Denies the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["add_aws_keys_connection"]}},"deny-add-aws-profile-connection":{"identifier":"deny-add-aws-profile-connection","description":"Denies the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["add_aws_profile_connection"]}},"deny-add-marketplace":{"identifier":"deny-add-marketplace","description":"Denies the add_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace"]}},"deny-add-marketplace-gh-host-account":{"identifier":"deny-add-marketplace-gh-host-account","description":"Denies the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace_gh_host_account"]}},"deny-add-marketplace-token-account":{"identifier":"deny-add-marketplace-token-account","description":"Denies the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace_token_account"]}},"deny-add-project":{"identifier":"deny-add-project","description":"Denies the add_project command without any pre-configured scope.","commands":{"allow":[],"deny":["add_project"]}},"deny-add-scheduled-task":{"identifier":"deny-add-scheduled-task","description":"Denies the add_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["add_scheduled_task"]}},"deny-apply-marketplace-now":{"identifier":"deny-apply-marketplace-now","description":"Denies the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":[],"deny":["apply_marketplace_now"]}},"deny-apply-settings-import":{"identifier":"deny-apply-settings-import","description":"Denies the apply_settings_import command without any pre-configured scope.","commands":{"allow":[],"deny":["apply_settings_import"]}},"deny-aws-connection-identity":{"identifier":"deny-aws-connection-identity","description":"Denies the aws_connection_identity command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_connection_identity"]}},"deny-aws-connection-sso-login":{"identifier":"deny-aws-connection-sso-login","description":"Denies the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_connection_sso_login"]}},"deny-aws-cost-estimate":{"identifier":"deny-aws-cost-estimate","description":"Denies the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_cost_estimate"]}},"deny-aws-environment-max-hours":{"identifier":"deny-aws-environment-max-hours","description":"Denies the aws_environment_max_hours command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_environment_max_hours"]}},"deny-aws-policy-document":{"identifier":"deny-aws-policy-document","description":"Denies the aws_policy_document command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_policy_document"]}},"deny-aws-sso-refresh":{"identifier":"deny-aws-sso-refresh","description":"Denies the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_sso_refresh"]}},"deny-aws-task-log":{"identifier":"deny-aws-task-log","description":"Denies the aws_task_log command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_task_log"]}},"deny-aws-workspace-status":{"identifier":"deny-aws-workspace-status","description":"Denies the aws_workspace_status command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_workspace_status"]}},"deny-build-gateway-image":{"identifier":"deny-build-gateway-image","description":"Denies the build_gateway_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_gateway_image"]}},"deny-build-image":{"identifier":"deny-build-image","description":"Denies the build_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_image"]}},"deny-build-stt-image":{"identifier":"deny-build-stt-image","description":"Denies the build_stt_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_stt_image"]}},"deny-cancel-aws-deployment":{"identifier":"deny-cancel-aws-deployment","description":"Denies the cancel_aws_deployment command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_aws_deployment"]}},"deny-cancel-claude-token":{"identifier":"deny-cancel-claude-token","description":"Denies the cancel_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_claude_token"]}},"deny-cancel-marketplace-gh-login":{"identifier":"deny-cancel-marketplace-gh-login","description":"Denies the cancel_marketplace_gh_login command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_marketplace_gh_login"]}},"deny-check-aws-permissions":{"identifier":"deny-check-aws-permissions","description":"Denies the check_aws_permissions command without any pre-configured scope.","commands":{"allow":[],"deny":["check_aws_permissions"]}},"deny-check-browser-view-support":{"identifier":"deny-check-browser-view-support","description":"Denies the check_browser_view_support command without any pre-configured scope.","commands":{"allow":[],"deny":["check_browser_view_support"]}},"deny-check-docker":{"identifier":"deny-check-docker","description":"Denies the check_docker command without any pre-configured scope.","commands":{"allow":[],"deny":["check_docker"]}},"deny-check-for-updates":{"identifier":"deny-check-for-updates","description":"Denies the check_for_updates command without any pre-configured scope.","commands":{"allow":[],"deny":["check_for_updates"]}},"deny-check-gateway-health":{"identifier":"deny-check-gateway-health","description":"Denies the check_gateway_health command without any pre-configured scope.","commands":{"allow":[],"deny":["check_gateway_health"]}},"deny-check-image-exists":{"identifier":"deny-check-image-exists","description":"Denies the check_image_exists command without any pre-configured scope.","commands":{"allow":[],"deny":["check_image_exists"]}},"deny-check-image-update":{"identifier":"deny-check-image-update","description":"Denies the check_image_update command without any pre-configured scope.","commands":{"allow":[],"deny":["check_image_update"]}},"deny-check-unsaved-work":{"identifier":"deny-check-unsaved-work","description":"Denies the check_unsaved_work command without any pre-configured scope.","commands":{"allow":[],"deny":["check_unsaved_work"]}},"deny-clear-claude-token":{"identifier":"deny-clear-claude-token","description":"Denies the clear_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_claude_token"]}},"deny-clear-gateway-api-key":{"identifier":"deny-clear-gateway-api-key","description":"Denies the clear_gateway_api_key command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_gateway_api_key"]}},"deny-clear-scheduler-notifications":{"identifier":"deny-clear-scheduler-notifications","description":"Denies the clear_scheduler_notifications command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_scheduler_notifications"]}},"deny-close-browser-view-popout":{"identifier":"deny-close-browser-view-popout","description":"Denies the close_browser_view_popout command without any pre-configured scope.","commands":{"allow":[],"deny":["close_browser_view_popout"]}},"deny-close-container-page":{"identifier":"deny-close-container-page","description":"Denies the close_container_page command without any pre-configured scope.","commands":{"allow":[],"deny":["close_container_page"]}},"deny-close-terminal-session":{"identifier":"deny-close-terminal-session","description":"Denies the close_terminal_session command without any pre-configured scope.","commands":{"allow":[],"deny":["close_terminal_session"]}},"deny-confirm-migration":{"identifier":"deny-confirm-migration","description":"Denies the confirm_migration command without any pre-configured scope.","commands":{"allow":[],"deny":["confirm_migration"]}},"deny-create-container-directory":{"identifier":"deny-create-container-directory","description":"Denies the create_container_directory command without any pre-configured scope.","commands":{"allow":[],"deny":["create_container_directory"]}},"deny-delete-note":{"identifier":"deny-delete-note","description":"Denies the delete_note command without any pre-configured scope.","commands":{"allow":[],"deny":["delete_note"]}},"deny-deploy-aws-environment":{"identifier":"deny-deploy-aws-environment","description":"Denies the deploy_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["deploy_aws_environment"]}},"deny-deploy-aws-permissions-boundary":{"identifier":"deny-deploy-aws-permissions-boundary","description":"Denies the deploy_aws_permissions_boundary command without any pre-configured scope.","commands":{"allow":[],"deny":["deploy_aws_permissions_boundary"]}},"deny-destroy-incomplete-aws-environment":{"identifier":"deny-destroy-incomplete-aws-environment","description":"Denies the destroy_incomplete_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["destroy_incomplete_aws_environment"]}},"deny-detect-aws-config":{"identifier":"deny-detect-aws-config","description":"Denies the detect_aws_config command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_aws_config"]}},"deny-detect-aws-environments":{"identifier":"deny-detect-aws-environments","description":"Denies the detect_aws_environments command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_aws_environments"]}},"deny-detect-host-timezone":{"identifier":"deny-detect-host-timezone","description":"Denies the detect_host_timezone command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_host_timezone"]}},"deny-detect-install-options":{"identifier":"deny-detect-install-options","description":"Denies the detect_install_options command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_install_options"]}},"deny-download-container-backup":{"identifier":"deny-download-container-backup","description":"Denies the download_container_backup command without any pre-configured scope.","commands":{"allow":[],"deny":["download_container_backup"]}},"deny-download-container-file":{"identifier":"deny-download-container-file","description":"Denies the download_container_file command without any pre-configured scope.","commands":{"allow":[],"deny":["download_container_file"]}},"deny-export-settings":{"identifier":"deny-export-settings","description":"Denies the export_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["export_settings"]}},"deny-follow-aws-deployment":{"identifier":"deny-follow-aws-deployment","description":"Denies the follow_aws_deployment command without any pre-configured scope.","commands":{"allow":[],"deny":["follow_aws_deployment"]}},"deny-forget-marketplace-installs":{"identifier":"deny-forget-marketplace-installs","description":"Denies the forget_marketplace_installs command without any pre-configured scope.","commands":{"allow":[],"deny":["forget_marketplace_installs"]}},"deny-get-app-version":{"identifier":"deny-get-app-version","description":"Denies the get_app_version command without any pre-configured scope.","commands":{"allow":[],"deny":["get_app_version"]}},"deny-get-auth-bridge-status":{"identifier":"deny-get-auth-bridge-status","description":"Denies the get_auth_bridge_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_auth_bridge_status"]}},"deny-get-browser-view-match-window":{"identifier":"deny-get-browser-view-match-window","description":"Denies the get_browser_view_match_window command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_match_window"]}},"deny-get-browser-view-popout-state":{"identifier":"deny-get-browser-view-popout-state","description":"Denies the get_browser_view_popout_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_popout_state"]}},"deny-get-browser-view-status":{"identifier":"deny-get-browser-view-status","description":"Denies the get_browser_view_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_status"]}},"deny-get-container-info":{"identifier":"deny-get-container-info","description":"Denies the get_container_info command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_info"]}},"deny-get-container-page-state":{"identifier":"deny-get-container-page-state","description":"Denies the get_container_page_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_page_state"]}},"deny-get-container-staleness":{"identifier":"deny-get-container-staleness","description":"Denies the get_container_staleness command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_staleness"]}},"deny-get-gateway-auth-token":{"identifier":"deny-get-gateway-auth-token","description":"Denies the get_gateway_auth_token command without any pre-configured scope.","commands":{"allow":[],"deny":["get_gateway_auth_token"]}},"deny-get-gateway-status":{"identifier":"deny-get-gateway-status","description":"Denies the get_gateway_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_gateway_status"]}},"deny-get-help-content":{"identifier":"deny-get-help-content","description":"Denies the get_help_content command without any pre-configured scope.","commands":{"allow":[],"deny":["get_help_content"]}},"deny-get-marketplace-sync-report":{"identifier":"deny-get-marketplace-sync-report","description":"Denies the get_marketplace_sync_report command without any pre-configured scope.","commands":{"allow":[],"deny":["get_marketplace_sync_report"]}},"deny-get-migration-state":{"identifier":"deny-get-migration-state","description":"Denies the get_migration_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_migration_state"]}},"deny-get-scheduled-task-log":{"identifier":"deny-get-scheduled-task-log","description":"Denies the get_scheduled_task_log command without any pre-configured scope.","commands":{"allow":[],"deny":["get_scheduled_task_log"]}},"deny-get-scheduler-notifications":{"identifier":"deny-get-scheduler-notifications","description":"Denies the get_scheduler_notifications command without any pre-configured scope.","commands":{"allow":[],"deny":["get_scheduler_notifications"]}},"deny-get-settings":{"identifier":"deny-get-settings","description":"Denies the get_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["get_settings"]}},"deny-get-stt-status":{"identifier":"deny-get-stt-status","description":"Denies the get_stt_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_stt_status"]}},"deny-get-web-terminal-status":{"identifier":"deny-get-web-terminal-status","description":"Denies the get_web_terminal_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_web_terminal_status"]}},"deny-has-claude-token":{"identifier":"deny-has-claude-token","description":"Denies the has_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["has_claude_token"]}},"deny-inspect-ca-cert-path":{"identifier":"deny-inspect-ca-cert-path","description":"Denies the inspect_ca_cert_path command without any pre-configured scope.","commands":{"allow":[],"deny":["inspect_ca_cert_path"]}},"deny-install-browser-view-browser":{"identifier":"deny-install-browser-view-browser","description":"Denies the install_browser_view_browser command without any pre-configured scope.","commands":{"allow":[],"deny":["install_browser_view_browser"]}},"deny-install-browser-view-support":{"identifier":"deny-install-browser-view-support","description":"Denies the install_browser_view_support command without any pre-configured scope.","commands":{"allow":[],"deny":["install_browser_view_support"]}},"deny-install-marketplace-item":{"identifier":"deny-install-marketplace-item","description":"Denies the install_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["install_marketplace_item"]}},"deny-list-aws-profiles":{"identifier":"deny-list-aws-profiles","description":"Denies the list_aws_profiles command without any pre-configured scope.","commands":{"allow":[],"deny":["list_aws_profiles"]}},"deny-list-claude-sessions":{"identifier":"deny-list-claude-sessions","description":"Denies the list_claude_sessions command without any pre-configured scope.","commands":{"allow":[],"deny":["list_claude_sessions"]}},"deny-list-container-capabilities":{"identifier":"deny-list-container-capabilities","description":"Denies the list_container_capabilities command without any pre-configured scope.","commands":{"allow":[],"deny":["list_container_capabilities"]}},"deny-list-container-files":{"identifier":"deny-list-container-files","description":"Denies the list_container_files command without any pre-configured scope.","commands":{"allow":[],"deny":["list_container_files"]}},"deny-list-ec2-instance-types":{"identifier":"deny-list-ec2-instance-types","description":"Denies the list_ec2_instance_types command without any pre-configured scope.","commands":{"allow":[],"deny":["list_ec2_instance_types"]}},"deny-list-marketplace-snapshots":{"identifier":"deny-list-marketplace-snapshots","description":"Denies the list_marketplace_snapshots command without any pre-configured scope.","commands":{"allow":[],"deny":["list_marketplace_snapshots"]}},"deny-list-marketplace-updates":{"identifier":"deny-list-marketplace-updates","description":"Denies the list_marketplace_updates command without any pre-configured scope.","commands":{"allow":[],"deny":["list_marketplace_updates"]}},"deny-list-notes":{"identifier":"deny-list-notes","description":"Denies the list_notes command without any pre-configured scope.","commands":{"allow":[],"deny":["list_notes"]}},"deny-list-projects":{"identifier":"deny-list-projects","description":"Denies the list_projects command without any pre-configured scope.","commands":{"allow":[],"deny":["list_projects"]}},"deny-list-scheduled-tasks":{"identifier":"deny-list-scheduled-tasks","description":"Denies the list_scheduled_tasks command without any pre-configured scope.","commands":{"allow":[],"deny":["list_scheduled_tasks"]}},"deny-marketplace-gh-host-available":{"identifier":"deny-marketplace-gh-host-available","description":"Denies the marketplace_gh_host_available command without any pre-configured scope.","commands":{"allow":[],"deny":["marketplace_gh_host_available"]}},"deny-marketplace-item-diff":{"identifier":"deny-marketplace-item-diff","description":"Denies the marketplace_item_diff command without any pre-configured scope.","commands":{"allow":[],"deny":["marketplace_item_diff"]}},"deny-migrate-project-to-base":{"identifier":"deny-migrate-project-to-base","description":"Denies the migrate_project_to_base command without any pre-configured scope.","commands":{"allow":[],"deny":["migrate_project_to_base"]}},"deny-onboard-aws-user":{"identifier":"deny-onboard-aws-user","description":"Denies the onboard_aws_user command without any pre-configured scope.","commands":{"allow":[],"deny":["onboard_aws_user"]}},"deny-open-browser-view-popout":{"identifier":"deny-open-browser-view-popout","description":"Denies the open_browser_view_popout command without any pre-configured scope.","commands":{"allow":[],"deny":["open_browser_view_popout"]}},"deny-open-file-viewer":{"identifier":"deny-open-file-viewer","description":"Denies the open_file_viewer command without any pre-configured scope.","commands":{"allow":[],"deny":["open_file_viewer"]}},"deny-open-page-in-container-browser":{"identifier":"deny-open-page-in-container-browser","description":"Denies the open_page_in_container_browser command without any pre-configured scope.","commands":{"allow":[],"deny":["open_page_in_container_browser"]}},"deny-open-terminal-session":{"identifier":"deny-open-terminal-session","description":"Denies the open_terminal_session command without any pre-configured scope.","commands":{"allow":[],"deny":["open_terminal_session"]}},"deny-open-url-external":{"identifier":"deny-open-url-external","description":"Denies the open_url_external command without any pre-configured scope.","commands":{"allow":[],"deny":["open_url_external"]}},"deny-paste-image-to-terminal":{"identifier":"deny-paste-image-to-terminal","description":"Denies the paste_image_to_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["paste_image_to_terminal"]}},"deny-preview-settings-import":{"identifier":"deny-preview-settings-import","description":"Denies the preview_settings_import command without any pre-configured scope.","commands":{"allow":[],"deny":["preview_settings_import"]}},"deny-pull-gateway-image":{"identifier":"deny-pull-gateway-image","description":"Denies the pull_gateway_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_gateway_image"]}},"deny-pull-image":{"identifier":"deny-pull-image","description":"Denies the pull_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_image"]}},"deny-pull-stt-image":{"identifier":"deny-pull-stt-image","description":"Denies the pull_stt_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_stt_image"]}},"deny-push-aws-saved-state":{"identifier":"deny-push-aws-saved-state","description":"Denies the push_aws_saved_state command without any pre-configured scope.","commands":{"allow":[],"deny":["push_aws_saved_state"]}},"deny-read-container-file":{"identifier":"deny-read-container-file","description":"Denies the read_container_file command without any pre-configured scope.","commands":{"allow":[],"deny":["read_container_file"]}},"deny-rebuild-project-container":{"identifier":"deny-rebuild-project-container","description":"Denies the rebuild_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["rebuild_project_container"]}},"deny-reconcile-aws-projects":{"identifier":"deny-reconcile-aws-projects","description":"Denies the reconcile_aws_projects command without any pre-configured scope.","commands":{"allow":[],"deny":["reconcile_aws_projects"]}},"deny-reconcile-project-statuses":{"identifier":"deny-reconcile-project-statuses","description":"Denies the reconcile_project_statuses command without any pre-configured scope.","commands":{"allow":[],"deny":["reconcile_project_statuses"]}},"deny-refresh-marketplaces":{"identifier":"deny-refresh-marketplaces","description":"Denies the refresh_marketplaces command without any pre-configured scope.","commands":{"allow":[],"deny":["refresh_marketplaces"]}},"deny-regenerate-gateway-auth-token":{"identifier":"deny-regenerate-gateway-auth-token","description":"Denies the regenerate_gateway_auth_token command without any pre-configured scope.","commands":{"allow":[],"deny":["regenerate_gateway_auth_token"]}},"deny-regenerate-web-terminal-token":{"identifier":"deny-regenerate-web-terminal-token","description":"Denies the regenerate_web_terminal_token command without any pre-configured scope.","commands":{"allow":[],"deny":["regenerate_web_terminal_token"]}},"deny-remove-aws-resources":{"identifier":"deny-remove-aws-resources","description":"Denies the remove_aws_resources command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_aws_resources"]}},"deny-remove-host-connection":{"identifier":"deny-remove-host-connection","description":"Denies the remove_host_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_host_connection"]}},"deny-remove-marketplace":{"identifier":"deny-remove-marketplace","description":"Denies the remove_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_marketplace"]}},"deny-remove-marketplace-account":{"identifier":"deny-remove-marketplace-account","description":"Denies the remove_marketplace_account command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_marketplace_account"]}},"deny-remove-project":{"identifier":"deny-remove-project","description":"Denies the remove_project command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_project"]}},"deny-remove-scheduled-task":{"identifier":"deny-remove-scheduled-task","description":"Denies the remove_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_scheduled_task"]}},"deny-rename-container-path":{"identifier":"deny-rename-container-path","description":"Denies the rename_container_path command without any pre-configured scope.","commands":{"allow":[],"deny":["rename_container_path"]}},"deny-repair-aws-environment":{"identifier":"deny-repair-aws-environment","description":"Denies the repair_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["repair_aws_environment"]}},"deny-rollback-migration":{"identifier":"deny-rollback-migration","description":"Denies the rollback_migration command without any pre-configured scope.","commands":{"allow":[],"deny":["rollback_migration"]}},"deny-run-docker-install":{"identifier":"deny-run-docker-install","description":"Denies the run_docker_install command without any pre-configured scope.","commands":{"allow":[],"deny":["run_docker_install"]}},"deny-run-scheduled-task-now":{"identifier":"deny-run-scheduled-task-now","description":"Denies the run_scheduled_task_now command without any pre-configured scope.","commands":{"allow":[],"deny":["run_scheduled_task_now"]}},"deny-save-aws-admin-bundle":{"identifier":"deny-save-aws-admin-bundle","description":"Denies the save_aws_admin_bundle command without any pre-configured scope.","commands":{"allow":[],"deny":["save_aws_admin_bundle"]}},"deny-save-note":{"identifier":"deny-save-note","description":"Denies the save_note command without any pre-configured scope.","commands":{"allow":[],"deny":["save_note"]}},"deny-send-audio-data":{"identifier":"deny-send-audio-data","description":"Denies the send_audio_data command without any pre-configured scope.","commands":{"allow":[],"deny":["send_audio_data"]}},"deny-set-auth-bridge-enabled":{"identifier":"deny-set-auth-bridge-enabled","description":"Denies the set_auth_bridge_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_auth_bridge_enabled"]}},"deny-set-browser-view-enabled":{"identifier":"deny-set-browser-view-enabled","description":"Denies the set_browser_view_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_enabled"]}},"deny-set-browser-view-match-window":{"identifier":"deny-set-browser-view-match-window","description":"Denies the set_browser_view_match_window command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_match_window"]}},"deny-set-browser-view-popout-always-on-top":{"identifier":"deny-set-browser-view-popout-always-on-top","description":"Denies the set_browser_view_popout_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_popout_always_on_top"]}},"deny-set-container-page-viewport":{"identifier":"deny-set-container-page-viewport","description":"Denies the set_container_page_viewport command without any pre-configured scope.","commands":{"allow":[],"deny":["set_container_page_viewport"]}},"deny-set-gateway-api-key":{"identifier":"deny-set-gateway-api-key","description":"Denies the set_gateway_api_key command without any pre-configured scope.","commands":{"allow":[],"deny":["set_gateway_api_key"]}},"deny-set-global-item-disabled":{"identifier":"deny-set-global-item-disabled","description":"Denies the set_global_item_disabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_global_item_disabled"]}},"deny-set-scheduled-task-enabled":{"identifier":"deny-set-scheduled-task-enabled","description":"Denies the set_scheduled_task_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_scheduled_task_enabled"]}},"deny-start-audio-bridge":{"identifier":"deny-start-audio-bridge","description":"Denies the start_audio_bridge command without any pre-configured scope.","commands":{"allow":[],"deny":["start_audio_bridge"]}},"deny-start-gateway":{"identifier":"deny-start-gateway","description":"Denies the start_gateway command without any pre-configured scope.","commands":{"allow":[],"deny":["start_gateway"]}},"deny-start-marketplace-gh-container-login":{"identifier":"deny-start-marketplace-gh-container-login","description":"Denies the start_marketplace_gh_container_login command without any pre-configured scope.","commands":{"allow":[],"deny":["start_marketplace_gh_container_login"]}},"deny-start-project-container":{"identifier":"deny-start-project-container","description":"Denies the start_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["start_project_container"]}},"deny-start-stt":{"identifier":"deny-start-stt","description":"Denies the start_stt command without any pre-configured scope.","commands":{"allow":[],"deny":["start_stt"]}},"deny-start-web-terminal":{"identifier":"deny-start-web-terminal","description":"Denies the start_web_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["start_web_terminal"]}},"deny-stop-audio-bridge":{"identifier":"deny-stop-audio-bridge","description":"Denies the stop_audio_bridge command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_audio_bridge"]}},"deny-stop-gateway":{"identifier":"deny-stop-gateway","description":"Denies the stop_gateway command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_gateway"]}},"deny-stop-project-container":{"identifier":"deny-stop-project-container","description":"Denies the stop_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_project_container"]}},"deny-stop-stt":{"identifier":"deny-stop-stt","description":"Denies the stop_stt command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_stt"]}},"deny-stop-web-terminal":{"identifier":"deny-stop-web-terminal","description":"Denies the stop_web_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_web_terminal"]}},"deny-submit-claude-token-code":{"identifier":"deny-submit-claude-token-code","description":"Denies the submit_claude_token_code command without any pre-configured scope.","commands":{"allow":[],"deny":["submit_claude_token_code"]}},"deny-sweep-claude-token-snapshots":{"identifier":"deny-sweep-claude-token-snapshots","description":"Denies the sweep_claude_token_snapshots command without any pre-configured scope.","commands":{"allow":[],"deny":["sweep_claude_token_snapshots"]}},"deny-terminal-input":{"identifier":"deny-terminal-input","description":"Denies the terminal_input command without any pre-configured scope.","commands":{"allow":[],"deny":["terminal_input"]}},"deny-terminal-resize":{"identifier":"deny-terminal-resize","description":"Denies the terminal_resize command without any pre-configured scope.","commands":{"allow":[],"deny":["terminal_resize"]}},"deny-test-marketplace-account":{"identifier":"deny-test-marketplace-account","description":"Denies the test_marketplace_account command without any pre-configured scope.","commands":{"allow":[],"deny":["test_marketplace_account"]}},"deny-transcribe-audio":{"identifier":"deny-transcribe-audio","description":"Denies the transcribe_audio command without any pre-configured scope.","commands":{"allow":[],"deny":["transcribe_audio"]}},"deny-uninstall-marketplace-item":{"identifier":"deny-uninstall-marketplace-item","description":"Denies the uninstall_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["uninstall_marketplace_item"]}},"deny-unlock-aws-state":{"identifier":"deny-unlock-aws-state","description":"Denies the unlock_aws_state command without any pre-configured scope.","commands":{"allow":[],"deny":["unlock_aws_state"]}},"deny-update-aws-connection":{"identifier":"deny-update-aws-connection","description":"Denies the update_aws_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["update_aws_connection"]}},"deny-update-aws-environment":{"identifier":"deny-update-aws-environment","description":"Denies the update_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["update_aws_environment"]}},"deny-update-marketplace":{"identifier":"deny-update-marketplace","description":"Denies the update_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["update_marketplace"]}},"deny-update-marketplace-item":{"identifier":"deny-update-marketplace-item","description":"Denies the update_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["update_marketplace_item"]}},"deny-update-project":{"identifier":"deny-update-project","description":"Denies the update_project command without any pre-configured scope.","commands":{"allow":[],"deny":["update_project"]}},"deny-update-scheduled-task":{"identifier":"deny-update-scheduled-task","description":"Denies the update_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["update_scheduled_task"]}},"deny-update-settings":{"identifier":"deny-update-settings","description":"Denies the update_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["update_settings"]}},"deny-upload-files-to-container":{"identifier":"deny-upload-files-to-container","description":"Denies the upload_files_to_container command without any pre-configured scope.","commands":{"allow":[],"deny":["upload_files_to_container"]}},"deny-upload-host-file-to-terminal":{"identifier":"deny-upload-host-file-to-terminal","description":"Denies the upload_host_file_to_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["upload_host_file_to_terminal"]}},"deny-viewer-choose-file":{"identifier":"deny-viewer-choose-file","description":"Denies the viewer_choose_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_choose_file"]}},"deny-viewer-get-state":{"identifier":"deny-viewer-get-state","description":"Denies the viewer_get_state command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_get_state"]}},"deny-viewer-poll-file":{"identifier":"deny-viewer-poll-file","description":"Denies the viewer_poll_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_poll_file"]}},"deny-viewer-read-file":{"identifier":"deny-viewer-read-file","description":"Denies the viewer_read_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_read_file"]}},"deny-viewer-write-file":{"identifier":"deny-viewer-write-file","description":"Denies the viewer_write_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_write_file"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","commands":{"allow":["name"],"deny":[]}},"allow-register-listener":{"identifier":"allow-register-listener","description":"Enables the register_listener command without any pre-configured scope.","commands":{"allow":["register_listener"],"deny":[]}},"allow-remove-data-store":{"identifier":"allow-remove-data-store","description":"Enables the remove_data_store command without any pre-configured scope.","commands":{"allow":["remove_data_store"],"deny":[]}},"allow-remove-listener":{"identifier":"allow-remove-listener","description":"Enables the remove_listener command without any pre-configured scope.","commands":{"allow":["remove_listener"],"deny":[]}},"allow-set-app-theme":{"identifier":"allow-set-app-theme","description":"Enables the set_app_theme command without any pre-configured scope.","commands":{"allow":["set_app_theme"],"deny":[]}},"allow-set-dock-visibility":{"identifier":"allow-set-dock-visibility","description":"Enables the set_dock_visibility command without any pre-configured scope.","commands":{"allow":["set_dock_visibility"],"deny":[]}},"allow-supports-multiple-windows":{"identifier":"allow-supports-multiple-windows","description":"Enables the supports_multiple_windows command without any pre-configured scope.","commands":{"allow":["supports_multiple_windows"],"deny":[]}},"allow-tauri-version":{"identifier":"allow-tauri-version","description":"Enables the tauri_version command without any pre-configured scope.","commands":{"allow":["tauri_version"],"deny":[]}},"allow-version":{"identifier":"allow-version","description":"Enables the version command without any pre-configured scope.","commands":{"allow":["version"],"deny":[]}},"deny-app-hide":{"identifier":"deny-app-hide","description":"Denies the app_hide command without any pre-configured scope.","commands":{"allow":[],"deny":["app_hide"]}},"deny-app-show":{"identifier":"deny-app-show","description":"Denies the app_show command without any pre-configured scope.","commands":{"allow":[],"deny":["app_show"]}},"deny-bundle-type":{"identifier":"deny-bundle-type","description":"Denies the bundle_type command without any pre-configured scope.","commands":{"allow":[],"deny":["bundle_type"]}},"deny-default-window-icon":{"identifier":"deny-default-window-icon","description":"Denies the default_window_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["default_window_icon"]}},"deny-fetch-data-store-identifiers":{"identifier":"deny-fetch-data-store-identifiers","description":"Denies the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":[],"deny":["fetch_data_store_identifiers"]}},"deny-identifier":{"identifier":"deny-identifier","description":"Denies the identifier command without any pre-configured scope.","commands":{"allow":[],"deny":["identifier"]}},"deny-name":{"identifier":"deny-name","description":"Denies the name command without any pre-configured scope.","commands":{"allow":[],"deny":["name"]}},"deny-register-listener":{"identifier":"deny-register-listener","description":"Denies the register_listener command without any pre-configured scope.","commands":{"allow":[],"deny":["register_listener"]}},"deny-remove-data-store":{"identifier":"deny-remove-data-store","description":"Denies the remove_data_store command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_data_store"]}},"deny-remove-listener":{"identifier":"deny-remove-listener","description":"Denies the remove_listener command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_listener"]}},"deny-set-app-theme":{"identifier":"deny-set-app-theme","description":"Denies the set_app_theme command without any pre-configured scope.","commands":{"allow":[],"deny":["set_app_theme"]}},"deny-set-dock-visibility":{"identifier":"deny-set-dock-visibility","description":"Denies the set_dock_visibility command without any pre-configured scope.","commands":{"allow":[],"deny":["set_dock_visibility"]}},"deny-supports-multiple-windows":{"identifier":"deny-supports-multiple-windows","description":"Denies the supports_multiple_windows command without any pre-configured scope.","commands":{"allow":[],"deny":["supports_multiple_windows"]}},"deny-tauri-version":{"identifier":"deny-tauri-version","description":"Denies the tauri_version command without any pre-configured scope.","commands":{"allow":[],"deny":["tauri_version"]}},"deny-version":{"identifier":"deny-version","description":"Denies the version command without any pre-configured scope.","commands":{"allow":[],"deny":["version"]}}},"permission_sets":{},"global_scope_schema":null},"core:event":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-listen","allow-unlisten","allow-emit","allow-emit-to"]},"permissions":{"allow-emit":{"identifier":"allow-emit","description":"Enables the emit command without any pre-configured scope.","commands":{"allow":["emit"],"deny":[]}},"allow-emit-to":{"identifier":"allow-emit-to","description":"Enables the emit_to command without any pre-configured scope.","commands":{"allow":["emit_to"],"deny":[]}},"allow-listen":{"identifier":"allow-listen","description":"Enables the listen command without any pre-configured scope.","commands":{"allow":["listen"],"deny":[]}},"allow-unlisten":{"identifier":"allow-unlisten","description":"Enables the unlisten command without any pre-configured scope.","commands":{"allow":["unlisten"],"deny":[]}},"deny-emit":{"identifier":"deny-emit","description":"Denies the emit command without any pre-configured scope.","commands":{"allow":[],"deny":["emit"]}},"deny-emit-to":{"identifier":"deny-emit-to","description":"Denies the emit_to command without any pre-configured scope.","commands":{"allow":[],"deny":["emit_to"]}},"deny-listen":{"identifier":"deny-listen","description":"Denies the listen command without any pre-configured scope.","commands":{"allow":[],"deny":["listen"]}},"deny-unlisten":{"identifier":"deny-unlisten","description":"Denies the unlisten command without any pre-configured scope.","commands":{"allow":[],"deny":["unlisten"]}}},"permission_sets":{},"global_scope_schema":null},"core:image":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-from-bytes","allow-from-path","allow-rgba","allow-size"]},"permissions":{"allow-from-bytes":{"identifier":"allow-from-bytes","description":"Enables the from_bytes command without any pre-configured scope.","commands":{"allow":["from_bytes"],"deny":[]}},"allow-from-path":{"identifier":"allow-from-path","description":"Enables the from_path command without any pre-configured scope.","commands":{"allow":["from_path"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-rgba":{"identifier":"allow-rgba","description":"Enables the rgba command without any pre-configured scope.","commands":{"allow":["rgba"],"deny":[]}},"allow-size":{"identifier":"allow-size","description":"Enables the size command without any pre-configured scope.","commands":{"allow":["size"],"deny":[]}},"deny-from-bytes":{"identifier":"deny-from-bytes","description":"Denies the from_bytes command without any pre-configured scope.","commands":{"allow":[],"deny":["from_bytes"]}},"deny-from-path":{"identifier":"deny-from-path","description":"Denies the from_path command without any pre-configured scope.","commands":{"allow":[],"deny":["from_path"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-rgba":{"identifier":"deny-rgba","description":"Denies the rgba command without any pre-configured scope.","commands":{"allow":[],"deny":["rgba"]}},"deny-size":{"identifier":"deny-size","description":"Denies the size command without any pre-configured scope.","commands":{"allow":[],"deny":["size"]}}},"permission_sets":{},"global_scope_schema":null},"core:menu":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-append","allow-prepend","allow-insert","allow-remove","allow-remove-at","allow-items","allow-get","allow-popup","allow-create-default","allow-set-as-app-menu","allow-set-as-window-menu","allow-text","allow-set-text","allow-is-enabled","allow-set-enabled","allow-set-accelerator","allow-set-as-windows-menu-for-nsapp","allow-set-as-help-menu-for-nsapp","allow-is-checked","allow-set-checked","allow-set-icon"]},"permissions":{"allow-append":{"identifier":"allow-append","description":"Enables the append command without any pre-configured scope.","commands":{"allow":["append"],"deny":[]}},"allow-create-default":{"identifier":"allow-create-default","description":"Enables the create_default command without any pre-configured scope.","commands":{"allow":["create_default"],"deny":[]}},"allow-get":{"identifier":"allow-get","description":"Enables the get command without any pre-configured scope.","commands":{"allow":["get"],"deny":[]}},"allow-insert":{"identifier":"allow-insert","description":"Enables the insert command without any pre-configured scope.","commands":{"allow":["insert"],"deny":[]}},"allow-is-checked":{"identifier":"allow-is-checked","description":"Enables the is_checked command without any pre-configured scope.","commands":{"allow":["is_checked"],"deny":[]}},"allow-is-enabled":{"identifier":"allow-is-enabled","description":"Enables the is_enabled command without any pre-configured scope.","commands":{"allow":["is_enabled"],"deny":[]}},"allow-items":{"identifier":"allow-items","description":"Enables the items command without any pre-configured scope.","commands":{"allow":["items"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-popup":{"identifier":"allow-popup","description":"Enables the popup command without any pre-configured scope.","commands":{"allow":["popup"],"deny":[]}},"allow-prepend":{"identifier":"allow-prepend","description":"Enables the prepend command without any pre-configured scope.","commands":{"allow":["prepend"],"deny":[]}},"allow-remove":{"identifier":"allow-remove","description":"Enables the remove command without any pre-configured scope.","commands":{"allow":["remove"],"deny":[]}},"allow-remove-at":{"identifier":"allow-remove-at","description":"Enables the remove_at command without any pre-configured scope.","commands":{"allow":["remove_at"],"deny":[]}},"allow-set-accelerator":{"identifier":"allow-set-accelerator","description":"Enables the set_accelerator command without any pre-configured scope.","commands":{"allow":["set_accelerator"],"deny":[]}},"allow-set-as-app-menu":{"identifier":"allow-set-as-app-menu","description":"Enables the set_as_app_menu command without any pre-configured scope.","commands":{"allow":["set_as_app_menu"],"deny":[]}},"allow-set-as-help-menu-for-nsapp":{"identifier":"allow-set-as-help-menu-for-nsapp","description":"Enables the set_as_help_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":["set_as_help_menu_for_nsapp"],"deny":[]}},"allow-set-as-window-menu":{"identifier":"allow-set-as-window-menu","description":"Enables the set_as_window_menu command without any pre-configured scope.","commands":{"allow":["set_as_window_menu"],"deny":[]}},"allow-set-as-windows-menu-for-nsapp":{"identifier":"allow-set-as-windows-menu-for-nsapp","description":"Enables the set_as_windows_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":["set_as_windows_menu_for_nsapp"],"deny":[]}},"allow-set-checked":{"identifier":"allow-set-checked","description":"Enables the set_checked command without any pre-configured scope.","commands":{"allow":["set_checked"],"deny":[]}},"allow-set-enabled":{"identifier":"allow-set-enabled","description":"Enables the set_enabled command without any pre-configured scope.","commands":{"allow":["set_enabled"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-text":{"identifier":"allow-set-text","description":"Enables the set_text command without any pre-configured scope.","commands":{"allow":["set_text"],"deny":[]}},"allow-text":{"identifier":"allow-text","description":"Enables the text command without any pre-configured scope.","commands":{"allow":["text"],"deny":[]}},"deny-append":{"identifier":"deny-append","description":"Denies the append command without any pre-configured scope.","commands":{"allow":[],"deny":["append"]}},"deny-create-default":{"identifier":"deny-create-default","description":"Denies the create_default command without any pre-configured scope.","commands":{"allow":[],"deny":["create_default"]}},"deny-get":{"identifier":"deny-get","description":"Denies the get command without any pre-configured scope.","commands":{"allow":[],"deny":["get"]}},"deny-insert":{"identifier":"deny-insert","description":"Denies the insert command without any pre-configured scope.","commands":{"allow":[],"deny":["insert"]}},"deny-is-checked":{"identifier":"deny-is-checked","description":"Denies the is_checked command without any pre-configured scope.","commands":{"allow":[],"deny":["is_checked"]}},"deny-is-enabled":{"identifier":"deny-is-enabled","description":"Denies the is_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["is_enabled"]}},"deny-items":{"identifier":"deny-items","description":"Denies the items command without any pre-configured scope.","commands":{"allow":[],"deny":["items"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-popup":{"identifier":"deny-popup","description":"Denies the popup command without any pre-configured scope.","commands":{"allow":[],"deny":["popup"]}},"deny-prepend":{"identifier":"deny-prepend","description":"Denies the prepend command without any pre-configured scope.","commands":{"allow":[],"deny":["prepend"]}},"deny-remove":{"identifier":"deny-remove","description":"Denies the remove command without any pre-configured scope.","commands":{"allow":[],"deny":["remove"]}},"deny-remove-at":{"identifier":"deny-remove-at","description":"Denies the remove_at command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_at"]}},"deny-set-accelerator":{"identifier":"deny-set-accelerator","description":"Denies the set_accelerator command without any pre-configured scope.","commands":{"allow":[],"deny":["set_accelerator"]}},"deny-set-as-app-menu":{"identifier":"deny-set-as-app-menu","description":"Denies the set_as_app_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_app_menu"]}},"deny-set-as-help-menu-for-nsapp":{"identifier":"deny-set-as-help-menu-for-nsapp","description":"Denies the set_as_help_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_help_menu_for_nsapp"]}},"deny-set-as-window-menu":{"identifier":"deny-set-as-window-menu","description":"Denies the set_as_window_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_window_menu"]}},"deny-set-as-windows-menu-for-nsapp":{"identifier":"deny-set-as-windows-menu-for-nsapp","description":"Denies the set_as_windows_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_windows_menu_for_nsapp"]}},"deny-set-checked":{"identifier":"deny-set-checked","description":"Denies the set_checked command without any pre-configured scope.","commands":{"allow":[],"deny":["set_checked"]}},"deny-set-enabled":{"identifier":"deny-set-enabled","description":"Denies the set_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_enabled"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-text":{"identifier":"deny-set-text","description":"Denies the set_text command without any pre-configured scope.","commands":{"allow":[],"deny":["set_text"]}},"deny-text":{"identifier":"deny-text","description":"Denies the text command without any pre-configured scope.","commands":{"allow":[],"deny":["text"]}}},"permission_sets":{},"global_scope_schema":null},"core:path":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-resolve-directory","allow-resolve","allow-normalize","allow-join","allow-dirname","allow-extname","allow-basename","allow-is-absolute"]},"permissions":{"allow-basename":{"identifier":"allow-basename","description":"Enables the basename command without any pre-configured scope.","commands":{"allow":["basename"],"deny":[]}},"allow-dirname":{"identifier":"allow-dirname","description":"Enables the dirname command without any pre-configured scope.","commands":{"allow":["dirname"],"deny":[]}},"allow-extname":{"identifier":"allow-extname","description":"Enables the extname command without any pre-configured scope.","commands":{"allow":["extname"],"deny":[]}},"allow-is-absolute":{"identifier":"allow-is-absolute","description":"Enables the is_absolute command without any pre-configured scope.","commands":{"allow":["is_absolute"],"deny":[]}},"allow-join":{"identifier":"allow-join","description":"Enables the join command without any pre-configured scope.","commands":{"allow":["join"],"deny":[]}},"allow-normalize":{"identifier":"allow-normalize","description":"Enables the normalize command without any pre-configured scope.","commands":{"allow":["normalize"],"deny":[]}},"allow-resolve":{"identifier":"allow-resolve","description":"Enables the resolve command without any pre-configured scope.","commands":{"allow":["resolve"],"deny":[]}},"allow-resolve-directory":{"identifier":"allow-resolve-directory","description":"Enables the resolve_directory command without any pre-configured scope.","commands":{"allow":["resolve_directory"],"deny":[]}},"deny-basename":{"identifier":"deny-basename","description":"Denies the basename command without any pre-configured scope.","commands":{"allow":[],"deny":["basename"]}},"deny-dirname":{"identifier":"deny-dirname","description":"Denies the dirname command without any pre-configured scope.","commands":{"allow":[],"deny":["dirname"]}},"deny-extname":{"identifier":"deny-extname","description":"Denies the extname command without any pre-configured scope.","commands":{"allow":[],"deny":["extname"]}},"deny-is-absolute":{"identifier":"deny-is-absolute","description":"Denies the is_absolute command without any pre-configured scope.","commands":{"allow":[],"deny":["is_absolute"]}},"deny-join":{"identifier":"deny-join","description":"Denies the join command without any pre-configured scope.","commands":{"allow":[],"deny":["join"]}},"deny-normalize":{"identifier":"deny-normalize","description":"Denies the normalize command without any pre-configured scope.","commands":{"allow":[],"deny":["normalize"]}},"deny-resolve":{"identifier":"deny-resolve","description":"Denies the resolve command without any pre-configured scope.","commands":{"allow":[],"deny":["resolve"]}},"deny-resolve-directory":{"identifier":"deny-resolve-directory","description":"Denies the resolve_directory command without any pre-configured scope.","commands":{"allow":[],"deny":["resolve_directory"]}}},"permission_sets":{},"global_scope_schema":null},"core:resources":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-close"]},"permissions":{"allow-close":{"identifier":"allow-close","description":"Enables the close command without any pre-configured scope.","commands":{"allow":["close"],"deny":[]}},"deny-close":{"identifier":"deny-close","description":"Denies the close command without any pre-configured scope.","commands":{"allow":[],"deny":["close"]}}},"permission_sets":{},"global_scope_schema":null},"core:tray":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-get-by-id","allow-remove-by-id","allow-set-icon","allow-set-menu","allow-set-tooltip","allow-set-title","allow-set-visible","allow-set-temp-dir-path","allow-set-icon-as-template","allow-set-icon-with-as-template","allow-set-show-menu-on-left-click"]},"permissions":{"allow-get-by-id":{"identifier":"allow-get-by-id","description":"Enables the get_by_id command without any pre-configured scope.","commands":{"allow":["get_by_id"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-remove-by-id":{"identifier":"allow-remove-by-id","description":"Enables the remove_by_id command without any pre-configured scope.","commands":{"allow":["remove_by_id"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-icon-as-template":{"identifier":"allow-set-icon-as-template","description":"Enables the set_icon_as_template command without any pre-configured scope.","commands":{"allow":["set_icon_as_template"],"deny":[]}},"allow-set-icon-with-as-template":{"identifier":"allow-set-icon-with-as-template","description":"Enables the set_icon_with_as_template command without any pre-configured scope.","commands":{"allow":["set_icon_with_as_template"],"deny":[]}},"allow-set-menu":{"identifier":"allow-set-menu","description":"Enables the set_menu command without any pre-configured scope.","commands":{"allow":["set_menu"],"deny":[]}},"allow-set-show-menu-on-left-click":{"identifier":"allow-set-show-menu-on-left-click","description":"Enables the set_show_menu_on_left_click command without any pre-configured scope.","commands":{"allow":["set_show_menu_on_left_click"],"deny":[]}},"allow-set-temp-dir-path":{"identifier":"allow-set-temp-dir-path","description":"Enables the set_temp_dir_path command without any pre-configured scope.","commands":{"allow":["set_temp_dir_path"],"deny":[]}},"allow-set-title":{"identifier":"allow-set-title","description":"Enables the set_title command without any pre-configured scope.","commands":{"allow":["set_title"],"deny":[]}},"allow-set-tooltip":{"identifier":"allow-set-tooltip","description":"Enables the set_tooltip command without any pre-configured scope.","commands":{"allow":["set_tooltip"],"deny":[]}},"allow-set-visible":{"identifier":"allow-set-visible","description":"Enables the set_visible command without any pre-configured scope.","commands":{"allow":["set_visible"],"deny":[]}},"deny-get-by-id":{"identifier":"deny-get-by-id","description":"Denies the get_by_id command without any pre-configured scope.","commands":{"allow":[],"deny":["get_by_id"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-remove-by-id":{"identifier":"deny-remove-by-id","description":"Denies the remove_by_id command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_by_id"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-icon-as-template":{"identifier":"deny-set-icon-as-template","description":"Denies the set_icon_as_template command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon_as_template"]}},"deny-set-icon-with-as-template":{"identifier":"deny-set-icon-with-as-template","description":"Denies the set_icon_with_as_template command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon_with_as_template"]}},"deny-set-menu":{"identifier":"deny-set-menu","description":"Denies the set_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_menu"]}},"deny-set-show-menu-on-left-click":{"identifier":"deny-set-show-menu-on-left-click","description":"Denies the set_show_menu_on_left_click command without any pre-configured scope.","commands":{"allow":[],"deny":["set_show_menu_on_left_click"]}},"deny-set-temp-dir-path":{"identifier":"deny-set-temp-dir-path","description":"Denies the set_temp_dir_path command without any pre-configured scope.","commands":{"allow":[],"deny":["set_temp_dir_path"]}},"deny-set-title":{"identifier":"deny-set-title","description":"Denies the set_title command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title"]}},"deny-set-tooltip":{"identifier":"deny-set-tooltip","description":"Denies the set_tooltip command without any pre-configured scope.","commands":{"allow":[],"deny":["set_tooltip"]}},"deny-set-visible":{"identifier":"deny-set-visible","description":"Denies the set_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["set_visible"]}}},"permission_sets":{},"global_scope_schema":null},"core:webview":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-get-all-webviews","allow-webview-position","allow-webview-size","allow-internal-toggle-devtools"]},"permissions":{"allow-clear-all-browsing-data":{"identifier":"allow-clear-all-browsing-data","description":"Enables the clear_all_browsing_data command without any pre-configured scope.","commands":{"allow":["clear_all_browsing_data"],"deny":[]}},"allow-create-webview":{"identifier":"allow-create-webview","description":"Enables the create_webview command without any pre-configured scope.","commands":{"allow":["create_webview"],"deny":[]}},"allow-create-webview-window":{"identifier":"allow-create-webview-window","description":"Enables the create_webview_window command without any pre-configured scope.","commands":{"allow":["create_webview_window"],"deny":[]}},"allow-get-all-webviews":{"identifier":"allow-get-all-webviews","description":"Enables the get_all_webviews command without any pre-configured scope.","commands":{"allow":["get_all_webviews"],"deny":[]}},"allow-internal-toggle-devtools":{"identifier":"allow-internal-toggle-devtools","description":"Enables the internal_toggle_devtools command without any pre-configured scope.","commands":{"allow":["internal_toggle_devtools"],"deny":[]}},"allow-print":{"identifier":"allow-print","description":"Enables the print command without any pre-configured scope.","commands":{"allow":["print"],"deny":[]}},"allow-reparent":{"identifier":"allow-reparent","description":"Enables the reparent command without any pre-configured scope.","commands":{"allow":["reparent"],"deny":[]}},"allow-set-webview-auto-resize":{"identifier":"allow-set-webview-auto-resize","description":"Enables the set_webview_auto_resize command without any pre-configured scope.","commands":{"allow":["set_webview_auto_resize"],"deny":[]}},"allow-set-webview-background-color":{"identifier":"allow-set-webview-background-color","description":"Enables the set_webview_background_color command without any pre-configured scope.","commands":{"allow":["set_webview_background_color"],"deny":[]}},"allow-set-webview-focus":{"identifier":"allow-set-webview-focus","description":"Enables the set_webview_focus command without any pre-configured scope.","commands":{"allow":["set_webview_focus"],"deny":[]}},"allow-set-webview-position":{"identifier":"allow-set-webview-position","description":"Enables the set_webview_position command without any pre-configured scope.","commands":{"allow":["set_webview_position"],"deny":[]}},"allow-set-webview-size":{"identifier":"allow-set-webview-size","description":"Enables the set_webview_size command without any pre-configured scope.","commands":{"allow":["set_webview_size"],"deny":[]}},"allow-set-webview-zoom":{"identifier":"allow-set-webview-zoom","description":"Enables the set_webview_zoom command without any pre-configured scope.","commands":{"allow":["set_webview_zoom"],"deny":[]}},"allow-webview-close":{"identifier":"allow-webview-close","description":"Enables the webview_close command without any pre-configured scope.","commands":{"allow":["webview_close"],"deny":[]}},"allow-webview-hide":{"identifier":"allow-webview-hide","description":"Enables the webview_hide command without any pre-configured scope.","commands":{"allow":["webview_hide"],"deny":[]}},"allow-webview-position":{"identifier":"allow-webview-position","description":"Enables the webview_position command without any pre-configured scope.","commands":{"allow":["webview_position"],"deny":[]}},"allow-webview-show":{"identifier":"allow-webview-show","description":"Enables the webview_show command without any pre-configured scope.","commands":{"allow":["webview_show"],"deny":[]}},"allow-webview-size":{"identifier":"allow-webview-size","description":"Enables the webview_size command without any pre-configured scope.","commands":{"allow":["webview_size"],"deny":[]}},"deny-clear-all-browsing-data":{"identifier":"deny-clear-all-browsing-data","description":"Denies the clear_all_browsing_data command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_all_browsing_data"]}},"deny-create-webview":{"identifier":"deny-create-webview","description":"Denies the create_webview command without any pre-configured scope.","commands":{"allow":[],"deny":["create_webview"]}},"deny-create-webview-window":{"identifier":"deny-create-webview-window","description":"Denies the create_webview_window command without any pre-configured scope.","commands":{"allow":[],"deny":["create_webview_window"]}},"deny-get-all-webviews":{"identifier":"deny-get-all-webviews","description":"Denies the get_all_webviews command without any pre-configured scope.","commands":{"allow":[],"deny":["get_all_webviews"]}},"deny-internal-toggle-devtools":{"identifier":"deny-internal-toggle-devtools","description":"Denies the internal_toggle_devtools command without any pre-configured scope.","commands":{"allow":[],"deny":["internal_toggle_devtools"]}},"deny-print":{"identifier":"deny-print","description":"Denies the print command without any pre-configured scope.","commands":{"allow":[],"deny":["print"]}},"deny-reparent":{"identifier":"deny-reparent","description":"Denies the reparent command without any pre-configured scope.","commands":{"allow":[],"deny":["reparent"]}},"deny-set-webview-auto-resize":{"identifier":"deny-set-webview-auto-resize","description":"Denies the set_webview_auto_resize command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_auto_resize"]}},"deny-set-webview-background-color":{"identifier":"deny-set-webview-background-color","description":"Denies the set_webview_background_color command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_background_color"]}},"deny-set-webview-focus":{"identifier":"deny-set-webview-focus","description":"Denies the set_webview_focus command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_focus"]}},"deny-set-webview-position":{"identifier":"deny-set-webview-position","description":"Denies the set_webview_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_position"]}},"deny-set-webview-size":{"identifier":"deny-set-webview-size","description":"Denies the set_webview_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_size"]}},"deny-set-webview-zoom":{"identifier":"deny-set-webview-zoom","description":"Denies the set_webview_zoom command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_zoom"]}},"deny-webview-close":{"identifier":"deny-webview-close","description":"Denies the webview_close command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_close"]}},"deny-webview-hide":{"identifier":"deny-webview-hide","description":"Denies the webview_hide command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_hide"]}},"deny-webview-position":{"identifier":"deny-webview-position","description":"Denies the webview_position command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_position"]}},"deny-webview-show":{"identifier":"deny-webview-show","description":"Denies the webview_show command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_show"]}},"deny-webview-size":{"identifier":"deny-webview-size","description":"Denies the webview_size command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_size"]}}},"permission_sets":{},"global_scope_schema":null},"core:window":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-get-all-windows","allow-scale-factor","allow-inner-position","allow-outer-position","allow-inner-size","allow-outer-size","allow-is-fullscreen","allow-is-minimized","allow-is-maximized","allow-is-focused","allow-is-decorated","allow-is-resizable","allow-is-maximizable","allow-is-minimizable","allow-is-closable","allow-is-visible","allow-is-enabled","allow-title","allow-current-monitor","allow-primary-monitor","allow-monitor-from-point","allow-available-monitors","allow-cursor-position","allow-theme","allow-is-always-on-top","allow-activity-name","allow-scene-identifier","allow-internal-toggle-maximize"]},"permissions":{"allow-activity-name":{"identifier":"allow-activity-name","description":"Enables the activity_name command without any pre-configured scope.","commands":{"allow":["activity_name"],"deny":[]}},"allow-available-monitors":{"identifier":"allow-available-monitors","description":"Enables the available_monitors command without any pre-configured scope.","commands":{"allow":["available_monitors"],"deny":[]}},"allow-center":{"identifier":"allow-center","description":"Enables the center command without any pre-configured scope.","commands":{"allow":["center"],"deny":[]}},"allow-close":{"identifier":"allow-close","description":"Enables the close command without any pre-configured scope.","commands":{"allow":["close"],"deny":[]}},"allow-create":{"identifier":"allow-create","description":"Enables the create command without any pre-configured scope.","commands":{"allow":["create"],"deny":[]}},"allow-current-monitor":{"identifier":"allow-current-monitor","description":"Enables the current_monitor command without any pre-configured scope.","commands":{"allow":["current_monitor"],"deny":[]}},"allow-cursor-position":{"identifier":"allow-cursor-position","description":"Enables the cursor_position command without any pre-configured scope.","commands":{"allow":["cursor_position"],"deny":[]}},"allow-destroy":{"identifier":"allow-destroy","description":"Enables the destroy command without any pre-configured scope.","commands":{"allow":["destroy"],"deny":[]}},"allow-get-all-windows":{"identifier":"allow-get-all-windows","description":"Enables the get_all_windows command without any pre-configured scope.","commands":{"allow":["get_all_windows"],"deny":[]}},"allow-hide":{"identifier":"allow-hide","description":"Enables the hide command without any pre-configured scope.","commands":{"allow":["hide"],"deny":[]}},"allow-inner-position":{"identifier":"allow-inner-position","description":"Enables the inner_position command without any pre-configured scope.","commands":{"allow":["inner_position"],"deny":[]}},"allow-inner-size":{"identifier":"allow-inner-size","description":"Enables the inner_size command without any pre-configured scope.","commands":{"allow":["inner_size"],"deny":[]}},"allow-internal-toggle-maximize":{"identifier":"allow-internal-toggle-maximize","description":"Enables the internal_toggle_maximize command without any pre-configured scope.","commands":{"allow":["internal_toggle_maximize"],"deny":[]}},"allow-is-always-on-top":{"identifier":"allow-is-always-on-top","description":"Enables the is_always_on_top command without any pre-configured scope.","commands":{"allow":["is_always_on_top"],"deny":[]}},"allow-is-closable":{"identifier":"allow-is-closable","description":"Enables the is_closable command without any pre-configured scope.","commands":{"allow":["is_closable"],"deny":[]}},"allow-is-decorated":{"identifier":"allow-is-decorated","description":"Enables the is_decorated command without any pre-configured scope.","commands":{"allow":["is_decorated"],"deny":[]}},"allow-is-enabled":{"identifier":"allow-is-enabled","description":"Enables the is_enabled command without any pre-configured scope.","commands":{"allow":["is_enabled"],"deny":[]}},"allow-is-focused":{"identifier":"allow-is-focused","description":"Enables the is_focused command without any pre-configured scope.","commands":{"allow":["is_focused"],"deny":[]}},"allow-is-fullscreen":{"identifier":"allow-is-fullscreen","description":"Enables the is_fullscreen command without any pre-configured scope.","commands":{"allow":["is_fullscreen"],"deny":[]}},"allow-is-maximizable":{"identifier":"allow-is-maximizable","description":"Enables the is_maximizable command without any pre-configured scope.","commands":{"allow":["is_maximizable"],"deny":[]}},"allow-is-maximized":{"identifier":"allow-is-maximized","description":"Enables the is_maximized command without any pre-configured scope.","commands":{"allow":["is_maximized"],"deny":[]}},"allow-is-minimizable":{"identifier":"allow-is-minimizable","description":"Enables the is_minimizable command without any pre-configured scope.","commands":{"allow":["is_minimizable"],"deny":[]}},"allow-is-minimized":{"identifier":"allow-is-minimized","description":"Enables the is_minimized command without any pre-configured scope.","commands":{"allow":["is_minimized"],"deny":[]}},"allow-is-resizable":{"identifier":"allow-is-resizable","description":"Enables the is_resizable command without any pre-configured scope.","commands":{"allow":["is_resizable"],"deny":[]}},"allow-is-visible":{"identifier":"allow-is-visible","description":"Enables the is_visible command without any pre-configured scope.","commands":{"allow":["is_visible"],"deny":[]}},"allow-maximize":{"identifier":"allow-maximize","description":"Enables the maximize command without any pre-configured scope.","commands":{"allow":["maximize"],"deny":[]}},"allow-minimize":{"identifier":"allow-minimize","description":"Enables the minimize command without any pre-configured scope.","commands":{"allow":["minimize"],"deny":[]}},"allow-monitor-from-point":{"identifier":"allow-monitor-from-point","description":"Enables the monitor_from_point command without any pre-configured scope.","commands":{"allow":["monitor_from_point"],"deny":[]}},"allow-outer-position":{"identifier":"allow-outer-position","description":"Enables the outer_position command without any pre-configured scope.","commands":{"allow":["outer_position"],"deny":[]}},"allow-outer-size":{"identifier":"allow-outer-size","description":"Enables the outer_size command without any pre-configured scope.","commands":{"allow":["outer_size"],"deny":[]}},"allow-primary-monitor":{"identifier":"allow-primary-monitor","description":"Enables the primary_monitor command without any pre-configured scope.","commands":{"allow":["primary_monitor"],"deny":[]}},"allow-request-user-attention":{"identifier":"allow-request-user-attention","description":"Enables the request_user_attention command without any pre-configured scope.","commands":{"allow":["request_user_attention"],"deny":[]}},"allow-scale-factor":{"identifier":"allow-scale-factor","description":"Enables the scale_factor command without any pre-configured scope.","commands":{"allow":["scale_factor"],"deny":[]}},"allow-scene-identifier":{"identifier":"allow-scene-identifier","description":"Enables the scene_identifier command without any pre-configured scope.","commands":{"allow":["scene_identifier"],"deny":[]}},"allow-set-always-on-bottom":{"identifier":"allow-set-always-on-bottom","description":"Enables the set_always_on_bottom command without any pre-configured scope.","commands":{"allow":["set_always_on_bottom"],"deny":[]}},"allow-set-always-on-top":{"identifier":"allow-set-always-on-top","description":"Enables the set_always_on_top command without any pre-configured scope.","commands":{"allow":["set_always_on_top"],"deny":[]}},"allow-set-background-color":{"identifier":"allow-set-background-color","description":"Enables the set_background_color command without any pre-configured scope.","commands":{"allow":["set_background_color"],"deny":[]}},"allow-set-badge-count":{"identifier":"allow-set-badge-count","description":"Enables the set_badge_count command without any pre-configured scope.","commands":{"allow":["set_badge_count"],"deny":[]}},"allow-set-badge-label":{"identifier":"allow-set-badge-label","description":"Enables the set_badge_label command without any pre-configured scope.","commands":{"allow":["set_badge_label"],"deny":[]}},"allow-set-closable":{"identifier":"allow-set-closable","description":"Enables the set_closable command without any pre-configured scope.","commands":{"allow":["set_closable"],"deny":[]}},"allow-set-content-protected":{"identifier":"allow-set-content-protected","description":"Enables the set_content_protected command without any pre-configured scope.","commands":{"allow":["set_content_protected"],"deny":[]}},"allow-set-cursor-grab":{"identifier":"allow-set-cursor-grab","description":"Enables the set_cursor_grab command without any pre-configured scope.","commands":{"allow":["set_cursor_grab"],"deny":[]}},"allow-set-cursor-icon":{"identifier":"allow-set-cursor-icon","description":"Enables the set_cursor_icon command without any pre-configured scope.","commands":{"allow":["set_cursor_icon"],"deny":[]}},"allow-set-cursor-position":{"identifier":"allow-set-cursor-position","description":"Enables the set_cursor_position command without any pre-configured scope.","commands":{"allow":["set_cursor_position"],"deny":[]}},"allow-set-cursor-visible":{"identifier":"allow-set-cursor-visible","description":"Enables the set_cursor_visible command without any pre-configured scope.","commands":{"allow":["set_cursor_visible"],"deny":[]}},"allow-set-decorations":{"identifier":"allow-set-decorations","description":"Enables the set_decorations command without any pre-configured scope.","commands":{"allow":["set_decorations"],"deny":[]}},"allow-set-effects":{"identifier":"allow-set-effects","description":"Enables the set_effects command without any pre-configured scope.","commands":{"allow":["set_effects"],"deny":[]}},"allow-set-enabled":{"identifier":"allow-set-enabled","description":"Enables the set_enabled command without any pre-configured scope.","commands":{"allow":["set_enabled"],"deny":[]}},"allow-set-focus":{"identifier":"allow-set-focus","description":"Enables the set_focus command without any pre-configured scope.","commands":{"allow":["set_focus"],"deny":[]}},"allow-set-focusable":{"identifier":"allow-set-focusable","description":"Enables the set_focusable command without any pre-configured scope.","commands":{"allow":["set_focusable"],"deny":[]}},"allow-set-fullscreen":{"identifier":"allow-set-fullscreen","description":"Enables the set_fullscreen command without any pre-configured scope.","commands":{"allow":["set_fullscreen"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-ignore-cursor-events":{"identifier":"allow-set-ignore-cursor-events","description":"Enables the set_ignore_cursor_events command without any pre-configured scope.","commands":{"allow":["set_ignore_cursor_events"],"deny":[]}},"allow-set-max-size":{"identifier":"allow-set-max-size","description":"Enables the set_max_size command without any pre-configured scope.","commands":{"allow":["set_max_size"],"deny":[]}},"allow-set-maximizable":{"identifier":"allow-set-maximizable","description":"Enables the set_maximizable command without any pre-configured scope.","commands":{"allow":["set_maximizable"],"deny":[]}},"allow-set-min-size":{"identifier":"allow-set-min-size","description":"Enables the set_min_size command without any pre-configured scope.","commands":{"allow":["set_min_size"],"deny":[]}},"allow-set-minimizable":{"identifier":"allow-set-minimizable","description":"Enables the set_minimizable command without any pre-configured scope.","commands":{"allow":["set_minimizable"],"deny":[]}},"allow-set-overlay-icon":{"identifier":"allow-set-overlay-icon","description":"Enables the set_overlay_icon command without any pre-configured scope.","commands":{"allow":["set_overlay_icon"],"deny":[]}},"allow-set-position":{"identifier":"allow-set-position","description":"Enables the set_position command without any pre-configured scope.","commands":{"allow":["set_position"],"deny":[]}},"allow-set-progress-bar":{"identifier":"allow-set-progress-bar","description":"Enables the set_progress_bar command without any pre-configured scope.","commands":{"allow":["set_progress_bar"],"deny":[]}},"allow-set-resizable":{"identifier":"allow-set-resizable","description":"Enables the set_resizable command without any pre-configured scope.","commands":{"allow":["set_resizable"],"deny":[]}},"allow-set-shadow":{"identifier":"allow-set-shadow","description":"Enables the set_shadow command without any pre-configured scope.","commands":{"allow":["set_shadow"],"deny":[]}},"allow-set-simple-fullscreen":{"identifier":"allow-set-simple-fullscreen","description":"Enables the set_simple_fullscreen command without any pre-configured scope.","commands":{"allow":["set_simple_fullscreen"],"deny":[]}},"allow-set-size":{"identifier":"allow-set-size","description":"Enables the set_size command without any pre-configured scope.","commands":{"allow":["set_size"],"deny":[]}},"allow-set-size-constraints":{"identifier":"allow-set-size-constraints","description":"Enables the set_size_constraints command without any pre-configured scope.","commands":{"allow":["set_size_constraints"],"deny":[]}},"allow-set-skip-taskbar":{"identifier":"allow-set-skip-taskbar","description":"Enables the set_skip_taskbar command without any pre-configured scope.","commands":{"allow":["set_skip_taskbar"],"deny":[]}},"allow-set-theme":{"identifier":"allow-set-theme","description":"Enables the set_theme command without any pre-configured scope.","commands":{"allow":["set_theme"],"deny":[]}},"allow-set-title":{"identifier":"allow-set-title","description":"Enables the set_title command without any pre-configured scope.","commands":{"allow":["set_title"],"deny":[]}},"allow-set-title-bar-style":{"identifier":"allow-set-title-bar-style","description":"Enables the set_title_bar_style command without any pre-configured scope.","commands":{"allow":["set_title_bar_style"],"deny":[]}},"allow-set-visible-on-all-workspaces":{"identifier":"allow-set-visible-on-all-workspaces","description":"Enables the set_visible_on_all_workspaces command without any pre-configured scope.","commands":{"allow":["set_visible_on_all_workspaces"],"deny":[]}},"allow-show":{"identifier":"allow-show","description":"Enables the show command without any pre-configured scope.","commands":{"allow":["show"],"deny":[]}},"allow-start-dragging":{"identifier":"allow-start-dragging","description":"Enables the start_dragging command without any pre-configured scope.","commands":{"allow":["start_dragging"],"deny":[]}},"allow-start-resize-dragging":{"identifier":"allow-start-resize-dragging","description":"Enables the start_resize_dragging command without any pre-configured scope.","commands":{"allow":["start_resize_dragging"],"deny":[]}},"allow-theme":{"identifier":"allow-theme","description":"Enables the theme command without any pre-configured scope.","commands":{"allow":["theme"],"deny":[]}},"allow-title":{"identifier":"allow-title","description":"Enables the title command without any pre-configured scope.","commands":{"allow":["title"],"deny":[]}},"allow-toggle-maximize":{"identifier":"allow-toggle-maximize","description":"Enables the toggle_maximize command without any pre-configured scope.","commands":{"allow":["toggle_maximize"],"deny":[]}},"allow-unmaximize":{"identifier":"allow-unmaximize","description":"Enables the unmaximize command without any pre-configured scope.","commands":{"allow":["unmaximize"],"deny":[]}},"allow-unminimize":{"identifier":"allow-unminimize","description":"Enables the unminimize command without any pre-configured scope.","commands":{"allow":["unminimize"],"deny":[]}},"deny-activity-name":{"identifier":"deny-activity-name","description":"Denies the activity_name command without any pre-configured scope.","commands":{"allow":[],"deny":["activity_name"]}},"deny-available-monitors":{"identifier":"deny-available-monitors","description":"Denies the available_monitors command without any pre-configured scope.","commands":{"allow":[],"deny":["available_monitors"]}},"deny-center":{"identifier":"deny-center","description":"Denies the center command without any pre-configured scope.","commands":{"allow":[],"deny":["center"]}},"deny-close":{"identifier":"deny-close","description":"Denies the close command without any pre-configured scope.","commands":{"allow":[],"deny":["close"]}},"deny-create":{"identifier":"deny-create","description":"Denies the create command without any pre-configured scope.","commands":{"allow":[],"deny":["create"]}},"deny-current-monitor":{"identifier":"deny-current-monitor","description":"Denies the current_monitor command without any pre-configured scope.","commands":{"allow":[],"deny":["current_monitor"]}},"deny-cursor-position":{"identifier":"deny-cursor-position","description":"Denies the cursor_position command without any pre-configured scope.","commands":{"allow":[],"deny":["cursor_position"]}},"deny-destroy":{"identifier":"deny-destroy","description":"Denies the destroy command without any pre-configured scope.","commands":{"allow":[],"deny":["destroy"]}},"deny-get-all-windows":{"identifier":"deny-get-all-windows","description":"Denies the get_all_windows command without any pre-configured scope.","commands":{"allow":[],"deny":["get_all_windows"]}},"deny-hide":{"identifier":"deny-hide","description":"Denies the hide command without any pre-configured scope.","commands":{"allow":[],"deny":["hide"]}},"deny-inner-position":{"identifier":"deny-inner-position","description":"Denies the inner_position command without any pre-configured scope.","commands":{"allow":[],"deny":["inner_position"]}},"deny-inner-size":{"identifier":"deny-inner-size","description":"Denies the inner_size command without any pre-configured scope.","commands":{"allow":[],"deny":["inner_size"]}},"deny-internal-toggle-maximize":{"identifier":"deny-internal-toggle-maximize","description":"Denies the internal_toggle_maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["internal_toggle_maximize"]}},"deny-is-always-on-top":{"identifier":"deny-is-always-on-top","description":"Denies the is_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["is_always_on_top"]}},"deny-is-closable":{"identifier":"deny-is-closable","description":"Denies the is_closable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_closable"]}},"deny-is-decorated":{"identifier":"deny-is-decorated","description":"Denies the is_decorated command without any pre-configured scope.","commands":{"allow":[],"deny":["is_decorated"]}},"deny-is-enabled":{"identifier":"deny-is-enabled","description":"Denies the is_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["is_enabled"]}},"deny-is-focused":{"identifier":"deny-is-focused","description":"Denies the is_focused command without any pre-configured scope.","commands":{"allow":[],"deny":["is_focused"]}},"deny-is-fullscreen":{"identifier":"deny-is-fullscreen","description":"Denies the is_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["is_fullscreen"]}},"deny-is-maximizable":{"identifier":"deny-is-maximizable","description":"Denies the is_maximizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_maximizable"]}},"deny-is-maximized":{"identifier":"deny-is-maximized","description":"Denies the is_maximized command without any pre-configured scope.","commands":{"allow":[],"deny":["is_maximized"]}},"deny-is-minimizable":{"identifier":"deny-is-minimizable","description":"Denies the is_minimizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_minimizable"]}},"deny-is-minimized":{"identifier":"deny-is-minimized","description":"Denies the is_minimized command without any pre-configured scope.","commands":{"allow":[],"deny":["is_minimized"]}},"deny-is-resizable":{"identifier":"deny-is-resizable","description":"Denies the is_resizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_resizable"]}},"deny-is-visible":{"identifier":"deny-is-visible","description":"Denies the is_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["is_visible"]}},"deny-maximize":{"identifier":"deny-maximize","description":"Denies the maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["maximize"]}},"deny-minimize":{"identifier":"deny-minimize","description":"Denies the minimize command without any pre-configured scope.","commands":{"allow":[],"deny":["minimize"]}},"deny-monitor-from-point":{"identifier":"deny-monitor-from-point","description":"Denies the monitor_from_point command without any pre-configured scope.","commands":{"allow":[],"deny":["monitor_from_point"]}},"deny-outer-position":{"identifier":"deny-outer-position","description":"Denies the outer_position command without any pre-configured scope.","commands":{"allow":[],"deny":["outer_position"]}},"deny-outer-size":{"identifier":"deny-outer-size","description":"Denies the outer_size command without any pre-configured scope.","commands":{"allow":[],"deny":["outer_size"]}},"deny-primary-monitor":{"identifier":"deny-primary-monitor","description":"Denies the primary_monitor command without any pre-configured scope.","commands":{"allow":[],"deny":["primary_monitor"]}},"deny-request-user-attention":{"identifier":"deny-request-user-attention","description":"Denies the request_user_attention command without any pre-configured scope.","commands":{"allow":[],"deny":["request_user_attention"]}},"deny-scale-factor":{"identifier":"deny-scale-factor","description":"Denies the scale_factor command without any pre-configured scope.","commands":{"allow":[],"deny":["scale_factor"]}},"deny-scene-identifier":{"identifier":"deny-scene-identifier","description":"Denies the scene_identifier command without any pre-configured scope.","commands":{"allow":[],"deny":["scene_identifier"]}},"deny-set-always-on-bottom":{"identifier":"deny-set-always-on-bottom","description":"Denies the set_always_on_bottom command without any pre-configured scope.","commands":{"allow":[],"deny":["set_always_on_bottom"]}},"deny-set-always-on-top":{"identifier":"deny-set-always-on-top","description":"Denies the set_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["set_always_on_top"]}},"deny-set-background-color":{"identifier":"deny-set-background-color","description":"Denies the set_background_color command without any pre-configured scope.","commands":{"allow":[],"deny":["set_background_color"]}},"deny-set-badge-count":{"identifier":"deny-set-badge-count","description":"Denies the set_badge_count command without any pre-configured scope.","commands":{"allow":[],"deny":["set_badge_count"]}},"deny-set-badge-label":{"identifier":"deny-set-badge-label","description":"Denies the set_badge_label command without any pre-configured scope.","commands":{"allow":[],"deny":["set_badge_label"]}},"deny-set-closable":{"identifier":"deny-set-closable","description":"Denies the set_closable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_closable"]}},"deny-set-content-protected":{"identifier":"deny-set-content-protected","description":"Denies the set_content_protected command without any pre-configured scope.","commands":{"allow":[],"deny":["set_content_protected"]}},"deny-set-cursor-grab":{"identifier":"deny-set-cursor-grab","description":"Denies the set_cursor_grab command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_grab"]}},"deny-set-cursor-icon":{"identifier":"deny-set-cursor-icon","description":"Denies the set_cursor_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_icon"]}},"deny-set-cursor-position":{"identifier":"deny-set-cursor-position","description":"Denies the set_cursor_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_position"]}},"deny-set-cursor-visible":{"identifier":"deny-set-cursor-visible","description":"Denies the set_cursor_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_visible"]}},"deny-set-decorations":{"identifier":"deny-set-decorations","description":"Denies the set_decorations command without any pre-configured scope.","commands":{"allow":[],"deny":["set_decorations"]}},"deny-set-effects":{"identifier":"deny-set-effects","description":"Denies the set_effects command without any pre-configured scope.","commands":{"allow":[],"deny":["set_effects"]}},"deny-set-enabled":{"identifier":"deny-set-enabled","description":"Denies the set_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_enabled"]}},"deny-set-focus":{"identifier":"deny-set-focus","description":"Denies the set_focus command without any pre-configured scope.","commands":{"allow":[],"deny":["set_focus"]}},"deny-set-focusable":{"identifier":"deny-set-focusable","description":"Denies the set_focusable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_focusable"]}},"deny-set-fullscreen":{"identifier":"deny-set-fullscreen","description":"Denies the set_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["set_fullscreen"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-ignore-cursor-events":{"identifier":"deny-set-ignore-cursor-events","description":"Denies the set_ignore_cursor_events command without any pre-configured scope.","commands":{"allow":[],"deny":["set_ignore_cursor_events"]}},"deny-set-max-size":{"identifier":"deny-set-max-size","description":"Denies the set_max_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_max_size"]}},"deny-set-maximizable":{"identifier":"deny-set-maximizable","description":"Denies the set_maximizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_maximizable"]}},"deny-set-min-size":{"identifier":"deny-set-min-size","description":"Denies the set_min_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_min_size"]}},"deny-set-minimizable":{"identifier":"deny-set-minimizable","description":"Denies the set_minimizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_minimizable"]}},"deny-set-overlay-icon":{"identifier":"deny-set-overlay-icon","description":"Denies the set_overlay_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_overlay_icon"]}},"deny-set-position":{"identifier":"deny-set-position","description":"Denies the set_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_position"]}},"deny-set-progress-bar":{"identifier":"deny-set-progress-bar","description":"Denies the set_progress_bar command without any pre-configured scope.","commands":{"allow":[],"deny":["set_progress_bar"]}},"deny-set-resizable":{"identifier":"deny-set-resizable","description":"Denies the set_resizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_resizable"]}},"deny-set-shadow":{"identifier":"deny-set-shadow","description":"Denies the set_shadow command without any pre-configured scope.","commands":{"allow":[],"deny":["set_shadow"]}},"deny-set-simple-fullscreen":{"identifier":"deny-set-simple-fullscreen","description":"Denies the set_simple_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["set_simple_fullscreen"]}},"deny-set-size":{"identifier":"deny-set-size","description":"Denies the set_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_size"]}},"deny-set-size-constraints":{"identifier":"deny-set-size-constraints","description":"Denies the set_size_constraints command without any pre-configured scope.","commands":{"allow":[],"deny":["set_size_constraints"]}},"deny-set-skip-taskbar":{"identifier":"deny-set-skip-taskbar","description":"Denies the set_skip_taskbar command without any pre-configured scope.","commands":{"allow":[],"deny":["set_skip_taskbar"]}},"deny-set-theme":{"identifier":"deny-set-theme","description":"Denies the set_theme command without any pre-configured scope.","commands":{"allow":[],"deny":["set_theme"]}},"deny-set-title":{"identifier":"deny-set-title","description":"Denies the set_title command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title"]}},"deny-set-title-bar-style":{"identifier":"deny-set-title-bar-style","description":"Denies the set_title_bar_style command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title_bar_style"]}},"deny-set-visible-on-all-workspaces":{"identifier":"deny-set-visible-on-all-workspaces","description":"Denies the set_visible_on_all_workspaces command without any pre-configured scope.","commands":{"allow":[],"deny":["set_visible_on_all_workspaces"]}},"deny-show":{"identifier":"deny-show","description":"Denies the show command without any pre-configured scope.","commands":{"allow":[],"deny":["show"]}},"deny-start-dragging":{"identifier":"deny-start-dragging","description":"Denies the start_dragging command without any pre-configured scope.","commands":{"allow":[],"deny":["start_dragging"]}},"deny-start-resize-dragging":{"identifier":"deny-start-resize-dragging","description":"Denies the start_resize_dragging command without any pre-configured scope.","commands":{"allow":[],"deny":["start_resize_dragging"]}},"deny-theme":{"identifier":"deny-theme","description":"Denies the theme command without any pre-configured scope.","commands":{"allow":[],"deny":["theme"]}},"deny-title":{"identifier":"deny-title","description":"Denies the title command without any pre-configured scope.","commands":{"allow":[],"deny":["title"]}},"deny-toggle-maximize":{"identifier":"deny-toggle-maximize","description":"Denies the toggle_maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["toggle_maximize"]}},"deny-unmaximize":{"identifier":"deny-unmaximize","description":"Denies the unmaximize command without any pre-configured scope.","commands":{"allow":[],"deny":["unmaximize"]}},"deny-unminimize":{"identifier":"deny-unminimize","description":"Denies the unminimize command without any pre-configured scope.","commands":{"allow":[],"deny":["unminimize"]}}},"permission_sets":{},"global_scope_schema":null},"dialog":{"default_permission":{"identifier":"default","description":"This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n","permissions":["allow-message","allow-save","allow-open"]},"permissions":{"allow-ask":{"identifier":"allow-ask","description":"Enables the ask command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `allow-message` and will be removed in v3)","commands":{"allow":["message"],"deny":[]}},"allow-confirm":{"identifier":"allow-confirm","description":"Enables the confirm command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `allow-message` and will be removed in v3)","commands":{"allow":["message"],"deny":[]}},"allow-message":{"identifier":"allow-message","description":"Enables the message command without any pre-configured scope.","commands":{"allow":["message"],"deny":[]}},"allow-open":{"identifier":"allow-open","description":"Enables the open command without any pre-configured scope.","commands":{"allow":["open"],"deny":[]}},"allow-save":{"identifier":"allow-save","description":"Enables the save command without any pre-configured scope.","commands":{"allow":["save"],"deny":[]}},"deny-ask":{"identifier":"deny-ask","description":"Denies the ask command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `deny-message` and will be removed in v3)","commands":{"allow":[],"deny":["message"]}},"deny-confirm":{"identifier":"deny-confirm","description":"Denies the confirm command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `deny-message` and will be removed in v3)","commands":{"allow":[],"deny":["message"]}},"deny-message":{"identifier":"deny-message","description":"Denies the message command without any pre-configured scope.","commands":{"allow":[],"deny":["message"]}},"deny-open":{"identifier":"deny-open","description":"Denies the open command without any pre-configured scope.","commands":{"allow":[],"deny":["open"]}},"deny-save":{"identifier":"deny-save","description":"Denies the save command without any pre-configured scope.","commands":{"allow":[],"deny":["save"]}}},"permission_sets":{},"global_scope_schema":null},"opener":{"default_permission":{"identifier":"default","description":"This permission set allows opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application\nas well as reveal file in directories using default file explorer","permissions":["allow-open-url","allow-reveal-item-in-dir","allow-default-urls"]},"permissions":{"allow-default-urls":{"identifier":"allow-default-urls","description":"This enables opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application.","commands":{"allow":[],"deny":[]},"scope":{"allow":[{"url":"mailto:*"},{"url":"tel:*"},{"url":"http://*"},{"url":"https://*"}]}},"allow-open-path":{"identifier":"allow-open-path","description":"Enables the open_path command without any pre-configured scope.","commands":{"allow":["open_path"],"deny":[]}},"allow-open-url":{"identifier":"allow-open-url","description":"Enables the open_url command without any pre-configured scope.","commands":{"allow":["open_url"],"deny":[]}},"allow-reveal-item-in-dir":{"identifier":"allow-reveal-item-in-dir","description":"Enables the reveal_item_in_dir command without any pre-configured scope.","commands":{"allow":["reveal_item_in_dir"],"deny":[]}},"deny-open-path":{"identifier":"deny-open-path","description":"Denies the open_path command without any pre-configured scope.","commands":{"allow":[],"deny":["open_path"]}},"deny-open-url":{"identifier":"deny-open-url","description":"Denies the open_url command without any pre-configured scope.","commands":{"allow":[],"deny":["open_url"]}},"deny-reveal-item-in-dir":{"identifier":"deny-reveal-item-in-dir","description":"Denies the reveal_item_in_dir command without any pre-configured scope.","commands":{"allow":[],"deny":["reveal_item_in_dir"]}}},"permission_sets":{},"global_scope_schema":{"$schema":"http://json-schema.org/draft-07/schema#","anyOf":[{"properties":{"app":{"allOf":[{"$ref":"#/definitions/Application"}],"description":"An application to open this url with, for example: firefox."},"url":{"description":"A URL that can be opened by the webview when using the Opener APIs.\n\nWildcards can be used following the UNIX glob pattern.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"","type":"string"}},"required":["url"],"type":"object"},{"properties":{"app":{"allOf":[{"$ref":"#/definitions/Application"}],"description":"An application to open this path with, for example: xdg-open."},"path":{"description":"A path that can be opened by the webview when using the Opener APIs.\n\nThe pattern can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.","type":"string"}},"required":["path"],"type":"object"}],"definitions":{"Application":{"anyOf":[{"description":"Open in default application.","type":"null"},{"description":"If true, allow open with any application.","type":"boolean"},{"description":"Allow specific application to open with.","type":"string"}],"description":"Opener scope application."}},"description":"Opener scope entry.","title":"OpenerScopeEntry"}}} \ No newline at end of file +{"__app-acl__":{"default_permission":null,"permissions":{"allow-acquire-claude-token":{"identifier":"allow-acquire-claude-token","description":"Enables the acquire_claude_token command without any pre-configured scope.","commands":{"allow":["acquire_claude_token"],"deny":[]}},"allow-add-aws-keys-connection":{"identifier":"allow-add-aws-keys-connection","description":"Enables the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":["add_aws_keys_connection"],"deny":[]}},"allow-add-aws-profile-connection":{"identifier":"allow-add-aws-profile-connection","description":"Enables the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":["add_aws_profile_connection"],"deny":[]}},"allow-add-marketplace":{"identifier":"allow-add-marketplace","description":"Enables the add_marketplace command without any pre-configured scope.","commands":{"allow":["add_marketplace"],"deny":[]}},"allow-add-marketplace-gh-host-account":{"identifier":"allow-add-marketplace-gh-host-account","description":"Enables the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_gh_host_account"],"deny":[]}},"allow-add-marketplace-token-account":{"identifier":"allow-add-marketplace-token-account","description":"Enables the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_token_account"],"deny":[]}},"allow-add-project":{"identifier":"allow-add-project","description":"Enables the add_project command without any pre-configured scope.","commands":{"allow":["add_project"],"deny":[]}},"allow-add-scheduled-task":{"identifier":"allow-add-scheduled-task","description":"Enables the add_scheduled_task command without any pre-configured scope.","commands":{"allow":["add_scheduled_task"],"deny":[]}},"allow-apply-marketplace-now":{"identifier":"allow-apply-marketplace-now","description":"Enables the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":["apply_marketplace_now"],"deny":[]}},"allow-apply-settings-import":{"identifier":"allow-apply-settings-import","description":"Enables the apply_settings_import command without any pre-configured scope.","commands":{"allow":["apply_settings_import"],"deny":[]}},"allow-aws-connection-identity":{"identifier":"allow-aws-connection-identity","description":"Enables the aws_connection_identity command without any pre-configured scope.","commands":{"allow":["aws_connection_identity"],"deny":[]}},"allow-aws-connection-sso-login":{"identifier":"allow-aws-connection-sso-login","description":"Enables the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":["aws_connection_sso_login"],"deny":[]}},"allow-aws-cost-estimate":{"identifier":"allow-aws-cost-estimate","description":"Enables the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":["aws_cost_estimate"],"deny":[]}},"allow-aws-ec2-capacity":{"identifier":"allow-aws-ec2-capacity","description":"Enables the aws_ec2_capacity command without any pre-configured scope.","commands":{"allow":["aws_ec2_capacity"],"deny":[]}},"allow-aws-environment-max-hours":{"identifier":"allow-aws-environment-max-hours","description":"Enables the aws_environment_max_hours command without any pre-configured scope.","commands":{"allow":["aws_environment_max_hours"],"deny":[]}},"allow-aws-policy-document":{"identifier":"allow-aws-policy-document","description":"Enables the aws_policy_document command without any pre-configured scope.","commands":{"allow":["aws_policy_document"],"deny":[]}},"allow-aws-sso-refresh":{"identifier":"allow-aws-sso-refresh","description":"Enables the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":["aws_sso_refresh"],"deny":[]}},"allow-aws-task-log":{"identifier":"allow-aws-task-log","description":"Enables the aws_task_log command without any pre-configured scope.","commands":{"allow":["aws_task_log"],"deny":[]}},"allow-aws-workspace-status":{"identifier":"allow-aws-workspace-status","description":"Enables the aws_workspace_status command without any pre-configured scope.","commands":{"allow":["aws_workspace_status"],"deny":[]}},"allow-build-gateway-image":{"identifier":"allow-build-gateway-image","description":"Enables the build_gateway_image command without any pre-configured scope.","commands":{"allow":["build_gateway_image"],"deny":[]}},"allow-build-image":{"identifier":"allow-build-image","description":"Enables the build_image command without any pre-configured scope.","commands":{"allow":["build_image"],"deny":[]}},"allow-build-stt-image":{"identifier":"allow-build-stt-image","description":"Enables the build_stt_image command without any pre-configured scope.","commands":{"allow":["build_stt_image"],"deny":[]}},"allow-cancel-aws-deployment":{"identifier":"allow-cancel-aws-deployment","description":"Enables the cancel_aws_deployment command without any pre-configured scope.","commands":{"allow":["cancel_aws_deployment"],"deny":[]}},"allow-cancel-claude-token":{"identifier":"allow-cancel-claude-token","description":"Enables the cancel_claude_token command without any pre-configured scope.","commands":{"allow":["cancel_claude_token"],"deny":[]}},"allow-cancel-marketplace-gh-login":{"identifier":"allow-cancel-marketplace-gh-login","description":"Enables the cancel_marketplace_gh_login command without any pre-configured scope.","commands":{"allow":["cancel_marketplace_gh_login"],"deny":[]}},"allow-check-aws-permissions":{"identifier":"allow-check-aws-permissions","description":"Enables the check_aws_permissions command without any pre-configured scope.","commands":{"allow":["check_aws_permissions"],"deny":[]}},"allow-check-browser-view-support":{"identifier":"allow-check-browser-view-support","description":"Enables the check_browser_view_support command without any pre-configured scope.","commands":{"allow":["check_browser_view_support"],"deny":[]}},"allow-check-docker":{"identifier":"allow-check-docker","description":"Enables the check_docker command without any pre-configured scope.","commands":{"allow":["check_docker"],"deny":[]}},"allow-check-for-updates":{"identifier":"allow-check-for-updates","description":"Enables the check_for_updates command without any pre-configured scope.","commands":{"allow":["check_for_updates"],"deny":[]}},"allow-check-gateway-health":{"identifier":"allow-check-gateway-health","description":"Enables the check_gateway_health command without any pre-configured scope.","commands":{"allow":["check_gateway_health"],"deny":[]}},"allow-check-image-exists":{"identifier":"allow-check-image-exists","description":"Enables the check_image_exists command without any pre-configured scope.","commands":{"allow":["check_image_exists"],"deny":[]}},"allow-check-image-update":{"identifier":"allow-check-image-update","description":"Enables the check_image_update command without any pre-configured scope.","commands":{"allow":["check_image_update"],"deny":[]}},"allow-check-unsaved-work":{"identifier":"allow-check-unsaved-work","description":"Enables the check_unsaved_work command without any pre-configured scope.","commands":{"allow":["check_unsaved_work"],"deny":[]}},"allow-clear-claude-token":{"identifier":"allow-clear-claude-token","description":"Enables the clear_claude_token command without any pre-configured scope.","commands":{"allow":["clear_claude_token"],"deny":[]}},"allow-clear-gateway-api-key":{"identifier":"allow-clear-gateway-api-key","description":"Enables the clear_gateway_api_key command without any pre-configured scope.","commands":{"allow":["clear_gateway_api_key"],"deny":[]}},"allow-clear-scheduler-notifications":{"identifier":"allow-clear-scheduler-notifications","description":"Enables the clear_scheduler_notifications command without any pre-configured scope.","commands":{"allow":["clear_scheduler_notifications"],"deny":[]}},"allow-close-browser-view-popout":{"identifier":"allow-close-browser-view-popout","description":"Enables the close_browser_view_popout command without any pre-configured scope.","commands":{"allow":["close_browser_view_popout"],"deny":[]}},"allow-close-container-page":{"identifier":"allow-close-container-page","description":"Enables the close_container_page command without any pre-configured scope.","commands":{"allow":["close_container_page"],"deny":[]}},"allow-close-terminal-session":{"identifier":"allow-close-terminal-session","description":"Enables the close_terminal_session command without any pre-configured scope.","commands":{"allow":["close_terminal_session"],"deny":[]}},"allow-confirm-migration":{"identifier":"allow-confirm-migration","description":"Enables the confirm_migration command without any pre-configured scope.","commands":{"allow":["confirm_migration"],"deny":[]}},"allow-create-container-directory":{"identifier":"allow-create-container-directory","description":"Enables the create_container_directory command without any pre-configured scope.","commands":{"allow":["create_container_directory"],"deny":[]}},"allow-delete-note":{"identifier":"allow-delete-note","description":"Enables the delete_note command without any pre-configured scope.","commands":{"allow":["delete_note"],"deny":[]}},"allow-deploy-aws-environment":{"identifier":"allow-deploy-aws-environment","description":"Enables the deploy_aws_environment command without any pre-configured scope.","commands":{"allow":["deploy_aws_environment"],"deny":[]}},"allow-deploy-aws-permissions-boundary":{"identifier":"allow-deploy-aws-permissions-boundary","description":"Enables the deploy_aws_permissions_boundary command without any pre-configured scope.","commands":{"allow":["deploy_aws_permissions_boundary"],"deny":[]}},"allow-destroy-incomplete-aws-environment":{"identifier":"allow-destroy-incomplete-aws-environment","description":"Enables the destroy_incomplete_aws_environment command without any pre-configured scope.","commands":{"allow":["destroy_incomplete_aws_environment"],"deny":[]}},"allow-detect-aws-config":{"identifier":"allow-detect-aws-config","description":"Enables the detect_aws_config command without any pre-configured scope.","commands":{"allow":["detect_aws_config"],"deny":[]}},"allow-detect-aws-environments":{"identifier":"allow-detect-aws-environments","description":"Enables the detect_aws_environments command without any pre-configured scope.","commands":{"allow":["detect_aws_environments"],"deny":[]}},"allow-detect-host-timezone":{"identifier":"allow-detect-host-timezone","description":"Enables the detect_host_timezone command without any pre-configured scope.","commands":{"allow":["detect_host_timezone"],"deny":[]}},"allow-detect-install-options":{"identifier":"allow-detect-install-options","description":"Enables the detect_install_options command without any pre-configured scope.","commands":{"allow":["detect_install_options"],"deny":[]}},"allow-download-container-backup":{"identifier":"allow-download-container-backup","description":"Enables the download_container_backup command without any pre-configured scope.","commands":{"allow":["download_container_backup"],"deny":[]}},"allow-download-container-file":{"identifier":"allow-download-container-file","description":"Enables the download_container_file command without any pre-configured scope.","commands":{"allow":["download_container_file"],"deny":[]}},"allow-ec2-fit-problem":{"identifier":"allow-ec2-fit-problem","description":"Enables the ec2_fit_problem command without any pre-configured scope.","commands":{"allow":["ec2_fit_problem"],"deny":[]}},"allow-export-settings":{"identifier":"allow-export-settings","description":"Enables the export_settings command without any pre-configured scope.","commands":{"allow":["export_settings"],"deny":[]}},"allow-follow-aws-deployment":{"identifier":"allow-follow-aws-deployment","description":"Enables the follow_aws_deployment command without any pre-configured scope.","commands":{"allow":["follow_aws_deployment"],"deny":[]}},"allow-forget-marketplace-installs":{"identifier":"allow-forget-marketplace-installs","description":"Enables the forget_marketplace_installs command without any pre-configured scope.","commands":{"allow":["forget_marketplace_installs"],"deny":[]}},"allow-get-app-version":{"identifier":"allow-get-app-version","description":"Enables the get_app_version command without any pre-configured scope.","commands":{"allow":["get_app_version"],"deny":[]}},"allow-get-auth-bridge-status":{"identifier":"allow-get-auth-bridge-status","description":"Enables the get_auth_bridge_status command without any pre-configured scope.","commands":{"allow":["get_auth_bridge_status"],"deny":[]}},"allow-get-browser-view-match-window":{"identifier":"allow-get-browser-view-match-window","description":"Enables the get_browser_view_match_window command without any pre-configured scope.","commands":{"allow":["get_browser_view_match_window"],"deny":[]}},"allow-get-browser-view-popout-state":{"identifier":"allow-get-browser-view-popout-state","description":"Enables the get_browser_view_popout_state command without any pre-configured scope.","commands":{"allow":["get_browser_view_popout_state"],"deny":[]}},"allow-get-browser-view-status":{"identifier":"allow-get-browser-view-status","description":"Enables the get_browser_view_status command without any pre-configured scope.","commands":{"allow":["get_browser_view_status"],"deny":[]}},"allow-get-container-info":{"identifier":"allow-get-container-info","description":"Enables the get_container_info command without any pre-configured scope.","commands":{"allow":["get_container_info"],"deny":[]}},"allow-get-container-page-state":{"identifier":"allow-get-container-page-state","description":"Enables the get_container_page_state command without any pre-configured scope.","commands":{"allow":["get_container_page_state"],"deny":[]}},"allow-get-container-staleness":{"identifier":"allow-get-container-staleness","description":"Enables the get_container_staleness command without any pre-configured scope.","commands":{"allow":["get_container_staleness"],"deny":[]}},"allow-get-gateway-auth-token":{"identifier":"allow-get-gateway-auth-token","description":"Enables the get_gateway_auth_token command without any pre-configured scope.","commands":{"allow":["get_gateway_auth_token"],"deny":[]}},"allow-get-gateway-status":{"identifier":"allow-get-gateway-status","description":"Enables the get_gateway_status command without any pre-configured scope.","commands":{"allow":["get_gateway_status"],"deny":[]}},"allow-get-help-content":{"identifier":"allow-get-help-content","description":"Enables the get_help_content command without any pre-configured scope.","commands":{"allow":["get_help_content"],"deny":[]}},"allow-get-marketplace-sync-report":{"identifier":"allow-get-marketplace-sync-report","description":"Enables the get_marketplace_sync_report command without any pre-configured scope.","commands":{"allow":["get_marketplace_sync_report"],"deny":[]}},"allow-get-migration-state":{"identifier":"allow-get-migration-state","description":"Enables the get_migration_state command without any pre-configured scope.","commands":{"allow":["get_migration_state"],"deny":[]}},"allow-get-scheduled-task-log":{"identifier":"allow-get-scheduled-task-log","description":"Enables the get_scheduled_task_log command without any pre-configured scope.","commands":{"allow":["get_scheduled_task_log"],"deny":[]}},"allow-get-scheduler-notifications":{"identifier":"allow-get-scheduler-notifications","description":"Enables the get_scheduler_notifications command without any pre-configured scope.","commands":{"allow":["get_scheduler_notifications"],"deny":[]}},"allow-get-settings":{"identifier":"allow-get-settings","description":"Enables the get_settings command without any pre-configured scope.","commands":{"allow":["get_settings"],"deny":[]}},"allow-get-stt-status":{"identifier":"allow-get-stt-status","description":"Enables the get_stt_status command without any pre-configured scope.","commands":{"allow":["get_stt_status"],"deny":[]}},"allow-get-web-terminal-status":{"identifier":"allow-get-web-terminal-status","description":"Enables the get_web_terminal_status command without any pre-configured scope.","commands":{"allow":["get_web_terminal_status"],"deny":[]}},"allow-has-claude-token":{"identifier":"allow-has-claude-token","description":"Enables the has_claude_token command without any pre-configured scope.","commands":{"allow":["has_claude_token"],"deny":[]}},"allow-inspect-ca-cert-path":{"identifier":"allow-inspect-ca-cert-path","description":"Enables the inspect_ca_cert_path command without any pre-configured scope.","commands":{"allow":["inspect_ca_cert_path"],"deny":[]}},"allow-install-browser-view-browser":{"identifier":"allow-install-browser-view-browser","description":"Enables the install_browser_view_browser command without any pre-configured scope.","commands":{"allow":["install_browser_view_browser"],"deny":[]}},"allow-install-browser-view-support":{"identifier":"allow-install-browser-view-support","description":"Enables the install_browser_view_support command without any pre-configured scope.","commands":{"allow":["install_browser_view_support"],"deny":[]}},"allow-install-marketplace-item":{"identifier":"allow-install-marketplace-item","description":"Enables the install_marketplace_item command without any pre-configured scope.","commands":{"allow":["install_marketplace_item"],"deny":[]}},"allow-list-aws-profiles":{"identifier":"allow-list-aws-profiles","description":"Enables the list_aws_profiles command without any pre-configured scope.","commands":{"allow":["list_aws_profiles"],"deny":[]}},"allow-list-claude-sessions":{"identifier":"allow-list-claude-sessions","description":"Enables the list_claude_sessions command without any pre-configured scope.","commands":{"allow":["list_claude_sessions"],"deny":[]}},"allow-list-container-capabilities":{"identifier":"allow-list-container-capabilities","description":"Enables the list_container_capabilities command without any pre-configured scope.","commands":{"allow":["list_container_capabilities"],"deny":[]}},"allow-list-container-files":{"identifier":"allow-list-container-files","description":"Enables the list_container_files command without any pre-configured scope.","commands":{"allow":["list_container_files"],"deny":[]}},"allow-list-ec2-instance-types":{"identifier":"allow-list-ec2-instance-types","description":"Enables the list_ec2_instance_types command without any pre-configured scope.","commands":{"allow":["list_ec2_instance_types"],"deny":[]}},"allow-list-marketplace-snapshots":{"identifier":"allow-list-marketplace-snapshots","description":"Enables the list_marketplace_snapshots command without any pre-configured scope.","commands":{"allow":["list_marketplace_snapshots"],"deny":[]}},"allow-list-marketplace-updates":{"identifier":"allow-list-marketplace-updates","description":"Enables the list_marketplace_updates command without any pre-configured scope.","commands":{"allow":["list_marketplace_updates"],"deny":[]}},"allow-list-notes":{"identifier":"allow-list-notes","description":"Enables the list_notes command without any pre-configured scope.","commands":{"allow":["list_notes"],"deny":[]}},"allow-list-projects":{"identifier":"allow-list-projects","description":"Enables the list_projects command without any pre-configured scope.","commands":{"allow":["list_projects"],"deny":[]}},"allow-list-scheduled-tasks":{"identifier":"allow-list-scheduled-tasks","description":"Enables the list_scheduled_tasks command without any pre-configured scope.","commands":{"allow":["list_scheduled_tasks"],"deny":[]}},"allow-marketplace-gh-host-available":{"identifier":"allow-marketplace-gh-host-available","description":"Enables the marketplace_gh_host_available command without any pre-configured scope.","commands":{"allow":["marketplace_gh_host_available"],"deny":[]}},"allow-marketplace-item-diff":{"identifier":"allow-marketplace-item-diff","description":"Enables the marketplace_item_diff command without any pre-configured scope.","commands":{"allow":["marketplace_item_diff"],"deny":[]}},"allow-migrate-project-to-base":{"identifier":"allow-migrate-project-to-base","description":"Enables the migrate_project_to_base command without any pre-configured scope.","commands":{"allow":["migrate_project_to_base"],"deny":[]}},"allow-onboard-aws-user":{"identifier":"allow-onboard-aws-user","description":"Enables the onboard_aws_user command without any pre-configured scope.","commands":{"allow":["onboard_aws_user"],"deny":[]}},"allow-open-browser-view-popout":{"identifier":"allow-open-browser-view-popout","description":"Enables the open_browser_view_popout command without any pre-configured scope.","commands":{"allow":["open_browser_view_popout"],"deny":[]}},"allow-open-file-viewer":{"identifier":"allow-open-file-viewer","description":"Enables the open_file_viewer command without any pre-configured scope.","commands":{"allow":["open_file_viewer"],"deny":[]}},"allow-open-page-in-container-browser":{"identifier":"allow-open-page-in-container-browser","description":"Enables the open_page_in_container_browser command without any pre-configured scope.","commands":{"allow":["open_page_in_container_browser"],"deny":[]}},"allow-open-terminal-session":{"identifier":"allow-open-terminal-session","description":"Enables the open_terminal_session command without any pre-configured scope.","commands":{"allow":["open_terminal_session"],"deny":[]}},"allow-open-url-external":{"identifier":"allow-open-url-external","description":"Enables the open_url_external command without any pre-configured scope.","commands":{"allow":["open_url_external"],"deny":[]}},"allow-paste-image-to-terminal":{"identifier":"allow-paste-image-to-terminal","description":"Enables the paste_image_to_terminal command without any pre-configured scope.","commands":{"allow":["paste_image_to_terminal"],"deny":[]}},"allow-preview-settings-import":{"identifier":"allow-preview-settings-import","description":"Enables the preview_settings_import command without any pre-configured scope.","commands":{"allow":["preview_settings_import"],"deny":[]}},"allow-pull-gateway-image":{"identifier":"allow-pull-gateway-image","description":"Enables the pull_gateway_image command without any pre-configured scope.","commands":{"allow":["pull_gateway_image"],"deny":[]}},"allow-pull-image":{"identifier":"allow-pull-image","description":"Enables the pull_image command without any pre-configured scope.","commands":{"allow":["pull_image"],"deny":[]}},"allow-pull-stt-image":{"identifier":"allow-pull-stt-image","description":"Enables the pull_stt_image command without any pre-configured scope.","commands":{"allow":["pull_stt_image"],"deny":[]}},"allow-push-aws-saved-state":{"identifier":"allow-push-aws-saved-state","description":"Enables the push_aws_saved_state command without any pre-configured scope.","commands":{"allow":["push_aws_saved_state"],"deny":[]}},"allow-read-container-file":{"identifier":"allow-read-container-file","description":"Enables the read_container_file command without any pre-configured scope.","commands":{"allow":["read_container_file"],"deny":[]}},"allow-rebuild-project-container":{"identifier":"allow-rebuild-project-container","description":"Enables the rebuild_project_container command without any pre-configured scope.","commands":{"allow":["rebuild_project_container"],"deny":[]}},"allow-reconcile-aws-projects":{"identifier":"allow-reconcile-aws-projects","description":"Enables the reconcile_aws_projects command without any pre-configured scope.","commands":{"allow":["reconcile_aws_projects"],"deny":[]}},"allow-reconcile-project-statuses":{"identifier":"allow-reconcile-project-statuses","description":"Enables the reconcile_project_statuses command without any pre-configured scope.","commands":{"allow":["reconcile_project_statuses"],"deny":[]}},"allow-refresh-marketplaces":{"identifier":"allow-refresh-marketplaces","description":"Enables the refresh_marketplaces command without any pre-configured scope.","commands":{"allow":["refresh_marketplaces"],"deny":[]}},"allow-regenerate-gateway-auth-token":{"identifier":"allow-regenerate-gateway-auth-token","description":"Enables the regenerate_gateway_auth_token command without any pre-configured scope.","commands":{"allow":["regenerate_gateway_auth_token"],"deny":[]}},"allow-regenerate-web-terminal-token":{"identifier":"allow-regenerate-web-terminal-token","description":"Enables the regenerate_web_terminal_token command without any pre-configured scope.","commands":{"allow":["regenerate_web_terminal_token"],"deny":[]}},"allow-remove-aws-resources":{"identifier":"allow-remove-aws-resources","description":"Enables the remove_aws_resources command without any pre-configured scope.","commands":{"allow":["remove_aws_resources"],"deny":[]}},"allow-remove-host-connection":{"identifier":"allow-remove-host-connection","description":"Enables the remove_host_connection command without any pre-configured scope.","commands":{"allow":["remove_host_connection"],"deny":[]}},"allow-remove-marketplace":{"identifier":"allow-remove-marketplace","description":"Enables the remove_marketplace command without any pre-configured scope.","commands":{"allow":["remove_marketplace"],"deny":[]}},"allow-remove-marketplace-account":{"identifier":"allow-remove-marketplace-account","description":"Enables the remove_marketplace_account command without any pre-configured scope.","commands":{"allow":["remove_marketplace_account"],"deny":[]}},"allow-remove-project":{"identifier":"allow-remove-project","description":"Enables the remove_project command without any pre-configured scope.","commands":{"allow":["remove_project"],"deny":[]}},"allow-remove-scheduled-task":{"identifier":"allow-remove-scheduled-task","description":"Enables the remove_scheduled_task command without any pre-configured scope.","commands":{"allow":["remove_scheduled_task"],"deny":[]}},"allow-rename-container-path":{"identifier":"allow-rename-container-path","description":"Enables the rename_container_path command without any pre-configured scope.","commands":{"allow":["rename_container_path"],"deny":[]}},"allow-repair-aws-environment":{"identifier":"allow-repair-aws-environment","description":"Enables the repair_aws_environment command without any pre-configured scope.","commands":{"allow":["repair_aws_environment"],"deny":[]}},"allow-rollback-migration":{"identifier":"allow-rollback-migration","description":"Enables the rollback_migration command without any pre-configured scope.","commands":{"allow":["rollback_migration"],"deny":[]}},"allow-run-docker-install":{"identifier":"allow-run-docker-install","description":"Enables the run_docker_install command without any pre-configured scope.","commands":{"allow":["run_docker_install"],"deny":[]}},"allow-run-scheduled-task-now":{"identifier":"allow-run-scheduled-task-now","description":"Enables the run_scheduled_task_now command without any pre-configured scope.","commands":{"allow":["run_scheduled_task_now"],"deny":[]}},"allow-save-aws-admin-bundle":{"identifier":"allow-save-aws-admin-bundle","description":"Enables the save_aws_admin_bundle command without any pre-configured scope.","commands":{"allow":["save_aws_admin_bundle"],"deny":[]}},"allow-save-note":{"identifier":"allow-save-note","description":"Enables the save_note command without any pre-configured scope.","commands":{"allow":["save_note"],"deny":[]}},"allow-send-audio-data":{"identifier":"allow-send-audio-data","description":"Enables the send_audio_data command without any pre-configured scope.","commands":{"allow":["send_audio_data"],"deny":[]}},"allow-set-auth-bridge-enabled":{"identifier":"allow-set-auth-bridge-enabled","description":"Enables the set_auth_bridge_enabled command without any pre-configured scope.","commands":{"allow":["set_auth_bridge_enabled"],"deny":[]}},"allow-set-browser-view-enabled":{"identifier":"allow-set-browser-view-enabled","description":"Enables the set_browser_view_enabled command without any pre-configured scope.","commands":{"allow":["set_browser_view_enabled"],"deny":[]}},"allow-set-browser-view-match-window":{"identifier":"allow-set-browser-view-match-window","description":"Enables the set_browser_view_match_window command without any pre-configured scope.","commands":{"allow":["set_browser_view_match_window"],"deny":[]}},"allow-set-browser-view-popout-always-on-top":{"identifier":"allow-set-browser-view-popout-always-on-top","description":"Enables the set_browser_view_popout_always_on_top command without any pre-configured scope.","commands":{"allow":["set_browser_view_popout_always_on_top"],"deny":[]}},"allow-set-container-page-viewport":{"identifier":"allow-set-container-page-viewport","description":"Enables the set_container_page_viewport command without any pre-configured scope.","commands":{"allow":["set_container_page_viewport"],"deny":[]}},"allow-set-gateway-api-key":{"identifier":"allow-set-gateway-api-key","description":"Enables the set_gateway_api_key command without any pre-configured scope.","commands":{"allow":["set_gateway_api_key"],"deny":[]}},"allow-set-global-item-disabled":{"identifier":"allow-set-global-item-disabled","description":"Enables the set_global_item_disabled command without any pre-configured scope.","commands":{"allow":["set_global_item_disabled"],"deny":[]}},"allow-set-scheduled-task-enabled":{"identifier":"allow-set-scheduled-task-enabled","description":"Enables the set_scheduled_task_enabled command without any pre-configured scope.","commands":{"allow":["set_scheduled_task_enabled"],"deny":[]}},"allow-start-audio-bridge":{"identifier":"allow-start-audio-bridge","description":"Enables the start_audio_bridge command without any pre-configured scope.","commands":{"allow":["start_audio_bridge"],"deny":[]}},"allow-start-gateway":{"identifier":"allow-start-gateway","description":"Enables the start_gateway command without any pre-configured scope.","commands":{"allow":["start_gateway"],"deny":[]}},"allow-start-marketplace-gh-container-login":{"identifier":"allow-start-marketplace-gh-container-login","description":"Enables the start_marketplace_gh_container_login command without any pre-configured scope.","commands":{"allow":["start_marketplace_gh_container_login"],"deny":[]}},"allow-start-project-container":{"identifier":"allow-start-project-container","description":"Enables the start_project_container command without any pre-configured scope.","commands":{"allow":["start_project_container"],"deny":[]}},"allow-start-stt":{"identifier":"allow-start-stt","description":"Enables the start_stt command without any pre-configured scope.","commands":{"allow":["start_stt"],"deny":[]}},"allow-start-web-terminal":{"identifier":"allow-start-web-terminal","description":"Enables the start_web_terminal command without any pre-configured scope.","commands":{"allow":["start_web_terminal"],"deny":[]}},"allow-stop-audio-bridge":{"identifier":"allow-stop-audio-bridge","description":"Enables the stop_audio_bridge command without any pre-configured scope.","commands":{"allow":["stop_audio_bridge"],"deny":[]}},"allow-stop-gateway":{"identifier":"allow-stop-gateway","description":"Enables the stop_gateway command without any pre-configured scope.","commands":{"allow":["stop_gateway"],"deny":[]}},"allow-stop-project-container":{"identifier":"allow-stop-project-container","description":"Enables the stop_project_container command without any pre-configured scope.","commands":{"allow":["stop_project_container"],"deny":[]}},"allow-stop-stt":{"identifier":"allow-stop-stt","description":"Enables the stop_stt command without any pre-configured scope.","commands":{"allow":["stop_stt"],"deny":[]}},"allow-stop-web-terminal":{"identifier":"allow-stop-web-terminal","description":"Enables the stop_web_terminal command without any pre-configured scope.","commands":{"allow":["stop_web_terminal"],"deny":[]}},"allow-submit-claude-token-code":{"identifier":"allow-submit-claude-token-code","description":"Enables the submit_claude_token_code command without any pre-configured scope.","commands":{"allow":["submit_claude_token_code"],"deny":[]}},"allow-sweep-claude-token-snapshots":{"identifier":"allow-sweep-claude-token-snapshots","description":"Enables the sweep_claude_token_snapshots command without any pre-configured scope.","commands":{"allow":["sweep_claude_token_snapshots"],"deny":[]}},"allow-terminal-input":{"identifier":"allow-terminal-input","description":"Enables the terminal_input command without any pre-configured scope.","commands":{"allow":["terminal_input"],"deny":[]}},"allow-terminal-resize":{"identifier":"allow-terminal-resize","description":"Enables the terminal_resize command without any pre-configured scope.","commands":{"allow":["terminal_resize"],"deny":[]}},"allow-test-marketplace-account":{"identifier":"allow-test-marketplace-account","description":"Enables the test_marketplace_account command without any pre-configured scope.","commands":{"allow":["test_marketplace_account"],"deny":[]}},"allow-transcribe-audio":{"identifier":"allow-transcribe-audio","description":"Enables the transcribe_audio command without any pre-configured scope.","commands":{"allow":["transcribe_audio"],"deny":[]}},"allow-uninstall-marketplace-item":{"identifier":"allow-uninstall-marketplace-item","description":"Enables the uninstall_marketplace_item command without any pre-configured scope.","commands":{"allow":["uninstall_marketplace_item"],"deny":[]}},"allow-unlock-aws-state":{"identifier":"allow-unlock-aws-state","description":"Enables the unlock_aws_state command without any pre-configured scope.","commands":{"allow":["unlock_aws_state"],"deny":[]}},"allow-update-aws-connection":{"identifier":"allow-update-aws-connection","description":"Enables the update_aws_connection command without any pre-configured scope.","commands":{"allow":["update_aws_connection"],"deny":[]}},"allow-update-aws-environment":{"identifier":"allow-update-aws-environment","description":"Enables the update_aws_environment command without any pre-configured scope.","commands":{"allow":["update_aws_environment"],"deny":[]}},"allow-update-marketplace":{"identifier":"allow-update-marketplace","description":"Enables the update_marketplace command without any pre-configured scope.","commands":{"allow":["update_marketplace"],"deny":[]}},"allow-update-marketplace-item":{"identifier":"allow-update-marketplace-item","description":"Enables the update_marketplace_item command without any pre-configured scope.","commands":{"allow":["update_marketplace_item"],"deny":[]}},"allow-update-project":{"identifier":"allow-update-project","description":"Enables the update_project command without any pre-configured scope.","commands":{"allow":["update_project"],"deny":[]}},"allow-update-scheduled-task":{"identifier":"allow-update-scheduled-task","description":"Enables the update_scheduled_task command without any pre-configured scope.","commands":{"allow":["update_scheduled_task"],"deny":[]}},"allow-update-settings":{"identifier":"allow-update-settings","description":"Enables the update_settings command without any pre-configured scope.","commands":{"allow":["update_settings"],"deny":[]}},"allow-upload-files-to-container":{"identifier":"allow-upload-files-to-container","description":"Enables the upload_files_to_container command without any pre-configured scope.","commands":{"allow":["upload_files_to_container"],"deny":[]}},"allow-upload-host-file-to-terminal":{"identifier":"allow-upload-host-file-to-terminal","description":"Enables the upload_host_file_to_terminal command without any pre-configured scope.","commands":{"allow":["upload_host_file_to_terminal"],"deny":[]}},"allow-viewer-choose-file":{"identifier":"allow-viewer-choose-file","description":"Enables the viewer_choose_file command without any pre-configured scope.","commands":{"allow":["viewer_choose_file"],"deny":[]}},"allow-viewer-get-state":{"identifier":"allow-viewer-get-state","description":"Enables the viewer_get_state command without any pre-configured scope.","commands":{"allow":["viewer_get_state"],"deny":[]}},"allow-viewer-poll-file":{"identifier":"allow-viewer-poll-file","description":"Enables the viewer_poll_file command without any pre-configured scope.","commands":{"allow":["viewer_poll_file"],"deny":[]}},"allow-viewer-read-file":{"identifier":"allow-viewer-read-file","description":"Enables the viewer_read_file command without any pre-configured scope.","commands":{"allow":["viewer_read_file"],"deny":[]}},"allow-viewer-write-file":{"identifier":"allow-viewer-write-file","description":"Enables the viewer_write_file command without any pre-configured scope.","commands":{"allow":["viewer_write_file"],"deny":[]}},"deny-acquire-claude-token":{"identifier":"deny-acquire-claude-token","description":"Denies the acquire_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["acquire_claude_token"]}},"deny-add-aws-keys-connection":{"identifier":"deny-add-aws-keys-connection","description":"Denies the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["add_aws_keys_connection"]}},"deny-add-aws-profile-connection":{"identifier":"deny-add-aws-profile-connection","description":"Denies the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["add_aws_profile_connection"]}},"deny-add-marketplace":{"identifier":"deny-add-marketplace","description":"Denies the add_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace"]}},"deny-add-marketplace-gh-host-account":{"identifier":"deny-add-marketplace-gh-host-account","description":"Denies the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace_gh_host_account"]}},"deny-add-marketplace-token-account":{"identifier":"deny-add-marketplace-token-account","description":"Denies the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":[],"deny":["add_marketplace_token_account"]}},"deny-add-project":{"identifier":"deny-add-project","description":"Denies the add_project command without any pre-configured scope.","commands":{"allow":[],"deny":["add_project"]}},"deny-add-scheduled-task":{"identifier":"deny-add-scheduled-task","description":"Denies the add_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["add_scheduled_task"]}},"deny-apply-marketplace-now":{"identifier":"deny-apply-marketplace-now","description":"Denies the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":[],"deny":["apply_marketplace_now"]}},"deny-apply-settings-import":{"identifier":"deny-apply-settings-import","description":"Denies the apply_settings_import command without any pre-configured scope.","commands":{"allow":[],"deny":["apply_settings_import"]}},"deny-aws-connection-identity":{"identifier":"deny-aws-connection-identity","description":"Denies the aws_connection_identity command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_connection_identity"]}},"deny-aws-connection-sso-login":{"identifier":"deny-aws-connection-sso-login","description":"Denies the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_connection_sso_login"]}},"deny-aws-cost-estimate":{"identifier":"deny-aws-cost-estimate","description":"Denies the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_cost_estimate"]}},"deny-aws-ec2-capacity":{"identifier":"deny-aws-ec2-capacity","description":"Denies the aws_ec2_capacity command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_ec2_capacity"]}},"deny-aws-environment-max-hours":{"identifier":"deny-aws-environment-max-hours","description":"Denies the aws_environment_max_hours command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_environment_max_hours"]}},"deny-aws-policy-document":{"identifier":"deny-aws-policy-document","description":"Denies the aws_policy_document command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_policy_document"]}},"deny-aws-sso-refresh":{"identifier":"deny-aws-sso-refresh","description":"Denies the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_sso_refresh"]}},"deny-aws-task-log":{"identifier":"deny-aws-task-log","description":"Denies the aws_task_log command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_task_log"]}},"deny-aws-workspace-status":{"identifier":"deny-aws-workspace-status","description":"Denies the aws_workspace_status command without any pre-configured scope.","commands":{"allow":[],"deny":["aws_workspace_status"]}},"deny-build-gateway-image":{"identifier":"deny-build-gateway-image","description":"Denies the build_gateway_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_gateway_image"]}},"deny-build-image":{"identifier":"deny-build-image","description":"Denies the build_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_image"]}},"deny-build-stt-image":{"identifier":"deny-build-stt-image","description":"Denies the build_stt_image command without any pre-configured scope.","commands":{"allow":[],"deny":["build_stt_image"]}},"deny-cancel-aws-deployment":{"identifier":"deny-cancel-aws-deployment","description":"Denies the cancel_aws_deployment command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_aws_deployment"]}},"deny-cancel-claude-token":{"identifier":"deny-cancel-claude-token","description":"Denies the cancel_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_claude_token"]}},"deny-cancel-marketplace-gh-login":{"identifier":"deny-cancel-marketplace-gh-login","description":"Denies the cancel_marketplace_gh_login command without any pre-configured scope.","commands":{"allow":[],"deny":["cancel_marketplace_gh_login"]}},"deny-check-aws-permissions":{"identifier":"deny-check-aws-permissions","description":"Denies the check_aws_permissions command without any pre-configured scope.","commands":{"allow":[],"deny":["check_aws_permissions"]}},"deny-check-browser-view-support":{"identifier":"deny-check-browser-view-support","description":"Denies the check_browser_view_support command without any pre-configured scope.","commands":{"allow":[],"deny":["check_browser_view_support"]}},"deny-check-docker":{"identifier":"deny-check-docker","description":"Denies the check_docker command without any pre-configured scope.","commands":{"allow":[],"deny":["check_docker"]}},"deny-check-for-updates":{"identifier":"deny-check-for-updates","description":"Denies the check_for_updates command without any pre-configured scope.","commands":{"allow":[],"deny":["check_for_updates"]}},"deny-check-gateway-health":{"identifier":"deny-check-gateway-health","description":"Denies the check_gateway_health command without any pre-configured scope.","commands":{"allow":[],"deny":["check_gateway_health"]}},"deny-check-image-exists":{"identifier":"deny-check-image-exists","description":"Denies the check_image_exists command without any pre-configured scope.","commands":{"allow":[],"deny":["check_image_exists"]}},"deny-check-image-update":{"identifier":"deny-check-image-update","description":"Denies the check_image_update command without any pre-configured scope.","commands":{"allow":[],"deny":["check_image_update"]}},"deny-check-unsaved-work":{"identifier":"deny-check-unsaved-work","description":"Denies the check_unsaved_work command without any pre-configured scope.","commands":{"allow":[],"deny":["check_unsaved_work"]}},"deny-clear-claude-token":{"identifier":"deny-clear-claude-token","description":"Denies the clear_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_claude_token"]}},"deny-clear-gateway-api-key":{"identifier":"deny-clear-gateway-api-key","description":"Denies the clear_gateway_api_key command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_gateway_api_key"]}},"deny-clear-scheduler-notifications":{"identifier":"deny-clear-scheduler-notifications","description":"Denies the clear_scheduler_notifications command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_scheduler_notifications"]}},"deny-close-browser-view-popout":{"identifier":"deny-close-browser-view-popout","description":"Denies the close_browser_view_popout command without any pre-configured scope.","commands":{"allow":[],"deny":["close_browser_view_popout"]}},"deny-close-container-page":{"identifier":"deny-close-container-page","description":"Denies the close_container_page command without any pre-configured scope.","commands":{"allow":[],"deny":["close_container_page"]}},"deny-close-terminal-session":{"identifier":"deny-close-terminal-session","description":"Denies the close_terminal_session command without any pre-configured scope.","commands":{"allow":[],"deny":["close_terminal_session"]}},"deny-confirm-migration":{"identifier":"deny-confirm-migration","description":"Denies the confirm_migration command without any pre-configured scope.","commands":{"allow":[],"deny":["confirm_migration"]}},"deny-create-container-directory":{"identifier":"deny-create-container-directory","description":"Denies the create_container_directory command without any pre-configured scope.","commands":{"allow":[],"deny":["create_container_directory"]}},"deny-delete-note":{"identifier":"deny-delete-note","description":"Denies the delete_note command without any pre-configured scope.","commands":{"allow":[],"deny":["delete_note"]}},"deny-deploy-aws-environment":{"identifier":"deny-deploy-aws-environment","description":"Denies the deploy_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["deploy_aws_environment"]}},"deny-deploy-aws-permissions-boundary":{"identifier":"deny-deploy-aws-permissions-boundary","description":"Denies the deploy_aws_permissions_boundary command without any pre-configured scope.","commands":{"allow":[],"deny":["deploy_aws_permissions_boundary"]}},"deny-destroy-incomplete-aws-environment":{"identifier":"deny-destroy-incomplete-aws-environment","description":"Denies the destroy_incomplete_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["destroy_incomplete_aws_environment"]}},"deny-detect-aws-config":{"identifier":"deny-detect-aws-config","description":"Denies the detect_aws_config command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_aws_config"]}},"deny-detect-aws-environments":{"identifier":"deny-detect-aws-environments","description":"Denies the detect_aws_environments command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_aws_environments"]}},"deny-detect-host-timezone":{"identifier":"deny-detect-host-timezone","description":"Denies the detect_host_timezone command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_host_timezone"]}},"deny-detect-install-options":{"identifier":"deny-detect-install-options","description":"Denies the detect_install_options command without any pre-configured scope.","commands":{"allow":[],"deny":["detect_install_options"]}},"deny-download-container-backup":{"identifier":"deny-download-container-backup","description":"Denies the download_container_backup command without any pre-configured scope.","commands":{"allow":[],"deny":["download_container_backup"]}},"deny-download-container-file":{"identifier":"deny-download-container-file","description":"Denies the download_container_file command without any pre-configured scope.","commands":{"allow":[],"deny":["download_container_file"]}},"deny-ec2-fit-problem":{"identifier":"deny-ec2-fit-problem","description":"Denies the ec2_fit_problem command without any pre-configured scope.","commands":{"allow":[],"deny":["ec2_fit_problem"]}},"deny-export-settings":{"identifier":"deny-export-settings","description":"Denies the export_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["export_settings"]}},"deny-follow-aws-deployment":{"identifier":"deny-follow-aws-deployment","description":"Denies the follow_aws_deployment command without any pre-configured scope.","commands":{"allow":[],"deny":["follow_aws_deployment"]}},"deny-forget-marketplace-installs":{"identifier":"deny-forget-marketplace-installs","description":"Denies the forget_marketplace_installs command without any pre-configured scope.","commands":{"allow":[],"deny":["forget_marketplace_installs"]}},"deny-get-app-version":{"identifier":"deny-get-app-version","description":"Denies the get_app_version command without any pre-configured scope.","commands":{"allow":[],"deny":["get_app_version"]}},"deny-get-auth-bridge-status":{"identifier":"deny-get-auth-bridge-status","description":"Denies the get_auth_bridge_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_auth_bridge_status"]}},"deny-get-browser-view-match-window":{"identifier":"deny-get-browser-view-match-window","description":"Denies the get_browser_view_match_window command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_match_window"]}},"deny-get-browser-view-popout-state":{"identifier":"deny-get-browser-view-popout-state","description":"Denies the get_browser_view_popout_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_popout_state"]}},"deny-get-browser-view-status":{"identifier":"deny-get-browser-view-status","description":"Denies the get_browser_view_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_browser_view_status"]}},"deny-get-container-info":{"identifier":"deny-get-container-info","description":"Denies the get_container_info command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_info"]}},"deny-get-container-page-state":{"identifier":"deny-get-container-page-state","description":"Denies the get_container_page_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_page_state"]}},"deny-get-container-staleness":{"identifier":"deny-get-container-staleness","description":"Denies the get_container_staleness command without any pre-configured scope.","commands":{"allow":[],"deny":["get_container_staleness"]}},"deny-get-gateway-auth-token":{"identifier":"deny-get-gateway-auth-token","description":"Denies the get_gateway_auth_token command without any pre-configured scope.","commands":{"allow":[],"deny":["get_gateway_auth_token"]}},"deny-get-gateway-status":{"identifier":"deny-get-gateway-status","description":"Denies the get_gateway_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_gateway_status"]}},"deny-get-help-content":{"identifier":"deny-get-help-content","description":"Denies the get_help_content command without any pre-configured scope.","commands":{"allow":[],"deny":["get_help_content"]}},"deny-get-marketplace-sync-report":{"identifier":"deny-get-marketplace-sync-report","description":"Denies the get_marketplace_sync_report command without any pre-configured scope.","commands":{"allow":[],"deny":["get_marketplace_sync_report"]}},"deny-get-migration-state":{"identifier":"deny-get-migration-state","description":"Denies the get_migration_state command without any pre-configured scope.","commands":{"allow":[],"deny":["get_migration_state"]}},"deny-get-scheduled-task-log":{"identifier":"deny-get-scheduled-task-log","description":"Denies the get_scheduled_task_log command without any pre-configured scope.","commands":{"allow":[],"deny":["get_scheduled_task_log"]}},"deny-get-scheduler-notifications":{"identifier":"deny-get-scheduler-notifications","description":"Denies the get_scheduler_notifications command without any pre-configured scope.","commands":{"allow":[],"deny":["get_scheduler_notifications"]}},"deny-get-settings":{"identifier":"deny-get-settings","description":"Denies the get_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["get_settings"]}},"deny-get-stt-status":{"identifier":"deny-get-stt-status","description":"Denies the get_stt_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_stt_status"]}},"deny-get-web-terminal-status":{"identifier":"deny-get-web-terminal-status","description":"Denies the get_web_terminal_status command without any pre-configured scope.","commands":{"allow":[],"deny":["get_web_terminal_status"]}},"deny-has-claude-token":{"identifier":"deny-has-claude-token","description":"Denies the has_claude_token command without any pre-configured scope.","commands":{"allow":[],"deny":["has_claude_token"]}},"deny-inspect-ca-cert-path":{"identifier":"deny-inspect-ca-cert-path","description":"Denies the inspect_ca_cert_path command without any pre-configured scope.","commands":{"allow":[],"deny":["inspect_ca_cert_path"]}},"deny-install-browser-view-browser":{"identifier":"deny-install-browser-view-browser","description":"Denies the install_browser_view_browser command without any pre-configured scope.","commands":{"allow":[],"deny":["install_browser_view_browser"]}},"deny-install-browser-view-support":{"identifier":"deny-install-browser-view-support","description":"Denies the install_browser_view_support command without any pre-configured scope.","commands":{"allow":[],"deny":["install_browser_view_support"]}},"deny-install-marketplace-item":{"identifier":"deny-install-marketplace-item","description":"Denies the install_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["install_marketplace_item"]}},"deny-list-aws-profiles":{"identifier":"deny-list-aws-profiles","description":"Denies the list_aws_profiles command without any pre-configured scope.","commands":{"allow":[],"deny":["list_aws_profiles"]}},"deny-list-claude-sessions":{"identifier":"deny-list-claude-sessions","description":"Denies the list_claude_sessions command without any pre-configured scope.","commands":{"allow":[],"deny":["list_claude_sessions"]}},"deny-list-container-capabilities":{"identifier":"deny-list-container-capabilities","description":"Denies the list_container_capabilities command without any pre-configured scope.","commands":{"allow":[],"deny":["list_container_capabilities"]}},"deny-list-container-files":{"identifier":"deny-list-container-files","description":"Denies the list_container_files command without any pre-configured scope.","commands":{"allow":[],"deny":["list_container_files"]}},"deny-list-ec2-instance-types":{"identifier":"deny-list-ec2-instance-types","description":"Denies the list_ec2_instance_types command without any pre-configured scope.","commands":{"allow":[],"deny":["list_ec2_instance_types"]}},"deny-list-marketplace-snapshots":{"identifier":"deny-list-marketplace-snapshots","description":"Denies the list_marketplace_snapshots command without any pre-configured scope.","commands":{"allow":[],"deny":["list_marketplace_snapshots"]}},"deny-list-marketplace-updates":{"identifier":"deny-list-marketplace-updates","description":"Denies the list_marketplace_updates command without any pre-configured scope.","commands":{"allow":[],"deny":["list_marketplace_updates"]}},"deny-list-notes":{"identifier":"deny-list-notes","description":"Denies the list_notes command without any pre-configured scope.","commands":{"allow":[],"deny":["list_notes"]}},"deny-list-projects":{"identifier":"deny-list-projects","description":"Denies the list_projects command without any pre-configured scope.","commands":{"allow":[],"deny":["list_projects"]}},"deny-list-scheduled-tasks":{"identifier":"deny-list-scheduled-tasks","description":"Denies the list_scheduled_tasks command without any pre-configured scope.","commands":{"allow":[],"deny":["list_scheduled_tasks"]}},"deny-marketplace-gh-host-available":{"identifier":"deny-marketplace-gh-host-available","description":"Denies the marketplace_gh_host_available command without any pre-configured scope.","commands":{"allow":[],"deny":["marketplace_gh_host_available"]}},"deny-marketplace-item-diff":{"identifier":"deny-marketplace-item-diff","description":"Denies the marketplace_item_diff command without any pre-configured scope.","commands":{"allow":[],"deny":["marketplace_item_diff"]}},"deny-migrate-project-to-base":{"identifier":"deny-migrate-project-to-base","description":"Denies the migrate_project_to_base command without any pre-configured scope.","commands":{"allow":[],"deny":["migrate_project_to_base"]}},"deny-onboard-aws-user":{"identifier":"deny-onboard-aws-user","description":"Denies the onboard_aws_user command without any pre-configured scope.","commands":{"allow":[],"deny":["onboard_aws_user"]}},"deny-open-browser-view-popout":{"identifier":"deny-open-browser-view-popout","description":"Denies the open_browser_view_popout command without any pre-configured scope.","commands":{"allow":[],"deny":["open_browser_view_popout"]}},"deny-open-file-viewer":{"identifier":"deny-open-file-viewer","description":"Denies the open_file_viewer command without any pre-configured scope.","commands":{"allow":[],"deny":["open_file_viewer"]}},"deny-open-page-in-container-browser":{"identifier":"deny-open-page-in-container-browser","description":"Denies the open_page_in_container_browser command without any pre-configured scope.","commands":{"allow":[],"deny":["open_page_in_container_browser"]}},"deny-open-terminal-session":{"identifier":"deny-open-terminal-session","description":"Denies the open_terminal_session command without any pre-configured scope.","commands":{"allow":[],"deny":["open_terminal_session"]}},"deny-open-url-external":{"identifier":"deny-open-url-external","description":"Denies the open_url_external command without any pre-configured scope.","commands":{"allow":[],"deny":["open_url_external"]}},"deny-paste-image-to-terminal":{"identifier":"deny-paste-image-to-terminal","description":"Denies the paste_image_to_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["paste_image_to_terminal"]}},"deny-preview-settings-import":{"identifier":"deny-preview-settings-import","description":"Denies the preview_settings_import command without any pre-configured scope.","commands":{"allow":[],"deny":["preview_settings_import"]}},"deny-pull-gateway-image":{"identifier":"deny-pull-gateway-image","description":"Denies the pull_gateway_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_gateway_image"]}},"deny-pull-image":{"identifier":"deny-pull-image","description":"Denies the pull_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_image"]}},"deny-pull-stt-image":{"identifier":"deny-pull-stt-image","description":"Denies the pull_stt_image command without any pre-configured scope.","commands":{"allow":[],"deny":["pull_stt_image"]}},"deny-push-aws-saved-state":{"identifier":"deny-push-aws-saved-state","description":"Denies the push_aws_saved_state command without any pre-configured scope.","commands":{"allow":[],"deny":["push_aws_saved_state"]}},"deny-read-container-file":{"identifier":"deny-read-container-file","description":"Denies the read_container_file command without any pre-configured scope.","commands":{"allow":[],"deny":["read_container_file"]}},"deny-rebuild-project-container":{"identifier":"deny-rebuild-project-container","description":"Denies the rebuild_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["rebuild_project_container"]}},"deny-reconcile-aws-projects":{"identifier":"deny-reconcile-aws-projects","description":"Denies the reconcile_aws_projects command without any pre-configured scope.","commands":{"allow":[],"deny":["reconcile_aws_projects"]}},"deny-reconcile-project-statuses":{"identifier":"deny-reconcile-project-statuses","description":"Denies the reconcile_project_statuses command without any pre-configured scope.","commands":{"allow":[],"deny":["reconcile_project_statuses"]}},"deny-refresh-marketplaces":{"identifier":"deny-refresh-marketplaces","description":"Denies the refresh_marketplaces command without any pre-configured scope.","commands":{"allow":[],"deny":["refresh_marketplaces"]}},"deny-regenerate-gateway-auth-token":{"identifier":"deny-regenerate-gateway-auth-token","description":"Denies the regenerate_gateway_auth_token command without any pre-configured scope.","commands":{"allow":[],"deny":["regenerate_gateway_auth_token"]}},"deny-regenerate-web-terminal-token":{"identifier":"deny-regenerate-web-terminal-token","description":"Denies the regenerate_web_terminal_token command without any pre-configured scope.","commands":{"allow":[],"deny":["regenerate_web_terminal_token"]}},"deny-remove-aws-resources":{"identifier":"deny-remove-aws-resources","description":"Denies the remove_aws_resources command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_aws_resources"]}},"deny-remove-host-connection":{"identifier":"deny-remove-host-connection","description":"Denies the remove_host_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_host_connection"]}},"deny-remove-marketplace":{"identifier":"deny-remove-marketplace","description":"Denies the remove_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_marketplace"]}},"deny-remove-marketplace-account":{"identifier":"deny-remove-marketplace-account","description":"Denies the remove_marketplace_account command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_marketplace_account"]}},"deny-remove-project":{"identifier":"deny-remove-project","description":"Denies the remove_project command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_project"]}},"deny-remove-scheduled-task":{"identifier":"deny-remove-scheduled-task","description":"Denies the remove_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_scheduled_task"]}},"deny-rename-container-path":{"identifier":"deny-rename-container-path","description":"Denies the rename_container_path command without any pre-configured scope.","commands":{"allow":[],"deny":["rename_container_path"]}},"deny-repair-aws-environment":{"identifier":"deny-repair-aws-environment","description":"Denies the repair_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["repair_aws_environment"]}},"deny-rollback-migration":{"identifier":"deny-rollback-migration","description":"Denies the rollback_migration command without any pre-configured scope.","commands":{"allow":[],"deny":["rollback_migration"]}},"deny-run-docker-install":{"identifier":"deny-run-docker-install","description":"Denies the run_docker_install command without any pre-configured scope.","commands":{"allow":[],"deny":["run_docker_install"]}},"deny-run-scheduled-task-now":{"identifier":"deny-run-scheduled-task-now","description":"Denies the run_scheduled_task_now command without any pre-configured scope.","commands":{"allow":[],"deny":["run_scheduled_task_now"]}},"deny-save-aws-admin-bundle":{"identifier":"deny-save-aws-admin-bundle","description":"Denies the save_aws_admin_bundle command without any pre-configured scope.","commands":{"allow":[],"deny":["save_aws_admin_bundle"]}},"deny-save-note":{"identifier":"deny-save-note","description":"Denies the save_note command without any pre-configured scope.","commands":{"allow":[],"deny":["save_note"]}},"deny-send-audio-data":{"identifier":"deny-send-audio-data","description":"Denies the send_audio_data command without any pre-configured scope.","commands":{"allow":[],"deny":["send_audio_data"]}},"deny-set-auth-bridge-enabled":{"identifier":"deny-set-auth-bridge-enabled","description":"Denies the set_auth_bridge_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_auth_bridge_enabled"]}},"deny-set-browser-view-enabled":{"identifier":"deny-set-browser-view-enabled","description":"Denies the set_browser_view_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_enabled"]}},"deny-set-browser-view-match-window":{"identifier":"deny-set-browser-view-match-window","description":"Denies the set_browser_view_match_window command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_match_window"]}},"deny-set-browser-view-popout-always-on-top":{"identifier":"deny-set-browser-view-popout-always-on-top","description":"Denies the set_browser_view_popout_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["set_browser_view_popout_always_on_top"]}},"deny-set-container-page-viewport":{"identifier":"deny-set-container-page-viewport","description":"Denies the set_container_page_viewport command without any pre-configured scope.","commands":{"allow":[],"deny":["set_container_page_viewport"]}},"deny-set-gateway-api-key":{"identifier":"deny-set-gateway-api-key","description":"Denies the set_gateway_api_key command without any pre-configured scope.","commands":{"allow":[],"deny":["set_gateway_api_key"]}},"deny-set-global-item-disabled":{"identifier":"deny-set-global-item-disabled","description":"Denies the set_global_item_disabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_global_item_disabled"]}},"deny-set-scheduled-task-enabled":{"identifier":"deny-set-scheduled-task-enabled","description":"Denies the set_scheduled_task_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_scheduled_task_enabled"]}},"deny-start-audio-bridge":{"identifier":"deny-start-audio-bridge","description":"Denies the start_audio_bridge command without any pre-configured scope.","commands":{"allow":[],"deny":["start_audio_bridge"]}},"deny-start-gateway":{"identifier":"deny-start-gateway","description":"Denies the start_gateway command without any pre-configured scope.","commands":{"allow":[],"deny":["start_gateway"]}},"deny-start-marketplace-gh-container-login":{"identifier":"deny-start-marketplace-gh-container-login","description":"Denies the start_marketplace_gh_container_login command without any pre-configured scope.","commands":{"allow":[],"deny":["start_marketplace_gh_container_login"]}},"deny-start-project-container":{"identifier":"deny-start-project-container","description":"Denies the start_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["start_project_container"]}},"deny-start-stt":{"identifier":"deny-start-stt","description":"Denies the start_stt command without any pre-configured scope.","commands":{"allow":[],"deny":["start_stt"]}},"deny-start-web-terminal":{"identifier":"deny-start-web-terminal","description":"Denies the start_web_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["start_web_terminal"]}},"deny-stop-audio-bridge":{"identifier":"deny-stop-audio-bridge","description":"Denies the stop_audio_bridge command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_audio_bridge"]}},"deny-stop-gateway":{"identifier":"deny-stop-gateway","description":"Denies the stop_gateway command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_gateway"]}},"deny-stop-project-container":{"identifier":"deny-stop-project-container","description":"Denies the stop_project_container command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_project_container"]}},"deny-stop-stt":{"identifier":"deny-stop-stt","description":"Denies the stop_stt command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_stt"]}},"deny-stop-web-terminal":{"identifier":"deny-stop-web-terminal","description":"Denies the stop_web_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["stop_web_terminal"]}},"deny-submit-claude-token-code":{"identifier":"deny-submit-claude-token-code","description":"Denies the submit_claude_token_code command without any pre-configured scope.","commands":{"allow":[],"deny":["submit_claude_token_code"]}},"deny-sweep-claude-token-snapshots":{"identifier":"deny-sweep-claude-token-snapshots","description":"Denies the sweep_claude_token_snapshots command without any pre-configured scope.","commands":{"allow":[],"deny":["sweep_claude_token_snapshots"]}},"deny-terminal-input":{"identifier":"deny-terminal-input","description":"Denies the terminal_input command without any pre-configured scope.","commands":{"allow":[],"deny":["terminal_input"]}},"deny-terminal-resize":{"identifier":"deny-terminal-resize","description":"Denies the terminal_resize command without any pre-configured scope.","commands":{"allow":[],"deny":["terminal_resize"]}},"deny-test-marketplace-account":{"identifier":"deny-test-marketplace-account","description":"Denies the test_marketplace_account command without any pre-configured scope.","commands":{"allow":[],"deny":["test_marketplace_account"]}},"deny-transcribe-audio":{"identifier":"deny-transcribe-audio","description":"Denies the transcribe_audio command without any pre-configured scope.","commands":{"allow":[],"deny":["transcribe_audio"]}},"deny-uninstall-marketplace-item":{"identifier":"deny-uninstall-marketplace-item","description":"Denies the uninstall_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["uninstall_marketplace_item"]}},"deny-unlock-aws-state":{"identifier":"deny-unlock-aws-state","description":"Denies the unlock_aws_state command without any pre-configured scope.","commands":{"allow":[],"deny":["unlock_aws_state"]}},"deny-update-aws-connection":{"identifier":"deny-update-aws-connection","description":"Denies the update_aws_connection command without any pre-configured scope.","commands":{"allow":[],"deny":["update_aws_connection"]}},"deny-update-aws-environment":{"identifier":"deny-update-aws-environment","description":"Denies the update_aws_environment command without any pre-configured scope.","commands":{"allow":[],"deny":["update_aws_environment"]}},"deny-update-marketplace":{"identifier":"deny-update-marketplace","description":"Denies the update_marketplace command without any pre-configured scope.","commands":{"allow":[],"deny":["update_marketplace"]}},"deny-update-marketplace-item":{"identifier":"deny-update-marketplace-item","description":"Denies the update_marketplace_item command without any pre-configured scope.","commands":{"allow":[],"deny":["update_marketplace_item"]}},"deny-update-project":{"identifier":"deny-update-project","description":"Denies the update_project command without any pre-configured scope.","commands":{"allow":[],"deny":["update_project"]}},"deny-update-scheduled-task":{"identifier":"deny-update-scheduled-task","description":"Denies the update_scheduled_task command without any pre-configured scope.","commands":{"allow":[],"deny":["update_scheduled_task"]}},"deny-update-settings":{"identifier":"deny-update-settings","description":"Denies the update_settings command without any pre-configured scope.","commands":{"allow":[],"deny":["update_settings"]}},"deny-upload-files-to-container":{"identifier":"deny-upload-files-to-container","description":"Denies the upload_files_to_container command without any pre-configured scope.","commands":{"allow":[],"deny":["upload_files_to_container"]}},"deny-upload-host-file-to-terminal":{"identifier":"deny-upload-host-file-to-terminal","description":"Denies the upload_host_file_to_terminal command without any pre-configured scope.","commands":{"allow":[],"deny":["upload_host_file_to_terminal"]}},"deny-viewer-choose-file":{"identifier":"deny-viewer-choose-file","description":"Denies the viewer_choose_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_choose_file"]}},"deny-viewer-get-state":{"identifier":"deny-viewer-get-state","description":"Denies the viewer_get_state command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_get_state"]}},"deny-viewer-poll-file":{"identifier":"deny-viewer-poll-file","description":"Denies the viewer_poll_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_poll_file"]}},"deny-viewer-read-file":{"identifier":"deny-viewer-read-file","description":"Denies the viewer_read_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_read_file"]}},"deny-viewer-write-file":{"identifier":"deny-viewer-write-file","description":"Denies the viewer_write_file command without any pre-configured scope.","commands":{"allow":[],"deny":["viewer_write_file"]}}},"permission_sets":{},"global_scope_schema":null},"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","commands":{"allow":["name"],"deny":[]}},"allow-register-listener":{"identifier":"allow-register-listener","description":"Enables the register_listener command without any pre-configured scope.","commands":{"allow":["register_listener"],"deny":[]}},"allow-remove-data-store":{"identifier":"allow-remove-data-store","description":"Enables the remove_data_store command without any pre-configured scope.","commands":{"allow":["remove_data_store"],"deny":[]}},"allow-remove-listener":{"identifier":"allow-remove-listener","description":"Enables the remove_listener command without any pre-configured scope.","commands":{"allow":["remove_listener"],"deny":[]}},"allow-set-app-theme":{"identifier":"allow-set-app-theme","description":"Enables the set_app_theme command without any pre-configured scope.","commands":{"allow":["set_app_theme"],"deny":[]}},"allow-set-dock-visibility":{"identifier":"allow-set-dock-visibility","description":"Enables the set_dock_visibility command without any pre-configured scope.","commands":{"allow":["set_dock_visibility"],"deny":[]}},"allow-supports-multiple-windows":{"identifier":"allow-supports-multiple-windows","description":"Enables the supports_multiple_windows command without any pre-configured scope.","commands":{"allow":["supports_multiple_windows"],"deny":[]}},"allow-tauri-version":{"identifier":"allow-tauri-version","description":"Enables the tauri_version command without any pre-configured scope.","commands":{"allow":["tauri_version"],"deny":[]}},"allow-version":{"identifier":"allow-version","description":"Enables the version command without any pre-configured scope.","commands":{"allow":["version"],"deny":[]}},"deny-app-hide":{"identifier":"deny-app-hide","description":"Denies the app_hide command without any pre-configured scope.","commands":{"allow":[],"deny":["app_hide"]}},"deny-app-show":{"identifier":"deny-app-show","description":"Denies the app_show command without any pre-configured scope.","commands":{"allow":[],"deny":["app_show"]}},"deny-bundle-type":{"identifier":"deny-bundle-type","description":"Denies the bundle_type command without any pre-configured scope.","commands":{"allow":[],"deny":["bundle_type"]}},"deny-default-window-icon":{"identifier":"deny-default-window-icon","description":"Denies the default_window_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["default_window_icon"]}},"deny-fetch-data-store-identifiers":{"identifier":"deny-fetch-data-store-identifiers","description":"Denies the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":[],"deny":["fetch_data_store_identifiers"]}},"deny-identifier":{"identifier":"deny-identifier","description":"Denies the identifier command without any pre-configured scope.","commands":{"allow":[],"deny":["identifier"]}},"deny-name":{"identifier":"deny-name","description":"Denies the name command without any pre-configured scope.","commands":{"allow":[],"deny":["name"]}},"deny-register-listener":{"identifier":"deny-register-listener","description":"Denies the register_listener command without any pre-configured scope.","commands":{"allow":[],"deny":["register_listener"]}},"deny-remove-data-store":{"identifier":"deny-remove-data-store","description":"Denies the remove_data_store command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_data_store"]}},"deny-remove-listener":{"identifier":"deny-remove-listener","description":"Denies the remove_listener command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_listener"]}},"deny-set-app-theme":{"identifier":"deny-set-app-theme","description":"Denies the set_app_theme command without any pre-configured scope.","commands":{"allow":[],"deny":["set_app_theme"]}},"deny-set-dock-visibility":{"identifier":"deny-set-dock-visibility","description":"Denies the set_dock_visibility command without any pre-configured scope.","commands":{"allow":[],"deny":["set_dock_visibility"]}},"deny-supports-multiple-windows":{"identifier":"deny-supports-multiple-windows","description":"Denies the supports_multiple_windows command without any pre-configured scope.","commands":{"allow":[],"deny":["supports_multiple_windows"]}},"deny-tauri-version":{"identifier":"deny-tauri-version","description":"Denies the tauri_version command without any pre-configured scope.","commands":{"allow":[],"deny":["tauri_version"]}},"deny-version":{"identifier":"deny-version","description":"Denies the version command without any pre-configured scope.","commands":{"allow":[],"deny":["version"]}}},"permission_sets":{},"global_scope_schema":null},"core:event":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-listen","allow-unlisten","allow-emit","allow-emit-to"]},"permissions":{"allow-emit":{"identifier":"allow-emit","description":"Enables the emit command without any pre-configured scope.","commands":{"allow":["emit"],"deny":[]}},"allow-emit-to":{"identifier":"allow-emit-to","description":"Enables the emit_to command without any pre-configured scope.","commands":{"allow":["emit_to"],"deny":[]}},"allow-listen":{"identifier":"allow-listen","description":"Enables the listen command without any pre-configured scope.","commands":{"allow":["listen"],"deny":[]}},"allow-unlisten":{"identifier":"allow-unlisten","description":"Enables the unlisten command without any pre-configured scope.","commands":{"allow":["unlisten"],"deny":[]}},"deny-emit":{"identifier":"deny-emit","description":"Denies the emit command without any pre-configured scope.","commands":{"allow":[],"deny":["emit"]}},"deny-emit-to":{"identifier":"deny-emit-to","description":"Denies the emit_to command without any pre-configured scope.","commands":{"allow":[],"deny":["emit_to"]}},"deny-listen":{"identifier":"deny-listen","description":"Denies the listen command without any pre-configured scope.","commands":{"allow":[],"deny":["listen"]}},"deny-unlisten":{"identifier":"deny-unlisten","description":"Denies the unlisten command without any pre-configured scope.","commands":{"allow":[],"deny":["unlisten"]}}},"permission_sets":{},"global_scope_schema":null},"core:image":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-from-bytes","allow-from-path","allow-rgba","allow-size"]},"permissions":{"allow-from-bytes":{"identifier":"allow-from-bytes","description":"Enables the from_bytes command without any pre-configured scope.","commands":{"allow":["from_bytes"],"deny":[]}},"allow-from-path":{"identifier":"allow-from-path","description":"Enables the from_path command without any pre-configured scope.","commands":{"allow":["from_path"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-rgba":{"identifier":"allow-rgba","description":"Enables the rgba command without any pre-configured scope.","commands":{"allow":["rgba"],"deny":[]}},"allow-size":{"identifier":"allow-size","description":"Enables the size command without any pre-configured scope.","commands":{"allow":["size"],"deny":[]}},"deny-from-bytes":{"identifier":"deny-from-bytes","description":"Denies the from_bytes command without any pre-configured scope.","commands":{"allow":[],"deny":["from_bytes"]}},"deny-from-path":{"identifier":"deny-from-path","description":"Denies the from_path command without any pre-configured scope.","commands":{"allow":[],"deny":["from_path"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-rgba":{"identifier":"deny-rgba","description":"Denies the rgba command without any pre-configured scope.","commands":{"allow":[],"deny":["rgba"]}},"deny-size":{"identifier":"deny-size","description":"Denies the size command without any pre-configured scope.","commands":{"allow":[],"deny":["size"]}}},"permission_sets":{},"global_scope_schema":null},"core:menu":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-append","allow-prepend","allow-insert","allow-remove","allow-remove-at","allow-items","allow-get","allow-popup","allow-create-default","allow-set-as-app-menu","allow-set-as-window-menu","allow-text","allow-set-text","allow-is-enabled","allow-set-enabled","allow-set-accelerator","allow-set-as-windows-menu-for-nsapp","allow-set-as-help-menu-for-nsapp","allow-is-checked","allow-set-checked","allow-set-icon"]},"permissions":{"allow-append":{"identifier":"allow-append","description":"Enables the append command without any pre-configured scope.","commands":{"allow":["append"],"deny":[]}},"allow-create-default":{"identifier":"allow-create-default","description":"Enables the create_default command without any pre-configured scope.","commands":{"allow":["create_default"],"deny":[]}},"allow-get":{"identifier":"allow-get","description":"Enables the get command without any pre-configured scope.","commands":{"allow":["get"],"deny":[]}},"allow-insert":{"identifier":"allow-insert","description":"Enables the insert command without any pre-configured scope.","commands":{"allow":["insert"],"deny":[]}},"allow-is-checked":{"identifier":"allow-is-checked","description":"Enables the is_checked command without any pre-configured scope.","commands":{"allow":["is_checked"],"deny":[]}},"allow-is-enabled":{"identifier":"allow-is-enabled","description":"Enables the is_enabled command without any pre-configured scope.","commands":{"allow":["is_enabled"],"deny":[]}},"allow-items":{"identifier":"allow-items","description":"Enables the items command without any pre-configured scope.","commands":{"allow":["items"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-popup":{"identifier":"allow-popup","description":"Enables the popup command without any pre-configured scope.","commands":{"allow":["popup"],"deny":[]}},"allow-prepend":{"identifier":"allow-prepend","description":"Enables the prepend command without any pre-configured scope.","commands":{"allow":["prepend"],"deny":[]}},"allow-remove":{"identifier":"allow-remove","description":"Enables the remove command without any pre-configured scope.","commands":{"allow":["remove"],"deny":[]}},"allow-remove-at":{"identifier":"allow-remove-at","description":"Enables the remove_at command without any pre-configured scope.","commands":{"allow":["remove_at"],"deny":[]}},"allow-set-accelerator":{"identifier":"allow-set-accelerator","description":"Enables the set_accelerator command without any pre-configured scope.","commands":{"allow":["set_accelerator"],"deny":[]}},"allow-set-as-app-menu":{"identifier":"allow-set-as-app-menu","description":"Enables the set_as_app_menu command without any pre-configured scope.","commands":{"allow":["set_as_app_menu"],"deny":[]}},"allow-set-as-help-menu-for-nsapp":{"identifier":"allow-set-as-help-menu-for-nsapp","description":"Enables the set_as_help_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":["set_as_help_menu_for_nsapp"],"deny":[]}},"allow-set-as-window-menu":{"identifier":"allow-set-as-window-menu","description":"Enables the set_as_window_menu command without any pre-configured scope.","commands":{"allow":["set_as_window_menu"],"deny":[]}},"allow-set-as-windows-menu-for-nsapp":{"identifier":"allow-set-as-windows-menu-for-nsapp","description":"Enables the set_as_windows_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":["set_as_windows_menu_for_nsapp"],"deny":[]}},"allow-set-checked":{"identifier":"allow-set-checked","description":"Enables the set_checked command without any pre-configured scope.","commands":{"allow":["set_checked"],"deny":[]}},"allow-set-enabled":{"identifier":"allow-set-enabled","description":"Enables the set_enabled command without any pre-configured scope.","commands":{"allow":["set_enabled"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-text":{"identifier":"allow-set-text","description":"Enables the set_text command without any pre-configured scope.","commands":{"allow":["set_text"],"deny":[]}},"allow-text":{"identifier":"allow-text","description":"Enables the text command without any pre-configured scope.","commands":{"allow":["text"],"deny":[]}},"deny-append":{"identifier":"deny-append","description":"Denies the append command without any pre-configured scope.","commands":{"allow":[],"deny":["append"]}},"deny-create-default":{"identifier":"deny-create-default","description":"Denies the create_default command without any pre-configured scope.","commands":{"allow":[],"deny":["create_default"]}},"deny-get":{"identifier":"deny-get","description":"Denies the get command without any pre-configured scope.","commands":{"allow":[],"deny":["get"]}},"deny-insert":{"identifier":"deny-insert","description":"Denies the insert command without any pre-configured scope.","commands":{"allow":[],"deny":["insert"]}},"deny-is-checked":{"identifier":"deny-is-checked","description":"Denies the is_checked command without any pre-configured scope.","commands":{"allow":[],"deny":["is_checked"]}},"deny-is-enabled":{"identifier":"deny-is-enabled","description":"Denies the is_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["is_enabled"]}},"deny-items":{"identifier":"deny-items","description":"Denies the items command without any pre-configured scope.","commands":{"allow":[],"deny":["items"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-popup":{"identifier":"deny-popup","description":"Denies the popup command without any pre-configured scope.","commands":{"allow":[],"deny":["popup"]}},"deny-prepend":{"identifier":"deny-prepend","description":"Denies the prepend command without any pre-configured scope.","commands":{"allow":[],"deny":["prepend"]}},"deny-remove":{"identifier":"deny-remove","description":"Denies the remove command without any pre-configured scope.","commands":{"allow":[],"deny":["remove"]}},"deny-remove-at":{"identifier":"deny-remove-at","description":"Denies the remove_at command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_at"]}},"deny-set-accelerator":{"identifier":"deny-set-accelerator","description":"Denies the set_accelerator command without any pre-configured scope.","commands":{"allow":[],"deny":["set_accelerator"]}},"deny-set-as-app-menu":{"identifier":"deny-set-as-app-menu","description":"Denies the set_as_app_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_app_menu"]}},"deny-set-as-help-menu-for-nsapp":{"identifier":"deny-set-as-help-menu-for-nsapp","description":"Denies the set_as_help_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_help_menu_for_nsapp"]}},"deny-set-as-window-menu":{"identifier":"deny-set-as-window-menu","description":"Denies the set_as_window_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_window_menu"]}},"deny-set-as-windows-menu-for-nsapp":{"identifier":"deny-set-as-windows-menu-for-nsapp","description":"Denies the set_as_windows_menu_for_nsapp command without any pre-configured scope.","commands":{"allow":[],"deny":["set_as_windows_menu_for_nsapp"]}},"deny-set-checked":{"identifier":"deny-set-checked","description":"Denies the set_checked command without any pre-configured scope.","commands":{"allow":[],"deny":["set_checked"]}},"deny-set-enabled":{"identifier":"deny-set-enabled","description":"Denies the set_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_enabled"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-text":{"identifier":"deny-set-text","description":"Denies the set_text command without any pre-configured scope.","commands":{"allow":[],"deny":["set_text"]}},"deny-text":{"identifier":"deny-text","description":"Denies the text command without any pre-configured scope.","commands":{"allow":[],"deny":["text"]}}},"permission_sets":{},"global_scope_schema":null},"core:path":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-resolve-directory","allow-resolve","allow-normalize","allow-join","allow-dirname","allow-extname","allow-basename","allow-is-absolute"]},"permissions":{"allow-basename":{"identifier":"allow-basename","description":"Enables the basename command without any pre-configured scope.","commands":{"allow":["basename"],"deny":[]}},"allow-dirname":{"identifier":"allow-dirname","description":"Enables the dirname command without any pre-configured scope.","commands":{"allow":["dirname"],"deny":[]}},"allow-extname":{"identifier":"allow-extname","description":"Enables the extname command without any pre-configured scope.","commands":{"allow":["extname"],"deny":[]}},"allow-is-absolute":{"identifier":"allow-is-absolute","description":"Enables the is_absolute command without any pre-configured scope.","commands":{"allow":["is_absolute"],"deny":[]}},"allow-join":{"identifier":"allow-join","description":"Enables the join command without any pre-configured scope.","commands":{"allow":["join"],"deny":[]}},"allow-normalize":{"identifier":"allow-normalize","description":"Enables the normalize command without any pre-configured scope.","commands":{"allow":["normalize"],"deny":[]}},"allow-resolve":{"identifier":"allow-resolve","description":"Enables the resolve command without any pre-configured scope.","commands":{"allow":["resolve"],"deny":[]}},"allow-resolve-directory":{"identifier":"allow-resolve-directory","description":"Enables the resolve_directory command without any pre-configured scope.","commands":{"allow":["resolve_directory"],"deny":[]}},"deny-basename":{"identifier":"deny-basename","description":"Denies the basename command without any pre-configured scope.","commands":{"allow":[],"deny":["basename"]}},"deny-dirname":{"identifier":"deny-dirname","description":"Denies the dirname command without any pre-configured scope.","commands":{"allow":[],"deny":["dirname"]}},"deny-extname":{"identifier":"deny-extname","description":"Denies the extname command without any pre-configured scope.","commands":{"allow":[],"deny":["extname"]}},"deny-is-absolute":{"identifier":"deny-is-absolute","description":"Denies the is_absolute command without any pre-configured scope.","commands":{"allow":[],"deny":["is_absolute"]}},"deny-join":{"identifier":"deny-join","description":"Denies the join command without any pre-configured scope.","commands":{"allow":[],"deny":["join"]}},"deny-normalize":{"identifier":"deny-normalize","description":"Denies the normalize command without any pre-configured scope.","commands":{"allow":[],"deny":["normalize"]}},"deny-resolve":{"identifier":"deny-resolve","description":"Denies the resolve command without any pre-configured scope.","commands":{"allow":[],"deny":["resolve"]}},"deny-resolve-directory":{"identifier":"deny-resolve-directory","description":"Denies the resolve_directory command without any pre-configured scope.","commands":{"allow":[],"deny":["resolve_directory"]}}},"permission_sets":{},"global_scope_schema":null},"core:resources":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-close"]},"permissions":{"allow-close":{"identifier":"allow-close","description":"Enables the close command without any pre-configured scope.","commands":{"allow":["close"],"deny":[]}},"deny-close":{"identifier":"deny-close","description":"Denies the close command without any pre-configured scope.","commands":{"allow":[],"deny":["close"]}}},"permission_sets":{},"global_scope_schema":null},"core:tray":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin, which enables all commands.","permissions":["allow-new","allow-get-by-id","allow-remove-by-id","allow-set-icon","allow-set-menu","allow-set-tooltip","allow-set-title","allow-set-visible","allow-set-temp-dir-path","allow-set-icon-as-template","allow-set-icon-with-as-template","allow-set-show-menu-on-left-click"]},"permissions":{"allow-get-by-id":{"identifier":"allow-get-by-id","description":"Enables the get_by_id command without any pre-configured scope.","commands":{"allow":["get_by_id"],"deny":[]}},"allow-new":{"identifier":"allow-new","description":"Enables the new command without any pre-configured scope.","commands":{"allow":["new"],"deny":[]}},"allow-remove-by-id":{"identifier":"allow-remove-by-id","description":"Enables the remove_by_id command without any pre-configured scope.","commands":{"allow":["remove_by_id"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-icon-as-template":{"identifier":"allow-set-icon-as-template","description":"Enables the set_icon_as_template command without any pre-configured scope.","commands":{"allow":["set_icon_as_template"],"deny":[]}},"allow-set-icon-with-as-template":{"identifier":"allow-set-icon-with-as-template","description":"Enables the set_icon_with_as_template command without any pre-configured scope.","commands":{"allow":["set_icon_with_as_template"],"deny":[]}},"allow-set-menu":{"identifier":"allow-set-menu","description":"Enables the set_menu command without any pre-configured scope.","commands":{"allow":["set_menu"],"deny":[]}},"allow-set-show-menu-on-left-click":{"identifier":"allow-set-show-menu-on-left-click","description":"Enables the set_show_menu_on_left_click command without any pre-configured scope.","commands":{"allow":["set_show_menu_on_left_click"],"deny":[]}},"allow-set-temp-dir-path":{"identifier":"allow-set-temp-dir-path","description":"Enables the set_temp_dir_path command without any pre-configured scope.","commands":{"allow":["set_temp_dir_path"],"deny":[]}},"allow-set-title":{"identifier":"allow-set-title","description":"Enables the set_title command without any pre-configured scope.","commands":{"allow":["set_title"],"deny":[]}},"allow-set-tooltip":{"identifier":"allow-set-tooltip","description":"Enables the set_tooltip command without any pre-configured scope.","commands":{"allow":["set_tooltip"],"deny":[]}},"allow-set-visible":{"identifier":"allow-set-visible","description":"Enables the set_visible command without any pre-configured scope.","commands":{"allow":["set_visible"],"deny":[]}},"deny-get-by-id":{"identifier":"deny-get-by-id","description":"Denies the get_by_id command without any pre-configured scope.","commands":{"allow":[],"deny":["get_by_id"]}},"deny-new":{"identifier":"deny-new","description":"Denies the new command without any pre-configured scope.","commands":{"allow":[],"deny":["new"]}},"deny-remove-by-id":{"identifier":"deny-remove-by-id","description":"Denies the remove_by_id command without any pre-configured scope.","commands":{"allow":[],"deny":["remove_by_id"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-icon-as-template":{"identifier":"deny-set-icon-as-template","description":"Denies the set_icon_as_template command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon_as_template"]}},"deny-set-icon-with-as-template":{"identifier":"deny-set-icon-with-as-template","description":"Denies the set_icon_with_as_template command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon_with_as_template"]}},"deny-set-menu":{"identifier":"deny-set-menu","description":"Denies the set_menu command without any pre-configured scope.","commands":{"allow":[],"deny":["set_menu"]}},"deny-set-show-menu-on-left-click":{"identifier":"deny-set-show-menu-on-left-click","description":"Denies the set_show_menu_on_left_click command without any pre-configured scope.","commands":{"allow":[],"deny":["set_show_menu_on_left_click"]}},"deny-set-temp-dir-path":{"identifier":"deny-set-temp-dir-path","description":"Denies the set_temp_dir_path command without any pre-configured scope.","commands":{"allow":[],"deny":["set_temp_dir_path"]}},"deny-set-title":{"identifier":"deny-set-title","description":"Denies the set_title command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title"]}},"deny-set-tooltip":{"identifier":"deny-set-tooltip","description":"Denies the set_tooltip command without any pre-configured scope.","commands":{"allow":[],"deny":["set_tooltip"]}},"deny-set-visible":{"identifier":"deny-set-visible","description":"Denies the set_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["set_visible"]}}},"permission_sets":{},"global_scope_schema":null},"core:webview":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-get-all-webviews","allow-webview-position","allow-webview-size","allow-internal-toggle-devtools"]},"permissions":{"allow-clear-all-browsing-data":{"identifier":"allow-clear-all-browsing-data","description":"Enables the clear_all_browsing_data command without any pre-configured scope.","commands":{"allow":["clear_all_browsing_data"],"deny":[]}},"allow-create-webview":{"identifier":"allow-create-webview","description":"Enables the create_webview command without any pre-configured scope.","commands":{"allow":["create_webview"],"deny":[]}},"allow-create-webview-window":{"identifier":"allow-create-webview-window","description":"Enables the create_webview_window command without any pre-configured scope.","commands":{"allow":["create_webview_window"],"deny":[]}},"allow-get-all-webviews":{"identifier":"allow-get-all-webviews","description":"Enables the get_all_webviews command without any pre-configured scope.","commands":{"allow":["get_all_webviews"],"deny":[]}},"allow-internal-toggle-devtools":{"identifier":"allow-internal-toggle-devtools","description":"Enables the internal_toggle_devtools command without any pre-configured scope.","commands":{"allow":["internal_toggle_devtools"],"deny":[]}},"allow-print":{"identifier":"allow-print","description":"Enables the print command without any pre-configured scope.","commands":{"allow":["print"],"deny":[]}},"allow-reparent":{"identifier":"allow-reparent","description":"Enables the reparent command without any pre-configured scope.","commands":{"allow":["reparent"],"deny":[]}},"allow-set-webview-auto-resize":{"identifier":"allow-set-webview-auto-resize","description":"Enables the set_webview_auto_resize command without any pre-configured scope.","commands":{"allow":["set_webview_auto_resize"],"deny":[]}},"allow-set-webview-background-color":{"identifier":"allow-set-webview-background-color","description":"Enables the set_webview_background_color command without any pre-configured scope.","commands":{"allow":["set_webview_background_color"],"deny":[]}},"allow-set-webview-focus":{"identifier":"allow-set-webview-focus","description":"Enables the set_webview_focus command without any pre-configured scope.","commands":{"allow":["set_webview_focus"],"deny":[]}},"allow-set-webview-position":{"identifier":"allow-set-webview-position","description":"Enables the set_webview_position command without any pre-configured scope.","commands":{"allow":["set_webview_position"],"deny":[]}},"allow-set-webview-size":{"identifier":"allow-set-webview-size","description":"Enables the set_webview_size command without any pre-configured scope.","commands":{"allow":["set_webview_size"],"deny":[]}},"allow-set-webview-zoom":{"identifier":"allow-set-webview-zoom","description":"Enables the set_webview_zoom command without any pre-configured scope.","commands":{"allow":["set_webview_zoom"],"deny":[]}},"allow-webview-close":{"identifier":"allow-webview-close","description":"Enables the webview_close command without any pre-configured scope.","commands":{"allow":["webview_close"],"deny":[]}},"allow-webview-hide":{"identifier":"allow-webview-hide","description":"Enables the webview_hide command without any pre-configured scope.","commands":{"allow":["webview_hide"],"deny":[]}},"allow-webview-position":{"identifier":"allow-webview-position","description":"Enables the webview_position command without any pre-configured scope.","commands":{"allow":["webview_position"],"deny":[]}},"allow-webview-show":{"identifier":"allow-webview-show","description":"Enables the webview_show command without any pre-configured scope.","commands":{"allow":["webview_show"],"deny":[]}},"allow-webview-size":{"identifier":"allow-webview-size","description":"Enables the webview_size command without any pre-configured scope.","commands":{"allow":["webview_size"],"deny":[]}},"deny-clear-all-browsing-data":{"identifier":"deny-clear-all-browsing-data","description":"Denies the clear_all_browsing_data command without any pre-configured scope.","commands":{"allow":[],"deny":["clear_all_browsing_data"]}},"deny-create-webview":{"identifier":"deny-create-webview","description":"Denies the create_webview command without any pre-configured scope.","commands":{"allow":[],"deny":["create_webview"]}},"deny-create-webview-window":{"identifier":"deny-create-webview-window","description":"Denies the create_webview_window command without any pre-configured scope.","commands":{"allow":[],"deny":["create_webview_window"]}},"deny-get-all-webviews":{"identifier":"deny-get-all-webviews","description":"Denies the get_all_webviews command without any pre-configured scope.","commands":{"allow":[],"deny":["get_all_webviews"]}},"deny-internal-toggle-devtools":{"identifier":"deny-internal-toggle-devtools","description":"Denies the internal_toggle_devtools command without any pre-configured scope.","commands":{"allow":[],"deny":["internal_toggle_devtools"]}},"deny-print":{"identifier":"deny-print","description":"Denies the print command without any pre-configured scope.","commands":{"allow":[],"deny":["print"]}},"deny-reparent":{"identifier":"deny-reparent","description":"Denies the reparent command without any pre-configured scope.","commands":{"allow":[],"deny":["reparent"]}},"deny-set-webview-auto-resize":{"identifier":"deny-set-webview-auto-resize","description":"Denies the set_webview_auto_resize command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_auto_resize"]}},"deny-set-webview-background-color":{"identifier":"deny-set-webview-background-color","description":"Denies the set_webview_background_color command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_background_color"]}},"deny-set-webview-focus":{"identifier":"deny-set-webview-focus","description":"Denies the set_webview_focus command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_focus"]}},"deny-set-webview-position":{"identifier":"deny-set-webview-position","description":"Denies the set_webview_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_position"]}},"deny-set-webview-size":{"identifier":"deny-set-webview-size","description":"Denies the set_webview_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_size"]}},"deny-set-webview-zoom":{"identifier":"deny-set-webview-zoom","description":"Denies the set_webview_zoom command without any pre-configured scope.","commands":{"allow":[],"deny":["set_webview_zoom"]}},"deny-webview-close":{"identifier":"deny-webview-close","description":"Denies the webview_close command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_close"]}},"deny-webview-hide":{"identifier":"deny-webview-hide","description":"Denies the webview_hide command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_hide"]}},"deny-webview-position":{"identifier":"deny-webview-position","description":"Denies the webview_position command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_position"]}},"deny-webview-show":{"identifier":"deny-webview-show","description":"Denies the webview_show command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_show"]}},"deny-webview-size":{"identifier":"deny-webview-size","description":"Denies the webview_size command without any pre-configured scope.","commands":{"allow":[],"deny":["webview_size"]}}},"permission_sets":{},"global_scope_schema":null},"core:window":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-get-all-windows","allow-scale-factor","allow-inner-position","allow-outer-position","allow-inner-size","allow-outer-size","allow-is-fullscreen","allow-is-minimized","allow-is-maximized","allow-is-focused","allow-is-decorated","allow-is-resizable","allow-is-maximizable","allow-is-minimizable","allow-is-closable","allow-is-visible","allow-is-enabled","allow-title","allow-current-monitor","allow-primary-monitor","allow-monitor-from-point","allow-available-monitors","allow-cursor-position","allow-theme","allow-is-always-on-top","allow-activity-name","allow-scene-identifier","allow-internal-toggle-maximize"]},"permissions":{"allow-activity-name":{"identifier":"allow-activity-name","description":"Enables the activity_name command without any pre-configured scope.","commands":{"allow":["activity_name"],"deny":[]}},"allow-available-monitors":{"identifier":"allow-available-monitors","description":"Enables the available_monitors command without any pre-configured scope.","commands":{"allow":["available_monitors"],"deny":[]}},"allow-center":{"identifier":"allow-center","description":"Enables the center command without any pre-configured scope.","commands":{"allow":["center"],"deny":[]}},"allow-close":{"identifier":"allow-close","description":"Enables the close command without any pre-configured scope.","commands":{"allow":["close"],"deny":[]}},"allow-create":{"identifier":"allow-create","description":"Enables the create command without any pre-configured scope.","commands":{"allow":["create"],"deny":[]}},"allow-current-monitor":{"identifier":"allow-current-monitor","description":"Enables the current_monitor command without any pre-configured scope.","commands":{"allow":["current_monitor"],"deny":[]}},"allow-cursor-position":{"identifier":"allow-cursor-position","description":"Enables the cursor_position command without any pre-configured scope.","commands":{"allow":["cursor_position"],"deny":[]}},"allow-destroy":{"identifier":"allow-destroy","description":"Enables the destroy command without any pre-configured scope.","commands":{"allow":["destroy"],"deny":[]}},"allow-get-all-windows":{"identifier":"allow-get-all-windows","description":"Enables the get_all_windows command without any pre-configured scope.","commands":{"allow":["get_all_windows"],"deny":[]}},"allow-hide":{"identifier":"allow-hide","description":"Enables the hide command without any pre-configured scope.","commands":{"allow":["hide"],"deny":[]}},"allow-inner-position":{"identifier":"allow-inner-position","description":"Enables the inner_position command without any pre-configured scope.","commands":{"allow":["inner_position"],"deny":[]}},"allow-inner-size":{"identifier":"allow-inner-size","description":"Enables the inner_size command without any pre-configured scope.","commands":{"allow":["inner_size"],"deny":[]}},"allow-internal-toggle-maximize":{"identifier":"allow-internal-toggle-maximize","description":"Enables the internal_toggle_maximize command without any pre-configured scope.","commands":{"allow":["internal_toggle_maximize"],"deny":[]}},"allow-is-always-on-top":{"identifier":"allow-is-always-on-top","description":"Enables the is_always_on_top command without any pre-configured scope.","commands":{"allow":["is_always_on_top"],"deny":[]}},"allow-is-closable":{"identifier":"allow-is-closable","description":"Enables the is_closable command without any pre-configured scope.","commands":{"allow":["is_closable"],"deny":[]}},"allow-is-decorated":{"identifier":"allow-is-decorated","description":"Enables the is_decorated command without any pre-configured scope.","commands":{"allow":["is_decorated"],"deny":[]}},"allow-is-enabled":{"identifier":"allow-is-enabled","description":"Enables the is_enabled command without any pre-configured scope.","commands":{"allow":["is_enabled"],"deny":[]}},"allow-is-focused":{"identifier":"allow-is-focused","description":"Enables the is_focused command without any pre-configured scope.","commands":{"allow":["is_focused"],"deny":[]}},"allow-is-fullscreen":{"identifier":"allow-is-fullscreen","description":"Enables the is_fullscreen command without any pre-configured scope.","commands":{"allow":["is_fullscreen"],"deny":[]}},"allow-is-maximizable":{"identifier":"allow-is-maximizable","description":"Enables the is_maximizable command without any pre-configured scope.","commands":{"allow":["is_maximizable"],"deny":[]}},"allow-is-maximized":{"identifier":"allow-is-maximized","description":"Enables the is_maximized command without any pre-configured scope.","commands":{"allow":["is_maximized"],"deny":[]}},"allow-is-minimizable":{"identifier":"allow-is-minimizable","description":"Enables the is_minimizable command without any pre-configured scope.","commands":{"allow":["is_minimizable"],"deny":[]}},"allow-is-minimized":{"identifier":"allow-is-minimized","description":"Enables the is_minimized command without any pre-configured scope.","commands":{"allow":["is_minimized"],"deny":[]}},"allow-is-resizable":{"identifier":"allow-is-resizable","description":"Enables the is_resizable command without any pre-configured scope.","commands":{"allow":["is_resizable"],"deny":[]}},"allow-is-visible":{"identifier":"allow-is-visible","description":"Enables the is_visible command without any pre-configured scope.","commands":{"allow":["is_visible"],"deny":[]}},"allow-maximize":{"identifier":"allow-maximize","description":"Enables the maximize command without any pre-configured scope.","commands":{"allow":["maximize"],"deny":[]}},"allow-minimize":{"identifier":"allow-minimize","description":"Enables the minimize command without any pre-configured scope.","commands":{"allow":["minimize"],"deny":[]}},"allow-monitor-from-point":{"identifier":"allow-monitor-from-point","description":"Enables the monitor_from_point command without any pre-configured scope.","commands":{"allow":["monitor_from_point"],"deny":[]}},"allow-outer-position":{"identifier":"allow-outer-position","description":"Enables the outer_position command without any pre-configured scope.","commands":{"allow":["outer_position"],"deny":[]}},"allow-outer-size":{"identifier":"allow-outer-size","description":"Enables the outer_size command without any pre-configured scope.","commands":{"allow":["outer_size"],"deny":[]}},"allow-primary-monitor":{"identifier":"allow-primary-monitor","description":"Enables the primary_monitor command without any pre-configured scope.","commands":{"allow":["primary_monitor"],"deny":[]}},"allow-request-user-attention":{"identifier":"allow-request-user-attention","description":"Enables the request_user_attention command without any pre-configured scope.","commands":{"allow":["request_user_attention"],"deny":[]}},"allow-scale-factor":{"identifier":"allow-scale-factor","description":"Enables the scale_factor command without any pre-configured scope.","commands":{"allow":["scale_factor"],"deny":[]}},"allow-scene-identifier":{"identifier":"allow-scene-identifier","description":"Enables the scene_identifier command without any pre-configured scope.","commands":{"allow":["scene_identifier"],"deny":[]}},"allow-set-always-on-bottom":{"identifier":"allow-set-always-on-bottom","description":"Enables the set_always_on_bottom command without any pre-configured scope.","commands":{"allow":["set_always_on_bottom"],"deny":[]}},"allow-set-always-on-top":{"identifier":"allow-set-always-on-top","description":"Enables the set_always_on_top command without any pre-configured scope.","commands":{"allow":["set_always_on_top"],"deny":[]}},"allow-set-background-color":{"identifier":"allow-set-background-color","description":"Enables the set_background_color command without any pre-configured scope.","commands":{"allow":["set_background_color"],"deny":[]}},"allow-set-badge-count":{"identifier":"allow-set-badge-count","description":"Enables the set_badge_count command without any pre-configured scope.","commands":{"allow":["set_badge_count"],"deny":[]}},"allow-set-badge-label":{"identifier":"allow-set-badge-label","description":"Enables the set_badge_label command without any pre-configured scope.","commands":{"allow":["set_badge_label"],"deny":[]}},"allow-set-closable":{"identifier":"allow-set-closable","description":"Enables the set_closable command without any pre-configured scope.","commands":{"allow":["set_closable"],"deny":[]}},"allow-set-content-protected":{"identifier":"allow-set-content-protected","description":"Enables the set_content_protected command without any pre-configured scope.","commands":{"allow":["set_content_protected"],"deny":[]}},"allow-set-cursor-grab":{"identifier":"allow-set-cursor-grab","description":"Enables the set_cursor_grab command without any pre-configured scope.","commands":{"allow":["set_cursor_grab"],"deny":[]}},"allow-set-cursor-icon":{"identifier":"allow-set-cursor-icon","description":"Enables the set_cursor_icon command without any pre-configured scope.","commands":{"allow":["set_cursor_icon"],"deny":[]}},"allow-set-cursor-position":{"identifier":"allow-set-cursor-position","description":"Enables the set_cursor_position command without any pre-configured scope.","commands":{"allow":["set_cursor_position"],"deny":[]}},"allow-set-cursor-visible":{"identifier":"allow-set-cursor-visible","description":"Enables the set_cursor_visible command without any pre-configured scope.","commands":{"allow":["set_cursor_visible"],"deny":[]}},"allow-set-decorations":{"identifier":"allow-set-decorations","description":"Enables the set_decorations command without any pre-configured scope.","commands":{"allow":["set_decorations"],"deny":[]}},"allow-set-effects":{"identifier":"allow-set-effects","description":"Enables the set_effects command without any pre-configured scope.","commands":{"allow":["set_effects"],"deny":[]}},"allow-set-enabled":{"identifier":"allow-set-enabled","description":"Enables the set_enabled command without any pre-configured scope.","commands":{"allow":["set_enabled"],"deny":[]}},"allow-set-focus":{"identifier":"allow-set-focus","description":"Enables the set_focus command without any pre-configured scope.","commands":{"allow":["set_focus"],"deny":[]}},"allow-set-focusable":{"identifier":"allow-set-focusable","description":"Enables the set_focusable command without any pre-configured scope.","commands":{"allow":["set_focusable"],"deny":[]}},"allow-set-fullscreen":{"identifier":"allow-set-fullscreen","description":"Enables the set_fullscreen command without any pre-configured scope.","commands":{"allow":["set_fullscreen"],"deny":[]}},"allow-set-icon":{"identifier":"allow-set-icon","description":"Enables the set_icon command without any pre-configured scope.","commands":{"allow":["set_icon"],"deny":[]}},"allow-set-ignore-cursor-events":{"identifier":"allow-set-ignore-cursor-events","description":"Enables the set_ignore_cursor_events command without any pre-configured scope.","commands":{"allow":["set_ignore_cursor_events"],"deny":[]}},"allow-set-max-size":{"identifier":"allow-set-max-size","description":"Enables the set_max_size command without any pre-configured scope.","commands":{"allow":["set_max_size"],"deny":[]}},"allow-set-maximizable":{"identifier":"allow-set-maximizable","description":"Enables the set_maximizable command without any pre-configured scope.","commands":{"allow":["set_maximizable"],"deny":[]}},"allow-set-min-size":{"identifier":"allow-set-min-size","description":"Enables the set_min_size command without any pre-configured scope.","commands":{"allow":["set_min_size"],"deny":[]}},"allow-set-minimizable":{"identifier":"allow-set-minimizable","description":"Enables the set_minimizable command without any pre-configured scope.","commands":{"allow":["set_minimizable"],"deny":[]}},"allow-set-overlay-icon":{"identifier":"allow-set-overlay-icon","description":"Enables the set_overlay_icon command without any pre-configured scope.","commands":{"allow":["set_overlay_icon"],"deny":[]}},"allow-set-position":{"identifier":"allow-set-position","description":"Enables the set_position command without any pre-configured scope.","commands":{"allow":["set_position"],"deny":[]}},"allow-set-progress-bar":{"identifier":"allow-set-progress-bar","description":"Enables the set_progress_bar command without any pre-configured scope.","commands":{"allow":["set_progress_bar"],"deny":[]}},"allow-set-resizable":{"identifier":"allow-set-resizable","description":"Enables the set_resizable command without any pre-configured scope.","commands":{"allow":["set_resizable"],"deny":[]}},"allow-set-shadow":{"identifier":"allow-set-shadow","description":"Enables the set_shadow command without any pre-configured scope.","commands":{"allow":["set_shadow"],"deny":[]}},"allow-set-simple-fullscreen":{"identifier":"allow-set-simple-fullscreen","description":"Enables the set_simple_fullscreen command without any pre-configured scope.","commands":{"allow":["set_simple_fullscreen"],"deny":[]}},"allow-set-size":{"identifier":"allow-set-size","description":"Enables the set_size command without any pre-configured scope.","commands":{"allow":["set_size"],"deny":[]}},"allow-set-size-constraints":{"identifier":"allow-set-size-constraints","description":"Enables the set_size_constraints command without any pre-configured scope.","commands":{"allow":["set_size_constraints"],"deny":[]}},"allow-set-skip-taskbar":{"identifier":"allow-set-skip-taskbar","description":"Enables the set_skip_taskbar command without any pre-configured scope.","commands":{"allow":["set_skip_taskbar"],"deny":[]}},"allow-set-theme":{"identifier":"allow-set-theme","description":"Enables the set_theme command without any pre-configured scope.","commands":{"allow":["set_theme"],"deny":[]}},"allow-set-title":{"identifier":"allow-set-title","description":"Enables the set_title command without any pre-configured scope.","commands":{"allow":["set_title"],"deny":[]}},"allow-set-title-bar-style":{"identifier":"allow-set-title-bar-style","description":"Enables the set_title_bar_style command without any pre-configured scope.","commands":{"allow":["set_title_bar_style"],"deny":[]}},"allow-set-visible-on-all-workspaces":{"identifier":"allow-set-visible-on-all-workspaces","description":"Enables the set_visible_on_all_workspaces command without any pre-configured scope.","commands":{"allow":["set_visible_on_all_workspaces"],"deny":[]}},"allow-show":{"identifier":"allow-show","description":"Enables the show command without any pre-configured scope.","commands":{"allow":["show"],"deny":[]}},"allow-start-dragging":{"identifier":"allow-start-dragging","description":"Enables the start_dragging command without any pre-configured scope.","commands":{"allow":["start_dragging"],"deny":[]}},"allow-start-resize-dragging":{"identifier":"allow-start-resize-dragging","description":"Enables the start_resize_dragging command without any pre-configured scope.","commands":{"allow":["start_resize_dragging"],"deny":[]}},"allow-theme":{"identifier":"allow-theme","description":"Enables the theme command without any pre-configured scope.","commands":{"allow":["theme"],"deny":[]}},"allow-title":{"identifier":"allow-title","description":"Enables the title command without any pre-configured scope.","commands":{"allow":["title"],"deny":[]}},"allow-toggle-maximize":{"identifier":"allow-toggle-maximize","description":"Enables the toggle_maximize command without any pre-configured scope.","commands":{"allow":["toggle_maximize"],"deny":[]}},"allow-unmaximize":{"identifier":"allow-unmaximize","description":"Enables the unmaximize command without any pre-configured scope.","commands":{"allow":["unmaximize"],"deny":[]}},"allow-unminimize":{"identifier":"allow-unminimize","description":"Enables the unminimize command without any pre-configured scope.","commands":{"allow":["unminimize"],"deny":[]}},"deny-activity-name":{"identifier":"deny-activity-name","description":"Denies the activity_name command without any pre-configured scope.","commands":{"allow":[],"deny":["activity_name"]}},"deny-available-monitors":{"identifier":"deny-available-monitors","description":"Denies the available_monitors command without any pre-configured scope.","commands":{"allow":[],"deny":["available_monitors"]}},"deny-center":{"identifier":"deny-center","description":"Denies the center command without any pre-configured scope.","commands":{"allow":[],"deny":["center"]}},"deny-close":{"identifier":"deny-close","description":"Denies the close command without any pre-configured scope.","commands":{"allow":[],"deny":["close"]}},"deny-create":{"identifier":"deny-create","description":"Denies the create command without any pre-configured scope.","commands":{"allow":[],"deny":["create"]}},"deny-current-monitor":{"identifier":"deny-current-monitor","description":"Denies the current_monitor command without any pre-configured scope.","commands":{"allow":[],"deny":["current_monitor"]}},"deny-cursor-position":{"identifier":"deny-cursor-position","description":"Denies the cursor_position command without any pre-configured scope.","commands":{"allow":[],"deny":["cursor_position"]}},"deny-destroy":{"identifier":"deny-destroy","description":"Denies the destroy command without any pre-configured scope.","commands":{"allow":[],"deny":["destroy"]}},"deny-get-all-windows":{"identifier":"deny-get-all-windows","description":"Denies the get_all_windows command without any pre-configured scope.","commands":{"allow":[],"deny":["get_all_windows"]}},"deny-hide":{"identifier":"deny-hide","description":"Denies the hide command without any pre-configured scope.","commands":{"allow":[],"deny":["hide"]}},"deny-inner-position":{"identifier":"deny-inner-position","description":"Denies the inner_position command without any pre-configured scope.","commands":{"allow":[],"deny":["inner_position"]}},"deny-inner-size":{"identifier":"deny-inner-size","description":"Denies the inner_size command without any pre-configured scope.","commands":{"allow":[],"deny":["inner_size"]}},"deny-internal-toggle-maximize":{"identifier":"deny-internal-toggle-maximize","description":"Denies the internal_toggle_maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["internal_toggle_maximize"]}},"deny-is-always-on-top":{"identifier":"deny-is-always-on-top","description":"Denies the is_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["is_always_on_top"]}},"deny-is-closable":{"identifier":"deny-is-closable","description":"Denies the is_closable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_closable"]}},"deny-is-decorated":{"identifier":"deny-is-decorated","description":"Denies the is_decorated command without any pre-configured scope.","commands":{"allow":[],"deny":["is_decorated"]}},"deny-is-enabled":{"identifier":"deny-is-enabled","description":"Denies the is_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["is_enabled"]}},"deny-is-focused":{"identifier":"deny-is-focused","description":"Denies the is_focused command without any pre-configured scope.","commands":{"allow":[],"deny":["is_focused"]}},"deny-is-fullscreen":{"identifier":"deny-is-fullscreen","description":"Denies the is_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["is_fullscreen"]}},"deny-is-maximizable":{"identifier":"deny-is-maximizable","description":"Denies the is_maximizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_maximizable"]}},"deny-is-maximized":{"identifier":"deny-is-maximized","description":"Denies the is_maximized command without any pre-configured scope.","commands":{"allow":[],"deny":["is_maximized"]}},"deny-is-minimizable":{"identifier":"deny-is-minimizable","description":"Denies the is_minimizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_minimizable"]}},"deny-is-minimized":{"identifier":"deny-is-minimized","description":"Denies the is_minimized command without any pre-configured scope.","commands":{"allow":[],"deny":["is_minimized"]}},"deny-is-resizable":{"identifier":"deny-is-resizable","description":"Denies the is_resizable command without any pre-configured scope.","commands":{"allow":[],"deny":["is_resizable"]}},"deny-is-visible":{"identifier":"deny-is-visible","description":"Denies the is_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["is_visible"]}},"deny-maximize":{"identifier":"deny-maximize","description":"Denies the maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["maximize"]}},"deny-minimize":{"identifier":"deny-minimize","description":"Denies the minimize command without any pre-configured scope.","commands":{"allow":[],"deny":["minimize"]}},"deny-monitor-from-point":{"identifier":"deny-monitor-from-point","description":"Denies the monitor_from_point command without any pre-configured scope.","commands":{"allow":[],"deny":["monitor_from_point"]}},"deny-outer-position":{"identifier":"deny-outer-position","description":"Denies the outer_position command without any pre-configured scope.","commands":{"allow":[],"deny":["outer_position"]}},"deny-outer-size":{"identifier":"deny-outer-size","description":"Denies the outer_size command without any pre-configured scope.","commands":{"allow":[],"deny":["outer_size"]}},"deny-primary-monitor":{"identifier":"deny-primary-monitor","description":"Denies the primary_monitor command without any pre-configured scope.","commands":{"allow":[],"deny":["primary_monitor"]}},"deny-request-user-attention":{"identifier":"deny-request-user-attention","description":"Denies the request_user_attention command without any pre-configured scope.","commands":{"allow":[],"deny":["request_user_attention"]}},"deny-scale-factor":{"identifier":"deny-scale-factor","description":"Denies the scale_factor command without any pre-configured scope.","commands":{"allow":[],"deny":["scale_factor"]}},"deny-scene-identifier":{"identifier":"deny-scene-identifier","description":"Denies the scene_identifier command without any pre-configured scope.","commands":{"allow":[],"deny":["scene_identifier"]}},"deny-set-always-on-bottom":{"identifier":"deny-set-always-on-bottom","description":"Denies the set_always_on_bottom command without any pre-configured scope.","commands":{"allow":[],"deny":["set_always_on_bottom"]}},"deny-set-always-on-top":{"identifier":"deny-set-always-on-top","description":"Denies the set_always_on_top command without any pre-configured scope.","commands":{"allow":[],"deny":["set_always_on_top"]}},"deny-set-background-color":{"identifier":"deny-set-background-color","description":"Denies the set_background_color command without any pre-configured scope.","commands":{"allow":[],"deny":["set_background_color"]}},"deny-set-badge-count":{"identifier":"deny-set-badge-count","description":"Denies the set_badge_count command without any pre-configured scope.","commands":{"allow":[],"deny":["set_badge_count"]}},"deny-set-badge-label":{"identifier":"deny-set-badge-label","description":"Denies the set_badge_label command without any pre-configured scope.","commands":{"allow":[],"deny":["set_badge_label"]}},"deny-set-closable":{"identifier":"deny-set-closable","description":"Denies the set_closable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_closable"]}},"deny-set-content-protected":{"identifier":"deny-set-content-protected","description":"Denies the set_content_protected command without any pre-configured scope.","commands":{"allow":[],"deny":["set_content_protected"]}},"deny-set-cursor-grab":{"identifier":"deny-set-cursor-grab","description":"Denies the set_cursor_grab command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_grab"]}},"deny-set-cursor-icon":{"identifier":"deny-set-cursor-icon","description":"Denies the set_cursor_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_icon"]}},"deny-set-cursor-position":{"identifier":"deny-set-cursor-position","description":"Denies the set_cursor_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_position"]}},"deny-set-cursor-visible":{"identifier":"deny-set-cursor-visible","description":"Denies the set_cursor_visible command without any pre-configured scope.","commands":{"allow":[],"deny":["set_cursor_visible"]}},"deny-set-decorations":{"identifier":"deny-set-decorations","description":"Denies the set_decorations command without any pre-configured scope.","commands":{"allow":[],"deny":["set_decorations"]}},"deny-set-effects":{"identifier":"deny-set-effects","description":"Denies the set_effects command without any pre-configured scope.","commands":{"allow":[],"deny":["set_effects"]}},"deny-set-enabled":{"identifier":"deny-set-enabled","description":"Denies the set_enabled command without any pre-configured scope.","commands":{"allow":[],"deny":["set_enabled"]}},"deny-set-focus":{"identifier":"deny-set-focus","description":"Denies the set_focus command without any pre-configured scope.","commands":{"allow":[],"deny":["set_focus"]}},"deny-set-focusable":{"identifier":"deny-set-focusable","description":"Denies the set_focusable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_focusable"]}},"deny-set-fullscreen":{"identifier":"deny-set-fullscreen","description":"Denies the set_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["set_fullscreen"]}},"deny-set-icon":{"identifier":"deny-set-icon","description":"Denies the set_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_icon"]}},"deny-set-ignore-cursor-events":{"identifier":"deny-set-ignore-cursor-events","description":"Denies the set_ignore_cursor_events command without any pre-configured scope.","commands":{"allow":[],"deny":["set_ignore_cursor_events"]}},"deny-set-max-size":{"identifier":"deny-set-max-size","description":"Denies the set_max_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_max_size"]}},"deny-set-maximizable":{"identifier":"deny-set-maximizable","description":"Denies the set_maximizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_maximizable"]}},"deny-set-min-size":{"identifier":"deny-set-min-size","description":"Denies the set_min_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_min_size"]}},"deny-set-minimizable":{"identifier":"deny-set-minimizable","description":"Denies the set_minimizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_minimizable"]}},"deny-set-overlay-icon":{"identifier":"deny-set-overlay-icon","description":"Denies the set_overlay_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["set_overlay_icon"]}},"deny-set-position":{"identifier":"deny-set-position","description":"Denies the set_position command without any pre-configured scope.","commands":{"allow":[],"deny":["set_position"]}},"deny-set-progress-bar":{"identifier":"deny-set-progress-bar","description":"Denies the set_progress_bar command without any pre-configured scope.","commands":{"allow":[],"deny":["set_progress_bar"]}},"deny-set-resizable":{"identifier":"deny-set-resizable","description":"Denies the set_resizable command without any pre-configured scope.","commands":{"allow":[],"deny":["set_resizable"]}},"deny-set-shadow":{"identifier":"deny-set-shadow","description":"Denies the set_shadow command without any pre-configured scope.","commands":{"allow":[],"deny":["set_shadow"]}},"deny-set-simple-fullscreen":{"identifier":"deny-set-simple-fullscreen","description":"Denies the set_simple_fullscreen command without any pre-configured scope.","commands":{"allow":[],"deny":["set_simple_fullscreen"]}},"deny-set-size":{"identifier":"deny-set-size","description":"Denies the set_size command without any pre-configured scope.","commands":{"allow":[],"deny":["set_size"]}},"deny-set-size-constraints":{"identifier":"deny-set-size-constraints","description":"Denies the set_size_constraints command without any pre-configured scope.","commands":{"allow":[],"deny":["set_size_constraints"]}},"deny-set-skip-taskbar":{"identifier":"deny-set-skip-taskbar","description":"Denies the set_skip_taskbar command without any pre-configured scope.","commands":{"allow":[],"deny":["set_skip_taskbar"]}},"deny-set-theme":{"identifier":"deny-set-theme","description":"Denies the set_theme command without any pre-configured scope.","commands":{"allow":[],"deny":["set_theme"]}},"deny-set-title":{"identifier":"deny-set-title","description":"Denies the set_title command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title"]}},"deny-set-title-bar-style":{"identifier":"deny-set-title-bar-style","description":"Denies the set_title_bar_style command without any pre-configured scope.","commands":{"allow":[],"deny":["set_title_bar_style"]}},"deny-set-visible-on-all-workspaces":{"identifier":"deny-set-visible-on-all-workspaces","description":"Denies the set_visible_on_all_workspaces command without any pre-configured scope.","commands":{"allow":[],"deny":["set_visible_on_all_workspaces"]}},"deny-show":{"identifier":"deny-show","description":"Denies the show command without any pre-configured scope.","commands":{"allow":[],"deny":["show"]}},"deny-start-dragging":{"identifier":"deny-start-dragging","description":"Denies the start_dragging command without any pre-configured scope.","commands":{"allow":[],"deny":["start_dragging"]}},"deny-start-resize-dragging":{"identifier":"deny-start-resize-dragging","description":"Denies the start_resize_dragging command without any pre-configured scope.","commands":{"allow":[],"deny":["start_resize_dragging"]}},"deny-theme":{"identifier":"deny-theme","description":"Denies the theme command without any pre-configured scope.","commands":{"allow":[],"deny":["theme"]}},"deny-title":{"identifier":"deny-title","description":"Denies the title command without any pre-configured scope.","commands":{"allow":[],"deny":["title"]}},"deny-toggle-maximize":{"identifier":"deny-toggle-maximize","description":"Denies the toggle_maximize command without any pre-configured scope.","commands":{"allow":[],"deny":["toggle_maximize"]}},"deny-unmaximize":{"identifier":"deny-unmaximize","description":"Denies the unmaximize command without any pre-configured scope.","commands":{"allow":[],"deny":["unmaximize"]}},"deny-unminimize":{"identifier":"deny-unminimize","description":"Denies the unminimize command without any pre-configured scope.","commands":{"allow":[],"deny":["unminimize"]}}},"permission_sets":{},"global_scope_schema":null},"dialog":{"default_permission":{"identifier":"default","description":"This permission set configures the types of dialogs\navailable from the dialog plugin.\n\n#### Granted Permissions\n\nAll dialog types are enabled.\n\n\n","permissions":["allow-message","allow-save","allow-open"]},"permissions":{"allow-ask":{"identifier":"allow-ask","description":"Enables the ask command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `allow-message` and will be removed in v3)","commands":{"allow":["message"],"deny":[]}},"allow-confirm":{"identifier":"allow-confirm","description":"Enables the confirm command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `allow-message` and will be removed in v3)","commands":{"allow":["message"],"deny":[]}},"allow-message":{"identifier":"allow-message","description":"Enables the message command without any pre-configured scope.","commands":{"allow":["message"],"deny":[]}},"allow-open":{"identifier":"allow-open","description":"Enables the open command without any pre-configured scope.","commands":{"allow":["open"],"deny":[]}},"allow-save":{"identifier":"allow-save","description":"Enables the save command without any pre-configured scope.","commands":{"allow":["save"],"deny":[]}},"deny-ask":{"identifier":"deny-ask","description":"Denies the ask command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `deny-message` and will be removed in v3)","commands":{"allow":[],"deny":["message"]}},"deny-confirm":{"identifier":"deny-confirm","description":"Denies the confirm command without any pre-configured scope. (**DEPRECATED**: This is now an alias to `deny-message` and will be removed in v3)","commands":{"allow":[],"deny":["message"]}},"deny-message":{"identifier":"deny-message","description":"Denies the message command without any pre-configured scope.","commands":{"allow":[],"deny":["message"]}},"deny-open":{"identifier":"deny-open","description":"Denies the open command without any pre-configured scope.","commands":{"allow":[],"deny":["open"]}},"deny-save":{"identifier":"deny-save","description":"Denies the save command without any pre-configured scope.","commands":{"allow":[],"deny":["save"]}}},"permission_sets":{},"global_scope_schema":null},"opener":{"default_permission":{"identifier":"default","description":"This permission set allows opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application\nas well as reveal file in directories using default file explorer","permissions":["allow-open-url","allow-reveal-item-in-dir","allow-default-urls"]},"permissions":{"allow-default-urls":{"identifier":"allow-default-urls","description":"This enables opening `mailto:`, `tel:`, `https://` and `http://` urls using their default application.","commands":{"allow":[],"deny":[]},"scope":{"allow":[{"url":"mailto:*"},{"url":"tel:*"},{"url":"http://*"},{"url":"https://*"}]}},"allow-open-path":{"identifier":"allow-open-path","description":"Enables the open_path command without any pre-configured scope.","commands":{"allow":["open_path"],"deny":[]}},"allow-open-url":{"identifier":"allow-open-url","description":"Enables the open_url command without any pre-configured scope.","commands":{"allow":["open_url"],"deny":[]}},"allow-reveal-item-in-dir":{"identifier":"allow-reveal-item-in-dir","description":"Enables the reveal_item_in_dir command without any pre-configured scope.","commands":{"allow":["reveal_item_in_dir"],"deny":[]}},"deny-open-path":{"identifier":"deny-open-path","description":"Denies the open_path command without any pre-configured scope.","commands":{"allow":[],"deny":["open_path"]}},"deny-open-url":{"identifier":"deny-open-url","description":"Denies the open_url command without any pre-configured scope.","commands":{"allow":[],"deny":["open_url"]}},"deny-reveal-item-in-dir":{"identifier":"deny-reveal-item-in-dir","description":"Denies the reveal_item_in_dir command without any pre-configured scope.","commands":{"allow":[],"deny":["reveal_item_in_dir"]}}},"permission_sets":{},"global_scope_schema":{"$schema":"http://json-schema.org/draft-07/schema#","anyOf":[{"properties":{"app":{"allOf":[{"$ref":"#/definitions/Application"}],"description":"An application to open this url with, for example: firefox."},"url":{"description":"A URL that can be opened by the webview when using the Opener APIs.\n\nWildcards can be used following the UNIX glob pattern.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"","type":"string"}},"required":["url"],"type":"object"},{"properties":{"app":{"allOf":[{"$ref":"#/definitions/Application"}],"description":"An application to open this path with, for example: xdg-open."},"path":{"description":"A path that can be opened by the webview when using the Opener APIs.\n\nThe pattern can start with a variable that resolves to a system base directory. The variables are: `$AUDIO`, `$CACHE`, `$CONFIG`, `$DATA`, `$LOCALDATA`, `$DESKTOP`, `$DOCUMENT`, `$DOWNLOAD`, `$EXE`, `$FONT`, `$HOME`, `$PICTURE`, `$PUBLIC`, `$RUNTIME`, `$TEMPLATE`, `$VIDEO`, `$RESOURCE`, `$APP`, `$LOG`, `$TEMP`, `$APPCONFIG`, `$APPDATA`, `$APPLOCALDATA`, `$APPCACHE`, `$APPLOG`.","type":"string"}},"required":["path"],"type":"object"}],"definitions":{"Application":{"anyOf":[{"description":"Open in default application.","type":"null"},{"description":"If true, allow open with any application.","type":"boolean"},{"description":"Allow specific application to open with.","type":"string"}],"description":"Opener scope application."}},"description":"Opener scope entry.","title":"OpenerScopeEntry"}}} \ No newline at end of file diff --git a/app/src-tauri/gen/schemas/capabilities.json b/app/src-tauri/gen/schemas/capabilities.json index 4e459fa..d758281 100644 --- a/app/src-tauri/gen/schemas/capabilities.json +++ b/app/src-tauri/gen/schemas/capabilities.json @@ -1 +1 @@ -{"default":{"identifier":"default","description":"Default capabilities for Triple-C. Every entry here is an IPC command a compromised webview can call directly, so the set is an enumeration of what `app/src` actually invokes — plugin and core grants verified against tauri 2.11.0's `PLUGINS` table in tauri's own `build.rs` rather than assumed from a plugin's `default` set, app-command grants (the bare `allow-*` entries) cross-checked by this crate's `build.rs` against `generate_handler!`. `core:default` in particular is NOT used: it is an alias for `core:{path,event,window,webview,app,image,resources,menu,tray}:default`, and `core:image:default` carries `allow-from-path`, whose handler (`tauri-2.11.0/src/image/plugin.rs:41` → `src/image/mod.rs:96`) is a bare `std::fs::read(path)` with no scope mechanism of any kind. Nothing imports `@tauri-apps/api/image`, so the whole plugin is dropped rather than scoped — there is nothing to scope it with. `core:menu` and `core:tray` are dropped for the same reason (no menu, no tray icon); `core:window` and `core:path` because nothing imports them; `core:resources:allow-close` because no frontend value is a `Resource`; and `core:event`'s `allow-emit`/`allow-emit-to` because the frontend only ever *listens* — every emit in this app originates in Rust. Three notes on what is deliberately kept or accepted: (1) `core:webview:allow-internal-toggle-devtools` is not called by `app/src` at all — it is called by Tauri's own injected `toggle-devtools.js`, which binds Ctrl/Cmd+Shift+I. Both that script and the command behind it are `#[cfg(any(debug_assertions, feature = \"devtools\"))]`, so this grant is a `tauri dev` convenience that does not exist in a release bundle. (2) `opener:allow-open-url` is **gone**. It could not be narrowed by host — `TerminalView`'s `WebLinksAddon` opens links Claude printed inside the container, which are arbitrary by construction, so a host allowlist would have deleted the feature rather than bounded it — and it was carried here as an accepted residual risk: a compromised webview could make the OS open an attacker-chosen http(s) URL, an outbound channel. That risk is now closed rather than recorded. Every host-browser open in the app goes through the `open_url_external` command in `url_open.rs`, which exists because the AppImage environment leaks into a cold-launched browser on Linux (triple-c#34) and which re-validates the URL in Rust — scheme allowlist, no embedded credentials, no control characters, length cap, ASCII asserted before `execvp`. On macOS and Windows that command reaches the same plugin as before, via `OpenerExt::open_url`, whose desktop implementation calls `crate::open::open` directly and is therefore not gated by this file at all (`tauri-plugin-opener-2.5.3/src/lib.rs:60`). The plugin stays a dependency for exactly that reason; what is removed is the webview's ability to reach it without passing the Rust validation. (3) `drag:allow-start-drag` is **gone**, together with the OS drag-out it existed for. It could not be scoped — `tauri-plugin-drag` takes the item paths from the caller and has no scope mechanism, so a compromised webview could call `startDrag({ item: ['~/.ssh/id_rsa'] })` against any host path the user can read — and it was carried as an accepted residual risk for one gesture. Drag-out was held back for separate hardening (see branch `hold/disk-and-dragout`) and the plugin is no longer a dependency. Getting a file *out* of a container is either \"Back up container\" on the project's Overview tab, which archives a tree through the Docker API, or the Files tab's per-row \"Save to host…\", which copies one file; getting one *in* is a drop on the Terminal or the Files tab's \"Upload…\". None of the four touches this permission. The Files tab's two are worth separating out here, because they are the only host-path commands in the app whose dialog is opened by **Rust** rather than by the webview — `pick_save_path` and `pick_files_to_upload` in `commands/file_commands.rs` drive `tauri-plugin-dialog` from the backend, so a compromised webview can ask for a picker and nothing more: it cannot name a host path as an *input* to either command. Be precise about the limit of that claim — host paths do still travel outward in error text (`Failed to create /home/j/Documents/x.txt.triple-c-part-1a2b3c4d: Permission denied`), including canonicalized ones, which disclose symlink targets. That is accepted; the app already hands the webview the project paths. What is closed is the direction that mattered — the webview naming where bytes go. That is the shape an earlier revision of this file named as the honest one if the Files tab ever regained host I/O, and it is the shape it regained it in. The `dialog:allow-open` / `dialog:allow-save` grants below are therefore *not* what those two use; they remain for the frontend pickers in Add Project, the Config tab's workspace and access sections, the CA-certificate field and Backup. Two commands still take a host path over IPC as a string — the terminal drop and `download_container_backup` — and for those `validate_host_path` is the boundary rather than defence in depth. This file is the reviewed threat model of record, so keep this census accurate: a stale reference here is worse than none. Note that dragging files *into* the app is unaffected: `dragDropEnabled` and `onDragDropEvent` are core webview behaviour and need no grant. Historical note kept because it is easy to re-introduce: the `store:*` grants were removed — nothing in `app/src` uses `@tauri-apps/plugin-store`, and the plugin's `resolve_store_path` is a `PathBuf::push` against AppData, which `push` discards outright when handed an absolute path, so the grant was an arbitrary host-file read/write primitive (`plugin:store|load` + `set` + `save` on `~/.claude/settings.json` is host code execution). A second capability file, `file-viewer.json`, covers the `file-viewer-*` windows the terminal file viewer opens on `viewer.html`; it is the only other local-origin window, its grants are listed and justified there, and its one non-obvious grant (`core:window:allow-destroy`) exists because `onCloseRequested` cannot close a window without it. App commands are gated by this file too. `build.rs` declares a Tauri `AppManifest` listing every command in `generate_handler!`, which is what makes tauri 2.11.0 apply the ACL to app commands at all (`webview/mod.rs:1794` skips it when no app manifest exists), and the bare `allow-` entries below are the complete list of app commands the main window may call. `build.rs` refuses to build unless every registered command has exactly one such grant, in the file whose `windows` its name says it belongs to (`viewer_*` in `file-viewer.json`, everything else here), and unless every bare entry names a registered command — so a forgotten, misspelled, duplicated or misfiled grant is a failed `cargo check`, not a feature that dies at runtime with `not allowed by ACL`. `deny-*` is banned by the same check: in tauri 2.11.0 a deny matches regardless of window or origin, so a deny meant for the viewer would deny main too. Hand-written files under `permissions/` are refused for the same reason — they would be grants this census cannot see. Because the census can only vouch for what it reads, `build.rs` also refuses any capability it did not check: anything in `capabilities/` other than a top-level `*.json` file (tauri also loads `.toml`/`.json5` there, and subdirectories), a `webviews` or `remote` key in a capability file (either would extend grants beyond what `windows` says), `app.security.capabilities` declared inline in `tauri.conf.json`, any `tauri..conf.json`, or `TAURI_CONFIG`, and a tauri config in a format the census cannot parse (JSON5, TOML). OS/editor junk (`.DS_Store`, `Thumbs.db`, editor swap files) is recognised and skipped in `capabilities/` and `permissions/` rather than refused, since tauri never loads it either. Each failure names the check that failed (\"stray entry in capabilities/\", \"capabilities declared outside capabilities/\", \"hand-written permission\", …) rather than always reading as a grant/handler mismatch. Known gap: adding a new `tauri..conf.json` to a tree that has already been built once only takes effect on a clean build or in CI — cargo's incremental build has no reason to notice a file that did not exist on the previous build. The `*marketplace*` commands fetch user-configured https git repos on the host and push pinned files into containers; account tokens stay in the OS keychain and never cross IPC outward — the only inbound one is the token pasted into `add_marketplace_token_account`. The pop-out stays capability-less. The Rust label gates in `commands/file_viewer_commands.rs` remain, because the ACL says *which* window may call a command and the label says *whose* registry entry it acts on; they are not redundant. The rules live in `src/command_census.rs`, which is unit-tested, and `src/test/capabilities.test.ts` checks the other direction: that the code that runs in each window imports only the wrappers that window is granted. On the CSP side: `app.security.csp` in `tauri.conf.json` covers the shipped bundle, and there is deliberately no `devCsp`. `npm run tauri dev` loads the main document straight from Vite at `build.devUrl` (`http://localhost:1420`), and Tauri only attaches a CSP to documents it serves itself — `protocol/tauri.rs:217` sets the header on `tauri://` assets, and the dev server is proxied through that protocol only when `PROXY_DEV_SERVER`, which is `cfg!(all(dev, mobile))` and therefore false for every desktop build. A `devCsp` here would be inert config that reads as protection, which is worse than its absence. If a CSP in dev is wanted, the only place that can set one is the Vite dev server's own `server.headers` in `app/vite.config.ts`; it is not set today, and dev is not the shipped configuration.","local":true,"windows":["main"],"permissions":["core:event:allow-listen","core:event:allow-unlisten","core:webview:allow-internal-toggle-devtools","dialog:allow-open","dialog:allow-save","allow-check-docker","allow-check-image-exists","allow-build-image","allow-get-container-info","allow-list-projects","allow-add-project","allow-remove-project","allow-update-project","allow-start-project-container","allow-stop-project-container","allow-check-unsaved-work","allow-aws-task-log","allow-aws-workspace-status","allow-aws-environment-max-hours","allow-remove-aws-resources","allow-rebuild-project-container","allow-reconcile-project-statuses","allow-reconcile-aws-projects","allow-list-notes","allow-save-note","allow-delete-note","allow-get-container-staleness","allow-migrate-project-to-base","allow-confirm-migration","allow-rollback-migration","allow-get-migration-state","allow-set-auth-bridge-enabled","allow-get-auth-bridge-status","allow-set-browser-view-enabled","allow-get-browser-view-status","allow-check-browser-view-support","allow-install-browser-view-support","allow-install-browser-view-browser","allow-open-browser-view-popout","allow-close-browser-view-popout","allow-get-browser-view-popout-state","allow-set-browser-view-popout-always-on-top","allow-open-page-in-container-browser","allow-set-container-page-viewport","allow-get-container-page-state","allow-close-container-page","allow-set-browser-view-match-window","allow-get-browser-view-match-window","allow-acquire-claude-token","allow-submit-claude-token-code","allow-cancel-claude-token","allow-has-claude-token","allow-clear-claude-token","allow-sweep-claude-token-snapshots","allow-get-settings","allow-update-settings","allow-pull-image","allow-detect-aws-config","allow-inspect-ca-cert-path","allow-list-aws-profiles","allow-add-aws-profile-connection","allow-add-aws-keys-connection","allow-update-aws-connection","allow-remove-host-connection","allow-aws-connection-identity","allow-aws-connection-sso-login","allow-check-aws-permissions","allow-aws-policy-document","allow-aws-cost-estimate","allow-detect-aws-environments","allow-deploy-aws-environment","allow-update-aws-environment","allow-repair-aws-environment","allow-destroy-incomplete-aws-environment","allow-unlock-aws-state","allow-follow-aws-deployment","allow-cancel-aws-deployment","allow-push-aws-saved-state","allow-onboard-aws-user","allow-list-ec2-instance-types","allow-deploy-aws-permissions-boundary","allow-save-aws-admin-bundle","allow-detect-host-timezone","allow-export-settings","allow-preview-settings-import","allow-apply-settings-import","allow-open-terminal-session","allow-terminal-input","allow-terminal-resize","allow-close-terminal-session","allow-paste-image-to-terminal","allow-upload-host-file-to-terminal","allow-start-audio-bridge","allow-send-audio-data","allow-stop-audio-bridge","allow-list-container-files","allow-download-container-backup","allow-download-container-file","allow-upload-files-to-container","allow-read-container-file","allow-rename-container-path","allow-create-container-directory","allow-open-file-viewer","allow-aws-sso-refresh","allow-get-app-version","allow-check-for-updates","allow-check-image-update","allow-get-help-content","allow-open-url-external","allow-detect-install-options","allow-run-docker-install","allow-start-web-terminal","allow-stop-web-terminal","allow-get-web-terminal-status","allow-regenerate-web-terminal-token","allow-get-stt-status","allow-start-stt","allow-stop-stt","allow-build-stt-image","allow-pull-stt-image","allow-transcribe-audio","allow-get-gateway-status","allow-start-gateway","allow-stop-gateway","allow-check-gateway-health","allow-build-gateway-image","allow-pull-gateway-image","allow-set-gateway-api-key","allow-clear-gateway-api-key","allow-get-gateway-auth-token","allow-regenerate-gateway-auth-token","allow-list-claude-sessions","allow-list-container-capabilities","allow-list-scheduled-tasks","allow-add-scheduled-task","allow-update-scheduled-task","allow-get-scheduled-task-log","allow-set-scheduled-task-enabled","allow-run-scheduled-task-now","allow-remove-scheduled-task","allow-get-scheduler-notifications","allow-clear-scheduler-notifications","allow-list-marketplace-snapshots","allow-refresh-marketplaces","allow-add-marketplace","allow-update-marketplace","allow-remove-marketplace","allow-install-marketplace-item","allow-uninstall-marketplace-item","allow-set-global-item-disabled","allow-forget-marketplace-installs","allow-list-marketplace-updates","allow-marketplace-item-diff","allow-update-marketplace-item","allow-apply-marketplace-now","allow-get-marketplace-sync-report","allow-add-marketplace-token-account","allow-add-marketplace-gh-host-account","allow-start-marketplace-gh-container-login","allow-cancel-marketplace-gh-login","allow-test-marketplace-account","allow-remove-marketplace-account","allow-marketplace-gh-host-available"]},"file-viewer":{"identifier":"file-viewer","description":"The terminal file viewer windows (`file-viewer-`, opened by `open_file_viewer` on the app's own `viewer.html`). Same rules as `default.json`, including the layout checks: this file itself must stay a top-level `capabilities/*.json` with no `webviews` or `remote` key, or `build.rs` refuses the build rather than grant something the census cannot see. The five bare `allow-viewer-*` grants are the only app commands a viewer window can invoke: `build.rs` declares the AppManifest that makes tauri enforce that, and refuses any other bare grant in this file. The label gate inside `commands/file_viewer_commands.rs` is still what stops window A acting on window B's registry entry, because the ACL only decides which window may call. The rest of this file is the plugin-command surface a compromised viewer webview could reach, and it is the smallest one that lets the window work. `core:event:allow-listen`/`allow-unlisten` are for `file-viewer-goto` (Rust → this window; the viewer subscribes through `getCurrentWindow().listen`, because a bare `listen()` in *any* window receives an `emit_to`). `core:window:allow-destroy` is not optional: `getCurrentWindow().onCloseRequested` in @tauri-apps/api 2.11 makes Rust `prevent_close()` whenever a JS listener exists and then calls `destroy()` itself, so without this grant the window's X button does nothing once the unsaved-changes guard is installed. `allow-close` is deliberately absent — nothing calls it, and `destroy` is the only exit. No `set-title`/`set-focus`/`unminimize`: those are done from Rust when a second click targets an already-open file. `core:webview:allow-internal-toggle-devtools` is the same dev-only convenience `default.json` carries.","local":true,"windows":["file-viewer-*"],"permissions":["core:event:allow-listen","core:event:allow-unlisten","core:window:allow-destroy","core:webview:allow-internal-toggle-devtools","allow-viewer-get-state","allow-viewer-choose-file","allow-viewer-read-file","allow-viewer-poll-file","allow-viewer-write-file"]}} \ No newline at end of file +{"default":{"identifier":"default","description":"Default capabilities for Triple-C. Every entry here is an IPC command a compromised webview can call directly, so the set is an enumeration of what `app/src` actually invokes — plugin and core grants verified against tauri 2.11.0's `PLUGINS` table in tauri's own `build.rs` rather than assumed from a plugin's `default` set, app-command grants (the bare `allow-*` entries) cross-checked by this crate's `build.rs` against `generate_handler!`. `core:default` in particular is NOT used: it is an alias for `core:{path,event,window,webview,app,image,resources,menu,tray}:default`, and `core:image:default` carries `allow-from-path`, whose handler (`tauri-2.11.0/src/image/plugin.rs:41` → `src/image/mod.rs:96`) is a bare `std::fs::read(path)` with no scope mechanism of any kind. Nothing imports `@tauri-apps/api/image`, so the whole plugin is dropped rather than scoped — there is nothing to scope it with. `core:menu` and `core:tray` are dropped for the same reason (no menu, no tray icon); `core:window` and `core:path` because nothing imports them; `core:resources:allow-close` because no frontend value is a `Resource`; and `core:event`'s `allow-emit`/`allow-emit-to` because the frontend only ever *listens* — every emit in this app originates in Rust. Three notes on what is deliberately kept or accepted: (1) `core:webview:allow-internal-toggle-devtools` is not called by `app/src` at all — it is called by Tauri's own injected `toggle-devtools.js`, which binds Ctrl/Cmd+Shift+I. Both that script and the command behind it are `#[cfg(any(debug_assertions, feature = \"devtools\"))]`, so this grant is a `tauri dev` convenience that does not exist in a release bundle. (2) `opener:allow-open-url` is **gone**. It could not be narrowed by host — `TerminalView`'s `WebLinksAddon` opens links Claude printed inside the container, which are arbitrary by construction, so a host allowlist would have deleted the feature rather than bounded it — and it was carried here as an accepted residual risk: a compromised webview could make the OS open an attacker-chosen http(s) URL, an outbound channel. That risk is now closed rather than recorded. Every host-browser open in the app goes through the `open_url_external` command in `url_open.rs`, which exists because the AppImage environment leaks into a cold-launched browser on Linux (triple-c#34) and which re-validates the URL in Rust — scheme allowlist, no embedded credentials, no control characters, length cap, ASCII asserted before `execvp`. On macOS and Windows that command reaches the same plugin as before, via `OpenerExt::open_url`, whose desktop implementation calls `crate::open::open` directly and is therefore not gated by this file at all (`tauri-plugin-opener-2.5.3/src/lib.rs:60`). The plugin stays a dependency for exactly that reason; what is removed is the webview's ability to reach it without passing the Rust validation. (3) `drag:allow-start-drag` is **gone**, together with the OS drag-out it existed for. It could not be scoped — `tauri-plugin-drag` takes the item paths from the caller and has no scope mechanism, so a compromised webview could call `startDrag({ item: ['~/.ssh/id_rsa'] })` against any host path the user can read — and it was carried as an accepted residual risk for one gesture. Drag-out was held back for separate hardening (see branch `hold/disk-and-dragout`) and the plugin is no longer a dependency. Getting a file *out* of a container is either \"Back up container\" on the project's Overview tab, which archives a tree through the Docker API, or the Files tab's per-row \"Save to host…\", which copies one file; getting one *in* is a drop on the Terminal or the Files tab's \"Upload…\". None of the four touches this permission. The Files tab's two are worth separating out here, because they are the only host-path commands in the app whose dialog is opened by **Rust** rather than by the webview — `pick_save_path` and `pick_files_to_upload` in `commands/file_commands.rs` drive `tauri-plugin-dialog` from the backend, so a compromised webview can ask for a picker and nothing more: it cannot name a host path as an *input* to either command. Be precise about the limit of that claim — host paths do still travel outward in error text (`Failed to create /home/j/Documents/x.txt.triple-c-part-1a2b3c4d: Permission denied`), including canonicalized ones, which disclose symlink targets. That is accepted; the app already hands the webview the project paths. What is closed is the direction that mattered — the webview naming where bytes go. That is the shape an earlier revision of this file named as the honest one if the Files tab ever regained host I/O, and it is the shape it regained it in. The `dialog:allow-open` / `dialog:allow-save` grants below are therefore *not* what those two use; they remain for the frontend pickers in Add Project, the Config tab's workspace and access sections, the CA-certificate field and Backup. Two commands still take a host path over IPC as a string — the terminal drop and `download_container_backup` — and for those `validate_host_path` is the boundary rather than defence in depth. This file is the reviewed threat model of record, so keep this census accurate: a stale reference here is worse than none. Note that dragging files *into* the app is unaffected: `dragDropEnabled` and `onDragDropEvent` are core webview behaviour and need no grant. Historical note kept because it is easy to re-introduce: the `store:*` grants were removed — nothing in `app/src` uses `@tauri-apps/plugin-store`, and the plugin's `resolve_store_path` is a `PathBuf::push` against AppData, which `push` discards outright when handed an absolute path, so the grant was an arbitrary host-file read/write primitive (`plugin:store|load` + `set` + `save` on `~/.claude/settings.json` is host code execution). A second capability file, `file-viewer.json`, covers the `file-viewer-*` windows the terminal file viewer opens on `viewer.html`; it is the only other local-origin window, its grants are listed and justified there, and its one non-obvious grant (`core:window:allow-destroy`) exists because `onCloseRequested` cannot close a window without it. App commands are gated by this file too. `build.rs` declares a Tauri `AppManifest` listing every command in `generate_handler!`, which is what makes tauri 2.11.0 apply the ACL to app commands at all (`webview/mod.rs:1794` skips it when no app manifest exists), and the bare `allow-` entries below are the complete list of app commands the main window may call. `build.rs` refuses to build unless every registered command has exactly one such grant, in the file whose `windows` its name says it belongs to (`viewer_*` in `file-viewer.json`, everything else here), and unless every bare entry names a registered command — so a forgotten, misspelled, duplicated or misfiled grant is a failed `cargo check`, not a feature that dies at runtime with `not allowed by ACL`. `deny-*` is banned by the same check: in tauri 2.11.0 a deny matches regardless of window or origin, so a deny meant for the viewer would deny main too. Hand-written files under `permissions/` are refused for the same reason — they would be grants this census cannot see. Because the census can only vouch for what it reads, `build.rs` also refuses any capability it did not check: anything in `capabilities/` other than a top-level `*.json` file (tauri also loads `.toml`/`.json5` there, and subdirectories), a `webviews` or `remote` key in a capability file (either would extend grants beyond what `windows` says), `app.security.capabilities` declared inline in `tauri.conf.json`, any `tauri..conf.json`, or `TAURI_CONFIG`, and a tauri config in a format the census cannot parse (JSON5, TOML). OS/editor junk (`.DS_Store`, `Thumbs.db`, editor swap files) is recognised and skipped in `capabilities/` and `permissions/` rather than refused, since tauri never loads it either. Each failure names the check that failed (\"stray entry in capabilities/\", \"capabilities declared outside capabilities/\", \"hand-written permission\", …) rather than always reading as a grant/handler mismatch. Known gap: adding a new `tauri..conf.json` to a tree that has already been built once only takes effect on a clean build or in CI — cargo's incremental build has no reason to notice a file that did not exist on the previous build. The `*marketplace*` commands fetch user-configured https git repos on the host and push pinned files into containers; account tokens stay in the OS keychain and never cross IPC outward — the only inbound one is the token pasted into `add_marketplace_token_account`. The pop-out stays capability-less. The Rust label gates in `commands/file_viewer_commands.rs` remain, because the ACL says *which* window may call a command and the label says *whose* registry entry it acts on; they are not redundant. The rules live in `src/command_census.rs`, which is unit-tested, and `src/test/capabilities.test.ts` checks the other direction: that the code that runs in each window imports only the wrappers that window is granted. On the CSP side: `app.security.csp` in `tauri.conf.json` covers the shipped bundle, and there is deliberately no `devCsp`. `npm run tauri dev` loads the main document straight from Vite at `build.devUrl` (`http://localhost:1420`), and Tauri only attaches a CSP to documents it serves itself — `protocol/tauri.rs:217` sets the header on `tauri://` assets, and the dev server is proxied through that protocol only when `PROXY_DEV_SERVER`, which is `cfg!(all(dev, mobile))` and therefore false for every desktop build. A `devCsp` here would be inert config that reads as protection, which is worse than its absence. If a CSP in dev is wanted, the only place that can set one is the Vite dev server's own `server.headers` in `app/vite.config.ts`; it is not set today, and dev is not the shipped configuration.","local":true,"windows":["main"],"permissions":["core:event:allow-listen","core:event:allow-unlisten","core:webview:allow-internal-toggle-devtools","dialog:allow-open","dialog:allow-save","allow-check-docker","allow-check-image-exists","allow-build-image","allow-get-container-info","allow-list-projects","allow-add-project","allow-remove-project","allow-update-project","allow-start-project-container","allow-stop-project-container","allow-check-unsaved-work","allow-aws-task-log","allow-aws-workspace-status","allow-aws-environment-max-hours","allow-aws-ec2-capacity","allow-ec2-fit-problem","allow-remove-aws-resources","allow-rebuild-project-container","allow-reconcile-project-statuses","allow-reconcile-aws-projects","allow-list-notes","allow-save-note","allow-delete-note","allow-get-container-staleness","allow-migrate-project-to-base","allow-confirm-migration","allow-rollback-migration","allow-get-migration-state","allow-set-auth-bridge-enabled","allow-get-auth-bridge-status","allow-set-browser-view-enabled","allow-get-browser-view-status","allow-check-browser-view-support","allow-install-browser-view-support","allow-install-browser-view-browser","allow-open-browser-view-popout","allow-close-browser-view-popout","allow-get-browser-view-popout-state","allow-set-browser-view-popout-always-on-top","allow-open-page-in-container-browser","allow-set-container-page-viewport","allow-get-container-page-state","allow-close-container-page","allow-set-browser-view-match-window","allow-get-browser-view-match-window","allow-acquire-claude-token","allow-submit-claude-token-code","allow-cancel-claude-token","allow-has-claude-token","allow-clear-claude-token","allow-sweep-claude-token-snapshots","allow-get-settings","allow-update-settings","allow-pull-image","allow-detect-aws-config","allow-inspect-ca-cert-path","allow-list-aws-profiles","allow-add-aws-profile-connection","allow-add-aws-keys-connection","allow-update-aws-connection","allow-remove-host-connection","allow-aws-connection-identity","allow-aws-connection-sso-login","allow-check-aws-permissions","allow-aws-policy-document","allow-aws-cost-estimate","allow-detect-aws-environments","allow-deploy-aws-environment","allow-update-aws-environment","allow-repair-aws-environment","allow-destroy-incomplete-aws-environment","allow-unlock-aws-state","allow-follow-aws-deployment","allow-cancel-aws-deployment","allow-push-aws-saved-state","allow-onboard-aws-user","allow-list-ec2-instance-types","allow-deploy-aws-permissions-boundary","allow-save-aws-admin-bundle","allow-detect-host-timezone","allow-export-settings","allow-preview-settings-import","allow-apply-settings-import","allow-open-terminal-session","allow-terminal-input","allow-terminal-resize","allow-close-terminal-session","allow-paste-image-to-terminal","allow-upload-host-file-to-terminal","allow-start-audio-bridge","allow-send-audio-data","allow-stop-audio-bridge","allow-list-container-files","allow-download-container-backup","allow-download-container-file","allow-upload-files-to-container","allow-read-container-file","allow-rename-container-path","allow-create-container-directory","allow-open-file-viewer","allow-aws-sso-refresh","allow-get-app-version","allow-check-for-updates","allow-check-image-update","allow-get-help-content","allow-open-url-external","allow-detect-install-options","allow-run-docker-install","allow-start-web-terminal","allow-stop-web-terminal","allow-get-web-terminal-status","allow-regenerate-web-terminal-token","allow-get-stt-status","allow-start-stt","allow-stop-stt","allow-build-stt-image","allow-pull-stt-image","allow-transcribe-audio","allow-get-gateway-status","allow-start-gateway","allow-stop-gateway","allow-check-gateway-health","allow-build-gateway-image","allow-pull-gateway-image","allow-set-gateway-api-key","allow-clear-gateway-api-key","allow-get-gateway-auth-token","allow-regenerate-gateway-auth-token","allow-list-claude-sessions","allow-list-container-capabilities","allow-list-scheduled-tasks","allow-add-scheduled-task","allow-update-scheduled-task","allow-get-scheduled-task-log","allow-set-scheduled-task-enabled","allow-run-scheduled-task-now","allow-remove-scheduled-task","allow-get-scheduler-notifications","allow-clear-scheduler-notifications","allow-list-marketplace-snapshots","allow-refresh-marketplaces","allow-add-marketplace","allow-update-marketplace","allow-remove-marketplace","allow-install-marketplace-item","allow-uninstall-marketplace-item","allow-set-global-item-disabled","allow-forget-marketplace-installs","allow-list-marketplace-updates","allow-marketplace-item-diff","allow-update-marketplace-item","allow-apply-marketplace-now","allow-get-marketplace-sync-report","allow-add-marketplace-token-account","allow-add-marketplace-gh-host-account","allow-start-marketplace-gh-container-login","allow-cancel-marketplace-gh-login","allow-test-marketplace-account","allow-remove-marketplace-account","allow-marketplace-gh-host-available"]},"file-viewer":{"identifier":"file-viewer","description":"The terminal file viewer windows (`file-viewer-`, opened by `open_file_viewer` on the app's own `viewer.html`). Same rules as `default.json`, including the layout checks: this file itself must stay a top-level `capabilities/*.json` with no `webviews` or `remote` key, or `build.rs` refuses the build rather than grant something the census cannot see. The five bare `allow-viewer-*` grants are the only app commands a viewer window can invoke: `build.rs` declares the AppManifest that makes tauri enforce that, and refuses any other bare grant in this file. The label gate inside `commands/file_viewer_commands.rs` is still what stops window A acting on window B's registry entry, because the ACL only decides which window may call. The rest of this file is the plugin-command surface a compromised viewer webview could reach, and it is the smallest one that lets the window work. `core:event:allow-listen`/`allow-unlisten` are for `file-viewer-goto` (Rust → this window; the viewer subscribes through `getCurrentWindow().listen`, because a bare `listen()` in *any* window receives an `emit_to`). `core:window:allow-destroy` is not optional: `getCurrentWindow().onCloseRequested` in @tauri-apps/api 2.11 makes Rust `prevent_close()` whenever a JS listener exists and then calls `destroy()` itself, so without this grant the window's X button does nothing once the unsaved-changes guard is installed. `allow-close` is deliberately absent — nothing calls it, and `destroy` is the only exit. No `set-title`/`set-focus`/`unminimize`: those are done from Rust when a second click targets an already-open file. `core:webview:allow-internal-toggle-devtools` is the same dev-only convenience `default.json` carries.","local":true,"windows":["file-viewer-*"],"permissions":["core:event:allow-listen","core:event:allow-unlisten","core:window:allow-destroy","core:webview:allow-internal-toggle-devtools","allow-viewer-get-state","allow-viewer-choose-file","allow-viewer-read-file","allow-viewer-poll-file","allow-viewer-write-file"]}} \ No newline at end of file diff --git a/app/src-tauri/gen/schemas/desktop-schema.json b/app/src-tauri/gen/schemas/desktop-schema.json index 5bf0149..303c678 100644 --- a/app/src-tauri/gen/schemas/desktop-schema.json +++ b/app/src-tauri/gen/schemas/desktop-schema.json @@ -422,6 +422,12 @@ "const": "allow-aws-cost-estimate", "markdownDescription": "Enables the aws_cost_estimate command without any pre-configured scope." }, + { + "description": "Enables the aws_ec2_capacity command without any pre-configured scope.", + "type": "string", + "const": "allow-aws-ec2-capacity", + "markdownDescription": "Enables the aws_ec2_capacity command without any pre-configured scope." + }, { "description": "Enables the aws_environment_max_hours command without any pre-configured scope.", "type": "string", @@ -644,6 +650,12 @@ "const": "allow-download-container-file", "markdownDescription": "Enables the download_container_file command without any pre-configured scope." }, + { + "description": "Enables the ec2_fit_problem command without any pre-configured scope.", + "type": "string", + "const": "allow-ec2-fit-problem", + "markdownDescription": "Enables the ec2_fit_problem command without any pre-configured scope." + }, { "description": "Enables the export_settings command without any pre-configured scope.", "type": "string", @@ -1400,6 +1412,12 @@ "const": "deny-aws-cost-estimate", "markdownDescription": "Denies the aws_cost_estimate command without any pre-configured scope." }, + { + "description": "Denies the aws_ec2_capacity command without any pre-configured scope.", + "type": "string", + "const": "deny-aws-ec2-capacity", + "markdownDescription": "Denies the aws_ec2_capacity command without any pre-configured scope." + }, { "description": "Denies the aws_environment_max_hours command without any pre-configured scope.", "type": "string", @@ -1622,6 +1640,12 @@ "const": "deny-download-container-file", "markdownDescription": "Denies the download_container_file command without any pre-configured scope." }, + { + "description": "Denies the ec2_fit_problem command without any pre-configured scope.", + "type": "string", + "const": "deny-ec2-fit-problem", + "markdownDescription": "Denies the ec2_fit_problem command without any pre-configured scope." + }, { "description": "Denies the export_settings command without any pre-configured scope.", "type": "string", diff --git a/app/src-tauri/gen/schemas/linux-schema.json b/app/src-tauri/gen/schemas/linux-schema.json index 5bf0149..303c678 100644 --- a/app/src-tauri/gen/schemas/linux-schema.json +++ b/app/src-tauri/gen/schemas/linux-schema.json @@ -422,6 +422,12 @@ "const": "allow-aws-cost-estimate", "markdownDescription": "Enables the aws_cost_estimate command without any pre-configured scope." }, + { + "description": "Enables the aws_ec2_capacity command without any pre-configured scope.", + "type": "string", + "const": "allow-aws-ec2-capacity", + "markdownDescription": "Enables the aws_ec2_capacity command without any pre-configured scope." + }, { "description": "Enables the aws_environment_max_hours command without any pre-configured scope.", "type": "string", @@ -644,6 +650,12 @@ "const": "allow-download-container-file", "markdownDescription": "Enables the download_container_file command without any pre-configured scope." }, + { + "description": "Enables the ec2_fit_problem command without any pre-configured scope.", + "type": "string", + "const": "allow-ec2-fit-problem", + "markdownDescription": "Enables the ec2_fit_problem command without any pre-configured scope." + }, { "description": "Enables the export_settings command without any pre-configured scope.", "type": "string", @@ -1400,6 +1412,12 @@ "const": "deny-aws-cost-estimate", "markdownDescription": "Denies the aws_cost_estimate command without any pre-configured scope." }, + { + "description": "Denies the aws_ec2_capacity command without any pre-configured scope.", + "type": "string", + "const": "deny-aws-ec2-capacity", + "markdownDescription": "Denies the aws_ec2_capacity command without any pre-configured scope." + }, { "description": "Denies the aws_environment_max_hours command without any pre-configured scope.", "type": "string", @@ -1622,6 +1640,12 @@ "const": "deny-download-container-file", "markdownDescription": "Denies the download_container_file command without any pre-configured scope." }, + { + "description": "Denies the ec2_fit_problem command without any pre-configured scope.", + "type": "string", + "const": "deny-ec2-fit-problem", + "markdownDescription": "Denies the ec2_fit_problem command without any pre-configured scope." + }, { "description": "Denies the export_settings command without any pre-configured scope.", "type": "string", diff --git a/app/src-tauri/src/aws/live_tests.rs b/app/src-tauri/src/aws/live_tests.rs index 41d2ad9..4623f19 100644 --- a/app/src-tauri/src/aws/live_tests.rs +++ b/app/src-tauri/src/aws/live_tests.rs @@ -642,6 +642,12 @@ async fn a_workspace_role_reads_fargate_prices_and_a_bare_role_cannot() { eprintln!("{}: x86 {x86:?}, ARM {arm:?}", e.region); assert!(x86.vcpu_hour > 0.0 && x86.gb_hour > 0.0 && x86.storage_gb_hour > 0.0); assert!(arm.vcpu_hour < x86.vcpu_hour, "ARM is cheaper per vCPU"); + // E10: an EC2 instance type's on-demand price, with the same rights. + let m7i = super::pricing::fetch_ec2_price(&SdkPricingApi::new(&cfg), &e.region, "m7i.large") + .await + .expect("workspace role reads EC2 prices"); + eprintln!("{}: m7i.large {m7i}/hour", e.region); + assert!(m7i > 0.0 && m7i < 1.0, "{m7i}"); let bare = e.role("noprice", None, &[]).await; let cfg = sdk_config_for_keys(&e.assume_keys(&bare).await, PRICING_REGION); diff --git a/app/src-tauri/src/aws/pricing.rs b/app/src-tauri/src/aws/pricing.rs index 60de75d..ca4bc15 100644 --- a/app/src-tauri/src/aws/pricing.rs +++ b/app/src-tauri/src/aws/pricing.rs @@ -1,6 +1,9 @@ //! The estimated hourly cost of a Fargate workspace (Q5): on-demand rates //! from the Price List API (`pricing:GetProducts`, service `AmazonECS`, -//! served from us-east-1 only), cached on disk per region for a day. +//! served from us-east-1 only), cached on disk per region for a day. An EC2 +//! workspace (phase 7 E10) is priced as its instance: the `AmazonEC2` +//! on-demand Linux, shared-tenancy price of the user's instance type, cached +//! per region and type the same way. //! //! Everything here is best effort. A denied call, no network, a slow answer //! or a price list we can't read all end in "no estimate" (`None`), never an @@ -13,6 +16,7 @@ use std::path::{Path, PathBuf}; use std::sync::Mutex; use std::time::{Duration, SystemTime, UNIX_EPOCH}; +use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -22,6 +26,8 @@ use crate::models::project::{Arch, AwsWorkspaceConfig, StorageMode}; /// eu-central-1; any of them serves every region's prices). pub const PRICING_REGION: &str = "us-east-1"; pub const SERVICE_CODE: &str = "AmazonECS"; +/// EC2 instances' prices (phase 7 E10). +pub const EC2_SERVICE_CODE: &str = "AmazonEC2"; /// How long a region's rates are used before they are fetched again. pub const CACHE_TTL: Duration = Duration::from_secs(24 * 60 * 60); /// The whole fetch (every page), so the command answers quickly offline. @@ -45,6 +51,55 @@ pub const FILTERS: &[(&str, &str, &str)] = &[ ("CONTAINS", "usagetype", "Fargate"), ]; +/// `GetProducts` filters for one EC2 instance type's on-demand Linux price +/// (`{region}`, `{instance_type}` filled in). Verified against the live API +/// (2026-11-16): exactly one row per type and region (`USW2-BoxUsage:m7i.large`, +/// $0.1008/hour), carrying both its OnDemand and Reserved terms. +pub const EC2_FILTERS: &[(&str, &str, &str)] = &[ + ("TERM_MATCH", "regionCode", "{region}"), + ("TERM_MATCH", "instanceType", "{instance_type}"), + ("TERM_MATCH", "operatingSystem", "Linux"), + ("TERM_MATCH", "tenancy", "Shared"), + ("TERM_MATCH", "preInstalledSw", "NA"), + ("TERM_MATCH", "capacitystatus", "Used"), + ("TERM_MATCH", "licenseModel", "No License required"), +]; + +/// One `GetProducts` query: a service and its filters, values filled in. +#[derive(Debug, Clone, PartialEq)] +pub struct Query { + pub service_code: &'static str, + pub filters: Vec<(&'static str, &'static str, String)>, +} + +fn fill(filters: &[(&'static str, &'static str, &str)], vars: &[(&str, &str)]) -> Vec<(&'static str, &'static str, String)> { + filters + .iter() + .map(|(kind, field, value)| { + let value = vars + .iter() + .fold(value.to_string(), |v, (name, with)| v.replace(&format!("{{{name}}}"), with)); + (*kind, *field, value) + }) + .collect() +} + +/// The Fargate rates of `region` ([`FILTERS`]). +pub fn fargate_query(region: &str) -> Query { + Query { + service_code: SERVICE_CODE, + filters: fill(FILTERS, &[("region", region)]), + } +} + +/// The on-demand price of `instance_type` in `region` ([`EC2_FILTERS`]). +pub fn ec2_query(region: &str, instance_type: &str) -> Query { + Query { + service_code: EC2_SERVICE_CODE, + filters: fill(EC2_FILTERS, &[("region", region), ("instance_type", instance_type)]), + } +} + /// One architecture's on-demand rates in a region, in USD. #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub struct FargateRates { @@ -74,12 +129,15 @@ impl RegionRates { /// runs. A gateway sidecar shares the task's CPU and memory, so it adds /// nothing; Spot isn't in the Price List API (`note_spot`: say it is /// usually cheaper); EFS is billed per GB-month, not per hour -/// (`efs_billed_separately`). +/// (`efs_billed_separately`). `ec2_instance`: the figure is the user's EC2 +/// instance's hourly price, whatever the project reserves of it, and +/// instances scale to zero when no workspace is running (E10). #[derive(Debug, Clone, Copy, PartialEq, Serialize)] pub struct HourlyEstimate { pub usd_per_hour: f64, pub note_spot: bool, pub efs_billed_separately: bool, + pub ec2_instance: bool, } pub fn estimate(cfg: &AwsWorkspaceConfig, rates: &FargateRates) -> HourlyEstimate { @@ -92,9 +150,54 @@ pub fn estimate(cfg: &AwsWorkspaceConfig, rates: &FargateRates) -> HourlyEstimat + billed_storage * rates.storage_gb_hour, note_spot: cfg.spot, efs_billed_separately: cfg.storage != StorageMode::Ephemeral, + ec2_instance: false, } } +/// An EC2 project's estimate: its instance's on-demand hourly price — the +/// instance is billed whole while it runs, so the reservations, the +/// ephemeral size and Spot (none on EC2) change nothing. +pub fn estimate_ec2(cfg: &AwsWorkspaceConfig, instance_usd_per_hour: f64) -> HourlyEstimate { + HourlyEstimate { + usd_per_hour: instance_usd_per_hour, + note_spot: false, + efs_billed_separately: cfg.storage != StorageMode::Ephemeral, + ec2_instance: true, + } +} + +/// The on-demand hourly price of `instance_type` (Linux, shared tenancy) in +/// an `AmazonEC2` price list for `region`. The filters already narrow it to +/// one row; the attributes are checked again so a looser answer can't price +/// the wrong product. `None` when no row matches. +pub fn parse_ec2_price(region: &str, instance_type: &str, items: &[String]) -> Option { + items.iter().find_map(|item| { + let product = serde_json::from_str::(item).ok()?; + let attrs = &product["product"]["attributes"]; + let is = |k: &str, v: &str| attrs[k].as_str() == Some(v); + let matches = is("regionCode", region) + && is("instanceType", instance_type) + && is("operatingSystem", "Linux") + && is("tenancy", "Shared") + && is("preInstalledSw", "NA") + && is("capacitystatus", "Used") + && is("licenseModel", "No License required"); + if !matches { + return None; + } + on_demand_usd(&product).filter(|p| *p > 0.0) + }) +} + +/// Whether `instance_type` is safe in a cache file name and a filter value +/// (`m7i.large`): lowercase letters, digits, one dot. +fn plain_instance_type(instance_type: &str) -> bool { + instance_type.split_once('.').is_some_and(|(family, size)| { + let ok = |s: &str| !s.is_empty() && s.bytes().all(|b| b.is_ascii_lowercase() || b.is_ascii_digit()); + ok(family) && ok(size) + }) && instance_type.len() <= 32 +} + /// The rates in a `GetProducts` price list (each item one product's JSON) /// for `region`. `None` when no architecture is complete. pub fn parse_price_list(region: &str, items: &[String]) -> Option { @@ -174,10 +277,10 @@ pub struct Page { /// The Price List API, faked in tests. pub trait PricingApi { - /// One page of `AmazonECS` products matching [`FILTERS`] for `region`. + /// One page of the products `query` matches. fn get_products( &self, - region: &str, + query: &Query, next_token: Option, ) -> impl Future> + Send; } @@ -197,20 +300,20 @@ impl SdkPricingApi { } impl PricingApi for SdkPricingApi { - async fn get_products(&self, region: &str, next_token: Option) -> Result { + async fn get_products(&self, query: &Query, next_token: Option) -> Result { use aws_sdk_pricing::types::{Filter, FilterType}; let mut req = self .client .get_products() - .service_code(SERVICE_CODE) + .service_code(query.service_code) .format_version("aws_v1") .max_results(100) .set_next_token(next_token); - for (kind, field, value) in FILTERS { + for (kind, field, value) in &query.filters { let filter = Filter::builder() .r#type(FilterType::from(*kind)) .field(*field) - .value(value.replace("{region}", region)) + .value(value) .build() .map_err(|e| e.to_string())?; req = req.filters(filter); @@ -226,31 +329,73 @@ impl PricingApi for SdkPricingApi { } } -/// Every page for `region`, parsed. -pub async fn fetch_rates(api: &A, region: &str) -> Result { +/// Every page `query` matches. +async fn fetch_items(api: &A, query: &Query) -> Result, String> { let mut items = Vec::new(); let mut token = None; for _ in 0..MAX_PAGES { - let page = api.get_products(region, token).await?; + let page = api.get_products(query, token).await?; items.extend(page.items); token = page.next_token.filter(|t| !t.is_empty()); if token.is_none() { - return parse_price_list(region, &items) - .ok_or_else(|| format!("no Fargate rates for {region} in the price list")); + return Ok(items); } } - Err(format!( - "the {region} price list has more than {MAX_PAGES} pages" - )) + Err(format!("the {} price list has more than {MAX_PAGES} pages", query.service_code)) } -/// `

/.json`. +/// Every page for `region`, parsed (the live tests' direct call). +#[cfg_attr(not(test), allow(dead_code))] +pub async fn fetch_rates(api: &A, region: &str) -> Result { + let items = fetch_items(api, &fargate_query(region)).await?; + parse_price_list(region, &items).ok_or_else(|| format!("no Fargate rates for {region} in the price list")) +} + +/// The on-demand hourly price of `instance_type` in `region` (the live +/// tests' direct call). +#[cfg_attr(not(test), allow(dead_code))] +pub async fn fetch_ec2_price(api: &A, region: &str, instance_type: &str) -> Result { + if !plain_instance_type(instance_type) { + return Err(format!("{instance_type:?} is not an instance type")); + } + let items = fetch_items(api, &ec2_query(region, instance_type)).await?; + parse_ec2_price(region, instance_type, &items) + .ok_or_else(|| format!("no {instance_type} price for {region} in the price list")) +} + +/// One cached answer: Fargate rates under `.json`, an instance's +/// price under `--ec2-.json`. `key` is what the file must say +/// it holds (the region, or ` `), and what failures are +/// remembered under. +struct CacheKey { + key: String, + file: String, +} + +impl CacheKey { + fn fargate(region: &str) -> Self { + Self { + key: region.to_string(), + file: format!("{region}.json"), + } + } + fn ec2(region: &str, instance_type: &str) -> Self { + Self { + key: format!("{region} {instance_type}"), + file: format!("{region}--ec2-{instance_type}.json"), + } + } +} + +/// A cache file. `key` was `region` before EC2 prices were cached too (an +/// older file still reads). #[derive(Debug, Serialize, Deserialize)] -struct CacheFile { - region: String, +struct CacheFile { + #[serde(alias = "region")] + key: String, /// Unix seconds. fetched_at: u64, - rates: RegionRates, + rates: V, } /// The per-region rate files and the memory of recent failures. @@ -281,18 +426,38 @@ impl RatesCache { &self.dir } - /// The region must already be validated (it names a file). - fn path(&self, region: &str) -> PathBuf { - self.dir.join(format!("{region}.json")) - } - /// The cached rates and whether they are still fresh at `now`. A /// missing, unreadable or corrupt file, or one for another region, is - /// no cache. + /// no cache. The region must already be validated (it names a file). pub fn read(&self, region: &str, now: SystemTime) -> Option<(RegionRates, bool)> { - let text = std::fs::read_to_string(self.path(region)).ok()?; - let file: CacheFile = serde_json::from_str(&text).ok()?; - if file.region != region { + self.read_key(&CacheKey::fargate(region), now) + } + + #[cfg(test)] + pub fn write(&self, region: &str, rates: &RegionRates, now: SystemTime) -> Result<(), String> { + self.write_key(&CacheKey::fargate(region), rates, now) + } + + /// [`Self::read`] for an instance type's hourly price. + pub fn read_ec2(&self, region: &str, instance_type: &str, now: SystemTime) -> Option<(f64, bool)> { + if !plain_instance_type(instance_type) { + return None; + } + self.read_key(&CacheKey::ec2(region, instance_type), now) + } + + #[cfg(test)] + pub fn write_ec2(&self, region: &str, instance_type: &str, usd_per_hour: f64, now: SystemTime) -> Result<(), String> { + if !plain_instance_type(instance_type) { + return Err(format!("{instance_type:?} is not an instance type")); + } + self.write_key(&CacheKey::ec2(region, instance_type), &usd_per_hour, now) + } + + fn read_key(&self, key: &CacheKey, now: SystemTime) -> Option<(V, bool)> { + let text = std::fs::read_to_string(self.dir.join(&key.file)).ok()?; + let file: CacheFile = serde_json::from_str(&text).ok()?; + if file.key != key.key { return None; } let now = unix_secs(now); @@ -301,20 +466,20 @@ impl RatesCache { Some((file.rates, fresh)) } - pub fn write(&self, region: &str, rates: &RegionRates, now: SystemTime) -> Result<(), String> { + fn write_key(&self, key: &CacheKey, rates: &V, now: SystemTime) -> Result<(), String> { std::fs::create_dir_all(&self.dir).map_err(|e| e.to_string())?; let file = CacheFile { - region: region.to_string(), + key: key.key.clone(), fetched_at: unix_secs(now), - rates: *rates, + rates, }; let text = serde_json::to_string_pretty(&file).map_err(|e| e.to_string())?; // Write then rename, so a concurrent reader never sees half a file. let tmp = self .dir - .join(format!(".{region}.json.tmp-{}", std::process::id())); + .join(format!(".{}.tmp-{}", key.file, std::process::id())); std::fs::write(&tmp, text).map_err(|e| e.to_string())?; - std::fs::rename(&tmp, self.path(region)).map_err(|e| { + std::fs::rename(&tmp, self.dir.join(&key.file)).map_err(|e| { let _ = std::fs::remove_file(&tmp); e.to_string() }) @@ -360,17 +525,59 @@ impl RatesCache { region: &str, now: SystemTime, ) -> Option { - let cached = self.read(region, now); - if let Some((rates, true)) = cached { - return Some(rates); + let parse = |items: &[String]| { + parse_price_list(region, items).ok_or_else(|| format!("no Fargate rates for {region} in the price list")) + }; + self.cached::(&CacheKey::fargate(region), api, fargate_query(region), parse, now) + .await + } + + /// [`Self::rates_with`] for `instance_type`'s on-demand hourly price in + /// `region` (E10): the same cache rules, failure back-off and timeout. + pub async fn ec2_price_with>( + &self, + api: impl Future>, + region: &str, + instance_type: &str, + now: SystemTime, + ) -> Option { + if !plain_instance_type(instance_type) { + return None; } - let stale = cached.map(|(rates, _)| rates); - if self.recently_failed(region, now) { + let parse = |items: &[String]| { + parse_ec2_price(region, instance_type, items) + .ok_or_else(|| format!("no {instance_type} price for {region} in the price list")) + }; + let query = ec2_query(region, instance_type); + self.cached::(&CacheKey::ec2(region, instance_type), api, query, parse, now) + .await + } + + /// Fresh cache, else a fetch of `query` (client build included, within + /// [`FETCH_TIMEOUT`]) parsed by `parse` that refreshes the cache, else + /// the stale cache, else `None`; a key whose fetch failed is not asked + /// again for [`RETRY_AFTER_FAILURE`]. + async fn cached, V: Serialize + DeserializeOwned + Clone>( + &self, + key: &CacheKey, + api: impl Future>, + query: Query, + parse: impl FnOnce(&[String]) -> Result, + now: SystemTime, + ) -> Option { + let cached = self.read_key::(key, now); + let stale = match cached { + Some((rates, true)) => return Some(rates), + Some((rates, false)) => Some(rates), + None => None, + }; + let what = &key.key; + if self.recently_failed(what, now) { return stale; } let fetch = async { let api = api.await?; - Some(fetch_rates(api.borrow(), region).await) + Some(fetch_items(api.borrow(), &query).await.and_then(|items| parse(&items))) }; let fetched = match tokio::time::timeout(FETCH_TIMEOUT, fetch).await { Ok(Some(r)) => r, @@ -378,23 +585,23 @@ impl RatesCache { // one reads credentials, which can be slow), and the stale cache // answers. Ok(None) => { - log::info!("No Fargate rates for {region}: no Pricing client could be built"); - self.note_failure(region, now, true); + log::info!("No prices for {what}: no Pricing client could be built"); + self.note_failure(what, now, true); return stale; } Err(_) => Err(format!("timed out after {}s", FETCH_TIMEOUT.as_secs())), }; match fetched { Ok(rates) => { - self.note_failure(region, now, false); - if let Err(e) = self.write(region, &rates, now) { - log::warn!("Could not cache the {region} Fargate rates: {e}"); + self.note_failure(what, now, false); + if let Err(e) = self.write_key(key, &rates, now) { + log::warn!("Could not cache the prices for {what}: {e}"); } Some(rates) } Err(e) => { - log::info!("No Fargate rates for {region}: {e}"); - self.note_failure(region, now, true); + log::info!("No prices for {what}: {e}"); + self.note_failure(what, now, true); stale } } diff --git a/app/src-tauri/src/aws/pricing/fixtures/ec2-get-products-us-west-2.json b/app/src-tauri/src/aws/pricing/fixtures/ec2-get-products-us-west-2.json new file mode 100644 index 0000000..cd02308 --- /dev/null +++ b/app/src-tauri/src/aws/pricing/fixtures/ec2-get-products-us-west-2.json @@ -0,0 +1,7 @@ +{ + "FormatVersion": "aws_v1", + "PriceList": [ + "{\"product\":{\"productFamily\":\"Compute Instance\",\"attributes\":{\"enhancedNetworkingSupported\":\"Yes\",\"intelTurboAvailable\":\"Yes\",\"memory\":\"8 GiB\",\"dedicatedEbsThroughput\":\"Up to 10000 Mbps\",\"vcpu\":\"2\",\"classicnetworkingsupport\":\"false\",\"capacitystatus\":\"Used\",\"locationType\":\"AWS Region\",\"storage\":\"EBS only\",\"instanceFamily\":\"General purpose\",\"operatingSystem\":\"Linux\",\"intelAvx2Available\":\"Yes\",\"instanceFamilyCategory\":\"General Purpose\",\"regionCode\":\"us-west-2\",\"physicalProcessor\":\"Intel Xeon Scalable (Sapphire Rapids)\",\"clockSpeed\":\"3.2 GHz\",\"ecu\":\"NA\",\"networkPerformance\":\"Up to 12500 Megabit\",\"servicename\":\"Amazon Elastic Compute Cloud\",\"gpuMemory\":\"NA\",\"dedicatedEbsThroughputDescription\":\"650 Mbps\",\"vpcnetworkingsupport\":\"true\",\"instanceType\":\"m7i.large\",\"tenancy\":\"Shared\",\"usagetype\":\"USW2-BoxUsage:m7i.large\",\"normalizationSizeFactor\":\"4\",\"intelAvxAvailable\":\"Yes\",\"processorFeatures\":\"Intel AVX; Intel AVX2; Intel AVX512; Intel Turbo; Intel AMX\",\"servicecode\":\"AmazonEC2\",\"licenseModel\":\"No License required\",\"currentGeneration\":\"Yes\",\"preInstalledSw\":\"NA\",\"location\":\"US West (Oregon)\",\"processorArchitecture\":\"64-bit\",\"marketoption\":\"OnDemand\",\"operation\":\"RunInstances\",\"availabilityzone\":\"NA\"},\"sku\":\"76SYQ5S6SHTVH6CA\"},\"serviceCode\":\"AmazonEC2\",\"terms\":{\"OnDemand\":{\"76SYQ5S6SHTVH6CA.JRTCKXETXF\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.JRTCKXETXF.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"$0.1008 per On Demand Linux m7i.large Instance Hour\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.JRTCKXETXF.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.1008000000\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-01T00:00:00Z\",\"offerTermCode\":\"JRTCKXETXF\",\"termAttributes\":{}}},\"Reserved\":{\"76SYQ5S6SHTVH6CA.VJWZNREJX2\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.VJWZNREJX2.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"USD 0.0 per Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.VJWZNREJX2.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0000000000\"}},\"76SYQ5S6SHTVH6CA.VJWZNREJX2.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.VJWZNREJX2.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"605\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:11Z\",\"offerTermCode\":\"VJWZNREJX2\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"All Upfront\"}},\"76SYQ5S6SHTVH6CA.BPH4J8HBKS\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.BPH4J8HBKS.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.BPH4J8HBKS.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0457200000\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"BPH4J8HBKS\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"No Upfront\"}},\"76SYQ5S6SHTVH6CA.NQ3QZPMQV9\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.NQ3QZPMQV9.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"USD 0.0 per Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.NQ3QZPMQV9.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0000000000\"}},\"76SYQ5S6SHTVH6CA.NQ3QZPMQV9.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.NQ3QZPMQV9.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"1046\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:12Z\",\"offerTermCode\":\"NQ3QZPMQV9\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"All Upfront\"}},\"76SYQ5S6SHTVH6CA.HU7G6KETJZ\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.HU7G6KETJZ.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.HU7G6KETJZ.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0317500000\"}},\"76SYQ5S6SHTVH6CA.HU7G6KETJZ.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.HU7G6KETJZ.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"278\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:08Z\",\"offerTermCode\":\"HU7G6KETJZ\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"Partial Upfront\"}},\"76SYQ5S6SHTVH6CA.38NPMPTW36\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.38NPMPTW36.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.38NPMPTW36.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0211700000\"}},\"76SYQ5S6SHTVH6CA.38NPMPTW36.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.38NPMPTW36.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"556\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:10Z\",\"offerTermCode\":\"38NPMPTW36\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"Partial Upfront\"}},\"76SYQ5S6SHTVH6CA.R5XV2EPZQZ\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.R5XV2EPZQZ.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.R5XV2EPZQZ.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0236700000\"}},\"76SYQ5S6SHTVH6CA.R5XV2EPZQZ.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.R5XV2EPZQZ.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"622\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:11Z\",\"offerTermCode\":\"R5XV2EPZQZ\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"Partial Upfront\"}},\"76SYQ5S6SHTVH6CA.6QCMYABX3D\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.6QCMYABX3D.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"USD 0.0 per Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.6QCMYABX3D.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0000000000\"}},\"76SYQ5S6SHTVH6CA.6QCMYABX3D.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.6QCMYABX3D.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"545\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"6QCMYABX3D\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"All Upfront\"}},\"76SYQ5S6SHTVH6CA.Z2E3P23VKM\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.Z2E3P23VKM.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.Z2E3P23VKM.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0511200000\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"Z2E3P23VKM\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"No Upfront\"}},\"76SYQ5S6SHTVH6CA.7NE97W5U4E\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.7NE97W5U4E.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.7NE97W5U4E.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0740600000\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"7NE97W5U4E\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"No Upfront\"}},\"76SYQ5S6SHTVH6CA.4NA7Y494T4\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.4NA7Y494T4.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.4NA7Y494T4.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0666800000\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"4NA7Y494T4\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"No Upfront\"}},\"76SYQ5S6SHTVH6CA.MZU6U2429S\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.MZU6U2429S.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.MZU6U2429S.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"1219\"}},\"76SYQ5S6SHTVH6CA.MZU6U2429S.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"USD 0.0 per Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.MZU6U2429S.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0000000000\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"MZU6U2429S\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"All Upfront\"}},\"76SYQ5S6SHTVH6CA.CUZHX8X6JH\":{\"priceDimensions\":{\"76SYQ5S6SHTVH6CA.CUZHX8X6JH.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7i.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.CUZHX8X6JH.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0352600000\"}},\"76SYQ5S6SHTVH6CA.CUZHX8X6JH.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"76SYQ5S6SHTVH6CA.CUZHX8X6JH.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"309\"}}},\"sku\":\"76SYQ5S6SHTVH6CA\",\"effectiveDate\":\"2026-11-14T01:50:10Z\",\"offerTermCode\":\"CUZHX8X6JH\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"Partial Upfront\"}}}},\"version\":\"20261114012926\",\"publicationDate\":\"2026-11-14T01:29:26Z\"}", + "{\"product\":{\"productFamily\":\"Compute Instance\",\"attributes\":{\"enhancedNetworkingSupported\":\"Yes\",\"intelTurboAvailable\":\"No\",\"memory\":\"8 GiB\",\"dedicatedEbsThroughput\":\"Up to 10000 Mbps\",\"vcpu\":\"2\",\"classicnetworkingsupport\":\"false\",\"capacitystatus\":\"Used\",\"locationType\":\"AWS Region\",\"storage\":\"EBS only\",\"instanceFamily\":\"General purpose\",\"operatingSystem\":\"Linux\",\"intelAvx2Available\":\"No\",\"instanceFamilyCategory\":\"General Purpose\",\"regionCode\":\"us-west-2\",\"physicalProcessor\":\"AWS Graviton3 Processor\",\"clockSpeed\":\"2.5 GHz\",\"ecu\":\"NA\",\"networkPerformance\":\"Up to 12500 Megabit\",\"servicename\":\"Amazon Elastic Compute Cloud\",\"gpuMemory\":\"NA\",\"dedicatedEbsThroughputDescription\":\"630 Mbps\",\"vpcnetworkingsupport\":\"true\",\"instanceType\":\"m7g.large\",\"tenancy\":\"Shared\",\"usagetype\":\"USW2-BoxUsage:m7g.large\",\"normalizationSizeFactor\":\"4\",\"intelAvxAvailable\":\"No\",\"servicecode\":\"AmazonEC2\",\"licenseModel\":\"No License required\",\"currentGeneration\":\"Yes\",\"preInstalledSw\":\"NA\",\"location\":\"US West (Oregon)\",\"processorArchitecture\":\"64-bit\",\"marketoption\":\"OnDemand\",\"operation\":\"RunInstances\",\"availabilityzone\":\"NA\"},\"sku\":\"NWX8JZYSP4RSV4Q2\"},\"serviceCode\":\"AmazonEC2\",\"terms\":{\"OnDemand\":{\"NWX8JZYSP4RSV4Q2.JRTCKXETXF\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.JRTCKXETXF.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"$0.0816 per On Demand Linux m7g.large Instance Hour\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.JRTCKXETXF.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0816000000\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-01T00:00:00Z\",\"offerTermCode\":\"JRTCKXETXF\",\"termAttributes\":{}}},\"Reserved\":{\"NWX8JZYSP4RSV4Q2.HU7G6KETJZ\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.HU7G6KETJZ.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.HU7G6KETJZ.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0257000000\"}},\"NWX8JZYSP4RSV4Q2.HU7G6KETJZ.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.HU7G6KETJZ.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"225\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:10Z\",\"offerTermCode\":\"HU7G6KETJZ\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"Partial Upfront\"}},\"NWX8JZYSP4RSV4Q2.R5XV2EPZQZ\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.R5XV2EPZQZ.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.R5XV2EPZQZ.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"503\"}},\"NWX8JZYSP4RSV4Q2.R5XV2EPZQZ.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.R5XV2EPZQZ.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0192000000\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"R5XV2EPZQZ\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"Partial Upfront\"}},\"NWX8JZYSP4RSV4Q2.38NPMPTW36\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.38NPMPTW36.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.38NPMPTW36.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0171000000\"}},\"NWX8JZYSP4RSV4Q2.38NPMPTW36.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.38NPMPTW36.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"450\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"38NPMPTW36\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"Partial Upfront\"}},\"NWX8JZYSP4RSV4Q2.Z2E3P23VKM\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.Z2E3P23VKM.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.Z2E3P23VKM.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0414000000\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:12Z\",\"offerTermCode\":\"Z2E3P23VKM\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"No Upfront\"}},\"NWX8JZYSP4RSV4Q2.NQ3QZPMQV9\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.NQ3QZPMQV9.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"USD 0.0 per Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.NQ3QZPMQV9.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0000000000\"}},\"NWX8JZYSP4RSV4Q2.NQ3QZPMQV9.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.NQ3QZPMQV9.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"847\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"NQ3QZPMQV9\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"All Upfront\"}},\"NWX8JZYSP4RSV4Q2.6QCMYABX3D\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.6QCMYABX3D.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"USD 0.0 per Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.6QCMYABX3D.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0000000000\"}},\"NWX8JZYSP4RSV4Q2.6QCMYABX3D.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.6QCMYABX3D.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"441\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:12Z\",\"offerTermCode\":\"6QCMYABX3D\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"All Upfront\"}},\"NWX8JZYSP4RSV4Q2.4NA7Y494T4\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.4NA7Y494T4.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.4NA7Y494T4.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0540000000\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:11Z\",\"offerTermCode\":\"4NA7Y494T4\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"No Upfront\"}},\"NWX8JZYSP4RSV4Q2.CUZHX8X6JH\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.CUZHX8X6JH.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.CUZHX8X6JH.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0285000000\"}},\"NWX8JZYSP4RSV4Q2.CUZHX8X6JH.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.CUZHX8X6JH.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"250\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:10Z\",\"offerTermCode\":\"CUZHX8X6JH\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"Partial Upfront\"}},\"NWX8JZYSP4RSV4Q2.7NE97W5U4E\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.7NE97W5U4E.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.7NE97W5U4E.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0599000000\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"7NE97W5U4E\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"No Upfront\"}},\"NWX8JZYSP4RSV4Q2.VJWZNREJX2\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.VJWZNREJX2.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"USD 0.0 per Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.VJWZNREJX2.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0000000000\"}},\"NWX8JZYSP4RSV4Q2.VJWZNREJX2.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.VJWZNREJX2.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"490\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"VJWZNREJX2\",\"termAttributes\":{\"LeaseContractLength\":\"1yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"All Upfront\"}},\"NWX8JZYSP4RSV4Q2.MZU6U2429S\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.MZU6U2429S.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"USD 0.0 per Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.MZU6U2429S.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0000000000\"}},\"NWX8JZYSP4RSV4Q2.MZU6U2429S.2TG2D8R56U\":{\"unit\":\"Quantity\",\"description\":\"Upfront Fee\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.MZU6U2429S.2TG2D8R56U\",\"pricePerUnit\":{\"USD\":\"987\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:08Z\",\"offerTermCode\":\"MZU6U2429S\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"convertible\",\"PurchaseOption\":\"All Upfront\"}},\"NWX8JZYSP4RSV4Q2.BPH4J8HBKS\":{\"priceDimensions\":{\"NWX8JZYSP4RSV4Q2.BPH4J8HBKS.6YS6EN2CT7\":{\"unit\":\"Hrs\",\"endRange\":\"Inf\",\"description\":\"Linux/UNIX (Amazon VPC), m7g.large reserved instance applied\",\"appliesTo\":[],\"rateCode\":\"NWX8JZYSP4RSV4Q2.BPH4J8HBKS.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0370000000\"}}},\"sku\":\"NWX8JZYSP4RSV4Q2\",\"effectiveDate\":\"2026-11-14T01:50:09Z\",\"offerTermCode\":\"BPH4J8HBKS\",\"termAttributes\":{\"LeaseContractLength\":\"3yr\",\"OfferingClass\":\"standard\",\"PurchaseOption\":\"No Upfront\"}}}},\"version\":\"20261114012926\",\"publicationDate\":\"2026-11-14T01:29:26Z\"}" + ] +} \ No newline at end of file diff --git a/app/src-tauri/src/aws/pricing/tests.rs b/app/src-tauri/src/aws/pricing/tests.rs index ad0bc82..30a9fe6 100644 --- a/app/src-tauri/src/aws/pricing/tests.rs +++ b/app/src-tauri/src/aws/pricing/tests.rs @@ -173,6 +173,7 @@ fn the_filters_name_the_region_on_demand_and_fargate() { struct FakeApi { pages: Mutex>>, calls: AtomicUsize, + queries: Mutex>, hang: bool, } @@ -181,6 +182,7 @@ impl FakeApi { Self { pages: Mutex::new(pages), calls: AtomicUsize::new(0), + queries: Mutex::new(Vec::new()), hang: false, } } @@ -205,8 +207,12 @@ impl FakeApi { } impl PricingApi for FakeApi { - async fn get_products(&self, region: &str, _token: Option) -> Result { - assert_eq!(region, "us-west-2"); + async fn get_products(&self, query: &Query, _token: Option) -> Result { + assert!( + query.filters.contains(&("TERM_MATCH", "regionCode", "us-west-2".to_string())), + "{query:?}" + ); + self.queries.lock().unwrap().push(query.clone()); self.calls.fetch_add(1, Ordering::SeqCst); if self.hang { std::future::pending::<()>().await; @@ -416,3 +422,193 @@ async fn no_client_counts_as_a_failure_and_is_not_asked_again_for_a_while() { assert_eq!(c.rates(Some(&api), "us-west-2", at(later)).await, Some(RATES)); assert_eq!(api.calls(), 1); } + +// ---- EC2 (phase 7 E10) ---- + +/// Real `AmazonEC2` `GetProducts` answers for us-west-2 with [`EC2_FILTERS`] +/// (recorded 2026-11-16): one row each for m7i.large and m7g.large. +const EC2_FIXTURE: &str = include_str!("fixtures/ec2-get-products-us-west-2.json"); +const M7I_LARGE: f64 = 0.1008; +const M7G_LARGE: f64 = 0.0816; + +fn ec2_items() -> Vec { + let v: Value = serde_json::from_str(EC2_FIXTURE).unwrap(); + v["PriceList"] + .as_array() + .unwrap() + .iter() + .map(|s| s.as_str().unwrap().to_string()) + .collect() +} + +fn ec2_cfg(cpu: u32, memory_mib: u32, storage: StorageMode) -> AwsWorkspaceConfig { + AwsWorkspaceConfig { + launch_type: crate::models::project::LaunchType::Ec2, + cpu, + memory_mib, + storage, + ..Default::default() + } +} + +#[test] +fn the_recorded_ec2_price_list_gives_each_instance_types_hourly_price() { + let items = ec2_items(); + assert_eq!(parse_ec2_price("us-west-2", "m7i.large", &items), Some(M7I_LARGE)); + assert_eq!(parse_ec2_price("us-west-2", "m7g.large", &items), Some(M7G_LARGE)); + // Not a type in the list, or another region: nothing. + assert_eq!(parse_ec2_price("us-west-2", "c7i.large", &items), None); + assert_eq!(parse_ec2_price("eu-west-1", "m7i.large", &items), None); +} + +#[test] +fn an_ec2_row_for_other_software_tenancy_or_capacity_never_counts() { + let row = ec2_items().into_iter().find(|s| s.contains("m7i.large")).unwrap(); + for (from, to) in [ + ("\"tenancy\":\"Shared\"", "\"tenancy\":\"Dedicated\""), + ("\"preInstalledSw\":\"NA\"", "\"preInstalledSw\":\"SQL Web\""), + ("\"capacitystatus\":\"Used\"", "\"capacitystatus\":\"UnusedCapacityReservation\""), + ("\"operatingSystem\":\"Linux\"", "\"operatingSystem\":\"Windows\""), + ("\"licenseModel\":\"No License required\"", "\"licenseModel\":\"Bring your own license\""), + ] { + assert!(row.contains(from), "{from}"); + let other = row.replace(from, to); + assert_eq!(parse_ec2_price("us-west-2", "m7i.large", &[other]), None, "{to}"); + } + // A zero price (what an unused reservation row says) is not a price. + let zero = row.replace("0.1008000000", "0.0000000000"); + assert_eq!(parse_ec2_price("us-west-2", "m7i.large", &[zero]), None); + assert_eq!(parse_ec2_price("us-west-2", "m7i.large", &["garbage".into()]), None); +} + +#[test] +fn the_ec2_filters_name_linux_shared_tenancy_on_demand_for_the_type() { + assert_eq!(EC2_SERVICE_CODE, "AmazonEC2"); + let q = ec2_query("us-west-2", "m7i.large"); + assert_eq!(q.service_code, "AmazonEC2"); + let f = |field: &'static str, value: &str| ("TERM_MATCH", field, value.to_string()); + assert_eq!( + q.filters, + vec![ + f("regionCode", "us-west-2"), + f("instanceType", "m7i.large"), + f("operatingSystem", "Linux"), + f("tenancy", "Shared"), + f("preInstalledSw", "NA"), + f("capacitystatus", "Used"), + f("licenseModel", "No License required"), + ] + ); + // The Fargate query is unchanged. + let fq = fargate_query("us-west-2"); + assert_eq!(fq.service_code, "AmazonECS"); + assert_eq!( + fq.filters, + vec![ + ("TERM_MATCH", "regionCode", "us-west-2".to_string()), + ("TERM_MATCH", "termType", "OnDemand".to_string()), + ("CONTAINS", "usagetype", "Fargate".to_string()), + ] + ); +} + +#[test] +fn an_ec2_estimate_is_the_instances_price_whatever_the_reservations() { + let small = estimate_ec2(&ec2_cfg(512, 1024, StorageMode::Ephemeral), M7I_LARGE); + let big = estimate_ec2(&ec2_cfg(1920, 7373, StorageMode::Ephemeral), M7I_LARGE); + assert!(close(small.usd_per_hour, 0.1008) && close(big.usd_per_hour, 0.1008)); + assert!(small.ec2_instance && !small.note_spot && !small.efs_billed_separately); + // Ephemeral size and Spot don't apply on EC2; EFS is still billed apart. + let mut c = ec2_cfg(1024, 4096, StorageMode::Hybrid); + c.ephemeral_gib = 200; + c.spot = true; + let e = estimate_ec2(&c, M7G_LARGE); + assert!(close(e.usd_per_hour, 0.0816)); + assert!(e.efs_billed_separately && !e.note_spot && e.ec2_instance); + // Fargate estimates say they are not an instance's. + assert!(!estimate(&cfg(1024, 4096, 21), &X86).ec2_instance); +} + +fn ec2_api() -> FakeApi { + FakeApi::answering(vec![Ok(Page { + items: ec2_items(), + next_token: None, + })]) +} + +#[tokio::test] +async fn an_ec2_price_is_fetched_once_and_cached_per_region_and_type() { + let (_d, c) = cache(); + let api = ec2_api(); + let price = c.ec2_price_with::(async { Some(&api) }, "us-west-2", "m7i.large", at(T0)).await; + assert_eq!(price, Some(M7I_LARGE)); + assert_eq!(api.calls(), 1); + assert_eq!(api.queries.lock().unwrap()[0], ec2_query("us-west-2", "m7i.large")); + assert!(c.dir().join("us-west-2--ec2-m7i.large.json").is_file()); + assert_eq!(c.read_ec2("us-west-2", "m7i.large", at(T0 + DAY - 1)), Some((M7I_LARGE, true))); + assert_eq!(c.read_ec2("us-west-2", "m7i.large", at(T0 + DAY)), Some((M7I_LARGE, false))); + // Fresh: no call. Another type, or the region's Fargate rates, are not it. + let again = c + .ec2_price_with::(async { panic!("no client for a fresh cache") }, "us-west-2", "m7i.large", at(T0 + 60)) + .await; + assert_eq!(again, Some(M7I_LARGE)); + assert_eq!(c.read_ec2("us-west-2", "m7g.large", at(T0)), None); + assert_eq!(c.read("us-west-2", at(T0)), None); + // A file renamed to another type's name is no cache. + std::fs::copy( + c.dir().join("us-west-2--ec2-m7i.large.json"), + c.dir().join("us-west-2--ec2-m7g.large.json"), + ) + .unwrap(); + assert_eq!(c.read_ec2("us-west-2", "m7g.large", at(T0)), None); +} + +#[tokio::test] +async fn an_ec2_price_backs_off_after_a_failure_and_falls_back_to_the_stale_cache() { + let (_d, c) = cache(); + let denied = FakeApi::denied(); + assert_eq!(c.ec2_price_with::(async { Some(&denied) }, "us-west-2", "m7i.large", at(T0)).await, None); + assert_eq!(c.ec2_price_with::(async { Some(&denied) }, "us-west-2", "m7i.large", at(T0 + 60)).await, None); + assert_eq!(denied.calls(), 1, "a recent failure is not retried"); + // The failure is per type: another type is still asked. + let other = FakeApi::denied(); + let _ = c.ec2_price_with::(async { Some(&other) }, "us-west-2", "m7g.large", at(T0 + 60)).await; + assert_eq!(other.calls(), 1); + // A stale price answers when the refresh fails. + c.write_ec2("us-west-2", "c7i.large", 0.0893, at(T0)).unwrap(); + let r = c.ec2_price_with::(async { Some(&denied) }, "us-west-2", "c7i.large", at(T0 + 2 * DAY)).await; + assert_eq!(r, Some(0.0893)); +} + +#[tokio::test(start_paused = true)] +async fn a_hanging_ec2_price_times_out_to_none() { + let (_d, c) = cache(); + let api = FakeApi::hanging(); + let started = tokio::time::Instant::now(); + assert_eq!(c.ec2_price_with::(async { Some(&api) }, "us-west-2", "m7i.large", at(T0)).await, None); + assert_eq!(started.elapsed(), FETCH_TIMEOUT); +} + +#[tokio::test] +async fn an_instance_type_that_could_name_another_file_is_never_used() { + let (_d, c) = cache(); + for bad in ["../x", "m7i.large/..", "M7I.large", "m7i", "", "m7i.large.json", "m7i .large"] { + let r = c + .ec2_price_with::(async { panic!("no client for {bad:?}") }, "us-west-2", bad, at(T0)) + .await; + assert_eq!(r, None, "{bad}"); + assert_eq!(c.read_ec2("us-west-2", bad, at(T0)), None); + assert!(c.write_ec2("us-west-2", bad, 1.0, at(T0)).is_err(), "{bad}"); + assert!(fetch_ec2_price(&ec2_api(), "us-west-2", bad).await.is_err()); + } + assert_eq!(fetch_ec2_price(&ec2_api(), "us-west-2", "m7g.large").await, Ok(M7G_LARGE)); +} + +#[test] +fn a_fargate_cache_file_written_before_ec2_prices_still_reads() { + let (_d, c) = cache(); + std::fs::create_dir_all(c.dir()).unwrap(); + let old = serde_json::json!({ "region": "us-west-2", "fetched_at": T0, "rates": RATES }); + std::fs::write(c.dir().join("us-west-2.json"), old.to_string()).unwrap(); + assert_eq!(c.read("us-west-2", at(T0)), Some((RATES, true))); +} diff --git a/app/src-tauri/src/aws/workspace.rs b/app/src-tauri/src/aws/workspace.rs index d7d5638..594206c 100644 --- a/app/src-tauri/src/aws/workspace.rs +++ b/app/src-tauri/src/aws/workspace.rs @@ -49,7 +49,7 @@ use super::tofu_modules::{ }; use crate::host::ssm::AGENT_PORT; use crate::models::project::{ - fits_instance, validate_aws_workspace, Arch, Fit, LaunchType, RepoSource, + ec2_fit_problem, fits_instance, validate_aws_workspace, Arch, Fit, LaunchType, RepoSource, SecretsDelivery, StorageMode, }; use crate::models::Project; @@ -1019,14 +1019,12 @@ pub fn ec2_plan( let compute = compute.ok_or_else(|| no_ec2_capacity(env))?; match fits_instance(cfg, &compute.instance_type) { Fit::Ok => {} - Fit::TooBig { available_cpu, available_memory_mib } => { + Fit::TooBig { .. } => { + let problem = ec2_fit_problem(cfg, &compute.instance_type).unwrap_or_default(); return Err(format!( - "This project reserves {} CPU units and {} MiB of memory, more than your EC2 \ - instance type {} has for a workspace ({available_cpu} CPU units, \ - {available_memory_mib} MiB). Lower the reservations in the project's Host \ - settings, or ask an admin for a larger instance type.", - cfg.cpu, cfg.memory_mib, compute.instance_type - )) + "{problem} Lower the reservations in the project's Host settings, or ask an \ + admin for a larger instance type." + )); } // The record is validated against the same table, so this is a // newer app's type: let ECS decide. diff --git a/app/src-tauri/src/commands/host_commands.rs b/app/src-tauri/src/commands/host_commands.rs index 66581b7..b1a5172 100644 --- a/app/src-tauri/src/commands/host_commands.rs +++ b/app/src-tauri/src/commands/host_commands.rs @@ -11,6 +11,7 @@ use crate::aws::permissions::{check_permissions, PermissionReport, SdkPermission use crate::aws::policies::{policy_files, Tier}; use crate::aws::pricing::{self, HourlyEstimate, RatesCache, SdkPricingApi}; use crate::aws::{caller_identity, sdk_config, sdk_config_for_keys, AwsError, CallerIdentity}; +use crate::models::project::{ec2_instance_spec, LaunchType}; use crate::models::{ validate_connection_name, validate_profile_name, validate_supported_region, AppSettings, AwsAuth, AwsWorkspaceConfig, HostConnection, HostKind, @@ -322,18 +323,33 @@ fn pricing_cache() -> Option<&'static RatesCache> { /// error:** a bad region, a missing connection, a denied or slow call (8 s /// bound) or an unreadable price list is `None`, shown as "Estimate /// unavailable". Rates are cached a day per region. +/// +/// An EC2 project (E10) is priced as `instance_type` (the user's, from their +/// onboarding record, which the UI already holds): its on-demand hourly +/// price, the same cache and back-off rules. No instance type, or one not in +/// the app's table, is `None`. #[tauri::command] pub async fn aws_cost_estimate( connection_id: String, region: String, config: AwsWorkspaceConfig, + instance_type: Option, state: State<'_, AppState>, ) -> Result, String> { let Some(cache) = pricing_cache() else { return Ok(None); }; let settings = state.settings_store.get(); - Ok(cost_estimate(cache, &connection_id, ®ion, &config, &settings, SystemTime::now()).await) + Ok(cost_estimate( + cache, + &connection_id, + ®ion, + &config, + instance_type.as_deref(), + &settings, + SystemTime::now(), + ) + .await) } async fn cost_estimate( @@ -341,24 +357,35 @@ async fn cost_estimate( connection_id: &str, region: &str, config: &AwsWorkspaceConfig, + instance_type: Option<&str>, settings: &AppSettings, now: SystemTime, ) -> Option { let region = validate_supported_region(region).ok()?; + // Only now touch the connection (a keys connection reads the keychain), + // and inside the fetch's 8 s bound: reading a profile's credentials can + // hang as well (an SSO or process provider). + let api = || async { + let conn = aws_conn(connection_id, settings).ok()?; + let cfg = sdk_config(&conn, pricing::PRICING_REGION).await.ok()?; + Some(SdkPricingApi::new(&cfg)) + }; + if config.launch_type == LaunchType::Ec2 { + let instance_type = instance_type.filter(|t| ec2_instance_spec(t).is_some())?; + let price = match cache.read_ec2(®ion, instance_type, now) { + Some((price, true)) => price, + _ => { + cache + .ec2_price_with::(api(), ®ion, instance_type, now) + .await? + } + }; + return Some(pricing::estimate_ec2(config, price)); + } let rates = match cache.read(®ion, now) { Some((rates, true)) => Some(rates), - _ => { - // Only now touch the connection (a keys connection reads the - // keychain); without one, a stale cache still answers. - // Built inside the fetch's 8 s bound: reading a profile's - // credentials can hang as well (an SSO or process provider). - let api = async { - let conn = aws_conn(connection_id, settings).ok()?; - let cfg = sdk_config(&conn, pricing::PRICING_REGION).await.ok()?; - Some(SdkPricingApi::new(&cfg)) - }; - cache.rates_with::(api, ®ion, now).await - } + // Without a connection, a stale cache still answers. + _ => cache.rates_with::(api(), ®ion, now).await, }?; Some(pricing::estimate(config, &rates.for_arch(config.arch)?)) } @@ -654,7 +681,7 @@ mod tests { spot: true, ..Default::default() }; - let e = cost_estimate(&cache, "gone", "us-west-2", &config, &settings, now) + let e = cost_estimate(&cache, "gone", "us-west-2", &config, None, &settings, now) .await .expect("estimate"); assert!((e.usd_per_hour - (0.04 + 2.0 * 0.004)).abs() < 1e-9); @@ -664,7 +691,7 @@ mod tests { arch: crate::models::Arch::Arm64, ..config.clone() }; - assert_eq!(cost_estimate(&cache, "gone", "us-west-2", &arm, &settings, now).await, None); + assert_eq!(cost_estimate(&cache, "gone", "us-west-2", &arm, None, &settings, now).await, None); } #[tokio::test] @@ -675,11 +702,46 @@ mod tests { let config = AwsWorkspaceConfig::default(); let now = SystemTime::now(); // No cache and no such connection. - assert_eq!(cost_estimate(&cache, "gone", "us-west-2", &config, &settings, now).await, None); + assert_eq!(cost_estimate(&cache, "gone", "us-west-2", &config, None, &settings, now).await, None); // A region that isn't one (it would name the cache file). cache.write("us-west-2", &sample_rates(), now).unwrap(); for bad in ["../us-west-2", "", "us-west-2/x"] { - assert_eq!(cost_estimate(&cache, "gone", bad, &config, &settings, now).await, None); + assert_eq!(cost_estimate(&cache, "gone", bad, &config, None, &settings, now).await, None); } } + + /// E10: an EC2 project is priced as the user's instance type, from the + /// same cache; without a known type there is no estimate. + #[tokio::test] + async fn an_ec2_projects_estimate_is_its_instance_types_price() { + let dir = tempfile::tempdir().unwrap(); + let cache = RatesCache::new(dir.path().to_path_buf()); + let now = SystemTime::now(); + cache.write("us-west-2", &sample_rates(), now).unwrap(); + cache.write_ec2("us-west-2", "m7i.large", 0.1008, now).unwrap(); + let settings = AppSettings::default(); + let config = AwsWorkspaceConfig { + launch_type: LaunchType::Ec2, + cpu: 1024, + memory_mib: 2048, + storage: crate::models::project::StorageMode::Ephemeral, + ..Default::default() + }; + let e = cost_estimate(&cache, "gone", "us-west-2", &config, Some("m7i.large"), &settings, now) + .await + .expect("estimate"); + assert!((e.usd_per_hour - 0.1008).abs() < 1e-9); + assert!(e.ec2_instance && !e.note_spot && !e.efs_billed_separately); + // No instance type, one not in the table, or one with no cached price + // (and no connection to ask): no estimate — never Fargate's. + for t in [None, Some("x9.huge"), Some("m7g.large")] { + assert_eq!(cost_estimate(&cache, "gone", "us-west-2", &config, t, &settings, now).await, None, "{t:?}"); + } + // A Fargate project ignores an instance type. + let fargate = AwsWorkspaceConfig { launch_type: LaunchType::Fargate, ..config.clone() }; + let f = cost_estimate(&cache, "gone", "us-west-2", &fargate, Some("m7i.large"), &settings, now) + .await + .expect("fargate"); + assert!(!f.ec2_instance); + } } diff --git a/app/src-tauri/src/commands/project_commands.rs b/app/src-tauri/src/commands/project_commands.rs index 4b38340..3fad14f 100644 --- a/app/src-tauri/src/commands/project_commands.rs +++ b/app/src-tauri/src/commands/project_commands.rs @@ -1659,6 +1659,29 @@ pub async fn aws_environment_max_hours( Ok(crate::host::aws_host::environment_max_hours(&project, &settings).await) } +/// The caller's EC2 capacity in an AWS project's environment, for Host +/// settings' launch-type control and reservation limits (phase 7). Never an +/// error: a local project or a failed read is `unknown`. +#[tauri::command] +pub async fn aws_ec2_capacity( + project_id: String, + state: State<'_, AppState>, +) -> Result { + let Some(project) = state.projects_store.get(&project_id).filter(|p| p.is_aws()) else { + return Ok(crate::host::aws_host::Ec2Capacity::Unknown); + }; + let settings = state.settings_store.get(); + Ok(crate::host::aws_host::ec2_capacity(&project, &settings).await) +} + +/// Why `config`'s CPU/memory reservations don't fit `instance_type`, or +/// null (`models::project::ec2_fit_problem`: the start's own rule, so Host +/// settings never disagree with it). +#[tauri::command] +pub fn ec2_fit_problem(config: AwsWorkspaceConfig, instance_type: String) -> Option { + crate::models::project::ec2_fit_problem(&config, &instance_type) +} + #[tauri::command] pub async fn stop_project_container( project_id: String, diff --git a/app/src-tauri/src/docker/aws_mode_tests.rs b/app/src-tauri/src/docker/aws_mode_tests.rs index 4071414..1e754e8 100644 --- a/app/src-tauri/src/docker/aws_mode_tests.rs +++ b/app/src-tauri/src/docker/aws_mode_tests.rs @@ -2666,3 +2666,91 @@ fn two_connects_at_once_never_mix_their_files() { assert_eq!(c.run(&["../../etc"]).status.code(), Some(2)); assert_eq!(c.run(&[&a]).status.code(), Some(1)); } + +// ------------------------------------------- Docker access and VPN (phase 7, EC2) + +/// The `docker_socket` block with the socket at `sock` and the account tools +/// faked (they log to stdout): `getent` knows no group, so one is added. +fn docker_socket_step(sock: &Path, aws: bool) -> Output { + let script = format!( + "getent() {{ return 2; }}\n\ + groupadd() {{ echo \"groupadd $*\"; }}\n\ + usermod() {{ echo \"usermod $*\"; }}\n\ + triplec_aws={}\n{}", + u8::from(aws), + eblock("docker_socket").replace("/var/run/docker.sock", &sock.display().to_string()) + ); + bash(&script, &[], &[], &[]) +} + +fn unix_socket(path: &Path) -> std::os::unix::net::UnixListener { + std::os::unix::net::UnixListener::bind(path).expect("bind socket") +} + +/// E6: an EC2 project's Docker access is its instance's socket, so the group +/// step runs in aws mode too (it was Docker-only), and as before without one. +#[test] +fn the_docker_socket_group_step_runs_in_aws_mode_when_the_socket_exists() { + let tmp = tempfile::tempdir().unwrap(); + let sock = tmp.path().join("docker.sock"); + let _listener = unix_socket(&sock); + let gid = fs::metadata(&sock).map(|m| std::os::unix::fs::MetadataExt::gid(&m)).unwrap(); + for aws in [true, false] { + let out = docker_socket_step(&sock, aws); + let t = text(&out); + assert!(out.status.success(), "{t}"); + assert!(t.contains(&format!("groupadd -g {gid} docker-host")), "aws={aws}: {t}"); + assert!(t.contains("usermod -aG"), "aws={aws}: {t}"); + assert!(t.trim_end().ends_with(" claude"), "aws={aws}: {t}"); + } + // No socket (Fargate, or Docker access off): nothing happens. + let out = docker_socket_step(&tmp.path().join("absent.sock"), true); + assert!(out.status.success()); + assert_eq!(text(&out), ""); + // A regular file there is not a socket either. + let file = tmp.path().join("file.sock"); + fs::write(&file, "").unwrap(); + assert_eq!(text(&docker_socket_step(&file, true)), ""); + assert!(!eblock("docker_socket").contains("triplec_aws"), "no aws gate"); +} + +/// The feature-skills block with the skill source and destination in `tmp` +/// and `chown` switched off. +fn feature_skills(tmp: &Path, vpn: &str) -> Output { + let src = tmp.join("opt-skills"); + let dest = tmp.join("home-skills"); + let script = format!( + "chown() {{ :; }}\ntriplec_aws=1\n{}\n[ -z \"${{VPN_SUPPORT_ENABLED+x}}\" ] && echo unset-ok", + eblock("feature_skills") + .replace("/opt/triple-c-skills", &src.display().to_string()) + .replace("/home/claude/.claude/skills", &dest.display().to_string()) + ); + bash(&script, &[], &[("VPN_SUPPORT_ENABLED", vpn)], &[]) +} + +/// E7: in aws mode the VPN skill follows `VPN_SUPPORT_ENABLED` as on Docker +/// (installed when 1, removed when 0), and the variable is gone after. +#[test] +fn the_vpn_skill_follows_vpn_support_in_aws_mode() { + let tmp = tempfile::tempdir().unwrap(); + let src = tmp.path().join("opt-skills/pia-vpn"); + fs::create_dir_all(&src).unwrap(); + fs::write(src.join("SKILL.md"), "vpn").unwrap(); + let dest = tmp.path().join("home-skills/pia-vpn/SKILL.md"); + + let out = feature_skills(tmp.path(), "1"); + let t = text(&out); + assert!(t.contains("pia-vpn skill installed"), "{t}"); + assert!(t.contains("unset-ok"), "{t}"); + assert_eq!(fs::read_to_string(&dest).unwrap(), "vpn"); + + let t = text(&feature_skills(tmp.path(), "0")); + assert!(t.contains("pia-vpn skill removed"), "{t}"); + assert!(!dest.exists()); + // The call itself is not behind any mode check. + let call = ENTRYPOINT + .lines() + .find(|l| l.starts_with("install_feature_skill pia-vpn")) + .expect("the call"); + assert!(!call.contains("triplec_aws")); +} diff --git a/app/src-tauri/src/host/aws_host.rs b/app/src-tauri/src/host/aws_host.rs index cf01982..010daca 100644 --- a/app/src-tauri/src/host/aws_host.rs +++ b/app/src-tauri/src/host/aws_host.rs @@ -790,6 +790,60 @@ pub async fn environment_max_hours(project: &Project, settings: &AppSettings) -> Some(info.max_workspace_hours) } +/// What Host settings know of the user's EC2 capacity in an AWS project's +/// environment (phase 7): the launch-type control offers EC2 only with +/// `Ec2`, and sizes the reservations against `available_*` +/// ([`ec2_available`]; `None` for a type the app's table doesn't know). +#[derive(Debug, Clone, PartialEq, serde::Serialize)] +#[serde(tag = "state", rename_all = "snake_case")] +pub enum Ec2Capacity { + Ec2 { + compute: crate::aws::environments::UserCompute, + available_cpu: Option, + available_memory_mib: Option, + }, + /// No user record: no EC2 capacity in this environment. + None, + /// A record that can't be used (the reason names a field, never a value). + Unusable { reason: String }, + /// It couldn't be read (offline, no connection, slow, a local project). + Unknown, +} + +/// [`Ec2Capacity`] from a read of the user record (`None`: no read). +pub fn ec2_capacity_from(read: Option) -> Ec2Capacity { + match read { + Some(UserRecord::Valid(compute)) => { + let available = crate::models::project::ec2_available(&compute.instance_type); + Ec2Capacity::Ec2 { + available_cpu: available.map(|a| a.0), + available_memory_mib: available.map(|a| a.1), + compute, + } + } + Some(UserRecord::Absent) => Ec2Capacity::None, + Some(UserRecord::Unusable(reason)) => Ec2Capacity::Unusable { reason }, + None => Ec2Capacity::Unknown, + } +} + +/// The caller's EC2 capacity in `project`'s environment, from their user +/// record. Never an error: anything that stops the read (10 s bound) is +/// [`Ec2Capacity::Unknown`]. +pub async fn ec2_capacity(project: &Project, settings: &AppSettings) -> Ec2Capacity { + let read = async { + let placement = project.aws_placement.as_ref()?; + let (_, region, sdk) = project_sdk(project, settings).await.ok()?; + let who = caller_identity(&sdk).await.ok()?; + let ok = owner_key(®ion, &who.user_id); + read_user_record(&SdkRuntimeApi::new(&sdk), &placement.environment, &ok, &who.account, ®ion) + .await + .map_err(|e| log::info!("Project {}: could not read the EC2 record ({e})", project.id)) + .ok() + }; + ec2_capacity_from(tokio::time::timeout(std::time::Duration::from_secs(10), read).await.ok().flatten()) +} + /// `ProjectHost::Aws::ensure_started`. pub async fn ensure_started( project: &Project, diff --git a/app/src-tauri/src/host/aws_host/tests.rs b/app/src-tauri/src/host/aws_host/tests.rs index 09bba46..031a066 100644 --- a/app/src-tauri/src/host/aws_host/tests.rs +++ b/app/src-tauri/src/host/aws_host/tests.rs @@ -1510,3 +1510,51 @@ async fn stopping_an_ec2_task_by_its_arn_uses_its_cluster() { stop_task_arn(&fake, &ec2_task_arn("e7")).await.unwrap(); assert_eq!(*fake.stop_clusters.lock().unwrap(), [USER_CLUSTER]); } + +/// E7: the entrypoint installs the VPN skill from `VPN_SUPPORT_ENABLED`, as +/// on Docker; an EC2 project with VPN support gets `1`, Fargate `0`. +#[test] +fn vpn_support_reaches_an_ec2_workspace_as_on_docker() { + let vpn = |p: &Project| { + let (pairs, _) = aws_env(p, &AppSettings::default()).unwrap(); + pairs.into_iter().find(|(k, _)| k == "VPN_SUPPORT_ENABLED").map(|(_, v)| v) + }; + let mut p = ec2_project(); + p.vpn_support_enabled = true; + assert_eq!(vpn(&p).as_deref(), Some("1")); + p.vpn_support_enabled = false; + assert_eq!(vpn(&p).as_deref(), Some("0")); + assert_eq!(vpn(&aws_project(StorageMode::Ephemeral)).as_deref(), Some("0")); +} + +/// Host settings' view of the user's EC2 capacity: the record's compute with +/// the fit limits, none, unusable (with the reason) or unknown. +#[test] +fn ec2_capacity_reads_as_host_settings_need_it() { + use crate::aws::environments::{UserCompute, UserRecord}; + let compute = UserCompute { + instance_type: "m7i.large".into(), + max_instances: 1, + user_tag: "alice".into(), + cluster_arn: "arn:aws:ecs:us-west-2:123456789012:cluster/triple-c-dev--u-alice".into(), + capacity_provider: "triple-c-dev--u-alice".into(), + }; + let c = ec2_capacity_from(Some(UserRecord::Valid(compute.clone()))); + assert_eq!( + c, + Ec2Capacity::Ec2 { compute: compute.clone(), available_cpu: Some(1920), available_memory_mib: Some(7373) } + ); + let v = serde_json::to_value(&c).unwrap(); + assert_eq!(v["state"], "ec2"); + assert_eq!(v["compute"]["instance_type"], "m7i.large"); + assert_eq!(v["available_memory_mib"], 7373); + let unknown_type = UserCompute { instance_type: "x9.huge".into(), ..compute }; + assert!(matches!( + ec2_capacity_from(Some(UserRecord::Valid(unknown_type))), + Ec2Capacity::Ec2 { available_cpu: None, available_memory_mib: None, .. } + )); + assert_eq!(serde_json::to_value(ec2_capacity_from(Some(UserRecord::Absent))).unwrap()["state"], "none"); + let v = serde_json::to_value(ec2_capacity_from(Some(UserRecord::Unusable("schema is not 1".into())))).unwrap(); + assert_eq!(v, serde_json::json!({ "state": "unusable", "reason": "schema is not 1" })); + assert_eq!(serde_json::to_value(ec2_capacity_from(None)).unwrap(), serde_json::json!({ "state": "unknown" })); +} diff --git a/app/src-tauri/src/lib.rs b/app/src-tauri/src/lib.rs index f99e53b..e6e3e64 100644 --- a/app/src-tauri/src/lib.rs +++ b/app/src-tauri/src/lib.rs @@ -555,6 +555,8 @@ pub fn run() { commands::project_commands::aws_task_log, commands::project_commands::aws_workspace_status, commands::project_commands::aws_environment_max_hours, + commands::project_commands::aws_ec2_capacity, + commands::project_commands::ec2_fit_problem, commands::project_commands::remove_aws_resources, commands::project_commands::rebuild_project_container, commands::project_commands::reconcile_project_statuses, diff --git a/app/src-tauri/src/models/project.rs b/app/src-tauri/src/models/project.rs index e35b311..4fee6b0 100644 --- a/app/src-tauri/src/models/project.rs +++ b/app/src-tauri/src/models/project.rs @@ -822,11 +822,9 @@ pub fn fits_instance(cfg: &AwsWorkspaceConfig, instance_type: &str) -> Fit { if cfg.launch_type != LaunchType::Ec2 { return Fit::Ok; } - let Some((cpu, mem)) = ec2_instance_spec(instance_type) else { + let Some((available_cpu, available_memory_mib)) = ec2_available(instance_type) else { return Fit::UnknownType; }; - let available_cpu = cpu - EC2_RESERVED_CPU_UNITS; - let available_memory_mib = mem - ec2_memory_reserve_mib(mem); if cfg.cpu > available_cpu || cfg.memory_mib > available_memory_mib { Fit::TooBig { available_cpu, available_memory_mib } } else { @@ -834,6 +832,29 @@ pub fn fits_instance(cfg: &AwsWorkspaceConfig, instance_type: &str) -> Fit { } } +/// What `instance_type` leaves for one workspace's reservations, as +/// `(CPU units, MiB)`: [`fits_instance`]'s limits (the agent's CPU and the +/// memory margin taken off). `None` for a type not in the table. +pub fn ec2_available(instance_type: &str) -> Option<(u32, u32)> { + let (cpu, mem) = ec2_instance_spec(instance_type)?; + Some((cpu - EC2_RESERVED_CPU_UNITS, mem - ec2_memory_reserve_mib(mem))) +} + +/// Why `cfg`'s reservations don't fit `instance_type`, or `None` when they +/// do (or the type is unknown, or `cfg` is Fargate). The one wording of the +/// fit rule: the start's refusal and Host settings both use it. +pub fn ec2_fit_problem(cfg: &AwsWorkspaceConfig, instance_type: &str) -> Option { + match fits_instance(cfg, instance_type) { + Fit::TooBig { available_cpu, available_memory_mib } => Some(format!( + "This project reserves {} CPU units and {} MiB of memory, more than your EC2 \ + instance type {instance_type} has for a workspace ({available_cpu} CPU units, \ + {available_memory_mib} MiB).", + cfg.cpu, cfg.memory_mib + )), + Fit::Ok | Fit::UnknownType => None, + } +} + pub fn validate_aws_workspace(cfg: &AwsWorkspaceConfig) -> Result<(), String> { match cfg.launch_type { LaunchType::Fargate => { @@ -1686,6 +1707,24 @@ mod tests { assert_eq!(fits_instance(&cfg(16384, 122880), "m7i.large"), Fit::Ok); } + #[test] + fn the_fit_problem_words_the_fit_rule_once() { + assert_eq!(ec2_available("m7i.large"), Some((1920, 7373))); + assert_eq!(ec2_available("t4g.large"), Some((1920, 7373))); + assert_eq!(ec2_available("z9.huge"), None); + assert_eq!(ec2_fit_problem(&ec2(1920, 7373), "m7i.large"), None); + assert_eq!( + ec2_fit_problem(&ec2(1024, 7374), "m7i.large").as_deref(), + Some( + "This project reserves 1024 CPU units and 7374 MiB of memory, more than your EC2 \ + instance type m7i.large has for a workspace (1920 CPU units, 7373 MiB)." + ) + ); + // Unknown types and Fargate configs: no problem to report here. + assert_eq!(ec2_fit_problem(&ec2(99999, 99999), "z9.huge"), None); + assert_eq!(ec2_fit_problem(&cfg(16384, 122880), "m7i.large"), None); + } + #[test] fn cpu_and_memory_must_be_a_fargate_pair() { // Shared with the frontend's copy (`lib/awsWorkspace.test.ts`). diff --git a/app/src/components/projects/home/AwsCostEstimate.test.tsx b/app/src/components/projects/home/AwsCostEstimate.test.tsx index cd56a02..d108c83 100644 --- a/app/src/components/projects/home/AwsCostEstimate.test.tsx +++ b/app/src/components/projects/home/AwsCostEstimate.test.tsx @@ -4,10 +4,12 @@ import type { AwsWorkspaceConfig, HourlyEstimate } from "../../../lib/types"; import { defaultAwsWorkspace } from "../../../lib/awsWorkspace"; const awsCostEstimate = - vi.fn<(id: string, region: string, config: AwsWorkspaceConfig) => Promise>(); + vi.fn< + (id: string, region: string, config: AwsWorkspaceConfig, instanceType: string | null) => Promise + >(); vi.mock("../../../lib/tauri-commands", () => ({ - awsCostEstimate: (id: string, region: string, config: AwsWorkspaceConfig) => - awsCostEstimate(id, region, config), + awsCostEstimate: (id: string, region: string, config: AwsWorkspaceConfig, instanceType: string | null) => + awsCostEstimate(id, region, config, instanceType), })); import AwsCostEstimate, { ESTIMATE_DEBOUNCE_MS, formatHourly } from "./AwsCostEstimate"; @@ -43,12 +45,13 @@ describe("AwsCostEstimate", () => { usd_per_hour: 0.05826, note_spot: false, efs_billed_separately: false, + ec2_instance: false, }); const c = config(); render(); expect(screen.getByText("Estimating…")).toBeInTheDocument(); await settle(); - expect(awsCostEstimate).toHaveBeenCalledWith("c1", "us-west-2", c); + expect(awsCostEstimate).toHaveBeenCalledWith("c1", "us-west-2", c, null); expect(screen.getByText("≈ $0.058/hour")).toBeInTheDocument(); expect(screen.queryByText(/Spot/)).toBeNull(); expect(screen.queryByText(/EFS/)).toBeNull(); @@ -59,6 +62,7 @@ describe("AwsCostEstimate", () => { usd_per_hour: 0.05, note_spot: true, efs_billed_separately: true, + ec2_instance: false, }); render( { }); it("asks once per settled change of a cost field, not for unrelated edits", async () => { - awsCostEstimate.mockResolvedValue({ usd_per_hour: 0.1, note_spot: false, efs_billed_separately: false }); + awsCostEstimate.mockResolvedValue({ usd_per_hour: 0.1, note_spot: false, efs_billed_separately: false, ec2_instance: false }); const { rerender } = render(); await settle(); expect(awsCostEstimate).toHaveBeenCalledTimes(1); @@ -113,4 +117,31 @@ describe("AwsCostEstimate", () => { expect(awsCostEstimate).toHaveBeenCalledTimes(2); expect(awsCostEstimate.mock.calls[1][2].cpu).toBe(4096); }); + + it("prices an EC2 project as its instance type, and says instances scale to zero", async () => { + awsCostEstimate.mockResolvedValue({ usd_per_hour: 0.1008, note_spot: false, efs_billed_separately: true, ec2_instance: true }); + const c = config({ launch_type: "ec2", storage: "hybrid" }); + const { rerender } = render( + , + ); + await settle(); + expect(awsCostEstimate).toHaveBeenCalledWith("c1", "us-west-2", c, "m7i.large"); + expect(screen.getByText("≈ $0.10/hour")).toBeInTheDocument(); + expect(screen.getByText(/Instances scale to zero when no workspace is running/)).toBeInTheDocument(); + expect(screen.getByText(/EFS storage is billed separately/)).toBeInTheDocument(); + expect(screen.queryByText(/While the task runs/)).toBeNull(); + // The reservations don't change an instance's price: no new call. + rerender( + , + ); + await settle(); + expect(awsCostEstimate).toHaveBeenCalledTimes(1); + }); + + it("does not ask for an EC2 project whose instance type is unknown", async () => { + render(); + await settle(); + expect(awsCostEstimate).not.toHaveBeenCalled(); + expect(screen.getByText("Estimate unavailable")).toBeInTheDocument(); + }); }); diff --git a/app/src/components/projects/home/AwsCostEstimate.tsx b/app/src/components/projects/home/AwsCostEstimate.tsx index b711d29..f4f5d95 100644 --- a/app/src/components/projects/home/AwsCostEstimate.tsx +++ b/app/src/components/projects/home/AwsCostEstimate.tsx @@ -15,6 +15,8 @@ interface Props { connectionId: string | null; region: string | null | undefined; config: AwsWorkspaceConfig; + /** An EC2 project's instance type (the user's); null when unknown. */ + instanceType?: string | null; } type State = { kind: "loading" } | { kind: "done"; estimate: HourlyEstimate | null }; @@ -25,21 +27,27 @@ type State = { kind: "loading" } | { kind: "done"; estimate: HourlyEstimate | nu * network or no connection reads "Estimate unavailable" — never an error toast, and nothing waits * on it. Re-asked only when a field that changes the price changes, after edits settle. */ -export default function AwsCostEstimate({ connectionId, region, config }: Props) { +export default function AwsCostEstimate({ connectionId, region, config, instanceType = null }: Props) { const [state, setState] = useState({ kind: "loading" }); - const { cpu, memory_mib, arch, ephemeral_gib, spot, storage } = config; + const { launch_type, cpu, memory_mib, arch, ephemeral_gib, spot, storage } = config; + const ec2 = launch_type === "ec2"; // Only what the backend prices or notes; the rest of the config is sent but changes nothing. - const key = JSON.stringify([connectionId, region, cpu, memory_mib, arch, ephemeral_gib, spot, storage]); + // An EC2 project is priced as its instance (E10): only the type and storage matter. + const key = JSON.stringify( + ec2 + ? [connectionId, region, launch_type, instanceType, storage] + : [connectionId, region, launch_type, cpu, memory_mib, arch, ephemeral_gib, spot, storage], + ); useEffect(() => { - if (!connectionId || !region) { + if (!connectionId || !region || (ec2 && !instanceType)) { setState({ kind: "done", estimate: null }); return; } let cancelled = false; setState({ kind: "loading" }); const timer = setTimeout(() => { - awsCostEstimate(connectionId, region, config) + awsCostEstimate(connectionId, region, config, ec2 ? instanceType : null) .catch(() => null) .then((estimate) => { if (!cancelled) setState({ kind: "done", estimate }); @@ -65,7 +73,13 @@ export default function AwsCostEstimate({ connectionId, region, config }: Props) }` : "Estimate unavailable"}

- {estimate && ( + {estimate?.ec2_instance && ( +

+ While your instance runs. Instances scale to zero when no workspace is running. + {estimate.efs_billed_separately && " EFS storage is billed separately."} +

+ )} + {estimate && !estimate.ec2_instance && (

While the task runs; nothing while it is stopped. {estimate.efs_billed_separately && " EFS storage is billed separately."} diff --git a/app/src/components/projects/home/OverviewTab.tsx b/app/src/components/projects/home/OverviewTab.tsx index a0e7bb8..967a019 100644 --- a/app/src/components/projects/home/OverviewTab.tsx +++ b/app/src/components/projects/home/OverviewTab.tsx @@ -15,6 +15,7 @@ import ContainerMigrationBanner from "./ContainerMigrationBanner"; import AwsWorkspaceStatusCard from "./AwsWorkspaceStatusCard"; import AwsCostEstimate from "./AwsCostEstimate"; import { isAwsProject } from "../../../lib/awsWorkspace"; +import { useEc2Capacity } from "../../../lib/ec2Capacity"; import type { ContainerMigration } from "../../../hooks/useContainerMigration"; import SaveIndicator from "../../ui/SaveIndicator"; import Button from "../../ui/Button"; @@ -53,6 +54,11 @@ export default function OverviewTab({ onOpenMigration, }: Props) { const [sessions, setSessions] = useState([]); + // An EC2 project's estimate is its instance type's price (E10). + const ec2Capacity = useEc2Capacity( + project, + isAwsProject(project) && project.status === "running" && project.aws?.launch_type === "ec2", + ); const [tasks, setTasks] = useState([]); const [notificationCount, setNotificationCount] = useState(0); const running = project.status === "running"; @@ -152,6 +158,7 @@ export default function OverviewTab({ connectionId={project.host_id} region={project.aws_placement?.region} config={project.aws} + instanceType={ec2Capacity?.state === "ec2" ? ec2Capacity.compute.instance_type : null} /> )} diff --git a/app/src/components/projects/home/config/AwsConfig.test.tsx b/app/src/components/projects/home/config/AwsConfig.test.tsx index eeacc93..dcbc51e 100644 --- a/app/src/components/projects/home/config/AwsConfig.test.tsx +++ b/app/src/components/projects/home/config/AwsConfig.test.tsx @@ -9,11 +9,16 @@ import { awsProject, localProject } from "../../../../test/awsFixtures"; import type { AppSettings, AuthBridgeStatus, Project } from "../../../../lib/types"; import { useAppState } from "../../../../store/appState"; import { clearEnvironmentMaxHoursCache } from "../../../../lib/environmentMaxHours"; +import { clearEc2CapacityCache } from "../../../../lib/ec2Capacity"; +import type { Ec2Capacity } from "../../../../lib/types"; const OFF_BRIDGE: AuthBridgeStatus = { enabled: false, active_ports: [], conflicts: [] }; const removeAwsResources = vi.fn(); const awsCostEstimate = vi.fn(async (..._args: unknown[]) => null as unknown); const awsEnvironmentMaxHours = vi.fn(async (_id: string) => 0 as number | null); +const NO_EC2: Ec2Capacity = { state: "none" }; +const awsEc2Capacity = vi.fn(async (_id: string): Promise => NO_EC2); +const ec2FitProblem = vi.fn(async (..._args: unknown[]) => null as string | null); vi.mock("../../../../lib/tauri-commands", () => ({ getAuthBridgeStatus: vi.fn(async () => OFF_BRIDGE), @@ -22,6 +27,8 @@ vi.mock("../../../../lib/tauri-commands", () => ({ removeAwsResources: (id: string, discard: boolean) => removeAwsResources(id, discard), awsCostEstimate: (...args: unknown[]) => awsCostEstimate(...args), awsEnvironmentMaxHours: (id: string) => awsEnvironmentMaxHours(id), + awsEc2Capacity: (id: string) => awsEc2Capacity(id), + ec2FitProblem: (...args: unknown[]) => ec2FitProblem(...args), })); vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn(async () => () => {}) })); vi.mock("@tauri-apps/plugin-dialog", () => ({ open: vi.fn(async () => null) })); @@ -31,6 +38,8 @@ const save = vi.fn().mockResolvedValue(true); beforeEach(() => { vi.clearAllMocks(); clearEnvironmentMaxHoursCache(); + clearEc2CapacityCache(); + awsEc2Capacity.mockImplementation(async () => NO_EC2); }); function toggle(name: string) { @@ -244,7 +253,7 @@ describe("HostSection", () => { await waitFor(() => expect(within(card).getByText(/≈ \$0\.050\/hour \(on-demand; Spot is usually up to 70% cheaper\)/)).toBeInTheDocument(), ); - expect(awsCostEstimate).toHaveBeenCalledWith("c1", "eu-west-1", p.aws); + expect(awsCostEstimate).toHaveBeenCalledWith("c1", "eu-west-1", p.aws, null); expect(within(card).getByText(/EFS storage is billed separately/)).toBeInTheDocument(); useAppState.setState({ appSettings: null }); }); @@ -595,3 +604,167 @@ describe("HostSection", () => { expect(screen.queryByLabelText("Repository 1 URL")).toBeNull(); }); }); + +// ---- phase 7: EC2 projects ---- + +const M7I: Ec2Capacity = { + state: "ec2", + compute: { + instance_type: "m7i.large", + max_instances: 1, + user_tag: "alice", + cluster_arn: "arn:aws:ecs:eu-west-1:123456789012:cluster/triple-c-dev--u-alice", + capacity_provider: "triple-c-dev--u-alice", + }, + available_cpu: 1920, + available_memory_mib: 7373, +}; + +const ec2Project = (over: Partial = {}): Project => { + const p = awsProject(over); + return { ...p, aws: { ...p.aws!, launch_type: "ec2", cpu: 1024, memory_mib: 4096 } }; +}; + +describe("HostSection — launch type (EC2)", () => { + const renderHost = (p: Project = awsProject(), disabled = false) => + render(); + const ec2Segment = () => screen.getByRole("radio", { name: /^EC2/ }); + + it("offers EC2 with the user's instance type when their onboarding has EC2 capacity", async () => { + awsEc2Capacity.mockImplementation(async () => M7I); + renderHost(); + await waitFor(() => expect(ec2Segment()).toHaveTextContent("EC2 (your instance: m7i.large)")); + expect(ec2Segment()).toBeEnabled(); + expect(screen.queryByText(/Ask an admin/)).toBeNull(); + }); + + it("disables EC2 with the reason when the user has no EC2 capacity, or it can't be read", async () => { + renderHost(); + await waitFor(() => + expect(screen.getByText(/Ask an admin to add EC2 capacity to your onboarding/)).toBeInTheDocument(), + ); + expect(ec2Segment()).toBeDisabled(); + expect(screen.getByRole("radio", { name: "Fargate" })).toBeEnabled(); + cleanup(); + + clearEc2CapacityCache(); + awsEc2Capacity.mockImplementation(async () => ({ state: "unusable", reason: "schema is not 1" })); + renderHost(); + await waitFor(() => expect(screen.getByText(/can't be used \(schema is not 1\)/)).toBeInTheDocument()); + expect(ec2Segment()).toBeDisabled(); + cleanup(); + + clearEc2CapacityCache(); + awsEc2Capacity.mockImplementation(async () => ({ state: "unknown" })); + renderHost(); + await waitFor(() => expect(screen.getByText(/Could not read your EC2 capacity/)).toBeInTheDocument()); + expect(ec2Segment()).toBeDisabled(); + }); + + it("switches to EC2 through launchTypePatch: sidecar and Spot off, sizes fitted", async () => { + awsEc2Capacity.mockImplementation(async () => M7I); + const p = awsProject(); + p.aws = { ...p.aws!, cpu: 4096, memory_mib: 16384, spot: true, gateway_sidecar: true }; + renderHost(p); + await waitFor(() => expect(ec2Segment()).toBeEnabled()); + fireEvent.click(ec2Segment()); + await waitFor(() => expect(save).toHaveBeenCalledTimes(1)); + expect(save.mock.calls[0][0].aws).toMatchObject({ + launch_type: "ec2", + gateway_sidecar: false, + spot: false, + cpu: 1920, + memory_mib: 7373, + }); + expect(save.mock.calls[0][0].allow_docker_access).toBeUndefined(); + }); + + it("switches back to Fargate turning Docker access and VPN off, with a Fargate size", async () => { + awsEc2Capacity.mockImplementation(async () => M7I); + const p = ec2Project({ allow_docker_access: true, vpn_support_enabled: true }); + p.aws = { ...p.aws!, cpu: 1920, memory_mib: 7373 }; + renderHost(p); + fireEvent.click(screen.getByRole("radio", { name: "Fargate" })); + await waitFor(() => expect(save).toHaveBeenCalledTimes(1)); + const patch = save.mock.calls[0][0]; + expect(patch).toMatchObject({ allow_docker_access: false, vpn_support_enabled: false }); + expect(patch.aws).toMatchObject({ launch_type: "fargate", cpu: 1024, memory_mib: 7168 }); + }); + + it("an EC2 project keeps its launch type selectable back to Fargate even without capacity, and says why it can't start", async () => { + renderHost(ec2Project()); + await waitFor(() => expect(screen.getByText(/can't start on EC2 now/)).toBeInTheDocument()); + expect(ec2Segment()).toHaveAttribute("aria-checked", "true"); + expect(screen.getByRole("radio", { name: "Fargate" })).toBeEnabled(); + }); + + it("on EC2: reservation inputs with the instance's limits, no ephemeral size, Spot or architecture, and the notes", async () => { + awsEc2Capacity.mockImplementation(async () => M7I); + renderHost(ec2Project()); + await waitFor(() => expect(screen.getByText(/Up to 1920 on your m7i.large/)).toBeInTheDocument()); + expect(screen.getByText(/Up to 7373 MiB on your m7i.large/)).toBeInTheDocument(); + expect(screen.getByLabelText("CPU reservation (units)")).toHaveValue("1024"); + expect(screen.getByLabelText("Memory reservation (MiB)")).toHaveValue("4096"); + expect(screen.queryByLabelText("Ephemeral storage (GiB)")).toBeNull(); + expect(screen.queryByRole("switch", { name: "Spot" })).toBeNull(); + expect(screen.queryByRole("radiogroup", { name: "Architecture" })).toBeNull(); + const notes = screen.getByRole("note", { name: "On EC2" }); + expect(notes).toHaveTextContent(/first start after idle boots an instance — about 3 minutes/); + expect(notes).toHaveTextContent(/root on your own instance/); + expect(notes).toHaveTextContent(/gateway sidecar is not available on EC2/); + // Fargate shows none of this. + cleanup(); + renderHost(awsProject()); + expect(screen.queryByRole("note", { name: "On EC2" })).toBeNull(); + expect(screen.getByLabelText("Ephemeral storage (GiB)")).toBeInTheDocument(); + expect(screen.getByRole("switch", { name: "Spot" })).toBeInTheDocument(); + }); + + it("checks the reservations with the backend's fit rule before saving", async () => { + awsEc2Capacity.mockImplementation(async () => M7I); + ec2FitProblem.mockResolvedValueOnce("This project reserves 1024 CPU units and 8000 MiB of memory, more than …"); + renderHost(ec2Project()); + await waitFor(() => expect(screen.getByText(/Up to 1920/)).toBeInTheDocument()); + const mem = screen.getByLabelText("Memory reservation (MiB)"); + fireEvent.change(mem, { target: { value: "8000" } }); + fireEvent.blur(mem); + await waitFor(() => expect(screen.getByRole("alert")).toHaveTextContent(/more than/)); + expect(ec2FitProblem).toHaveBeenCalledWith(expect.objectContaining({ cpu: 1024, memory_mib: 8000 }), "m7i.large"); + expect(save).not.toHaveBeenCalled(); + + fireEvent.change(mem, { target: { value: "6000" } }); + fireEvent.blur(mem); + await waitFor(() => expect(save).toHaveBeenCalledTimes(1)); + expect(save.mock.calls[0][0].aws).toMatchObject({ cpu: 1024, memory_mib: 6000 }); + + const cpu = screen.getByLabelText("CPU reservation (units)"); + fireEvent.change(cpu, { target: { value: "0" } }); + fireEvent.blur(cpu); + await waitFor(() => expect(screen.getByRole("alert")).toHaveTextContent(/positive whole numbers/)); + }); + + it("prices an EC2 project as the user's instance type", async () => { + awsEc2Capacity.mockImplementation(async () => M7I); + useAppState.setState({ + appSettings: { hosts: [{ id: "c1", name: "lab" }] } as unknown as AppSettings, + }); + const p = ec2Project(); + renderHost(p); + await waitFor(() => expect(awsCostEstimate).toHaveBeenCalledWith("c1", "eu-west-1", p.aws, "m7i.large")); + expect(screen.getByText(/price in this region of your EC2 instance \(m7i.large\)/)).toBeInTheDocument(); + useAppState.setState({ appSettings: null }); + }); +}); + +describe("RuntimeSection on EC2", () => { + it("enables Docker access, VPN and the sandbox, and says Docker access is root on the instance", () => { + render(); + for (const name of ["Allow container spawning", "VPN support", "Sandbox mode"]) { + expect(toggle(name)).toBeEnabled(); + } + expect(toggle("Sandbox mode")).toHaveAttribute("aria-checked", "true"); + expect(screen.getByText(/root on your own instance/)).toBeInTheDocument(); + expect(screen.queryByText(/Off on AWS for now/)).toBeNull(); + }); +}); + diff --git a/app/src/components/projects/home/config/HostSection.tsx b/app/src/components/projects/home/config/HostSection.tsx index 62970bb..4cb6ec0 100644 --- a/app/src/components/projects/home/config/HostSection.tsx +++ b/app/src/components/projects/home/config/HostSection.tsx @@ -1,7 +1,15 @@ import { useEffect, useRef, useState } from "react"; -import type { AwsWorkspaceConfig, HostConnection, Project, RepoSource } from "../../../../lib/types"; +import type { + AwsWorkspaceConfig, + Ec2Capacity, + HostConnection, + LaunchType, + Project, + RepoSource, +} from "../../../../lib/types"; import * as commands from "../../../../lib/tauri-commands"; import { environmentMaxHours } from "../../../../lib/environmentMaxHours"; +import { useEc2Capacity } from "../../../../lib/ec2Capacity"; import { useAppState } from "../../../../store/appState"; import { COPY_AT_CONNECT_GATEWAY_NOTE, @@ -16,6 +24,12 @@ import { setupScriptProblem, EFS_HINT, EPHEMERAL_WARNING, + EC2_DOCKER_ACCESS_NOTE, + EC2_NO_CAPACITY, + EC2_NO_SIDECAR, + EC2_SCALE_TO_ZERO_NOTE, + launchTypePatch, + type Ec2Limits, FARGATE_CPUS, defaultAwsWorkspace, formatCpu, @@ -43,6 +57,21 @@ interface Props { const DEFAULT_IDLE_MINUTES = 60; const STILL_RUNNING = "The task is still running — stop it first."; +/** Why EC2 can't be chosen, from what the user's record says (null: it can). */ +function ec2Unavailable(capacity: Ec2Capacity | null): string | null { + if (capacity === null) return "Checking your EC2 capacity in this environment…"; + switch (capacity.state) { + case "ec2": + return null; + case "none": + return `You have no EC2 capacity in this environment. ${EC2_NO_CAPACITY}.`; + case "unusable": + return `Your EC2 capacity record can't be used (${capacity.reason}). ${EC2_NO_CAPACITY}.`; + case "unknown": + return "Could not read your EC2 capacity in this environment; EC2 is offered once it can be read."; + } +} + /** * Where an AWS project runs and what its Fargate task looks like. Only shown * for AWS projects; a local project's host is chosen when it is added. @@ -55,6 +84,7 @@ export default function HostSection({ project, save, disabled }: Props) { const hosts = useAppState((s) => s.appSettings?.hosts ?? NO_HOSTS); const connection = hosts.find((h) => h.id === project.host_id); + const [cpuText, setCpuText] = useState(String(aws.cpu)); const [memory, setMemory] = useState(String(aws.memory_mib)); const [memoryProblem, setMemoryProblem] = useState(null); const [ephemeral, setEphemeral] = useState(String(aws.ephemeral_gib)); @@ -68,10 +98,22 @@ export default function HostSection({ project, save, disabled }: Props) { const [maxHours, setMaxHours] = useState(null); useEffect(() => { + setCpuText(String(aws.cpu)); setMemory(String(aws.memory_mib)); setEphemeral(String(aws.ephemeral_gib)); setIdle(String(aws.idle_stop_minutes ?? DEFAULT_IDLE_MINUTES)); - }, [aws.memory_mib, aws.ephemeral_gib, aws.idle_stop_minutes]); + }, [aws.cpu, aws.memory_mib, aws.ephemeral_gib, aws.idle_stop_minutes]); + + // Phase 7: the user's own EC2 capacity in this environment (their record), + // which decides whether EC2 can be chosen and what it can reserve. + const capacity = useEc2Capacity(project); + const ec2 = aws.launch_type === "ec2"; + const compute = capacity?.state === "ec2" ? capacity.compute : null; + const limits: Ec2Limits | null = + capacity?.state === "ec2" && capacity.available_cpu !== null && capacity.available_memory_mib !== null + ? { cpu: capacity.available_cpu, memory_mib: capacity.available_memory_mib } + : null; + const ec2Reason = ec2Unavailable(capacity); useEffect(() => { setSetupScript(aws.setup_script ?? ""); @@ -104,7 +146,7 @@ export default function HostSection({ project, save, disabled }: Props) { if (latest.current.base !== project.aws && latest.current.inFlight === 0) { latest.current = { base: project.aws, value: aws, inFlight: 0 }; } - const saveAws = async (patch: Partial) => { + const saveAws = async (patch: Partial, also: Partial = {}) => { const l = latest.current; const next = { ...l.value, ...patch }; l.value = next; @@ -114,7 +156,7 @@ export default function HostSection({ project, save, disabled }: Props) { if (l.value === next) l.value = l.base ?? defaultAwsWorkspace(); }; try { - const ok = await save({ aws: next }); + const ok = await save({ ...also, aws: next }); if (!ok) refused(); return ok; } catch (e) { @@ -141,6 +183,46 @@ export default function HostSection({ project, save, disabled }: Props) { // Not `disabled` (which also allows Error): on AWS, Error can mean a live task. const stopped = project.status === "stopped"; + // The launch-type switch: `launchTypePatch` keeps each side to what Rust + // accepts there (Docker/VPN, the sidecar, Spot, the sizes). + const switchLaunchType = (launch_type: LaunchType) => { + if (launch_type === latest.current.value.launch_type) return; + setMemoryProblem(null); + const { aws: next, ...also } = launchTypePatch( + { ...project, aws: latest.current.value }, + launch_type, + limits, + ); + void saveAws(next!, also); + }; + + // EC2 reservations: positive whole numbers that fit the user's instance + // type — checked by Rust's own fit rule (`ec2_fit_problem`), so this never + // disagrees with the start. + const commitEc2Sizing = async () => { + const cpu = Number(cpuText); + const memory_mib = Number(memory); + const whole = (n: number) => Number.isInteger(n) && n > 0; + if (!whole(cpu) || !whole(memory_mib)) { + setMemoryProblem("The CPU and memory reservations must be positive whole numbers"); + return; + } + if (compute) { + let problem: string | null = null; + try { + problem = await commands.ec2FitProblem({ ...aws, cpu, memory_mib }, compute.instance_type); + } catch { + problem = null; // The start checks again. + } + if (problem) { + setMemoryProblem(problem); + return; + } + } + setMemoryProblem(null); + if (cpu !== aws.cpu || memory_mib !== aws.memory_mib) void saveAws({ cpu, memory_mib }); + }; + const commitMemory = () => { const value = Number(memory); const problem = memoryError(aws.cpu, value); @@ -176,7 +258,11 @@ export default function HostSection({ project, save, disabled }: Props) { return (

Connection
@@ -200,6 +286,94 @@ export default function HostSection({ project, save, disabled }: Props) {

)} +
+ + Launch type + + + {ec2Reason && ( +

+ {ec2 && capacity !== null && capacity.state !== "unknown" + ? `This project can't start on EC2 now: ${ec2Reason} Or switch it to Fargate.` + : ec2Reason} +

+ )} + {ec2 && ( +
    +
  • {EC2_SCALE_TO_ZERO_NOTE}
  • +
  • {EC2_DOCKER_ACCESS_NOTE}
  • +
  • {EC2_NO_SIDECAR}.
  • +
+ )} +
+ + {ec2 ? ( +
+ + {(id) => ( + setCpuText(e.target.value)} + onBlur={() => void commitEc2Sizing()} + onKeyDown={(e) => e.key === "Enter" && void commitEc2Sizing()} + className={`w-32 ${inputClass}`} + /> + )} + + + {(id) => ( + setMemory(e.target.value)} + onBlur={() => void commitEc2Sizing()} + onKeyDown={(e) => e.key === "Enter" && void commitEc2Sizing()} + className={`w-32 ${inputClass}`} + /> + )} + +
+ ) : (
{(id) => ( @@ -273,6 +447,7 @@ export default function HostSection({ project, save, disabled }: Props) { />
+ )} {memoryProblem && (

{memoryProblem} @@ -328,6 +503,8 @@ export default function HostSection({ project, save, disabled }: Props) { )}

+ {!ec2 && ( + <> } /> + + )}

Estimated cost

- The on-demand Fargate price in this region for the CPU, memory, architecture and disk - above. + {ec2 + ? `The on-demand price in this region of your EC2 instance${compute ? ` (${compute.instance_type})` : ""}, whatever this project reserves of it.` + : "The on-demand Fargate price in this region for the CPU, memory, architecture and disk above."}

diff --git a/app/src/components/projects/home/config/RuntimeSection.tsx b/app/src/components/projects/home/config/RuntimeSection.tsx index ed31bf3..ebe8b6b 100644 --- a/app/src/components/projects/home/config/RuntimeSection.tsx +++ b/app/src/components/projects/home/config/RuntimeSection.tsx @@ -5,7 +5,12 @@ import PermissionModeControl, { permissionModePatch } from "../../PermissionMode import ClaudeInstructionsEditor from "../../ClaudeInstructionsEditor"; import ClaudeCodeSettingsEditor from "../../ClaudeCodeSettingsEditor"; import AuthBridgeRow from "./AuthBridgeRow"; -import { NOT_ON_AWS, SANDBOX_OFF_ON_AWS, isAwsProject } from "../../../../lib/awsWorkspace"; +import { + EC2_DOCKER_ACCESS_NOTE, + NOT_ON_AWS, + SANDBOX_OFF_ON_AWS, + isAwsProject, +} from "../../../../lib/awsWorkspace"; interface Props { project: Project; @@ -22,7 +27,11 @@ export default function RuntimeSection({ }: Props) { const aws = isAwsProject(project); // Docker access and VPN need the user's own EC2 instance (not Fargate). - const noPrivileged = aws && project.aws?.launch_type !== "ec2"; + const ec2 = aws && project.aws?.launch_type === "ec2"; + const noPrivileged = aws && !ec2; + // Fargate can't run Claude Code's sandbox (P9); the user's own EC2 + // instance can (E8), so it follows the project there. + const sandboxOff = aws && !ec2; return ( <> save({ sandbox_mode_enabled: v })} /> } @@ -58,7 +67,9 @@ export default function RuntimeSection({ hint={ noPrivileged ? NOT_ON_AWS - : "Mounts the Docker socket so Claude can build and run Docker containers from inside the sandbox." + : ec2 + ? `Mounts the Docker socket so Claude can build and run Docker containers from inside the workspace. ${EC2_DOCKER_ACCESS_NOTE}` + : "Mounts the Docker socket so Claude can build and run Docker containers from inside the sandbox." } control={ { + it("a disabled segment can't be clicked and arrow keys skip it", () => { + const onChange = vi.fn(); + render( + , + ); + expect(screen.getByRole("radio", { name: "B" })).toBeDisabled(); + fireEvent.click(screen.getByRole("radio", { name: "B" })); + expect(onChange).not.toHaveBeenCalled(); + fireEvent.keyDown(screen.getByRole("radiogroup"), { key: "ArrowRight" }); + expect(onChange).toHaveBeenLastCalledWith("c"); + fireEvent.keyDown(screen.getByRole("radiogroup"), { key: "ArrowLeft" }); + expect(onChange).toHaveBeenLastCalledWith("c"); + }); + + it("with every other segment disabled, the arrows stay put", () => { + const onChange = vi.fn(); + render( + , + ); + fireEvent.keyDown(screen.getByRole("radiogroup"), { key: "ArrowRight" }); + expect(onChange).not.toHaveBeenCalled(); + }); +}); diff --git a/app/src/components/ui/SegmentedControl.tsx b/app/src/components/ui/SegmentedControl.tsx index 0bd1487..4556fcc 100644 --- a/app/src/components/ui/SegmentedControl.tsx +++ b/app/src/components/ui/SegmentedControl.tsx @@ -7,6 +7,8 @@ export interface Segment { hint?: string; /** Paint this segment with the caution treatment when selected. */ caution?: boolean; + /** This segment can't be chosen (say why next to the control). */ + disabled?: boolean; } interface Props { @@ -35,12 +37,21 @@ export default function SegmentedControl({ const move = (delta: number) => { const index = segments.findIndex((s) => s.value === value); - const next = segments[(index + delta + segments.length) % segments.length]; + // The next segment that can be chosen; none other than this one: stay. + let next: Segment | undefined; + for (let step = 1; step < segments.length; step++) { + const s = segments[(index + delta * step + segments.length * step) % segments.length]; + if (!s.disabled) { + next = s; + break; + } + } if (!next) return; - onChange(next.value); + const target = next.value; + onChange(target); requestAnimationFrame(() => { groupRef.current - ?.querySelector(`[data-segment="${next.value}"]`) + ?.querySelector(`[data-segment="${target}"]`) ?.focus(); }); }; @@ -79,7 +90,7 @@ export default function SegmentedControl({ data-segment={segment.value} aria-checked={selected} tabIndex={selected ? 0 : -1} - disabled={disabled} + disabled={disabled || segment.disabled} onClick={() => onChange(segment.value)} className={`h-6 px-2.5 text-xs font-medium rounded-[4px] transition-colors disabled:text-[var(--text-disabled)] disabled:hover:bg-transparent ${cls}`} > diff --git a/app/src/lib/awsWorkspace.test.ts b/app/src/lib/awsWorkspace.test.ts index 654eeb0..d4d8268 100644 --- a/app/src/lib/awsWorkspace.test.ts +++ b/app/src/lib/awsWorkspace.test.ts @@ -6,13 +6,15 @@ import { hasWorkspaceFiles, environmentSelectable, gatewaySidecarProblem, + EC2_NO_SIDECAR, + launchTypePatch, memoryError, memoryOptions, nearestMemory, repoFolderFromUrl, stopGuardNeeded, } from "./awsWorkspace"; -import { environment } from "../test/awsFixtures"; +import { awsProject, environment } from "../test/awsFixtures"; // Shared with the Rust validator (`models/project.rs`). import fargatePairs from "../test/fixtures/fargate-pairs.json"; @@ -105,3 +107,47 @@ describe("gatewaySidecarProblem", () => { ).toMatch(/1 vCPU and 2 GiB/); }); }); + +describe("launchTypePatch (phase 7)", () => { + const base = () => { + const p = awsProject({ allow_docker_access: true, vpn_support_enabled: true }); + return { ...p, aws: { ...p.aws!, gateway_sidecar: true, spot: true, cpu: 4096, memory_mib: 16384 } }; + }; + + it("to EC2: keeps Docker/VPN, clears the sidecar and Spot, and fits the reservations to the instance", () => { + const patch = launchTypePatch(base(), "ec2", { cpu: 1920, memory_mib: 7373 }); + expect(patch.allow_docker_access).toBeUndefined(); + expect(patch.vpn_support_enabled).toBeUndefined(); + expect(patch.aws).toMatchObject({ launch_type: "ec2", gateway_sidecar: false, spot: false, cpu: 1920, memory_mib: 7373 }); + // Reservations that already fit stay; unknown limits change nothing. + const small = { ...base(), aws: { ...base().aws, cpu: 1024, memory_mib: 4096 } }; + expect(launchTypePatch(small, "ec2", { cpu: 1920, memory_mib: 7373 }).aws).toMatchObject({ cpu: 1024, memory_mib: 4096 }); + expect(launchTypePatch(base(), "ec2", null).aws).toMatchObject({ cpu: 4096, memory_mib: 16384 }); + }); + + it("to Fargate: clears Docker/VPN and snaps the reservations to a Fargate pair", () => { + const p = base(); + const ec2 = { ...p, aws: { ...p.aws, launch_type: "ec2" as const, cpu: 1920, memory_mib: 7373, spot: false } }; + const patch = launchTypePatch(ec2, "fargate"); + expect(patch).toMatchObject({ allow_docker_access: false, vpn_support_enabled: false }); + expect(patch.aws).toMatchObject({ launch_type: "fargate", cpu: 1024, memory_mib: 7168 }); + expect(memoryError(patch.aws!.cpu, patch.aws!.memory_mib)).toBeNull(); + // Below the smallest Fargate size: the smallest. + const tiny = { ...ec2, aws: { ...ec2.aws, cpu: 100, memory_mib: 300 } }; + expect(launchTypePatch(tiny, "fargate").aws).toMatchObject({ cpu: 256, memory_mib: 512 }); + // A valid pair is kept. + const ok = { ...ec2, aws: { ...ec2.aws, cpu: 1024, memory_mib: 4096 } }; + expect(launchTypePatch(ok, "fargate").aws).toMatchObject({ cpu: 1024, memory_mib: 4096 }); + }); + + it("the sidecar is not available on EC2 (words it as Rust's EC2_NO_SIDECAR)", () => { + const p = { ...base(), backend: "open_ai_compatible" as const }; + const ec2 = { ...p, aws: { ...p.aws, launch_type: "ec2" as const } }; + const gw = { models: [{ name: "m", model_id: "x" }] } as never; + expect(gatewaySidecarProblem(ec2, gw)).toBe(EC2_NO_SIDECAR); + expect(EC2_NO_SIDECAR).toBe( + "The LLM gateway sidecar is not available on EC2 yet: turn it off, or run the project on Fargate", + ); + expect(gatewaySidecarProblem(p, gw)).toBeNull(); + }); +}); diff --git a/app/src/lib/awsWorkspace.ts b/app/src/lib/awsWorkspace.ts index c07c528..4fcbd0d 100644 --- a/app/src/lib/awsWorkspace.ts +++ b/app/src/lib/awsWorkspace.ts @@ -199,6 +199,7 @@ export function gatewaySidecarProblem( project: Pick, gateway: Pick | null, ): string | null { + if (project.aws?.launch_type === "ec2") return EC2_NO_SIDECAR; if (project.backend !== "open_ai_compatible") { return "The LLM gateway sidecar needs the OpenAI Compatible backend."; } @@ -240,14 +241,56 @@ export function localEndpointProblem(url: string, gatewayPort: number | null): s return null; } -/** The save patch for switching an AWS project's launch type. Docker access and - * VPN need EC2 (Rust refuses them on Fargate), so switching to Fargate turns - * them off in the same save. Task 6's launch-type control must use this. */ -export function launchTypePatch(project: Project, launch_type: LaunchType): Partial { - const patch: Partial = { aws: { ...project.aws!, launch_type } }; - if (launch_type !== "ec2") { +/** What an EC2 instance leaves for a workspace's reservations (Rust `ec2_available`). */ +export interface Ec2Limits { + cpu: number; + memory_mib: number; +} + +/** The largest Fargate CPU size at most `cpu` (the smallest when below them all). */ +function fargateCpuAtMost(cpu: number): number { + return [...FARGATE_CPUS].reverse().find((c) => c <= cpu) ?? FARGATE_CPUS[0]; +} + +/** + * The save patch for switching an AWS project's launch type — the one place + * the switch is made. Each side keeps only what Rust accepts there: + * - to Fargate: Docker access and VPN off (they need EC2), and the + * reservations snapped to a Fargate CPU/memory pair; + * - to EC2: the gateway sidecar and Spot off (neither is available on EC2), + * and the reservations lowered to what the instance leaves (`limits`, when + * known). + */ +export function launchTypePatch( + project: Project, + launch_type: LaunchType, + limits: Ec2Limits | null = null, +): Partial { + const aws: AwsWorkspaceConfig = { ...project.aws!, launch_type }; + const patch: Partial = { aws }; + if (launch_type === "ec2") { + aws.gateway_sidecar = false; + aws.spot = false; + if (limits) { + aws.cpu = Math.min(aws.cpu, limits.cpu); + aws.memory_mib = Math.min(aws.memory_mib, limits.memory_mib); + } + } else { patch.allow_docker_access = false; patch.vpn_support_enabled = false; + aws.cpu = fargateCpuAtMost(aws.cpu); + if (memoryError(aws.cpu, aws.memory_mib)) aws.memory_mib = nearestMemory(aws.cpu, aws.memory_mib); } return patch; } + +/** Mirrors Rust `aws::workspace::EC2_NO_SIDECAR`. */ +export const EC2_NO_SIDECAR = + "The LLM gateway sidecar is not available on EC2 yet: turn it off, or run the project on Fargate"; + +/** Host settings' notes for an EC2 project (phase 7). */ +export const EC2_SCALE_TO_ZERO_NOTE = + "Your instances scale to zero when no workspace is running, so the first start after idle boots an instance — about 3 minutes."; +export const EC2_DOCKER_ACCESS_NOTE = + "Docker access mounts your instance's Docker socket: that is root on your own instance, which nobody else's workspace runs on."; +export const EC2_NO_CAPACITY = "Ask an admin to add EC2 capacity to your onboarding"; diff --git a/app/src/lib/ec2Capacity.test.ts b/app/src/lib/ec2Capacity.test.ts new file mode 100644 index 0000000..a646916 --- /dev/null +++ b/app/src/lib/ec2Capacity.test.ts @@ -0,0 +1,56 @@ +import { describe, it, expect, vi, beforeEach } from "vitest"; +import type { Ec2Capacity } from "./types"; + +const EC2: Ec2Capacity = { + state: "ec2", + compute: { + instance_type: "m7i.large", + max_instances: 1, + user_tag: "alice", + cluster_arn: "arn:aws:ecs:eu-west-1:1:cluster/triple-c-dev--u-alice", + capacity_provider: "triple-c-dev--u-alice", + }, + available_cpu: 1920, + available_memory_mib: 7373, +}; +const awsEc2Capacity = vi.fn(async (_id: string): Promise => EC2); +vi.mock("./tauri-commands", () => ({ + awsEc2Capacity: (id: string) => awsEc2Capacity(id), +})); + +import { EC2_CAPACITY_TTL_MS, clearEc2CapacityCache, ec2Capacity } from "./ec2Capacity"; + +describe("ec2Capacity", () => { + beforeEach(() => { + awsEc2Capacity.mockClear(); + clearEc2CapacityCache(); + }); + + it("asks once per connection, region and environment until the TTL passes", async () => { + expect(await ec2Capacity("p1", "c1", "eu-west-1", "dev", 0)).toEqual(EC2); + expect(await ec2Capacity("p2", "c1", "eu-west-1", "dev", 1000)).toEqual(EC2); + expect(awsEc2Capacity).toHaveBeenCalledTimes(1); + await ec2Capacity("p1", "c1", "eu-west-1", "prod", 1000); + expect(awsEc2Capacity).toHaveBeenCalledTimes(2); + await ec2Capacity("p1", "c1", "eu-west-1", "dev", EC2_CAPACITY_TTL_MS); + expect(awsEc2Capacity).toHaveBeenCalledTimes(3); + }); + + it("keeps none, but not unknown or a rejection", async () => { + awsEc2Capacity.mockResolvedValueOnce({ state: "none" }); + expect(await ec2Capacity("p1", "c1", "eu-west-1", "dev", 0)).toEqual({ state: "none" }); + await ec2Capacity("p1", "c1", "eu-west-1", "dev", 1); + expect(awsEc2Capacity).toHaveBeenCalledTimes(1); + + clearEc2CapacityCache(); + awsEc2Capacity.mockResolvedValueOnce({ state: "unknown" }); + expect(await ec2Capacity("p1", "c1", "eu-west-1", "dev", 0)).toEqual({ state: "unknown" }); + expect(await ec2Capacity("p1", "c1", "eu-west-1", "dev", 1)).toEqual(EC2); + expect(awsEc2Capacity).toHaveBeenCalledTimes(3); + + awsEc2Capacity.mockRejectedValueOnce(new Error("x")); + clearEc2CapacityCache(); + await expect(ec2Capacity("p1", "c1", "eu-west-1", "dev", 0)).rejects.toThrow("x"); + expect(await ec2Capacity("p1", "c1", "eu-west-1", "dev", 1)).toEqual(EC2); + }); +}); diff --git a/app/src/lib/ec2Capacity.ts b/app/src/lib/ec2Capacity.ts new file mode 100644 index 0000000..ab508ea --- /dev/null +++ b/app/src/lib/ec2Capacity.ts @@ -0,0 +1,73 @@ +import { useEffect, useState } from "react"; +import * as commands from "./tauri-commands"; +import type { Ec2Capacity, Project } from "./types"; + +/** How long a user's EC2 capacity is reused before AWS is asked again. */ +export const EC2_CAPACITY_TTL_MS = 10 * 60 * 1000; + +interface Entry { + at: number; + value: Promise; +} + +/** Keyed by connection, region and environment: the record is the caller's + * in that environment, so every project placed there shares one read. */ +const cache = new Map(); + +/** + * `aws_ec2_capacity`, cached per (connection, region, environment) for + * [`EC2_CAPACITY_TTL_MS`]. A read in flight is shared; an `unknown` answer + * (offline, slow) or a rejection is not kept, so the next mount asks again. + */ +export function ec2Capacity( + projectId: string, + connectionId: string, + region: string, + environment: string, + now: number = Date.now(), +): Promise { + const key = JSON.stringify([connectionId, region, environment]); + const hit = cache.get(key); + if (hit && now - hit.at < EC2_CAPACITY_TTL_MS) return hit.value; + const value = Promise.resolve().then(() => commands.awsEc2Capacity(projectId)); + const entry = { at: now, value }; + cache.set(key, entry); + const forget = () => { + if (cache.get(key) === entry) cache.delete(key); + }; + value.then((c) => c.state === "unknown" && forget(), forget); + return value; +} + +/** After an onboarding apply changed the user's EC2 capacity, and for tests. */ +export function clearEc2CapacityCache() { + cache.clear(); +} + +/** The project's EC2 capacity (null while it is read); only asked when `enabled`. */ +export function useEc2Capacity( + project: Pick, + enabled = true, +): Ec2Capacity | null { + const [capacity, setCapacity] = useState(null); + const region = project.aws_placement?.region; + const environment = project.aws_placement?.environment; + useEffect(() => { + setCapacity(null); + if (!enabled) return; + if (!project.host_id || !region || !environment) { + setCapacity({ state: "unknown" }); + return; + } + let cancelled = false; + ec2Capacity(project.id, project.host_id, region, environment) + .catch((): Ec2Capacity => ({ state: "unknown" })) + .then((c) => { + if (!cancelled) setCapacity(c); + }); + return () => { + cancelled = true; + }; + }, [enabled, project.id, project.host_id, region, environment]); + return capacity; +} diff --git a/app/src/lib/tauri-commands.ts b/app/src/lib/tauri-commands.ts index 894051b..0de89ca 100644 --- a/app/src/lib/tauri-commands.ts +++ b/app/src/lib/tauri-commands.ts @@ -1,5 +1,5 @@ import { invoke } from "@tauri-apps/api/core"; -import type { Project, ProjectPath, NewProjectHost, RemoveProjectOptions, WipChoice, UnsavedWork, WorkspaceStatus, ProjectRemovalReport, ProjectResetOutcome, ContainerInfo, AppSettings, SettingsImportPreview, SettingsImportOutcome, UpdateInfo, ImageUpdateInfo, FileEntry, FileContents, WebTerminalInfo, SttStatus, GatewayStatus, InstallOptions, ClaudeSession, ContainerCapabilities, ScheduledTask, ScheduledTaskInput, SchedulerNotification, AuthBridgeStatus, BrowserViewStatus, BrowserViewPopoutState, BrowserPageState, PlaywrightDetection, BrowserSetupOutcome, BrowserInstallTarget, ContainerStaleness, MigrationOptions, MigrationReport, MigrationState, ClearTokenOutcome, CaCertInfo, UploadOutcome, Note, ViewerFile, ViewerPoll, ViewerSaved, ViewerState, FileDiff, InstallScope, ItemUpdate, Marketplace, MarketplaceAccount, MarketplaceItemRef, MarketplaceSnapshot, ProjectSyncResult, SyncReport, HostConnection, CallerIdentity, PermissionReport, PolicyFile, HourlyEstimate, AwsWorkspaceConfig, Tier, EnvironmentScan, NetworkChoice, ModuleKind, Ec2Choice, Ec2Compute, Ec2InstanceTable, SavedBundle } from "./types"; +import type { Project, ProjectPath, NewProjectHost, RemoveProjectOptions, WipChoice, UnsavedWork, WorkspaceStatus, ProjectRemovalReport, ProjectResetOutcome, ContainerInfo, AppSettings, SettingsImportPreview, SettingsImportOutcome, UpdateInfo, ImageUpdateInfo, FileEntry, FileContents, WebTerminalInfo, SttStatus, GatewayStatus, InstallOptions, ClaudeSession, ContainerCapabilities, ScheduledTask, ScheduledTaskInput, SchedulerNotification, AuthBridgeStatus, BrowserViewStatus, BrowserViewPopoutState, BrowserPageState, PlaywrightDetection, BrowserSetupOutcome, BrowserInstallTarget, ContainerStaleness, MigrationOptions, MigrationReport, MigrationState, ClearTokenOutcome, CaCertInfo, UploadOutcome, Note, ViewerFile, ViewerPoll, ViewerSaved, ViewerState, FileDiff, InstallScope, ItemUpdate, Marketplace, MarketplaceAccount, MarketplaceItemRef, MarketplaceSnapshot, ProjectSyncResult, SyncReport, HostConnection, CallerIdentity, PermissionReport, PolicyFile, HourlyEstimate, AwsWorkspaceConfig, Tier, EnvironmentScan, NetworkChoice, ModuleKind, Ec2Choice, Ec2Compute, Ec2InstanceTable, Ec2Capacity, SavedBundle } from "./types"; // Docker export const checkDocker = () => invoke("check_docker"); @@ -46,6 +46,11 @@ export const awsWorkspaceStatus = (projectId: string) => * null when it can't be read. Never rejects for a missing project. */ export const awsEnvironmentMaxHours = (projectId: string) => invoke("aws_environment_max_hours", { projectId }); +export const awsEc2Capacity = (projectId: string) => + invoke("aws_ec2_capacity", { projectId }); +/** Rust `ec2_fit_problem`: why the reservations don't fit `instanceType`, or null. */ +export const ec2FitProblem = (config: AwsWorkspaceConfig, instanceType: string) => + invoke("ec2_fit_problem", { config, instanceType }); export const removeAwsResources = (projectId: string, discardData: boolean) => invoke("remove_aws_resources", { projectId, discardData }); export const rebuildProjectContainer = (projectId: string) => @@ -112,8 +117,13 @@ export const awsPolicyDocument = (tier: Tier) => /** The estimated hourly cost of `config` on Fargate in `region`, signed with the project's * connection. Never rejects for AWS reasons: `null` means "Estimate unavailable" (denied, offline, * no connection). Rates are cached a day on disk. */ -export const awsCostEstimate = (connectionId: string, region: string, config: AwsWorkspaceConfig) => - invoke("aws_cost_estimate", { connectionId, region, config }); +/** `instanceType`: an EC2 project's (the user's, from `awsEc2Capacity`); priced as that instance. */ +export const awsCostEstimate = ( + connectionId: string, + region: string, + config: AwsWorkspaceConfig, + instanceType: string | null = null, +) => invoke("aws_cost_estimate", { connectionId, region, config, instanceType }); // AWS environments (OpenTofu). Reject with an `AwsError`. Starting commands (and follow) resolve // to an op id; progress arrives on the `AWS_DEPLOY_PROGRESS_EVENT` event (`DeployProgress`, in diff --git a/app/src/lib/types.ts b/app/src/lib/types.ts index fb0a25d..8b52d4f 100644 --- a/app/src/lib/types.ts +++ b/app/src/lib/types.ts @@ -1280,6 +1280,9 @@ export interface HourlyEstimate { note_spot: boolean; /** Hybrid or EFS storage: EFS is billed per GB-month, not in this figure. */ efs_billed_separately: boolean; + /** EC2 (E10): the user's instance's on-demand price, whatever the project + * reserves of it; instances scale to zero when no workspace is running. */ + ec2_instance: boolean; } export type Verdict = "allowed" | "denied" | "unverified"; @@ -1385,6 +1388,20 @@ export interface Ec2Compute { /** An onboarding's EC2 choice (`environment_commands::Ec2Choice`). */ export type Ec2Choice = { kind: "none" } | ({ kind: "ec2" } & Ec2Compute); +/** `host::aws_host::Ec2Capacity`: the user's EC2 capacity in an AWS project's + * environment, for Host settings (phase 7). `available_*` are what the + * instance leaves for one workspace (null for a type the app doesn't know). */ +export type Ec2Capacity = + | { + state: "ec2"; + compute: UserCompute; + available_cpu: number | null; + available_memory_mib: number | null; + } + | { state: "none" } + | { state: "unusable"; reason: string } + | { state: "unknown" }; + /** One row of the app's built-in instance table (`models::project::Ec2InstanceType`). */ export interface Ec2InstanceType { instance_type: string; diff --git a/container/entrypoint.sh b/container/entrypoint.sh index 2c0cf21..f50a282 100644 --- a/container/entrypoint.sh +++ b/container/entrypoint.sh @@ -459,6 +459,7 @@ fi # That case says so rather than returning silently: the toggle is on, the # capability is there, and the skill simply never appears — which is impossible # to work out from the outside. +# >>> feature_skills install_feature_skill() { local _name="$1" local _enabled="$2" @@ -509,6 +510,7 @@ install_feature_skill() { install_feature_skill pia-vpn "${VPN_SUPPORT_ENABLED:-0}" unset VPN_SUPPORT_ENABLED +# <<< feature_skills # ── Claude Code settings ──────────────────────────────────────────────────── # Apply the managed Claude Code settings to ~/.claude/settings.json, keeping @@ -655,7 +657,10 @@ else fi # ── Docker socket permissions ──────────────────────────────────────────────── -if [ "$triplec_aws" != 1 ] && [ -S /var/run/docker.sock ]; then +# Docker mode and AWS alike: an EC2 project with Docker access mounts its own +# instance's socket here (phase 7 E6); Fargate never has one. +# >>> docker_socket +if [ -S /var/run/docker.sock ]; then DOCKER_GID=$(stat -c '%g' /var/run/docker.sock) if ! getent group "$DOCKER_GID" > /dev/null 2>&1; then groupadd -g "$DOCKER_GID" docker-host @@ -663,6 +668,7 @@ if [ "$triplec_aws" != 1 ] && [ -S /var/run/docker.sock ]; then DOCKER_GROUP=$(getent group "$DOCKER_GID" | cut -d: -f1) usermod -aG "$DOCKER_GROUP" claude fi +# <<< docker_socket # ── Timezone setup ─────────────────────────────────────────────────────────── if [ -n "${TZ:-}" ]; then -- 2.52.0 From bf5a810e0df78382dd8e9dc666f754587be803a5 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 15:24:55 -0800 Subject: [PATCH 13/29] fix(aws): allow template-only Auto Scaling group creates A CreateAutoScalingGroup that names only a launch template sends no autoscaling:InstanceTypes (verified live), so the scaling file's Null:false on it denied every per-user group. Drop it; the type is held by the caller's own ec2:RunInstances launch check on the template, which also refuses MixedInstancesPolicy overrides of unsupported types. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/policies.rs | 13 +++++++------ app/src-tauri/src/aws/tofu_modules/tests.rs | 1 - aws/README.md | 16 +++++++--------- aws/policies/environment-admin-scaling.json | 3 +-- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/src-tauri/src/aws/policies.rs b/app/src-tauri/src/aws/policies.rs index b1984c5..7e8e435 100644 --- a/app/src-tauri/src/aws/policies.rs +++ b/app/src-tauri/src/aws/policies.rs @@ -288,7 +288,6 @@ const GROUP_CREATE: Context = &[ "autoscaling:LaunchTemplateVersionSpecified", Literal("true"), ), - ("autoscaling:InstanceTypes", Literal("m7i.large")), ]; const GROUP_UPDATE: Context = &[ (COMPONENT_RESOURCE_TAG, Literal("user-onboarding")), @@ -2816,15 +2815,17 @@ mod tests { ); } } - // Creating always names the template version and its types; an - // update may leave the template alone (a size change, the drain - // before destroy). - assert!(!allowed( + // Creating always names the template version; an update may leave + // the template alone (a size change, the drain before destroy). + // A template-only create sends no `autoscaling:InstanceTypes` + // (verified live, phase 7): it must pass, and the type is held by + // the caller's own `ec2:RunInstances` launch check instead. + assert!(allowed( tier, &write( "autoscaling:CreateAutoScalingGroup", PROBE_AUTO_SCALING_GROUP, - without(GROUP_CREATE, "autoscaling:InstanceTypes") + GROUP_CREATE ), ME, ME diff --git a/app/src-tauri/src/aws/tofu_modules/tests.rs b/app/src-tauri/src/aws/tofu_modules/tests.rs index e85274d..0b9a8b0 100644 --- a/app/src-tauri/src/aws/tofu_modules/tests.rs +++ b/app/src-tauri/src/aws/tofu_modules/tests.rs @@ -1789,7 +1789,6 @@ const GROUP_CREATE: Context = &[ "autoscaling:LaunchTemplateVersionSpecified", Literal("true"), ), - ("autoscaling:InstanceTypes", Literal("m7i.large")), ]; const GROUP_UPDATE: Context = &[ (RESOURCE_COMPONENT, Literal("user-onboarding")), diff --git a/aws/README.md b/aws/README.md index 1d68b38..987b41c 100644 --- a/aws/README.md +++ b/aws/README.md @@ -237,7 +237,7 @@ the proof; an action it shows missing is added to the table, the policy, the che | `aws_ecs_capacity_provider` | `ecs:CreateCapacityProvider`, `TagResource` (at create), `ListTagsForResource`, `UpdateCapacityProvider`, `UntagResource`, `DeleteCapacityProvider` (`capacity-provider/triple-c-*--u-*`), `DescribeCapacityProviders` (`*`); `iam:CreateServiceLinkedRole` for `ecs.amazonaws.com` (managed scaling runs as ECS's service-linked role) | | `aws_ecs_cluster_capacity_providers` (the user's) | `ecs:PutClusterCapacityProviders` (the cluster and, expected, the capacity provider) | | `aws_launch_template` | `ec2:CreateLaunchTemplate` (request tag), `CreateTags` (at create), `CreateLaunchTemplateVersion`, `CreateTags`/`DeleteTags`, `DeleteLaunchTemplate` (tagged), `Describe*`. Never `ModifyLaunchTemplate`: the default version never moves (the module must not set `update_default_version` or `default_version`) | -| `aws_autoscaling_group` | `autoscaling:CreateAutoScalingGroup` (`triple-c-*--u-*`, request tag, `autoscaling:LaunchTemplateVersionSpecified = true`, no `TargetGroupARNs`/`LoadBalancerNames`, `autoscaling:InstanceTypes` present and supported), `UpdateAutoScalingGroup` (tagged; the same, except that an update which leaves the template alone passes the version check), `SetInstanceProtection`, `CreateOrUpdateTags`/`DeleteTags`, `DeleteAutoScalingGroup` (tagged), `Describe*` (`*`); `iam:CreateServiceLinkedRole` for `autoscaling.amazonaws.com`. Creating a group checks that the caller could launch its template: `ec2:RunInstances` on the tagged launch template; on the instance and its volume only with the component request tag, `ec2:LaunchTemplate` set and (instance) a supported `ec2:InstanceType` (required: a launch whose type IAM doesn't see is denied); on the network interface and subnet with `ec2:LaunchTemplate`; on the security group only the template's own (`ec2:IsLaunchTemplateResource`) component-tagged group; on images only Amazon's, named by the template; `ec2:CreateTags` at `RunInstances`; `iam:PassRole` of the instance role to `ec2.amazonaws.com`. ASG tags are **not** the provider's `default_tags`: the module must set the component tag on the group itself | +| `aws_autoscaling_group` | `autoscaling:CreateAutoScalingGroup` (`triple-c-*--u-*`, request tag, `autoscaling:LaunchTemplateVersionSpecified = true`, no `TargetGroupARNs`/`LoadBalancerNames`, `autoscaling:InstanceTypes` supported when present — a template-only create sends none, verified live, so the type is held by the launch check below), `UpdateAutoScalingGroup` (tagged; the same, except that an update which leaves the template alone passes the version check), `SetInstanceProtection`, `CreateOrUpdateTags`/`DeleteTags`, `DeleteAutoScalingGroup` (tagged), `Describe*` (`*`); `iam:CreateServiceLinkedRole` for `autoscaling.amazonaws.com`. Creating a group checks that the caller could launch its template: `ec2:RunInstances` on the tagged launch template; on the instance and its volume only with the component request tag, `ec2:LaunchTemplate` set and (instance) a supported `ec2:InstanceType` (required: a launch whose type IAM doesn't see is denied); on the network interface and subnet with `ec2:LaunchTemplate`; on the security group only the template's own (`ec2:IsLaunchTemplateResource`) component-tagged group; on images only Amazon's, named by the template; `ec2:CreateTags` at `RunInstances`; `iam:PassRole` of the instance role to `ec2.amazonaws.com`. ASG tags are **not** the provider's `default_tags`: the module must set the component tag on the group itself | | `aws_iam_role` (instance), `aws_iam_role_policy` | as the other per-user roles (bounded), on `triple-c---instance`, tagged `triple-c:cluster = triple-c---u-` (`iam:TagRole`) | | `aws_iam_instance_profile` | `iam:CreateInstanceProfile`, `TagInstanceProfile`, `AddRoleToInstanceProfile` (expected to need `iam:PassRole` of the role too), `GetInstanceProfile`, `ListInstanceProfileTags`, `UntagInstanceProfile`, `RemoveRoleFromInstanceProfile`, `DeleteInstanceProfile` (`instance-profile/triple-c-*`) | | `data.aws_ssm_parameter` (AMI) | `ssm:GetParameter`/`GetParameters` on the public `parameter/aws/service/ecs/optimized-ami/*` | @@ -585,14 +585,12 @@ expected, not verified: - **`ec2:IsLaunchTemplateResource`** is expected to be `true` on the image and security group the template names, and `aws:RequestTag` to carry the template's tag specifications for the instance and volume. If the group's launch check doesn't send either, that statement denies the create. -- **`autoscaling:InstanceTypes`** is required on a group create (`Null: false`) and checked - against the supported list (`ForAllValues`). Expected: Auto Scaling fills it with the launch - template's instance type. If it is absent for a template-only create, every create is denied: - then drop the `Null` and rely on the `RunInstances` check (instance type required there). On - update it is not required (an update that leaves the template alone, such as the drain before - destroy, names no type). There is **no condition key for `MixedInstancesPolicy` or - `InstanceRequirements`**; their overrides are expected to appear in `autoscaling:InstanceTypes` - and in the launch check, which is what keeps them to the list. +- ~~**`autoscaling:InstanceTypes`** required on a group create.~~ **Verified live (phase 7):** a + template-only create sends **no** `autoscaling:InstanceTypes`, so the `Null: false` denied every + group (the first live onboarding failed on it); it is dropped. Creating a group runs the caller's + own `ec2:RunInstances` check on the template ("You are not authorized to use launch template" + otherwise), so `ec2:InstanceType` holds the type; a `MixedInstancesPolicy` override of an + unsupported type is denied by both checks. - **Instance types in templates.** `ec2:CreateLaunchTemplate`/`CreateLaunchTemplateVersion` are not known to support `ec2:InstanceType` (not in the service authorization reference as I know it), so a template may *name* any type; it can only be *launched* (directly or by a group) with a diff --git a/aws/policies/environment-admin-scaling.json b/aws/policies/environment-admin-scaling.json index a8104fc..e1c7326 100644 --- a/aws/policies/environment-admin-scaling.json +++ b/aws/policies/environment-admin-scaling.json @@ -14,8 +14,7 @@ "Null": { "aws:RequestTag/triple-c:component": "false", "autoscaling:TargetGroupARNs": "true", - "autoscaling:LoadBalancerNames": "true", - "autoscaling:InstanceTypes": "false" + "autoscaling:LoadBalancerNames": "true" }, "Bool": { "autoscaling:LaunchTemplateVersionSpecified": "true" -- 2.52.0 From 43fcc520aba7bdc77dc6d0f718983c5ba0eb2444 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 16:34:38 -0800 Subject: [PATCH 14/29] fix(aws): run a cold EC2 task again once its instance is up ECS turns enableExecuteCommand off on a RunTask that has to wait for an instance (PROVISIONING behind a capacity provider), and the task keeps it off once placed: verified live (CloudTrail shows true in the request, false in the answer; a RunTask with an instance up keeps it). Such a task can never be reached, so every cold EC2 start timed out. A cold start now lets that first task bring the instance up, stops it as soon as it is placed, waits for it to stop and runs the task again onto the instance; a second task without ECS Exec is stopped and reported. A live task found with ECS Exec off is stopped and replaced. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/runtime/tests.rs | 1 + app/src-tauri/src/aws/tasks.rs | 5 + app/src-tauri/src/aws/tasks/tests.rs | 1 + app/src-tauri/src/host/aws_host.rs | 129 +++++++++++++++++++++-- app/src-tauri/src/host/aws_host/tests.rs | 97 ++++++++++++++++- 5 files changed, 225 insertions(+), 8 deletions(-) diff --git a/app/src-tauri/src/aws/runtime/tests.rs b/app/src-tauri/src/aws/runtime/tests.rs index be73910..f89dbe8 100644 --- a/app/src-tauri/src/aws/runtime/tests.rs +++ b/app/src-tauri/src/aws/runtime/tests.rs @@ -277,6 +277,7 @@ fn live(id: &str) -> TaskInfo { ), runtime_id: None, container_instance_arn: None, + exec_enabled: true, exec_agent_running: false, exit_code: None, owner: Some(USER.into()), diff --git a/app/src-tauri/src/aws/tasks.rs b/app/src-tauri/src/aws/tasks.rs index b65db02..18c451f 100644 --- a/app/src-tauri/src/aws/tasks.rs +++ b/app/src-tauri/src/aws/tasks.rs @@ -67,6 +67,10 @@ pub struct TaskInfo { pub container_instance_arn: Option, /// The `workspace` container's ExecuteCommandAgent is RUNNING. pub exec_agent_running: bool, + /// ECS Exec is on for the task (`enableExecuteCommand`). ECS turns it + /// off on a RunTask that has to wait for an EC2 instance (verified live, + /// phase 7), and such a task can never be reached. + pub exec_enabled: bool, /// The `workspace` container's exit code, once it has one. pub exit_code: Option, /// Its `triple-c:owner` / `triple-c:project` tags (DescribeTasks with @@ -116,6 +120,7 @@ pub(crate) fn task_info(t: &Task) -> TaskInfo { task_definition_arn: t.task_definition_arn().unwrap_or_default().to_string(), runtime_id: workspace.and_then(|c| c.runtime_id()).map(str::to_string), container_instance_arn: t.container_instance_arn().map(str::to_string), + exec_enabled: t.enable_execute_command(), exec_agent_running: workspace.is_some_and(|c| { c.managed_agents().iter().any(|a| { a.name() == Some(&ManagedAgentName::ExecuteCommandAgent) diff --git a/app/src-tauri/src/aws/tasks/tests.rs b/app/src-tauri/src/aws/tasks/tests.rs index 23c321b..f65133c 100644 --- a/app/src-tauri/src/aws/tasks/tests.rs +++ b/app/src-tauri/src/aws/tasks/tests.rs @@ -65,6 +65,7 @@ fn info(id: &str, last: &str) -> TaskInfo { task_definition_arn: td_arn(3), runtime_id: None, container_instance_arn: None, + exec_enabled: true, exec_agent_running: false, exit_code: None, owner: Some(USER.into()), diff --git a/app/src-tauri/src/host/aws_host.rs b/app/src-tauri/src/host/aws_host.rs index 010daca..1dc4b6c 100644 --- a/app/src-tauri/src/host/aws_host.rs +++ b/app/src-tauri/src/host/aws_host.rs @@ -532,6 +532,96 @@ async fn wait_task( } } +/// What a start says when ECS ran its task with ECS Exec off even with an +/// instance up (it should not happen; the task can't be reached). +pub const EXEC_OFF: &str = "ECS started the task with ECS Exec turned off, so Triple-C can't \ + reach it. Start the project again."; + +/// A cold EC2 start's second RunTask. ECS turns `enableExecuteCommand` off +/// on a RunTask that has to wait for an instance (PROVISIONING; verified +/// live, phase 7) and the task keeps it off once placed, so it could never +/// be reached. That first task still makes the capacity provider launch an +/// instance: once it is placed, it is stopped (it runs nothing yet) and the +/// task run again, now straight onto that instance with ECS Exec. Returns +/// the new task; the caller stops `first` itself if this fails before the +/// stop. +#[allow(clippy::too_many_arguments)] +async fn rerun_once_placed( + tasks: &T, + compute: &crate::aws::environments::UserCompute, + first: &str, + task_def_arn: &str, + tags: &[(String, String)], + timing: WaitTiming, + progress: &(dyn Fn(&str) + Send + Sync), +) -> Result { + let cluster = compute.cluster_arn.as_str(); + let deadline = tokio::time::Instant::now() + timing.timeout; + let wanted = [first.to_string()]; + progress(PROGRESS_INSTANCE); + // Until an instance has taken the first task (or it stopped). + loop { + let t = tasks + .describe(cluster, &wanted) + .await + .map_err(|e| e.to_string())? + .into_iter() + .find(|t| t.arn == first); + match t { + Some(t) if waiting_for_instance(&t) => {} + _ => break, + } + if tokio::time::Instant::now() + timing.interval > deadline { + let max = compute.max_instances; + return Err(format!( + "No EC2 instance had room for the task within {} minutes. Your capacity may \ + already be running its maximum of {max} instance{} (stop another EC2 \ + workspace), or its Auto Scaling group could not launch one (an admin can see \ + why in the group's activity in the EC2 console).", + timing.timeout.as_secs() / 60, + if max == 1 { "" } else { "s" } + )); + } + tokio::time::sleep(timing.interval).await; + } + // Free its reservation before running again, or the second task would + // wait for an instance too. + tasks + .stop_task(cluster, first, STOP_REASON) + .await + .map_err(|e| e.to_string())?; + loop { + let gone = tasks + .describe(cluster, &wanted) + .await + .map_err(|e| e.to_string())? + .into_iter() + .find(|t| t.arn == first) + .is_none_or(|t| t.last_status == "STOPPED"); + if gone { + break; + } + if tokio::time::Instant::now() + timing.interval > deadline { + return Err(format!( + "The first task on the new EC2 instance did not stop within {} minutes; \ + start the project again.", + timing.timeout.as_secs() / 60 + )); + } + tokio::time::sleep(timing.interval).await; + } + progress(PROGRESS_WAITING); + let task = tasks + .run_task(crate::aws::tasks::ec2_run_task_request(compute, task_def_arn, tags)) + .await + .map_err(|e| crate::aws::tasks::ec2_run_error(e).to_string())?; + if !task.exec_enabled { + let _ = stop_created(tasks, cluster, &task.arn).await; + return Err(EXEC_OFF.into()); + } + Ok(task) +} + /// Where a project's task may be: the environment's cluster, the user's EC2 /// cluster from their record, and the per-user cluster a stored task ARN /// names (the record may be gone while that task runs), without repeats. @@ -613,6 +703,12 @@ pub async fn start_core { + arn = t.arn; + record_task(&arn); + } + Err(e) => { + let msg = with_log_tail(tasks, &logs, &arn, e).await; + if stop_created(tasks, &cluster, &arn).await { + (inp.on_task)(None); + } + return Err(msg); + } + } + } let ec2 = match run_on { RunOn::Ec2(c) => Some(c.max_instances), RunOn::Fargate { .. } => None, diff --git a/app/src-tauri/src/host/aws_host/tests.rs b/app/src-tauri/src/host/aws_host/tests.rs index 031a066..a45a0cb 100644 --- a/app/src-tauri/src/host/aws_host/tests.rs +++ b/app/src-tauri/src/host/aws_host/tests.rs @@ -57,6 +57,7 @@ fn task(p: &Project, id: &str, last: &str, ready: bool) -> TaskInfo { task_definition_arn: format!("arn:aws:ecs:{REGION}:{ACCOUNT}:task-definition/{}:1", family(p)), runtime_id: ready.then(|| "rt-1".into()), container_instance_arn: None, + exec_enabled: true, exec_agent_running: ready, exit_code: None, owner: Some(USER.into()), @@ -86,6 +87,8 @@ struct Fake { tasks: Mutex>, /// What RunTask starts. run: Option, + /// When non-empty, what successive RunTasks start (before `run`). + runs: Mutex>, logs: Vec, role: Option, connect_fails: bool, @@ -134,7 +137,11 @@ impl TaskApi for Fake { async fn run_task(&self, req: RunTaskInput) -> Result { self.log("run"); self.run_requests.lock().unwrap().push(req); - let t = self.run.clone().expect("a run was expected"); + let queued = { + let mut q = self.runs.lock().unwrap(); + (!q.is_empty()).then(|| q.remove(0)) + }; + let t = queued.or_else(|| self.run.clone()).expect("a run was expected"); self.tasks.lock().unwrap().insert(t.arn.clone(), t.clone()); Ok(t) } @@ -167,6 +174,10 @@ impl TaskApi for Fake { if self.stop_fails { return Err(AwsError::Other { message: "ExpiredToken".into() }); } + // As ECS does: a stopped task is no longer live. + if let Some(t) = self.tasks.lock().unwrap().get_mut(arn) { + t.desired_status = "STOPPED".into(); + } Ok(()) } async fn log_tail(&self, g: &str, st: &str, l: i32) -> Result, AwsError> { @@ -1384,6 +1395,90 @@ async fn an_ec2_start_runs_on_the_users_capacity_and_says_when_it_waits_for_an_i assert!(fake.describe_clusters.lock().unwrap().iter().all(|c| *c == user_cluster_arn())); } +/// ECS turns ECS Exec off on a RunTask that has to wait for an instance +/// (verified live): that task only brings the instance up; once placed it +/// is stopped and the task run again, onto the instance, with ECS Exec. +#[tokio::test] +async fn a_cold_ec2_start_runs_the_task_again_once_an_instance_is_up() { + let p = ec2_project(); + let execless = |last: &str, placed: bool| TaskInfo { exec_enabled: false, ..ec2_task(&p, "e1", last, false, placed) }; + let fake = Fake { + user_record: Some(user_record_param()), + runs: Mutex::new(vec![execless("PROVISIONING", false), ec2_task(&p, "e9", "PENDING", false, true)]), + ..Default::default() + }; + *fake.script.lock().unwrap() = vec![ + execless("PROVISIONING", false), + execless("PENDING", true), + TaskInfo { desired_status: "STOPPED".into(), ..execless("PENDING", true) }, + execless("STOPPED", true), + ec2_task(&p, "e9", "RUNNING", true, true), + ]; + let (r, steps) = start(&fake, &p).await; + let started = r.unwrap(); + assert_eq!(started.task.arn, ec2_task_arn("e9")); + let calls = fake.calls(); + assert_eq!(calls.iter().filter(|c| *c == "run").count(), 2, "{calls:?}"); + let stop = format!("stop {} {STOP_REASON}", ec2_task_arn("e1")); + let pos = |c: &str| calls.iter().rposition(|x| x == c).unwrap(); + assert!(calls.iter().position(|c| *c == stop).unwrap() < pos("run"), "{calls:?}"); + assert_eq!(*fake.stop_clusters.lock().unwrap(), [user_cluster_arn()]); + // Both requests ask for ECS Exec on the user's capacity. + for req in fake.run_requests.lock().unwrap().iter() { + assert_eq!(req.enable_execute_command(), Some(true)); + assert_eq!(req.capacity_provider_strategy()[0].capacity_provider(), USER_CLUSTER); + } + // The second task is the one recorded. + assert_eq!(*fake.recorded.lock().unwrap(), vec![Some(ec2_task_arn("e1")), Some(ec2_task_arn("e9"))]); + assert_eq!( + steps, + vec![ + PROGRESS_READING, + PROGRESS_PREPARING, + PROGRESS_STARTING, + PROGRESS_WAITING, + PROGRESS_INSTANCE, + PROGRESS_WAITING, + PROGRESS_CONNECTING + ] + ); +} + +#[tokio::test] +async fn a_second_task_without_ecs_exec_is_stopped_and_reported() { + let p = ec2_project(); + let execless = |id: &str, last: &str, placed: bool| TaskInfo { exec_enabled: false, ..ec2_task(&p, id, last, false, placed) }; + let fake = Fake { + user_record: Some(user_record_param()), + runs: Mutex::new(vec![execless("e1", "PROVISIONING", false), execless("e9", "PENDING", true)]), + ..Default::default() + }; + *fake.script.lock().unwrap() = vec![execless("e1", "PENDING", true), execless("e1", "STOPPED", true)]; + let (r, _) = start(&fake, &p).await; + assert_eq!(r.err().unwrap().lines().next(), Some(EXEC_OFF)); + let calls = fake.calls(); + assert!(calls.contains(&format!("stop {} {STOP_REASON}", ec2_task_arn("e9"))), "{calls:?}"); +} + +#[tokio::test] +async fn a_live_task_with_ecs_exec_off_is_stopped_and_replaced() { + let mut p = ec2_project(); + p.aws.as_mut().unwrap().task_arn = Some(ec2_task_arn("old")); + let old = TaskInfo { exec_enabled: false, ..ec2_task(&p, "old", "RUNNING", false, true) }; + let fake = Fake { + user_record: Some(user_record_param()), + listed_by_cluster: Some(HashMap::from([(user_cluster_arn(), vec![ec2_task_arn("old")])])), + run: Some(ec2_task(&p, "new", "RUNNING", true, true)), + ..Default::default() + } + .with_task(old); + let (r, _) = start(&fake, &p).await; + assert_eq!(r.unwrap().task.arn, ec2_task_arn("new")); + let calls = fake.calls(); + let stop = calls.iter().position(|c| *c == format!("stop {} {STOP_REASON}", ec2_task_arn("old"))).expect("the old task is stopped"); + assert!(stop < calls.iter().position(|c| c == "run").unwrap(), "{calls:?}"); +} + #[tokio::test] async fn a_fargate_start_never_reads_the_ec2_record() { let p = aws_project(StorageMode::Ephemeral); -- 2.52.0 From 6c7c2ea4eff349823c9a8712c4b924635a276964 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 16:35:30 -0800 Subject: [PATCH 15/29] fix(aws): keep Claude Code's sandbox off on EC2 too (E8) Measured live on the ECS-optimized AL2023 AMI (kernel 6.1, max_user_namespaces 30937): bwrap --unshare-user in the ECS task fails with "No permissions to create new namespace", as on Fargate. Docker's default seccomp profile refuses it without CAP_SYS_ADMIN. sandbox_allowed is false for every AWS project, and the Runtime toggle is locked off on EC2 as on Fargate. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/host/aws_host.rs | 14 ++++++++------ app/src-tauri/src/host/aws_host/tests.rs | 11 ++++++----- .../projects/home/config/AwsConfig.test.tsx | 10 ++++++---- .../projects/home/config/RuntimeSection.tsx | 8 ++++---- app/src/lib/awsWorkspace.ts | 2 +- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/app/src-tauri/src/host/aws_host.rs b/app/src-tauri/src/host/aws_host.rs index 1dc4b6c..7047808 100644 --- a/app/src-tauri/src/host/aws_host.rs +++ b/app/src-tauri/src/host/aws_host.rs @@ -146,11 +146,13 @@ fn is_registry_reference(name: &str) -> bool { pub type AwsEnv = (Vec<(String, String)>, Option); /// Whether Claude Code's sandbox (bubblewrap) may run where `project`'s task -/// runs — the one place this is decided. Not on Fargate (P9: it can't create -/// namespaces there, verified live); allowed on the user's EC2 instances -/// (E8: the ECS-optimized AMI permits user namespaces; the live test checks). -pub fn sandbox_allowed(project: &Project) -> bool { - project.aws.as_ref().is_some_and(|a| a.launch_type == LaunchType::Ec2) +/// runs — the one place this is decided. Not on AWS: Fargate can't create +/// namespaces (P9), and neither can an ECS task on the user's EC2 instance +/// (E8, measured live in phase 7: `bwrap --unshare-user` fails with "No +/// permissions to create new namespace" — Docker's default seccomp profile +/// refuses it without CAP_SYS_ADMIN, though the AMI allows user namespaces). +pub fn sandbox_allowed(_project: &Project) -> bool { + false } /// The environment pairs an AWS task gets: [`workspace_env`] with the same @@ -162,7 +164,7 @@ pub fn aws_env(project: &Project, settings: &AppSettings) -> Result { }); describe("RuntimeSection on EC2", () => { - it("enables Docker access, VPN and the sandbox, and says Docker access is root on the instance", () => { + it("enables Docker access and VPN, keeps the sandbox off, and says Docker access is root on the instance", () => { render(); - for (const name of ["Allow container spawning", "VPN support", "Sandbox mode"]) { + for (const name of ["Allow container spawning", "VPN support"]) { expect(toggle(name)).toBeEnabled(); } - expect(toggle("Sandbox mode")).toHaveAttribute("aria-checked", "true"); + // E8, measured live: bubblewrap can't run in an ECS task on EC2 either. + expect(toggle("Sandbox mode")).toBeDisabled(); + expect(toggle("Sandbox mode")).toHaveAttribute("aria-checked", "false"); expect(screen.getByText(/root on your own instance/)).toBeInTheDocument(); - expect(screen.queryByText(/Off on AWS for now/)).toBeNull(); + expect(screen.getByText(/Off on AWS for now/)).toBeInTheDocument(); }); }); diff --git a/app/src/components/projects/home/config/RuntimeSection.tsx b/app/src/components/projects/home/config/RuntimeSection.tsx index ebe8b6b..b2fc661 100644 --- a/app/src/components/projects/home/config/RuntimeSection.tsx +++ b/app/src/components/projects/home/config/RuntimeSection.tsx @@ -29,9 +29,9 @@ export default function RuntimeSection({ // Docker access and VPN need the user's own EC2 instance (not Fargate). const ec2 = aws && project.aws?.launch_type === "ec2"; const noPrivileged = aws && !ec2; - // Fargate can't run Claude Code's sandbox (P9); the user's own EC2 - // instance can (E8), so it follows the project there. - const sandboxOff = aws && !ec2; + // No ECS task can run Claude Code's sandbox: not on Fargate (P9), and not + // on the user's own EC2 instance either (E8, measured live). + const sandboxOff = aws; return ( <> Date: Mon, 16 Nov 2026 17:52:36 -0800 Subject: [PATCH 16/29] test(aws): live phase 7 EC2 checks a_phase7_ec2_workspace_round_trips: onboarding with per-user EC2 capacity through prepare_onboarding (tagged workspace role, all four admin files), its collision check and refusal, admin-tier scaling probes, a cold and a warm EC2 start (Docker access, VPN, ECS Exec into the bridge task), in-container checks (docker ps, wg/tun, src_valid_mark, bwrap, IMDS, introspection), RunTask on another user's cluster, stop and scale-in, removal, re-apply without EC2 with an instance up, offboard and destroy. The guard (ec2_cleanup) force-deletes any per-user EC2 capacity. Results in aws/README.md and the spec. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/live_tests.rs | 817 +++++++++++++++++- aws/README.md | 146 ++-- .../specs/2026-11-13-aws-ecs-host-design.md | 15 + 3 files changed, 912 insertions(+), 66 deletions(-) diff --git a/app/src-tauri/src/aws/live_tests.rs b/app/src-tauri/src/aws/live_tests.rs index 4623f19..cf43f5c 100644 --- a/app/src-tauri/src/aws/live_tests.rs +++ b/app/src-tauri/src/aws/live_tests.rs @@ -1773,6 +1773,13 @@ mod environment { config_file_before: Option>, /// `TRIPLEC_E2E_ECR_REPO`: the throwaway repository to force-delete. ecr_repo: Option, + /// Phase 7: the environment whose per-user EC2 capacity + /// (`triple-c---u-*`) the guard tears down, and the user's + /// owner key (instance role, user record). + ec2_env: Option, + ec2_okey: Option, + /// Auto Scaling groups a probe made outside that prefix. + probe_groups: Vec, } /// The whole phase-5 body: a hang anywhere becomes a panic the guard @@ -1802,6 +1809,9 @@ mod environment { Some(None) => std::env::remove_var("AWS_CONFIG_FILE"), None => {} } + if let Some(env) = &p.ec2_env { + ec2_cleanup(e, env, p.ec2_okey.as_deref(), &p.probe_groups).await; + } let ecs = aws_sdk_ecs::Client::new(&e.cfg); if let Some(cluster) = &p.cluster { let mut arns = Vec::new(); @@ -1918,6 +1928,201 @@ mod environment { } } + /// The AWS CLI as the e2e profile (`keys`: as that session instead): + /// (success, stdout, stderr). The app has no EC2 SDK crate. + async fn aws_cli(keys: Option<&AwsKeys>, region: &str, args: &[&str]) -> (bool, String, String) { + let mut cmd = tokio::process::Command::new("aws"); + cmd.args(["--region", region, "--output", "json"]); + match keys { + None => { + cmd.args(["--profile", &super::var("TRIPLEC_AWS_E2E_PROFILE")]); + } + Some(k) => { + cmd.env_remove("AWS_PROFILE") + .env("AWS_ACCESS_KEY_ID", &k.access_key_id) + .env("AWS_SECRET_ACCESS_KEY", &k.secret_access_key); + match &k.session_token { + Some(t) => cmd.env("AWS_SESSION_TOKEN", t), + None => cmd.env_remove("AWS_SESSION_TOKEN"), + }; + } + } + cmd.args(args); + match tokio::time::timeout(Duration::from_secs(120), cmd.output()).await { + Ok(Ok(o)) => ( + o.status.success(), + String::from_utf8_lossy(&o.stdout).into_owned(), + String::from_utf8_lossy(&o.stderr).into_owned(), + ), + Ok(Err(err)) => (false, String::new(), format!("aws cli: {err}")), + Err(_) => (false, String::new(), "aws cli: timed out".into()), + } + } + + /// Phase 7's guard, as the account admin: everything of `env`'s per-user + /// EC2 capacity (`triple-c---u-*`) and the probes' groups, so no + /// instance outlives a failed run. Tasks on the per-user clusters are + /// stopped, groups force-deleted (terminating their instances) and waited + /// for, leftover tagged instances terminated, then capacity providers, + /// container instances, clusters, launch templates, the user record and + /// the instance role/profile deleted. A resource already gone is fine + /// (the modules' destroy then finds nothing). Logs, never fails. + async fn ec2_cleanup(e: &E2e, env: &str, okey: Option<&str>, probe_groups: &[String]) { + let prefix = format!("triple-c-{env}--u-"); + let ecs = aws_sdk_ecs::Client::new(&e.cfg); + let asg = aws_sdk_autoscaling::Client::new(&e.cfg); + // Tasks on the per-user clusters. + let mut clusters = Vec::new(); + if let Ok(out) = ecs.list_clusters().send().await { + clusters.extend(out.cluster_arns().iter().filter(|a| a.contains(&format!(":cluster/{prefix}"))).cloned()); + } + for cluster in &clusters { + if let Ok(out) = ecs.list_tasks().cluster(cluster).send().await { + for arn in out.task_arns() { + eprintln!("cleanup: stopping EC2 task {arn}"); + let _ = ecs.stop_task().cluster(cluster).task(arn).reason("triple-c-e2e cleanup").send().await; + } + } + } + // Groups (force: terminates their instances, ignores protection). + let mut groups: Vec = probe_groups.to_vec(); + if let Ok(out) = asg.describe_auto_scaling_groups().send().await { + for g in out.auto_scaling_groups() { + let n = g.auto_scaling_group_name().unwrap_or_default(); + if n.starts_with(&prefix) && !groups.iter().any(|x| x == n) { + groups.push(n.to_string()); + } + } + } + for g in &groups { + match asg.delete_auto_scaling_group().auto_scaling_group_name(g).force_delete(true).send().await { + Ok(_) => eprintln!("cleanup: force-deleting Auto Scaling group {g}"), + Err(err) => { + let msg = format!("{err:?}"); + if !msg.contains("not found") && !msg.contains("ValidationError") { + eprintln!("cleanup: delete group {g}: {msg}"); + } + } + } + } + if !groups.is_empty() { + for _ in 0..60 { + let left = asg + .describe_auto_scaling_groups() + .set_auto_scaling_group_names(Some(groups.clone())) + .send() + .await + .map(|o| o.auto_scaling_groups().len()) + .unwrap_or(0); + if left == 0 { + break; + } + tokio::time::sleep(Duration::from_secs(10)).await; + } + } + // Any instance still tagged with this environment. + let (ok_, out, err) = aws_cli( + None, + &e.region, + &[ + "ec2", "describe-instances", + "--filters", &format!("Name=tag:triple-c:environment,Values={env}"), + "Name=instance-state-name,Values=pending,running,stopping,stopped", + "--query", "Reservations[].Instances[].InstanceId", + ], + ) + .await; + if ok_ { + let ids: Vec = serde_json::from_str(&out).unwrap_or_default(); + if !ids.is_empty() { + let mut args = vec!["ec2", "terminate-instances", "--instance-ids"]; + args.extend(ids.iter().map(String::as_str)); + let r = aws_cli(None, &e.region, &args).await; + eprintln!("cleanup: terminate {ids:?}: ok {}", r.0); + let mut args = vec!["ec2", "wait", "instance-terminated", "--instance-ids"]; + args.extend(ids.iter().map(String::as_str)); + let _ = aws_cli(None, &e.region, &args).await; + } + } else { + eprintln!("cleanup: describe instances: {err}"); + } + // Capacity providers: off their clusters, then deleted. + for cluster in &clusters { + let _ = ecs.put_cluster_capacity_providers().cluster(cluster).set_capacity_providers(Some(vec![])).set_default_capacity_provider_strategy(Some(vec![])).send().await; + } + if let Ok(out) = ecs.describe_capacity_providers().send().await { + for cp in out.capacity_providers() { + let n = cp.name().unwrap_or_default(); + if n.starts_with(&prefix) && cp.status() != Some(&aws_sdk_ecs::types::CapacityProviderStatus::Inactive) { + match ecs.delete_capacity_provider().capacity_provider(n).send().await { + Ok(_) => eprintln!("cleanup: deleted capacity provider {n}"), + Err(err) => eprintln!("cleanup: delete capacity provider {n}: {err:?}"), + } + } + } + } + for cluster in &clusters { + if let Ok(out) = ecs.list_container_instances().cluster(cluster).send().await { + for ci in out.container_instance_arns() { + let _ = ecs.deregister_container_instance().cluster(cluster).container_instance(ci).force(true).send().await; + } + } + // Busy (UpdateInProgress) while the provider detaches: retry. + for attempt in 0..12 { + match ecs.delete_cluster().cluster(cluster).send().await { + Ok(_) => { + eprintln!("cleanup: deleted cluster {cluster}"); + break; + } + Err(err) if attempt < 11 && format!("{err:?}").contains("UpdateInProgress") => { + tokio::time::sleep(Duration::from_secs(10)).await; + } + Err(err) => { + eprintln!("cleanup: delete cluster {cluster}: {err:?}"); + break; + } + } + } + } + // Launch templates. + let (ok_, out, _) = aws_cli( + None, + &e.region, + &["ec2", "describe-launch-templates", "--filters", &format!("Name=launch-template-name,Values={prefix}*"), "--query", "LaunchTemplates[].LaunchTemplateName"], + ) + .await; + if ok_ { + let names: Vec = serde_json::from_str(&out).unwrap_or_default(); + for n in names { + let r = aws_cli(None, &e.region, &["ec2", "delete-launch-template", "--launch-template-name", &n]).await; + eprintln!("cleanup: delete launch template {n}: ok {} {}", r.0, r.2.trim()); + } + } + if let Some(okey) = okey { + let ssm = aws_sdk_ssm::Client::new(&e.cfg); + let param = crate::aws::tofu_modules::user_record_parameter_name(env, okey); + if ssm.delete_parameter().name(¶m).send().await.is_ok() { + eprintln!("cleanup: deleted {param}"); + } + let role = crate::aws::tofu_modules::user_instance_role_name(env, okey); + if e.iam.remove_role_from_instance_profile().instance_profile_name(&role).role_name(&role).send().await.is_ok() { + eprintln!("cleanup: removed {role} from its instance profile"); + } + if e.iam.delete_instance_profile().instance_profile_name(&role).send().await.is_ok() { + eprintln!("cleanup: deleted instance profile {role}"); + } + if let Ok(out) = e.iam.list_role_policies().role_name(&role).send().await { + for pn in out.policy_names() { + let _ = e.iam.delete_role_policy().role_name(&role).policy_name(pn).send().await; + } + match e.iam.delete_role().role_name(&role).send().await { + Ok(_) => eprintln!("cleanup: deleted role {role}"), + Err(err) => eprintln!("cleanup: delete role {role}: {err:?}"), + } + } + } + } + /// Poll `f` every `every` until it returns `Some`, or `None` after `within`. async fn poll(within: Duration, every: Duration, mut f: F) -> Option where @@ -1960,6 +2165,8 @@ mod environment { conn: HostConnection, ws_cfg: SdkConfig, ws: CallerIdentity, + /// The environment admin role (fresh sessions via `Env::session`). + admin: Admin, } /// The workspace tests' common start: the environment (with @@ -1973,6 +2180,7 @@ mod environment { p5: &std::sync::Mutex, image: &str, max_workspace_hours: u32, + ec2: Option<&crate::aws::tofu_modules::Ec2Compute>, ) -> Deployed { use crate::aws::tofu_modules::{environment_cluster_name, user_file_system_token}; @@ -2003,18 +2211,43 @@ mod environment { let fs_token = user_file_system_token(&name, &okey); p5_lock(p5).fs_token = Some(fs_token.clone()); - // Onboarded by the admin (an onboarding from an admin bundle). - let (keys, _, _) = t.session(&admin).await; + // Onboarded by the admin (an onboarding from an admin bundle). With + // EC2 capacity (phase 7): the user's role carries the triple-c-user + // principal tag, and the vars come from the app's own pre-apply + // step (record, choice, name-collision check) as the admin. + let (keys, admin_cfg, _) = t.session(&admin).await; + let vars = match ec2 { + None => onboarding_vars(&name, ®ion, &owner, None).unwrap(), + Some(c) => { + use crate::aws::tofu_modules::EC2_USER_TAG_KEY; + use crate::commands::environment_commands::{prepare_onboarding, Ec2Choice}; + t.e.tag_role(&user, EC2_USER_TAG_KEY, &c.user_tag).await; + { + let mut g = p5_lock(p5); + g.ec2_env = Some(name.clone()); + g.ec2_okey = Some(okey.clone()); + } + let api = crate::aws::environments::SdkOnboardApi::new(&admin_cfg); + let t0 = std::time::Instant::now(); + let vars = prepare_onboarding(&api, &name, ®ion, &t.e.account, &owner, Some(Ec2Choice::Ec2(c.clone()))) + .await + .unwrap_or_else(|e| panic!("the pre-apply onboarding step: {e}")); + eprintln!("RESULT pre-apply EC2 collision check (free names) passed in {:?}: {vars}", t0.elapsed()); + vars + } + }; + let t0 = std::time::Instant::now(); let (_, outcome, denied) = t .run( ModuleKind::UserOnboard, Deployment::User { env: &name, owner_key: &okey }, - &onboarding_vars(&name, ®ion, &owner, None).unwrap(), + &vars, TofuOp::Apply, t.keys_env(&keys), ) .await; assert_ok("onboard the workspace user", &outcome, &denied); + eprintln!("RESULT onboarding apply: {:?}", t0.elapsed()); let (_, exec_role) = user_role_names(&name, &okey); // Test-only: pull from the throwaway private ECR repository. @@ -2062,7 +2295,7 @@ mod environment { let ws = caller_identity(&ws_cfg).await.expect("workspace user identity"); assert_eq!(ws.user_id, owner, "the profile session is the onboarded owner"); eprintln!("workspace user: {}", ws.arn); - Deployed { region, name, owner, okey, fs_token, conn, ws_cfg, ws } + Deployed { region, name, owner, okey, fs_token, conn, ws_cfg, ws, admin } } /// Phase 5: a Fargate workspace's whole life through `ProjectHost::Aws`, @@ -2119,8 +2352,8 @@ log_stream_prefix, project_secret_name, task_family}; // Boxed: the body's state machine is far larger than a test // thread's 2 MiB stack once it is moved into the timeout. let inner = Box::pin(async { - let Deployed { region, name, owner, okey, fs_token, conn, ws_cfg, ws } = - deploy_for_workspace_user(&t, &p5, &image, 0).await; + let Deployed { region, name, owner, okey, fs_token, conn, ws_cfg, ws, .. } = + deploy_for_workspace_user(&t, &p5, &image, 0, None).await; let mut settings = AppSettings::default(); settings.hosts = vec![conn]; @@ -2579,8 +2812,8 @@ log_stream_prefix, project_secret_name, task_family}; let p5 = std::sync::Mutex::new(Phase5 { ecr_repo, ..Default::default() }); let inner = Box::pin(async { // ── 1. the environment carries the lifetime cap ── - let Deployed { region, name, owner: _, okey, fs_token: _, conn, ws_cfg, ws } = - deploy_for_workspace_user(&t, &p5, &image, 1).await; + let Deployed { region, name, okey, conn, ws_cfg, ws, .. } = + deploy_for_workspace_user(&t, &p5, &image, 1, None).await; let env = crate::aws::runtime::read_environment(&SdkRuntimeApi::new(&ws_cfg), &name, &ws.account, ®ion) .await .expect("the environment record, as the workspace user"); @@ -2927,4 +3160,572 @@ log_stream_prefix, project_secret_name, task_family}; }) .await; } + + // ─────────────────────────────────────────────── phase 7: ECS on EC2 + + /// The phase-7 body: two cold starts, a scale-in wait (managed scaling + /// takes ~15 minutes to remove an idle instance) and three applies. + const PHASE7_TIMEOUT: Duration = Duration::from_secs(110 * 60); + + /// A group's (instance count, desired capacity, `id:state` list) as the + /// account admin; `None` when it does not exist. + async fn group_size(asg: &aws_sdk_autoscaling::Client, name: &str) -> Option<(usize, i32, Vec)> { + let out = asg.describe_auto_scaling_groups().auto_scaling_group_names(name).send().await.ok()?; + let g = out.auto_scaling_groups().first()?; + let ids = g + .instances() + .iter() + .map(|i| format!("{}:{}", i.instance_id().unwrap_or_default(), i.lifecycle_state().map(|s| s.as_str()).unwrap_or("?"))) + .collect(); + Some((g.instances().len(), g.desired_capacity().unwrap_or(-1), ids)) + } + + /// Instances still tagged with `env` and not terminated, as the account admin. + async fn live_env_instances(region: &str, env: &str) -> Vec { + let (ok_, out, err) = aws_cli( + None, + region, + &[ + "ec2", "describe-instances", + "--filters", &format!("Name=tag:triple-c:environment,Values={env}"), + "Name=instance-state-name,Values=pending,running,stopping,stopped,shutting-down", + "--query", "Reservations[].Instances[].[InstanceId,State.Name]", + ], + ) + .await; + assert!(ok_, "describe-instances: {err}"); + let rows: Vec> = serde_json::from_str(&out).unwrap_or_default(); + rows.into_iter().map(|r| r.join(":")).collect() + } + + /// Phase 7: an EC2 project's whole life on the user's own capacity + /// (ECS on EC2, bridge networking, scale to zero), as a role holding + /// only the workspace files and carrying the `triple-c-user` principal + /// tag (a role tag: an assumed-role session's principal tags), onboarded + /// with `m7i.large`, at most 1 instance, by the environment admin + /// holding all four admin files. Run with `scripts/aws-e2e-workspace.sh` + /// and `TRIPLEC_E2E_TEST=aws::live_tests::environment::a_phase7_ec2_workspace_round_trips`. + /// + /// Covers: the onboarding's resources and its pre-apply collision check + /// (and its refusal for another owner); admin-tier probes of the + /// scaling file (`$Latest`, a pinned control, an unsupported type in a + /// template version, a capacity provider over a non-Triple-C group); + /// a cold start with Docker access, VPN and the sandbox on (instance + /// launch, ECS Exec port forward into the bridge-mode task), `docker + /// ps`, a WireGuard/TUN interface, `src_valid_mark`, bubblewrap, IMDS + /// and the agent's introspection port from the container; RunTask on + /// another user's cluster (the wrong-triple-c-user message); stop and + /// the scale-in to zero; a second start; removal; re-applying the + /// onboarding without EC2 (drain and delete with an instance still up); + /// offboarding and the environment's destroy, all as the admin tier. + /// Its guard (`ec2_cleanup`) force-deletes whatever EC2 capacity is + /// left. About one m7i.large instance-hour. + #[tokio::test] + #[ignore] + async fn a_phase7_ec2_workspace_round_trips() { + use crate::aws::environments::{OnboardApi, SdkOnboardApi, UserCompute, UserRecord}; + use crate::aws::runtime::{read_user_record, SdkRuntimeApi}; + use crate::aws::tasks::{ec2_run_error, ec2_run_task_request, SdkTaskApi, TaskApi, EC2_TAG_MISMATCH}; + use crate::aws::tofu_modules::{user_ec2_stem, user_instance_role_name, Ec2Compute}; + use crate::aws::workspace::workspace_tags; + use crate::commands::environment_commands::{prepare_onboarding, Ec2Choice}; + use crate::host::aws_host::PROGRESS_INSTANCE; + use crate::host::lifecycle::ProjectHost; + use crate::models::app_settings::ImageSource; + use crate::models::project::{AwsPlacement, AwsWorkspaceConfig, LaunchType, StorageMode}; + use crate::models::{AppSettings, Project}; + use crate::storage::projects_store::ProjectsStore; + + let image = super::var("TRIPLEC_E2E_IMAGE"); + let ecr_repo = std::env::var("TRIPLEC_E2E_ECR_REPO").ok().filter(|r| !r.is_empty()); + env_e2e(|t| async move { + let p5 = std::sync::Mutex::new(Phase5 { ecr_repo, ..Default::default() }); + let inner = Box::pin(async { + // TRIPLEC_E2E_PHASE7_SHORT=1: the life cycle only (no probes, no + // in-container checks or isolation, no scale-in wait; the second + // start is then warm, on the instance still up). + let quick = std::env::var("TRIPLEC_E2E_PHASE7_SHORT").is_ok_and(|v| v == "1"); + let short = uuid::Uuid::new_v4().simple().to_string(); + let user_tag = format!("e2e{}", &short[..6]); + let compute = Ec2Compute { instance_type: "m7i.large".into(), max_instances: 1, user_tag: user_tag.clone() }; + let Deployed { region, name, owner, okey, conn, ws_cfg, ws, admin, .. } = + deploy_for_workspace_user(&t, &p5, &image, 0, Some(&compute)).await; + let account = t.e.account.clone(); + let stem = user_ec2_stem(&name, &user_tag); + let asg_admin = aws_sdk_autoscaling::Client::new(&t.e.cfg); + let ecs_admin = aws_sdk_ecs::Client::new(&t.e.cfg); + + // ── 1. what the onboarding made ── + let groups = ok("describe the group", asg_admin.describe_auto_scaling_groups().auto_scaling_group_names(&stem).send().await); + let group = groups.auto_scaling_groups().first().expect("the user's Auto Scaling group").clone(); + let subnets = group.vpc_zone_identifier().unwrap_or_default().to_string(); + let group_tags: Vec<(String, String)> = group + .tags() + .iter() + .map(|t| (t.key().unwrap_or_default().to_string(), t.value().unwrap_or_default().to_string())) + .collect(); + eprintln!( + "RESULT group {stem}: min {:?} max {:?} desired {:?}, template {:?}, protect {:?}, tags {group_tags:?}", + group.min_size(), + group.max_size(), + group.desired_capacity(), + group.launch_template().map(|l| (l.launch_template_name(), l.version())), + group.new_instances_protected_from_scale_in() + ); + assert_eq!((group.min_size(), group.max_size()), (Some(0), Some(1))); + let cl = ok( + "describe the user's cluster", + ecs_admin.describe_clusters().clusters(&stem).include(aws_sdk_ecs::types::ClusterField::Tags).send().await, + ); + let cluster = cl.clusters().first().expect("the user's cluster"); + eprintln!( + "RESULT cluster {stem}: {:?}, providers {:?}, default strategy {:?}, tags {:?}", + cluster.status(), + cluster.capacity_providers(), + cluster.default_capacity_provider_strategy().iter().map(|s| s.capacity_provider()).collect::>(), + cluster.tags().iter().map(|t| (t.key().unwrap_or_default(), t.value().unwrap_or_default())).collect::>() + ); + let cps = ok("describe the capacity provider", ecs_admin.describe_capacity_providers().capacity_providers(&stem).send().await); + let cp = cps.capacity_providers().first().expect("the capacity provider"); + eprintln!( + "RESULT capacity provider {stem}: {:?}, managed scaling {:?}, termination protection {:?}", + cp.status(), + cp.auto_scaling_group_provider().and_then(|a| a.managed_scaling()).map(|m| (m.status(), m.target_capacity())), + cp.auto_scaling_group_provider().map(|a| a.managed_termination_protection()) + ); + let (_, lt, _) = aws_cli( + None, + ®ion, + &["ec2", "describe-launch-template-versions", "--launch-template-name", &stem, "--query", + "LaunchTemplateVersions[].[VersionNumber,LaunchTemplateData.InstanceType,LaunchTemplateData.ImageId,LaunchTemplateData.MetadataOptions]"], + ) + .await; + eprintln!("RESULT launch template {stem}: {}", lt.split_whitespace().collect::>().join(" ")); + let role_name = user_instance_role_name(&name, &okey); + let prof = ok("get the instance profile", t.e.iam.get_instance_profile().instance_profile_name(&role_name).send().await); + eprintln!( + "RESULT instance profile {role_name}: roles {:?}", + prof.instance_profile().map(|p| p.roles().iter().map(|r| r.role_name().to_string()).collect::>()) + ); + let record = read_user_record(&SdkRuntimeApi::new(&ws_cfg), &name, &okey, &account, ®ion).await.expect("read the user record"); + eprintln!("RESULT user record, as the workspace user: {record:?}"); + let Some(rec) = record.valid().cloned() else { panic!("the user record is not valid: {record:?}") }; + assert_eq!((rec.instance_type.as_str(), rec.max_instances, rec.user_tag.as_str()), ("m7i.large", 1, user_tag.as_str())); + assert!(rec.cluster_arn.ends_with(&format!(":cluster/{stem}")), "{}", rec.cluster_arn); + + // ── 1b / 6. the collision check's reads, and its refusal ── + let (akeys, acfg, _) = t.session(&admin).await; + let oapi = SdkOnboardApi::new(&acfg); + let held = oapi.cluster(&stem).await.expect("DescribeClusters include=TAGS as the admin tier"); + eprintln!("RESULT DescribeClusters include=TAGS as the environment admin: {held:?}"); + let held = held.expect("the cluster is found"); + assert!(held.tags.iter().any(|(k, v)| k == "triple-c:owner" && *v == owner), "{held:?}"); + let missing = oapi.cluster(&format!("{stem}zz")).await; + eprintln!("RESULT DescribeClusters on a missing name: {missing:?}"); + assert!(matches!(missing, Ok(None)), "{missing:?}"); + let missing_group = oapi.group(&format!("{stem}zz")).await; + eprintln!("RESULT DescribeAutoScalingGroups on a missing name: {missing_group:?}"); + assert!(matches!(missing_group, Ok(None)), "{missing_group:?}"); + let refused = prepare_onboarding(&oapi, &name, ®ion, &account, "AROAEXAMPLEOTHER0000:bob", Some(Ec2Choice::Ec2(compute.clone()))).await; + eprintln!("RESULT onboarding another owner with the same triple-c-user value: {refused:?}"); + let refused = refused.expect_err("another owner's onboarding with the same tag is refused"); + assert!(refused.to_string().contains("another onboarding"), "{refused}"); + + if !quick { + // ── 6. the scaling file's open points, as the environment admin ── + let asg_env = aws_sdk_autoscaling::Client::new(&acfg); + let ecs_env = aws_sdk_ecs::Client::new(&acfg); + let probe_tags = |n: &str| -> Vec { + group_tags + .iter() + .filter(|(k, _)| k.starts_with("triple-c:")) + .map(|(k, v)| { + aws_sdk_autoscaling::types::Tag::builder() + .key(k) + .value(v) + .resource_id(n) + .resource_type("auto-scaling-group") + .propagate_at_launch(false) + .build() + }) + .collect() + }; + let create_group = |client: aws_sdk_autoscaling::Client, n: String, version: String, tags: Vec| { + let subnets = subnets.clone(); + let lt_name = stem.clone(); + async move { + client + .create_auto_scaling_group() + .auto_scaling_group_name(&n) + .launch_template( + aws_sdk_autoscaling::types::LaunchTemplateSpecification::builder() + .launch_template_name(lt_name) + .version(version) + .build(), + ) + .min_size(0) + .max_size(0) + .desired_capacity(0) + .vpc_zone_identifier(subnets) + .set_tags(Some(tags)) + .send() + .await + .map(|_| ()) + .map_err(|e| classify_sdk_error("autoscaling:CreateAutoScalingGroup", &e).to_string()) + } + }; + let delete_group = |n: String| { + let client = asg_admin.clone(); + async move { + let _ = client.delete_auto_scaling_group().auto_scaling_group_name(&n).force_delete(true).send().await; + } + }; + // $Latest must be denied (LaunchTemplateVersionSpecified). + let pa = format!("{stem}-pa"); + let r = create_group(asg_env.clone(), pa.clone(), "$Latest".into(), probe_tags(&pa)).await; + eprintln!("RESULT probe: CreateAutoScalingGroup with $Latest as the environment admin: {r:?}"); + if r.is_ok() { + eprintln!("RESULT WARNING: $Latest was allowed"); + delete_group(pa).await; + } + // The control: the same create pinned to version 1 is allowed + // (InstanceTypes filled from the template). + let pb = format!("{stem}-pb"); + let r = create_group(asg_env.clone(), pb.clone(), "1".into(), probe_tags(&pb)).await; + eprintln!("RESULT probe: the same create pinned to version 1 (control): {r:?}"); + if r.is_ok() { + let d = asg_env.delete_auto_scaling_group().auto_scaling_group_name(&pb).send().await; + eprintln!("RESULT probe: DeleteAutoScalingGroup of it as the environment admin: {:?}", d.map(|_| ()).map_err(|e| classify_sdk_error("autoscaling:DeleteAutoScalingGroup", &e).to_string())); + delete_group(pb).await; + } + // A template version naming an unsupported type, then a group pinned to it. + let (made, out, err) = aws_cli( + Some(&akeys), + ®ion, + &["ec2", "create-launch-template-version", "--launch-template-name", &stem, "--source-version", "1", + "--launch-template-data", r#"{"InstanceType":"p5.48xlarge"}"#, "--query", "LaunchTemplateVersion.VersionNumber"], + ) + .await; + eprintln!("RESULT probe: CreateLaunchTemplateVersion with p5.48xlarge as the environment admin: ok {made} {} {}", out.trim(), err.trim()); + if made { + let pc = format!("{stem}-pc"); + let r = create_group(asg_env.clone(), pc.clone(), out.trim().to_string(), probe_tags(&pc)).await; + eprintln!("RESULT probe: CreateAutoScalingGroup pinned to the p5.48xlarge version: {r:?}"); + if r.is_ok() { + eprintln!("RESULT WARNING: a group of an unsupported type was allowed"); + delete_group(pc).await; + } + } + // A Triple-C capacity provider over a group that isn't Triple-C's. + let foreign_group = format!("e2e-untagged-{}", &short[..10]); + p5_lock(&p5).probe_groups.push(foreign_group.clone()); + let r = create_group(asg_admin.clone(), foreign_group.clone(), "1".into(), Vec::new()).await; + eprintln!("RESULT probe: account admin creates the untagged group {foreign_group}: {r:?}"); + if r.is_ok() { + let arn = ok("describe the untagged group", asg_admin.describe_auto_scaling_groups().auto_scaling_group_names(&foreign_group).send().await) + .auto_scaling_groups() + .first() + .and_then(|g| g.auto_scaling_group_arn().map(str::to_string)) + .unwrap(); + let pd = format!("{stem}-pd"); + let r = ecs_env + .create_capacity_provider() + .name(&pd) + .auto_scaling_group_provider( + aws_sdk_ecs::types::AutoScalingGroupProvider::builder() + .auto_scaling_group_arn(arn) + .managed_termination_protection(aws_sdk_ecs::types::ManagedTerminationProtection::Disabled) + .build() + .unwrap(), + ) + .set_tags(Some( + group_tags + .iter() + .filter(|(k, _)| k.starts_with("triple-c:")) + .map(|(k, v)| aws_sdk_ecs::types::Tag::builder().key(k).value(v).build()) + .collect(), + )) + .send() + .await; + eprintln!( + "RESULT probe: CreateCapacityProvider {pd} over the untagged group, as the environment admin: {:?}", + r.as_ref().map(|_| ()).map_err(|e| classify_sdk_error("ecs:CreateCapacityProvider", e).to_string()) + ); + if r.is_ok() { + eprintln!("RESULT WARNING: a Triple-C capacity provider over a foreign group was allowed"); + let _ = ecs_admin.delete_capacity_provider().capacity_provider(&pd).send().await; + } + delete_group(foreign_group).await; + } + } + + // ── 2. start 1: cold, with an instance launch ── + let mut settings = AppSettings::default(); + settings.hosts = vec![conn]; + settings.image_source = ImageSource::Custom; + settings.custom_image_name = Some(image.clone()); + let mut project = Project::new("e2e-ec2".into(), Vec::new()); + project.host_id = Some("e2e-wsuser".into()); + project.aws_placement = Some(AwsPlacement { region: region.clone(), environment: name.clone() }); + project.allow_docker_access = true; + project.vpn_support_enabled = true; + project.sandbox_mode_enabled = true; + project.aws = Some(AwsWorkspaceConfig { + launch_type: LaunchType::Ec2, + cpu: 1024, + memory_mib: 4096, + storage: StorageMode::Hybrid, + wip_push_on_stop: true, + ..Default::default() + }); + let id = project.id.clone(); + { + let mut g = p5_lock(&p5); + g.project_id = Some(id.clone()); + g.secrets.push(crate::aws::tofu_modules::project_secret_name(&name, &okey, &id)); + } + let store_dir = tempfile::tempdir().unwrap(); + let store = ProjectsStore::over_file_for_test(store_dir.path().join("projects.json"), vec![project.clone()]); + let host = ProjectHost::for_project(&project); + let current = |store: &ProjectsStore| store.get(&id).unwrap(); + let api = SdkTaskApi::new(&ws_cfg); + let steps: Arc>> = Default::default(); + let t0 = std::sync::Mutex::new(std::time::Instant::now()); + let progress = |m: &str| { + let at = t0.lock().unwrap().elapsed(); + eprintln!(" progress +{at:?}: {m}"); + steps.lock().unwrap().push((at, m.to_string())); + }; + + let started = host.ensure_started(¤t(&store), &settings, &store, &progress).await; + if let Err(err) = &started { + // Debugging aid: hold the workspace for an admin to look + // at before the guard tears it down. + let pause: u64 = std::env::var("TRIPLEC_E2E_PAUSE_SECS").ok().and_then(|v| v.parse().ok()).unwrap_or(0); + if pause > 0 { + eprintln!("RESULT start 1 failed ({err}); pausing {pause}s for inspection (task {:?})", current(&store).aws.and_then(|a| a.task_arn)); + tokio::time::sleep(Duration::from_secs(pause)).await; + } + } + let target = started.expect("EC2 start 1"); + let first_start = t0.lock().unwrap().elapsed(); + let s1: Vec<(Duration, String)> = std::mem::take(&mut *steps.lock().unwrap()); + eprintln!("RESULT EC2 start 1 (cold, instance launch): {first_start:?}; steps {s1:?}"); + assert!(s1.iter().any(|(_, m)| m == PROGRESS_INSTANCE), "no \"Starting an instance\" step: {s1:?}"); + let aws1 = current(&store).aws.unwrap(); + let task1 = aws1.task_arn.clone().expect("the task ARN is stored"); + let revision1 = aws1.task_definition_arn.clone().expect("the revision is stored"); + assert!(task1.contains(&format!(":task/{stem}/")), "the task runs on the user's cluster: {task1}"); + let d = api.describe(&rec.cluster_arn, std::slice::from_ref(&task1)).await.expect("describe task 1"); + eprintln!("RESULT task 1: {:?}", d.first().map(|t| (&t.last_status, &t.container_instance_arn))); + eprintln!("RESULT group after start 1: {:?}", group_size(&asg_admin, &stem).await); + let td = ok("describe revision 1", ecs_admin.describe_task_definition().task_definition(&revision1).send().await); + let td = td.task_definition().unwrap(); + eprintln!( + "RESULT revision 1: network {:?}, compat {:?}, volumes {:?}", + td.network_mode(), + td.requires_compatibilities(), + td.volumes().iter().map(|v| v.name().unwrap_or_default()).collect::>() + ); + + // ── through the agent (ECS Exec port forward into the bridge task) ── + let (out, code) = sh(&target, "claude", "echo hello-from-ec2; id").await; + eprintln!("RESULT agent tunnel over ECS Exec into the bridge-mode task: exit {code}: {}", out.trim()); + assert_eq!(code, 0, "{out}"); + let (mut docker_ok, mut vpn_ok, mut src_valid_mark, mut bwrap_ok) = (true, true, true, false); + if !quick { + let (out, code) = sh(&target, "claude", "ls -l /var/run/docker.sock; docker ps 2>&1; docker version --format '{{.Server.Version}}' 2>&1").await; + eprintln!("RESULT docker ps as claude (exit {code}):\n{}", out.trim()); + docker_ok = code == 0; + let (out, code) = sh( + &target, + "root", + "ip link add wg0 type wireguard && ip link show wg0 && ip link del wg0 && echo WG-OK; \ + ip tuntap add tun0 mode tun && ip link show tun0 && ip link del tun0 && echo TUN-OK; \ + ls -l /dev/net/tun; sysctl net.ipv4.conf.all.src_valid_mark; grep CapEff /proc/self/status", + ) + .await; + eprintln!("RESULT VPN pieces as root (exit {code}):\n{}", out.trim()); + let (sudo_out, _) = sh(&target, "claude", "sudo -n ip link add wg1 type wireguard && sudo -n ip link del wg1 && echo SUDO-WG-OK 2>&1").await; + eprintln!("RESULT wireguard via sudo as claude: {}", sudo_out.trim()); + vpn_ok = out.contains("WG-OK") || out.contains("TUN-OK"); + src_valid_mark = out.contains("src_valid_mark = 1"); + let (bwrap, _) = sh( + &target, + "claude", + "bwrap --unshare-user --ro-bind / / true 2>&1; echo \"unshare-user rc=$?\"; \ + bwrap --ro-bind / / --dev /dev --proc /proc --unshare-all --die-with-parent true 2>&1; echo \"unshare-all rc=$?\"; \ + cat /proc/sys/user/max_user_namespaces 2>&1; uname -r", + ) + .await; + eprintln!("RESULT E8 bwrap on EC2:\n{}", bwrap.trim()); + bwrap_ok = bwrap.contains("unshare-user rc=0"); + let (imds, _) = sh( + &target, + "claude", + "tok=$(curl -s -m 3 -X PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds: 60'); \ + echo \"token rc=$? len=${#tok}\"; \ + curl -s -m 3 -o /dev/null -w 'imdsv1 http=%{http_code}\\n' http://169.254.169.254/latest/meta-data/; \ + gw=$(ip route | awk '/default/ {print $3}'); echo \"gateway $gw\"; \ + for h in \"$gw\" 127.0.0.1; do curl -s -m 3 -o /dev/null -w \"introspection $h:51678 http=%{http_code}\\n\" http://$h:51678/v1/metadata; done; \ + curl -s -m 3 http://$gw:51678/v1/metadata | head -c 300; echo; \ + test -n \"$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI\" && curl -s -m 3 http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI | grep -q AccessKeyId && echo TASK-ROLE-CREDS-OK || echo task-role-creds-missing", + ) + .await; + eprintln!("RESULT IMDS / introspection from the container:\n{}", imds.trim()); + assert!(imds.contains("len=0"), "the container got an IMDS token: {imds}"); + + // ── 4. isolation: RunTask on another triple-c-user's cluster ── + let other = format!("e2eother{}", &short[6..10]); + let other_cluster = user_ec2_stem(&name, &other); + let made = ok("admin creates another user's (empty) cluster", ecs_admin.create_cluster().cluster_name(&other_cluster).send().await); + let other_arn = made.cluster().and_then(|c| c.cluster_arn()).unwrap().to_string(); + let fake = UserCompute { + instance_type: "m7i.large".into(), + max_instances: 1, + user_tag: other.clone(), + cluster_arn: other_arn.clone(), + capacity_provider: other_cluster.clone(), + }; + let r = api.run_task(ec2_run_task_request(&fake, &revision1, &workspace_tags(&owner, &id, &name))).await.map_err(ec2_run_error); + eprintln!("RESULT RunTask on {other_cluster} as triple-c-user {user_tag}: {r:?}"); + match r { + Err(crate::aws::error::AwsError::AccessDenied { message, .. }) => assert!(message.contains(EC2_TAG_MISMATCH), "{message}"), + other => panic!("RunTask on another user's cluster: expected AccessDenied, got {other:?}"), + } + let _ = ecs_admin.delete_cluster().cluster(&other_arn).send().await; + } + + // ── 5. stop 1, then the scale-in to zero ── + let t2 = std::time::Instant::now(); + host.stop_project(¤t(&store), &settings).await.expect("stop 1"); + poll(Duration::from_secs(300), Duration::from_secs(5), || async { + let d = api.describe(&rec.cluster_arn, std::slice::from_ref(&task1)).await.ok()?; + (d.first()?.last_status == "STOPPED").then_some(()) + }) + .await + .expect("task 1 never stopped"); + let stopped_after = t2.elapsed(); + eprintln!("RESULT stop 1: STOPPED after {stopped_after:?}"); + store.set_aws_runtime(&id, None, aws1.access_point_id.clone(), Some(revision1.clone()), None).unwrap(); + let mut scale_in = Duration::ZERO; + if !quick { + let mut last: Option<(usize, i32)> = None; + let mut scaled = None; + let deadline = std::time::Instant::now() + Duration::from_secs(40 * 60); + while std::time::Instant::now() < deadline { + let now = group_size(&asg_admin, &stem).await; + let key = now.as_ref().map(|n| (n.0, n.1)); + if key != last { + eprintln!(" group +{:?} after STOPPED: {now:?}", t2.elapsed() - stopped_after); + last = key; + } + if key == Some((0, 0)) { + scaled = Some(()); + break; + } + tokio::time::sleep(Duration::from_secs(30)).await; + } + scale_in = t2.elapsed() - stopped_after; + eprintln!("RESULT scale-in to 0 instances: {scaled:?} after {:.1} min from STOPPED", scale_in.as_secs_f64() / 60.0); + assert!(scaled.is_some(), "the group did not scale back to zero within 40 minutes"); + } + + // ── start 2 ── + *t0.lock().unwrap() = std::time::Instant::now(); + let target2 = host.ensure_started(¤t(&store), &settings, &store, &progress).await.expect("EC2 start 2"); + let second_start = t0.lock().unwrap().elapsed(); + let s2: Vec<(Duration, String)> = std::mem::take(&mut *steps.lock().unwrap()); + eprintln!("RESULT EC2 start 2 ({}): {second_start:?}; steps {s2:?}", if quick { "warm: right after stop 1" } else { "after scale-in" }); + let (out, code) = sh(&target2, "claude", "echo again; docker ps -q | wc -l").await; + assert_eq!(code, 0, "{out}"); + let aws2 = current(&store).aws.unwrap(); + let task2 = aws2.task_arn.clone().unwrap(); + host.stop_project(¤t(&store), &settings).await.expect("stop 2"); + poll(Duration::from_secs(300), Duration::from_secs(5), || async { + let d = api.describe(&rec.cluster_arn, std::slice::from_ref(&task2)).await.ok()?; + (d.first()?.last_status == "STOPPED").then_some(()) + }) + .await + .expect("task 2 never stopped"); + store.set_aws_runtime(&id, None, aws2.access_point_id.clone(), aws2.task_definition_arn.clone(), None).unwrap(); + let removed = host.remove_aws_resources(¤t(&store), &settings, true).await; + eprintln!("RESULT remove_aws_resources: {:?}", removed.as_ref().map_err(|e| e.chars().take(400).collect::())); + removed.expect("remove the project's resources"); + + // ── 7. the onboarding re-applied without EC2, an instance still up ── + eprintln!("RESULT group before the re-apply without EC2: {:?}", group_size(&asg_admin, &stem).await); + let (keys, acfg, _) = t.session(&admin).await; + let vars = prepare_onboarding(&SdkOnboardApi::new(&acfg), &name, ®ion, &account, &owner, Some(Ec2Choice::None)) + .await + .expect("the pre-apply step without EC2"); + let t5 = std::time::Instant::now(); + let (_, outcome, denied) = t + .run(ModuleKind::UserOnboard, Deployment::User { env: &name, owner_key: &okey }, &vars, TofuOp::Apply, t.keys_env(&keys)) + .await; + eprintln!("RESULT re-apply without EC2: {:?} in {:?}", outcome.summary, t5.elapsed()); + assert_ok("re-apply the onboarding without EC2", &outcome, &denied); + let g = group_size(&asg_admin, &stem).await; + let inst = live_env_instances(®ion, &name).await; + let cps = ecs_admin.describe_capacity_providers().capacity_providers(&stem).send().await; + let cl = ecs_admin.describe_clusters().clusters(&stem).send().await; + let (_, lt, lt_err) = aws_cli(None, ®ion, &["ec2", "describe-launch-templates", "--launch-template-names", &stem]).await; + let prof = t.e.iam.get_instance_profile().instance_profile_name(&role_name).send().await; + let role = t.e.iam.get_role().role_name(&role_name).send().await; + let record = read_user_record(&SdkRuntimeApi::new(&ws_cfg), &name, &okey, &account, ®ion).await; + eprintln!( + "RESULT after the re-apply: group {g:?}; live instances {inst:?}; provider {:?}; cluster {:?}; template {} {}; profile gone {}; role gone {}; record {record:?}", + cps.as_ref().map(|o| o.capacity_providers().iter().map(|c| c.status().cloned()).collect::>()), + cl.as_ref().map(|o| o.clusters().iter().map(|c| c.status().map(str::to_string)).collect::>()), + lt.trim().chars().take(100).collect::(), + lt_err.trim().chars().take(100).collect::(), + prof.is_err(), + role.is_err(), + ); + assert!(g.is_none(), "the group is gone"); + assert!(inst.is_empty(), "no instance is left: {inst:?}"); + assert!(prof.is_err() && role.is_err(), "the instance profile and role are gone"); + assert!(matches!(record, Ok(UserRecord::Absent)), "{record:?}"); + + // ── offboard, then destroy the environment, as the environment admin ── + if let Some(role) = p5_lock(&p5).exec_role.take() { + let _ = t.e.iam.delete_role_policy().role_name(&role).policy_name(ECR_POLICY).send().await; + } + let (keys, _, _) = t.session(&admin).await; + let (_, outcome, denied) = t + .run(ModuleKind::UserOnboard, Deployment::User { env: &name, owner_key: &okey }, &vars, TofuOp::Destroy, t.keys_env(&keys)) + .await; + assert_ok("offboard", &outcome, &denied); + let (_, outcome, denied) = t + .run( + ModuleKind::Environment, + Deployment::Environment(&name), + &environment_vars(&name, ®ion, &NetworkChoice::Public, 0).unwrap(), + TofuOp::Destroy, + t.keys_env(&keys), + ) + .await; + assert_ok("destroy the environment", &outcome, &denied); + eprintln!( + "RESULT summary: docker {docker_ok}, vpn {vpn_ok}, src_valid_mark {src_valid_mark}, bwrap {bwrap_ok}, start1 {first_start:?}, scale-in {:.1} min, start2 {second_start:?}", + scale_in.as_secs_f64() / 60.0 + ); + let _ = ws; + assert!(docker_ok, "docker ps failed as claude"); + assert!(vpn_ok && src_valid_mark, "the VPN pieces are missing"); + }); + let body = async { + if tokio::time::timeout(PHASE7_TIMEOUT, inner).await.is_err() { + panic!("the phase-7 body did not finish in {PHASE7_TIMEOUT:?}"); + } + }; + let result = std::panic::AssertUnwindSafe(body).catch_unwind().await; + let guard = std::mem::take(&mut *p5_lock(&p5)); + phase5_cleanup(&t.e, &guard).await; + if let Err(panic) = result { + std::panic::resume_unwind(panic); + } + }) + .await; + } } diff --git a/aws/README.md b/aws/README.md index 987b41c..27750d8 100644 --- a/aws/README.md +++ b/aws/README.md @@ -554,66 +554,55 @@ aws iam attach-user-policy --user-name \ `containerOverrides`: every workspace user can read them through `ecs:Describe*` on `*`. Use Secrets Manager (`triple-c/*`) references instead. -**Phase 7 (per-user EC2 capacity): still open until the live run (Task 7)** +**Phase 7 (per-user EC2 capacity): the live run's answers (Task 7, 2026-11-16)** -The unit tests' evaluator is not IAM; these points of the compute file and the boundary are -expected, not verified: +The unit tests' evaluator is not IAM. What the live run (see "Phase 7: ECS on EC2" below) settled, +and what is still open: -- **Creating an Auto Scaling group checks the caller's launch permissions.** Expected: a dry run - of `ec2:RunInstances` from the launch template as the admin, with `ec2:LaunchTemplate` set on - every resource, the template's own tags visible, `ec2:Owner = amazon` on the image, and - `iam:PassRole` of the instance role to `ec2.amazonaws.com`. If the dry run omits - `ec2:LaunchTemplate` on some resource, the group's create is denied and that statement needs - another condition. -- **`iam:AddRoleToInstanceProfile`** is expected to need `iam:PassRole` of the role; which - `iam:PassedToService` IAM sends then (if any) is unknown, and only `ec2.amazonaws.com` is allowed. -- **`ecs:PutClusterCapacityProviders`** may be authorized against the capacity provider as well as - the cluster (both are allowed); **`ecs:CreateCapacityProvider`** may check the caller's - `autoscaling:Describe*` on the group (allowed) or create ECS's service-linked role (allowed). -- **Service-linked roles.** The Auto Scaling and ECS roles exist in most accounts already; - creating them is allowed only for those two services. Whether creating a group in an account - without one creates it as the caller (needing this grant) is not verified. -- **The instance role's agent calls** (`ecs:Poll`, `StartTelemetrySession`, - `UpdateContainerInstancesState`) are expected to be authorized against - `container-instance//` and the rest against the cluster; the boundary allows both. -- **The public AMI parameter's ARN** has no account (`arn:aws:ssm:::parameter/aws/…`); - `arn:aws:ssm:*::parameter/aws/service/ecs/optimized-ami/*` is expected to match it. -- **Version pinning.** `autoscaling:LaunchTemplateVersionSpecified` is expected to be `true` for a - numeric version and `false` for `$Latest`/`$Default`, and absent on an update that names no - template (allowed by `BoolIfExists`, so the drain before destroy works). Probe: create a group - with `$Latest` as the admin; it must be denied. -- **`ec2:IsLaunchTemplateResource`** is expected to be `true` on the image and security group the - template names, and `aws:RequestTag` to carry the template's tag specifications for the instance - and volume. If the group's launch check doesn't send either, that statement denies the create. -- ~~**`autoscaling:InstanceTypes`** required on a group create.~~ **Verified live (phase 7):** a - template-only create sends **no** `autoscaling:InstanceTypes`, so the `Null: false` denied every - group (the first live onboarding failed on it); it is dropped. Creating a group runs the caller's - own `ec2:RunInstances` check on the template ("You are not authorized to use launch template" - otherwise), so `ec2:InstanceType` holds the type; a `MixedInstancesPolicy` override of an - unsupported type is denied by both checks. -- **Instance types in templates.** `ec2:CreateLaunchTemplate`/`CreateLaunchTemplateVersion` are - not known to support `ec2:InstanceType` (not in the service authorization reference as I know - it), so a template may *name* any type; it can only be *launched* (directly or by a group) with a - supported one. Probe: create a version with `p5.48xlarge` and pin a group to it; the group - create must be denied. -- **`aws:PrincipalTag/triple-c-user` from Identity Center** attributes for access control is - expected in the SSO session's request context, and `${aws:PrincipalTag/triple-c-user}` in - `ArnNotLike` to resolve from it. Probe: as a tagged and an untagged user, `RunTask` on a - per-user cluster. -- **Tags at group create.** If `CreateAutoScalingGroup` with tags also needs - `autoscaling:CreateOrUpdateTags`, it is denied (that is allowed only on an already-tagged - group); then add it to the create statement with the same conditions. -- **A `triple-c-*` capacity provider pointing at someone else's group.** Whether - `CreateCapacityProvider` checks the caller's rights on the named Auto Scaling group is unknown; - if it does not, an admin could put a non-Triple-C group under a Triple-C capacity provider (and - ECS's managed scaling would then scale it). Probe: create one naming an untagged group. -- **`aws:PrincipalTag` for the instance role**: the role's session is expected to carry its role - tags, so `${aws:PrincipalTag/triple-c:cluster}` resolves for the agent's calls. -- **IMDS and Docker access.** Tasks use `awsvpc`, with `ECS_AWSVPC_BLOCK_IMDS=true` and a hop - limit of 1 so a task can't read the instance role. A project with Docker access mounts the - host's socket, so its user can start a host-network container and read IMDS (and so the - instance role): accepted, since Docker access is root on the user's own instance; the boundary - keeps that role on the user's own cluster. +- ✓ **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 + pinned to a template version naming `p5.48xlarge` was refused with "You are not authorized to + use launch template", so the create does run the caller's `ec2:RunInstances` check, with + `ec2:LaunchTemplate`, `ec2:IsLaunchTemplateResource`, the template's tags and the instance role's + `iam:PassRole` all as the statements expect. +- ✓ **`iam:AddRoleToInstanceProfile`, `ecs:PutClusterCapacityProviders`, + `ecs:CreateCapacityProvider`**, the public AMI parameter read, and tags at group create + (`autoscaling:CreateOrUpdateTags` was not needed separately): all passed in the real apply, + with no denial. Which context keys each one sent is not visible; the policy is not narrowed further. +- — **Service-linked roles.** The test account already had both. Creating them as the admin is + still unverified. +- ✓ **The instance role's agent calls**, under the boundary: the instance registered into the user's + cluster, polled, and ran tasks. ECR pulls through the execution role and logs worked too. So the + `triple-c:cluster` role tag resolves as `${aws:PrincipalTag/triple-c:cluster}`. +- ✓ **Version pinning.** `$Latest` and `$Default` are denied, and a numeric version is allowed (a + probe group with min/max 0, created and deleted as the admin). +- ✗→fixed **`autoscaling:InstanceTypes` required on a group create.** A template-only create sends + **no** `autoscaling:InstanceTypes`, so the `Null: false` denied every group (the first live + onboarding failed on it). It is dropped. Creating a group runs the caller's own + `ec2:RunInstances` check on the template, so `ec2:InstanceType` holds the type. A + `MixedInstancesPolicy` override of an unsupported type is denied by both checks + (`ForAllValues` on the key once present, and the launch check). +- ✓ **Instance types in templates.** The admin *can* create a template version naming + `p5.48xlarge` (as expected, no condition key). A group pinned to it is denied by the launch check. +- ✓ **`aws:PrincipalTag/triple-c-user`** from a **role tag**: the tagged workspace role's session + ran tasks on its own `--u-` cluster. `RunTask` on another `--u-` cluster was denied, + and the app shows the wrong-triple-c-user message. — An Identity Center attribute and an + untagged user were not tried. The policy's tag test is the same for both, so this is expected + to hold. +- ✓ **A `triple-c-*` capacity provider over someone else's group** is refused. ECS checks the + caller's `autoscaling:CreateOrUpdateTags` on the named group ("you do not have + autoscaling:CreateOrUpdateTags permissions to create tags on the Auto Scaling group"), which the + admin tier allows only on component-tagged `triple-c-*--u-*` groups. +- **IMDS and Docker access.** EC2 tasks use `bridge` networking (R2), and the template sets IMDSv2 + with a hop limit of 1. Live: from the workspace container, the token `PUT` gets no answer + (curl times out) and an IMDSv1 `GET` gets 401, so no instance-role credentials. The task role's + credentials (169.254.170.2) work. The ECS agent's introspection API **is** reachable on the + bridge gateway (`172.17.0.1:51678`, 200). It returns the cluster, the container instance and + the instance's tasks, and no credentials. That is accepted: the instance runs only its user's + tasks (E1). A project with Docker access has the host's socket (group `docker-host`, `docker + ps` works as `claude`), so its user can start a host-network container and read IMDS (and so the + instance role). That is accepted too: Docker access is root on the user's own instance, and + the boundary keeps that role on the user's own cluster. **Phase 6** @@ -814,3 +803,44 @@ spend under $0.05. | Cost estimate | ✓ `fetch_rates` as the workspace user + `estimate`: $0.0495/hour for 1 vCPU / 2 GiB / 21 GiB x86, `efs_billed_separately` | | Removal with discard | ✓ `remove_aws_resources(…, true)` Ok; both access points gone; the secret deleted | | Cleanup | ✓ nothing `triple-c` left in us-west-2 (the run's environment KMS key pending deletion). The guard's task-definition retirement had never matched anything (ECS's `familyPrefix` is a whole family name); fixed, and 13 revisions earlier runs had left ACTIVE were deregistered and deleted | + +### Phase 7: ECS on EC2 (2026-11-16) + +```sh +TRIPLEC_E2E_TEST=aws::live_tests::environment::a_phase7_ec2_workspace_round_trips \ +TRIPLEC_AWS_E2E_PROFILE= TRIPLEC_AWS_E2E_REGION=us-west-2 scripts/aws-e2e-workspace.sh +``` + +Same fixture as phase 5. The account admin applies the current boundary (the account had none, +so it is created and destroyed again). The environment admin role holds all four admin files. +The workspace role carries the role tag `triple-c-user=`, which an assumed-role session has +as a principal tag. The admin onboards it with `m7i.large`, at most 1 instance, through the app's +own pre-apply step (`prepare_onboarding`: record, choice, name-collision check). The project is +EC2, Hybrid, 1024 CPU units / 4096 MiB reserved, with Docker access, VPN and sandbox mode on, and +no repos. The guard (`ec2_cleanup`, as the account admin) stops the per-user clusters' tasks, +force-deletes their groups (waiting until they are gone), terminates any instance tagged with the +environment, then deletes capacity providers, container instances, clusters (retried while busy), +launch templates, the user record and the instance role and profile. After that the fixture +destroys the modules. `TRIPLEC_E2E_PAUSE_SECS` holds a failed first start for inspection before +the guard runs. + +| Point | Result | +|---|---| +| Onboarding with EC2 | ✓ after the `InstanceTypes` fix (the first run's group create was denied, see above). Applied in 93 s: cluster `triple-c---u-` ACTIVE with exactly its capacity provider as the default strategy; group min 0, max 1, desired 0, template pinned to version 1, scale-in protection on, tagged with component/environment/owner/version; capacity provider with managed scaling at target 100 and managed termination protection; launch template `m7i.large`, the current ECS-optimized AL2023 AMI, IMDSv2 required, hop limit 1; instance profile holding the instance role; the user record reads `Valid` as the workspace user | +| Collision check | ✓ `DescribeClusters include=TAGS` as the admin tier returns the cluster's `triple-c:owner` tag. A missing name answers `None` for both the cluster (a `failures` entry) and the group. Onboarding another owner with the same `triple-c-user` value is refused: "An ECS cluster named … already belongs to another onboarding" | +| Admin-tier probes | ✓ `$Latest` denied; pinned version allowed and deleted; a `p5.48xlarge` template version created but a group pinned to it denied; a capacity provider over an untagged group denied (see "Phase 7" under Known gaps) | +| **ECS Exec on a cold start** | ✗→fixed (app). ECS turns `enableExecuteCommand` **off** on a RunTask that has to wait for an instance (the task goes PROVISIONING behind the capacity provider). CloudTrail shows `true` in the request and `false` in the answer, and the task keeps it off once placed, so the ExecuteCommandAgent never starts and every cold start timed out ("ECS Exec agent not running yet"). The same RunTask with an instance up and room keeps it `true`, and one that has to wait gets `false` even with an instance up. A cold start now lets that first task bring the instance up. Once the task is placed, the app stops it, waits until it has stopped and runs the task again onto the instance (`rerun_once_placed`). A live task found with ECS Exec off is stopped and replaced | +| Cold start | ✓ 249 s (run 4) and 203 s (run 5) from Start to connected. Run 4: RunTask at +4 s; "Starting an instance" until +186 s (instance launch, ECS registration and placement of the first task, which is then stopped); the second task ready and the tunnel at +248 s | +| Agent tunnel, bridge mode | ✓ the ECS Exec port forward reaches the agent on the container's own loopback (`echo` through the agent as `claude`); the task definition is `bridge`/`EC2` with the `docker-socket` host volume | +| Docker access | ✓ `/var/run/docker.sock` is `root:docker-host 0660`, and `claude` is in `docker-host`; `docker ps` as `claude` lists the workspace and the ECS agent (Docker 25.0.18) | +| VPN | ✓ as root: `ip link add wg0 type wireguard` and `ip tuntap add tun0 mode tun` both work; `/dev/net/tun` is there; `net.ipv4.conf.all.src_valid_mark = 1`; `sudo ip link add … wireguard` works as `claude` | +| E8 bubblewrap | ✗→decided. `bwrap --unshare-user` and `--unshare-all` fail with "No permissions to create new namespace", although the kernel (6.1, AL2023) allows user namespaces (`max_user_namespaces` 30937). Docker's default seccomp profile refuses `unshare` without `CAP_SYS_ADMIN`. The sandbox is kept off on EC2 as on Fargate (`sandbox_allowed`, the Runtime toggle) | +| IMDS / introspection | see "IMDS and Docker access" above: no token (hop limit 1), IMDSv1 401, task-role credentials work, introspection reachable on the bridge gateway (metadata only) | +| Isolation | ✓ `RunTask` on another user's cluster (`triple-c---u-`, created empty by the admin) as the tagged workspace user is denied, and the app's error is the wrong-triple-c-user one ("This EC2 capacity belongs to a different triple-c-user value than your sign-in's …") | +| Stop | ✓ STOPPED 6 s after `stop_project` | +| Scale-in to zero | ✓ from the group's activity history (run 4). The task STOPPED at 00:55:42Z. At 01:11:08Z managed scaling's low alarm set desired capacity 1 → 0. Scale-in protection first held the instance ("all remaining instances are protected from scale-in"). ECS then removed it from the now-idle instance, which was terminated at 01:11:59–01:12:44Z. That is **about 15.5 minutes to the scale-in decision and 17 minutes until the instance is gone**. The cold start's scale-out is similar: the high alarm fired about 3 minutes after the RunTask, and the instance was running a minute later | +| Second start | ✓ warm, right after stop 1 with the instance still up: 29 s (no instance wait, image cached, ECS Exec on at once). After a scale-in a start is cold again (≈ 3.5–4 min) | +| Removal | ✓ `remove_aws_resources(…, true)` after stop 2: Ok (task, secret, access point) | +| Re-apply without EC2, instance still up | ✓ `prepare_onboarding(…, None)` then the apply as the environment admin, 79 s: "0 added, 0 changed, 9 destroyed". The provider drained the group (the instance was InService, scale-in protected) and deleted it; after the apply no group, no live instance, capacity provider INACTIVE, cluster INACTIVE, launch template gone, instance profile and role gone, the user record Absent (as the workspace user). No denied action | +| Offboard and destroy | ✓ as the environment admin: onboarding destroy (9) and environment destroy (15) with no denied action; the account admin's boundary destroy after | +| Runs and cleanup | Five runs. Run 1: the `InstanceTypes` denial. Run 2: ECS Exec off on the cold start. Run 3: inspection over SSM (Session Manager core attached by hand to the instance role, boundary removed, both undone before the teardown), the ECS Exec diagnosis and the in-task checks. Run 4: everything to the scale-in, which the guard could not finish because the credentials expired. Run 5, `TRIPLEC_E2E_PHASE7_SHORT=1` (life cycle only): passed in 577 s. Every run's guard, or by hand with tofu destroy from the run's work folders once the credentials were renewed, left nothing: the final inventory of us-west-2 has no instance, group, launch template, Triple-C capacity provider, cluster, `triple-c*` role, policy or instance profile, `/triple-c` parameter, log group, ECR repository, file system, secret, task definition, VPC, state bucket or boundary. The environments' KMS keys are pending deletion (7 days). Spend: about 1.5 m7i.large instance-hours plus minutes of EFS and public IPv4, under $0.30 | diff --git a/docs/superpowers/specs/2026-11-13-aws-ecs-host-design.md b/docs/superpowers/specs/2026-11-13-aws-ecs-host-design.md index f40c47c..0711f0b 100644 --- a/docs/superpowers/specs/2026-11-13-aws-ecs-host-design.md +++ b/docs/superpowers/specs/2026-11-13-aws-ecs-host-design.md @@ -834,6 +834,21 @@ detached runner, detection, self-onboarding, an update ("No changes"), destroy; file-system policy accepted the just-created task role; conditional `DeleteObject` (`If-Match`) on the versioned bucket returns 412 on a stale ETag. +- **ECS on EC2, measured 2026-11-16** (phase 7, `aws/README.md` "Phase 7: ECS on EC2"): + - A per-user capacity (cluster, capacity provider, Auto Scaling group at 0, launch template) + applies as the environment admin once the scaling file stops requiring + `autoscaling:InstanceTypes`. A template-only group create doesn't send it, so the create's + own launch check (`ec2:InstanceType`) is what holds the type. + - ECS turns `enableExecuteCommand` off on a RunTask that has to wait for an instance, so a cold + start runs the task a second time once the instance is up. A cold start takes about 4 minutes. + - Bridge networking works for the agent tunnel (ECS Exec port forward), Docker access (host + socket) and VPN (`NET_ADMIN`, `/dev/net/tun`, `src_valid_mark`). + - Bubblewrap **does not** work in an ECS task on EC2 either (Docker's seccomp profile), so the + sandbox stays off on AWS. + - IMDS gives a bridge container no token. The agent's introspection port is reachable from it + (metadata only). + - The `triple-c-user` principal tag (a role tag) confines RunTask to the user's own cluster. + Still to verify: the `existing` network mode against a user's own VPC. Fargate tasks in the deployed environment were run in phase 5 (`aws/README.md`). -- 2.52.0 From c25761789ee5423b686e52fbfd545a2309e456f7 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 17:59:09 -0800 Subject: [PATCH 17/29] fix(aws): never run a second task for a stopped or contested cold EC2 start The cold-start rerun now runs again only once an instance has taken the first task and it is still meant to run; a first task that stops by itself (a user's Stop, a failed placement) ends the start with its reason. The second launch goes through find_or_run, so a concurrent start's task is reported as START_RACE instead of doubled. A found task with ECS Exec off that is still waiting for an instance belongs to a start in progress (INSTANCE_RACE); a placed one is stopped, the stop is checked and waited for (its own 3-minute budget) before a new run. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/host/aws_host.rs | 118 +++++++++++++++-------- app/src-tauri/src/host/aws_host/tests.rs | 77 +++++++++++++++ 2 files changed, 154 insertions(+), 41 deletions(-) diff --git a/app/src-tauri/src/host/aws_host.rs b/app/src-tauri/src/host/aws_host.rs index 7047808..8bac289 100644 --- a/app/src-tauri/src/host/aws_host.rs +++ b/app/src-tauri/src/host/aws_host.rs @@ -539,21 +539,58 @@ async fn wait_task( pub const EXEC_OFF: &str = "ECS started the task with ECS Exec turned off, so Triple-C can't \ reach it. Start the project again."; +/// The most a start waits for a task it stopped to reach STOPPED before +/// running another (its own budget, apart from the placement wait). +const STOP_WAIT: Duration = Duration::from_secs(3 * 60); + +/// A start found the project's task with ECS Exec off and still waiting for +/// an instance: another start is bringing one up. +pub const INSTANCE_RACE: &str = "Another start of this workspace is bringing up an EC2 \ + instance; try again in a minute (once it is up, Start connects to it)"; + +/// Wait (at most `min(timeout, STOP_WAIT)`) until `arn` is STOPPED or gone. +async fn wait_stopped(tasks: &T, cluster: &str, arn: &str, timing: WaitTiming) -> Result<(), String> { + let deadline = tokio::time::Instant::now() + timing.timeout.min(STOP_WAIT); + let wanted = [arn.to_string()]; + loop { + let gone = tasks + .describe(cluster, &wanted) + .await + .map_err(|e| e.to_string())? + .into_iter() + .find(|t| t.arn == arn) + .is_none_or(|t| t.last_status == "STOPPED"); + if gone { + return Ok(()); + } + if tokio::time::Instant::now() + timing.interval > deadline { + return Err(format!( + "The task {arn} did not stop in time; start the project again in a minute." + )); + } + tokio::time::sleep(timing.interval).await; + } +} + /// A cold EC2 start's second RunTask. ECS turns `enableExecuteCommand` off /// on a RunTask that has to wait for an instance (PROVISIONING; verified /// live, phase 7) and the task keeps it off once placed, so it could never /// be reached. That first task still makes the capacity provider launch an -/// instance: once it is placed, it is stopped (it runs nothing yet) and the -/// task run again, now straight onto that instance with ECS Exec. Returns -/// the new task; the caller stops `first` itself if this fails before the -/// stop. +/// instance: once an instance has taken it (and it is still meant to run), +/// it is stopped and the task run again — through [`find_or_run`], so a +/// concurrent start's task is never doubled ([`START_RACE`]) — now straight +/// onto that instance with ECS Exec. A first task that stops by itself (a +/// user's Stop, a failed placement) ends the start with its reason; nothing +/// is run again. Returns the new task. #[allow(clippy::too_many_arguments)] async fn rerun_once_placed( tasks: &T, + env: &EnvironmentInfo, + owner: &str, + project_id: &str, compute: &crate::aws::environments::UserCompute, first: &str, task_def_arn: &str, - tags: &[(String, String)], timing: WaitTiming, progress: &(dyn Fn(&str) + Send + Sync), ) -> Result { @@ -561,17 +598,25 @@ async fn rerun_once_placed( let deadline = tokio::time::Instant::now() + timing.timeout; let wanted = [first.to_string()]; progress(PROGRESS_INSTANCE); - // Until an instance has taken the first task (or it stopped). + // Until an instance has taken the first task. loop { - let t = tasks + let Some(t) = tasks .describe(cluster, &wanted) .await .map_err(|e| e.to_string())? .into_iter() - .find(|t| t.arn == first); - match t { - Some(t) if waiting_for_instance(&t) => {} - _ => break, + .find(|t| t.arn == first) + else { + return Err(format!("The task {first} is no longer known to ECS; start the project again")); + }; + if t.desired_status == "STOPPED" || t.last_status == "STOPPED" { + return Err(format!( + "The task stopped before an EC2 instance took it ({}); start the project again.", + t.stopped_reason.as_deref().unwrap_or("no reason given") + )); + } + if t.container_instance_arn.is_some() && t.desired_status == "RUNNING" { + break; } if tokio::time::Instant::now() + timing.interval > deadline { let max = compute.max_instances; @@ -592,36 +637,19 @@ async fn rerun_once_placed( .stop_task(cluster, first, STOP_REASON) .await .map_err(|e| e.to_string())?; - loop { - let gone = tasks - .describe(cluster, &wanted) - .await - .map_err(|e| e.to_string())? - .into_iter() - .find(|t| t.arn == first) - .is_none_or(|t| t.last_status == "STOPPED"); - if gone { - break; - } - if tokio::time::Instant::now() + timing.interval > deadline { - return Err(format!( - "The first task on the new EC2 instance did not stop within {} minutes; \ - start the project again.", - timing.timeout.as_secs() / 60 - )); - } - tokio::time::sleep(timing.interval).await; - } + wait_stopped(tasks, cluster, first, timing).await?; progress(PROGRESS_WAITING); - let task = tasks - .run_task(crate::aws::tasks::ec2_run_task_request(compute, task_def_arn, tags)) + let start = find_or_run(tasks, env, owner, project_id, task_def_arn, RunOn::Ec2(compute)) .await - .map_err(|e| crate::aws::tasks::ec2_run_error(e).to_string())?; - if !task.exec_enabled { - let _ = stop_created(tasks, cluster, &task.arn).await; + .map_err(|e| e.to_string())?; + if start.reused { + return Err(START_RACE.into()); + } + if !start.task.exec_enabled { + let _ = stop_created(tasks, cluster, &start.task.arn).await; return Err(EXEC_OFF.into()); } - Ok(task) + Ok(start.task) } /// Where a project's task may be: the environment's cluster, the user's EC2 @@ -707,9 +735,18 @@ pub async fn start_core { arn = t.arn; record_task(&arn); } Err(e) => { - let msg = with_log_tail(tasks, &logs, &arn, e).await; + let msg = if e == START_RACE { e } else { with_log_tail(tasks, &logs, &arn, e).await }; if stop_created(tasks, &cluster, &arn).await { (inp.on_task)(None); } diff --git a/app/src-tauri/src/host/aws_host/tests.rs b/app/src-tauri/src/host/aws_host/tests.rs index b9358ae..f1a3ded 100644 --- a/app/src-tauri/src/host/aws_host/tests.rs +++ b/app/src-tauri/src/host/aws_host/tests.rs @@ -177,6 +177,7 @@ impl TaskApi for Fake { // As ECS does: a stopped task is no longer live. if let Some(t) = self.tasks.lock().unwrap().get_mut(arn) { t.desired_status = "STOPPED".into(); + t.last_status = "STOPPED".into(); } Ok(()) } @@ -1461,6 +1462,82 @@ async fn a_second_task_without_ecs_exec_is_stopped_and_reported() { assert!(calls.contains(&format!("stop {} {STOP_REASON}", ec2_task_arn("e9"))), "{calls:?}"); } +#[tokio::test] +async fn a_cold_ec2_task_stopped_before_placement_ends_the_start_with_its_reason() { + let p = ec2_project(); + let execless = |last: &str| TaskInfo { exec_enabled: false, ..ec2_task(&p, "e1", last, false, false) }; + let fake = Fake { + user_record: Some(user_record_param()), + runs: Mutex::new(vec![execless("PROVISIONING")]), + ..Default::default() + }; + *fake.script.lock().unwrap() = vec![ + execless("PROVISIONING"), + TaskInfo { + desired_status: "STOPPED".into(), + stopped_reason: Some("Task stopped by user".into()), + ..execless("PROVISIONING") + }, + ]; + let (r, _) = start(&fake, &p).await; + let e = r.err().unwrap(); + assert!(e.contains("Task stopped by user"), "{e}"); + assert_eq!(fake.calls().iter().filter(|c| *c == "run").count(), 1, "no second RunTask"); +} + +#[tokio::test] +async fn an_execless_task_still_waiting_for_an_instance_is_another_starts() { + let mut p = ec2_project(); + p.aws.as_mut().unwrap().task_arn = Some(ec2_task_arn("other")); + let other = TaskInfo { exec_enabled: false, ..ec2_task(&p, "other", "PROVISIONING", false, false) }; + let fake = Fake { + user_record: Some(user_record_param()), + listed_by_cluster: Some(HashMap::from([(user_cluster_arn(), vec![ec2_task_arn("other")])])), + ..Default::default() + } + .with_task(other); + let (r, _) = start(&fake, &p).await; + assert_eq!(r.err().unwrap(), INSTANCE_RACE); + assert!(!fake.called("run") && !fake.called("stop"), "{:?}", fake.calls()); +} + +#[tokio::test] +async fn the_cold_reruns_launch_never_doubles_another_starts_task() { + let p = ec2_project(); + let execless = |last: &str, placed: bool| TaskInfo { exec_enabled: false, ..ec2_task(&p, "e1", last, false, placed) }; + let winner = ec2_task(&p, "w1", "PENDING", false, true); + let fake = Fake { + user_record: Some(user_record_param()), + runs: Mutex::new(vec![execless("PROVISIONING", false)]), + // Nothing for the start's own finds; the winner's task by the rerun. + listed: Mutex::new(vec![vec![], vec![], vec![], vec![ec2_task_arn("w1")]]), + ..Default::default() + } + .with_task(winner); + *fake.script.lock().unwrap() = vec![execless("PENDING", true), execless("STOPPED", true)]; + let (r, _) = start(&fake, &p).await; + assert_eq!(r.err().unwrap(), START_RACE); + assert_eq!(fake.calls().iter().filter(|c| *c == "run").count(), 1, "{:?}", fake.calls()); +} + +#[tokio::test] +async fn an_execless_task_that_cannot_be_stopped_fails_the_start() { + let mut p = ec2_project(); + p.aws.as_mut().unwrap().task_arn = Some(ec2_task_arn("old")); + let old = TaskInfo { exec_enabled: false, ..ec2_task(&p, "old", "RUNNING", false, true) }; + let fake = Fake { + user_record: Some(user_record_param()), + listed_by_cluster: Some(HashMap::from([(user_cluster_arn(), vec![ec2_task_arn("old")])])), + stop_fails: true, + ..Default::default() + } + .with_task(old); + let (r, _) = start(&fake, &p).await; + let e = r.err().unwrap(); + assert!(e.contains("Could not stop") && e.contains("ExpiredToken"), "{e}"); + assert!(!fake.called("run")); +} + #[tokio::test] async fn a_live_task_with_ecs_exec_off_is_stopped_and_replaced() { let mut p = ec2_project(); -- 2.52.0 From 10f473f3da0ed8e2237397c8dbd3fae6e7169213 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 17:59:44 -0800 Subject: [PATCH 18/29] fix(aws): show the sandbox as off wherever an AWS project can't run it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PermissionModeControl read the raw sandbox_mode_enabled, so an AWS project showed "Sandbox ON — bubblewrap isolation" and no Bypass caution although the host forces it off. A shared sandboxEffective() (false for any AWS project) now feeds both it and the Runtime toggle. Co-Authored-By: Claude Opus 5.5 --- app/src/components/projects/PermissionModeControl.test.tsx | 7 +++++++ app/src/components/projects/PermissionModeControl.tsx | 3 ++- app/src/components/projects/home/config/RuntimeSection.tsx | 3 ++- app/src/lib/awsWorkspace.ts | 7 +++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/src/components/projects/PermissionModeControl.test.tsx b/app/src/components/projects/PermissionModeControl.test.tsx index f1d6d83..f61b227 100644 --- a/app/src/components/projects/PermissionModeControl.test.tsx +++ b/app/src/components/projects/PermissionModeControl.test.tsx @@ -149,4 +149,11 @@ describe("PermissionModeControl", () => { /Caution/i, ); }); + + it("shows the sandbox OFF on an AWS project whatever the setting says", () => { + const aws = { ...baseProject, host_id: "aws-1", sandbox_mode_enabled: true, permission_mode: "bypass" as const }; + render(); + expect(screen.getByTestId("sandbox-state")).toHaveTextContent(/Sandbox OFF/); + expect(screen.getByTestId("permission-mode-hint")).toHaveTextContent(/Caution/i); + }); }); diff --git a/app/src/components/projects/PermissionModeControl.tsx b/app/src/components/projects/PermissionModeControl.tsx index 8d32012..043efdb 100644 --- a/app/src/components/projects/PermissionModeControl.tsx +++ b/app/src/components/projects/PermissionModeControl.tsx @@ -1,5 +1,6 @@ import type { PermissionMode, Project } from "../../lib/types"; import SegmentedControl, { type Segment } from "../ui/SegmentedControl"; +import { sandboxEffective } from "../../lib/awsWorkspace"; export const PERMISSION_MODES: Segment[] = [ { value: "plan", label: "Plan", hint: "Claude proposes a plan and makes no changes." }, @@ -56,7 +57,7 @@ export default function PermissionModeControl({ disabledReason, }: Props) { const mode = effectivePermissionMode(project); - const sandboxOn = project.sandbox_mode_enabled; + const sandboxOn = sandboxEffective(project); const uncontainedBypass = mode === "bypass" && !sandboxOn; const segments = PERMISSION_MODES.map((segment) => diff --git a/app/src/components/projects/home/config/RuntimeSection.tsx b/app/src/components/projects/home/config/RuntimeSection.tsx index b2fc661..b9bef91 100644 --- a/app/src/components/projects/home/config/RuntimeSection.tsx +++ b/app/src/components/projects/home/config/RuntimeSection.tsx @@ -10,6 +10,7 @@ import { NOT_ON_AWS, SANDBOX_OFF_ON_AWS, isAwsProject, + sandboxEffective, } from "../../../../lib/awsWorkspace"; interface Props { @@ -55,7 +56,7 @@ export default function RuntimeSection({ control={ save({ sandbox_mode_enabled: v })} /> diff --git a/app/src/lib/awsWorkspace.ts b/app/src/lib/awsWorkspace.ts index d2a38d2..68b0896 100644 --- a/app/src/lib/awsWorkspace.ts +++ b/app/src/lib/awsWorkspace.ts @@ -21,6 +21,13 @@ export function isAwsProject(p: Pick): boolean { return p.host_id != null; } +/** Whether Claude Code's sandbox actually runs for `p`: never on AWS (the + * host forces it off there; Rust `aws_host::sandbox_allowed`), else the + * project's setting. */ +export function sandboxEffective(p: Pick): boolean { + return !isAwsProject(p) && p.sandbox_mode_enabled; +} + /** Fargate CPU sizes (units of 1/1024 vCPU). */ export const FARGATE_CPUS = [256, 512, 1024, 2048, 4096, 8192, 16384] as const; -- 2.52.0 From 374fb5a35dc259892fa0d03976758a84c7032d44 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 18:12:51 -0800 Subject: [PATCH 19/29] test(aws): harden the phase 7 live test; record the update probe The guard paginates Auto Scaling groups and treats a failed read as not yet gone; the test asserts exactly one live task after a cold start, the sandbox off in the task's settings and bwrap failing (E8). README: updating a group to an unsupported template version is denied by the launch check (live probe); run 6 after the review fixes. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/live_tests.rs | 29 +++++++++++++++++++++++++++-- aws/README.md | 6 +++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/src-tauri/src/aws/live_tests.rs b/app/src-tauri/src/aws/live_tests.rs index cf43f5c..56d3626 100644 --- a/app/src-tauri/src/aws/live_tests.rs +++ b/app/src-tauri/src/aws/live_tests.rs @@ -1986,13 +1986,22 @@ mod environment { } // Groups (force: terminates their instances, ignores protection). let mut groups: Vec = probe_groups.to_vec(); - if let Ok(out) = asg.describe_auto_scaling_groups().send().await { + let mut next = None; + loop { + let Ok(out) = asg.describe_auto_scaling_groups().set_next_token(next.take()).send().await else { + eprintln!("cleanup: WARNING: could not list Auto Scaling groups; only the known ones are deleted"); + break; + }; for g in out.auto_scaling_groups() { let n = g.auto_scaling_group_name().unwrap_or_default(); if n.starts_with(&prefix) && !groups.iter().any(|x| x == n) { groups.push(n.to_string()); } } + next = out.next_token().map(str::to_string); + if next.is_none() { + break; + } } for g in &groups { match asg.delete_auto_scaling_group().auto_scaling_group_name(g).force_delete(true).send().await { @@ -2007,13 +2016,14 @@ mod environment { } if !groups.is_empty() { for _ in 0..60 { + // A failed read is "not yet gone", never "gone". let left = asg .describe_auto_scaling_groups() .set_auto_scaling_group_names(Some(groups.clone())) .send() .await .map(|o| o.auto_scaling_groups().len()) - .unwrap_or(0); + .unwrap_or(usize::MAX); if left == 0 { break; } @@ -3528,10 +3538,23 @@ log_stream_prefix, project_secret_name, task_family}; td.volumes().iter().map(|v| v.name().unwrap_or_default()).collect::>() ); + // The cold start's first (ECS Exec off) task is gone: exactly one + // live task of the project on the user's cluster. + let family = crate::aws::tofu_modules::task_family(&name, &okey, &id); + let live = api.list_project_tasks(&rec.cluster_arn, &family).await.expect("list the project's tasks"); + eprintln!("RESULT live tasks on the user's cluster after start 1: {live:?}"); + assert_eq!(live, vec![task1.clone()], "exactly one live task"); + // ── through the agent (ECS Exec port forward into the bridge task) ── let (out, code) = sh(&target, "claude", "echo hello-from-ec2; id").await; eprintln!("RESULT agent tunnel over ECS Exec into the bridge-mode task: exit {code}: {}", out.trim()); assert_eq!(code, 0, "{out}"); + // E8: the sandbox is forced off in the task's settings. + let (settings_json, code) = sh(&target, "claude", "printenv CLAUDE_CODE_SETTINGS_JSON").await; + assert_eq!(code, 0, "no CLAUDE_CODE_SETTINGS_JSON"); + let v: serde_json::Value = serde_json::from_str(settings_json.trim()).expect("settings JSON"); + eprintln!("RESULT sandbox in the task's Claude Code settings: {}", v["sandbox"]); + assert_eq!(v["sandbox"]["enabled"], false, "the sandbox is off on EC2"); let (mut docker_ok, mut vpn_ok, mut src_valid_mark, mut bwrap_ok) = (true, true, true, false); if !quick { let (out, code) = sh(&target, "claude", "ls -l /var/run/docker.sock; docker ps 2>&1; docker version --format '{{.Server.Version}}' 2>&1").await; @@ -3712,6 +3735,8 @@ log_stream_prefix, project_secret_name, task_family}; ); let _ = ws; assert!(docker_ok, "docker ps failed as claude"); + // E8, stable in every run: Docker's seccomp profile refuses it. + assert!(quick || !bwrap_ok, "bwrap worked in the task: revisit sandbox_allowed (E8)"); assert!(vpn_ok && src_valid_mark, "the VPN pieces are missing"); }); let body = async { diff --git a/aws/README.md b/aws/README.md index 27750d8..2a69a08 100644 --- a/aws/README.md +++ b/aws/README.md @@ -584,6 +584,10 @@ and what is still open: (`ForAllValues` on the key once present, and the launch check). - ✓ **Instance types in templates.** The admin *can* create a template version naming `p5.48xlarge` (as expected, no condition key). A group pinned to it is denied by the launch check. +- ✓ **Updating a group to an unsupported template version** runs the same launch check. In a + probe (a throwaway role whose `ec2:RunInstances` allows only `m7i.large`), a group pinned to an + `m7i.large` version updated to a `p5.48xlarge` version was refused ("You are not authorized to + use launch template"). A size-only update (no template) passed. - ✓ **`aws:PrincipalTag/triple-c-user`** from a **role tag**: the tagged workspace role's session ran tasks on its own `--u-` cluster. `RunTask` on another `--u-` cluster was denied, and the app shows the wrong-triple-c-user message. — An Identity Center attribute and an @@ -843,4 +847,4 @@ the guard runs. | Removal | ✓ `remove_aws_resources(…, true)` after stop 2: Ok (task, secret, access point) | | Re-apply without EC2, instance still up | ✓ `prepare_onboarding(…, None)` then the apply as the environment admin, 79 s: "0 added, 0 changed, 9 destroyed". The provider drained the group (the instance was InService, scale-in protected) and deleted it; after the apply no group, no live instance, capacity provider INACTIVE, cluster INACTIVE, launch template gone, instance profile and role gone, the user record Absent (as the workspace user). No denied action | | Offboard and destroy | ✓ as the environment admin: onboarding destroy (9) and environment destroy (15) with no denied action; the account admin's boundary destroy after | -| Runs and cleanup | Five runs. Run 1: the `InstanceTypes` denial. Run 2: ECS Exec off on the cold start. Run 3: inspection over SSM (Session Manager core attached by hand to the instance role, boundary removed, both undone before the teardown), the ECS Exec diagnosis and the in-task checks. Run 4: everything to the scale-in, which the guard could not finish because the credentials expired. Run 5, `TRIPLEC_E2E_PHASE7_SHORT=1` (life cycle only): passed in 577 s. Every run's guard, or by hand with tofu destroy from the run's work folders once the credentials were renewed, left nothing: the final inventory of us-west-2 has no instance, group, launch template, Triple-C capacity provider, cluster, `triple-c*` role, policy or instance profile, `/triple-c` parameter, log group, ECR repository, file system, secret, task definition, VPC, state bucket or boundary. The environments' KMS keys are pending deletion (7 days). Spend: about 1.5 m7i.large instance-hours plus minutes of EFS and public IPv4, under $0.30 | +| Runs and cleanup | Five runs. Run 1: the `InstanceTypes` denial. Run 2: ECS Exec off on the cold start. Run 3: inspection over SSM (Session Manager core attached by hand to the instance role, boundary removed, both undone before the teardown), the ECS Exec diagnosis and the in-task checks. Run 4: everything to the scale-in, which the guard could not finish because the credentials expired. Run 5, `TRIPLEC_E2E_PHASE7_SHORT=1` (life cycle only): passed in 577 s. Run 6 (short, after the review fixes: the rerun's launch through `find_or_run`, exactly one live task after the cold start, `sandbox.enabled = false` in the task's settings): passed in 583 s, with a cold start of 222 s and a warm one of 19 s. Every run's guard, or by hand with tofu destroy from the run's work folders once the credentials were renewed, left nothing: the final inventory of us-west-2 has no instance, group, launch template, Triple-C capacity provider, cluster, `triple-c*` role, policy or instance profile, `/triple-c` parameter, log group, ECR repository, file system, secret, task definition, VPC, state bucket or boundary. The environments' KMS keys are pending deletion (7 days). Spend: about 1.5 m7i.large instance-hours plus minutes of EFS and public IPv4, under $0.30 | -- 2.52.0 From 6e24977cf06b02032593dde3c360b50bf64ff307 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 18:16:22 -0800 Subject: [PATCH 20/29] fix(aws): replace an orphaned exec-off EC2 task instead of refusing for ever A found task with ECS Exec off that still waits for an instance is another start's only while one could still be waiting for it (created within the EC2 placement wait plus 2 minutes); an older one is a crashed start's orphan and is replaced (stopped with its own reason, checked, waited for). INSTANCE_RACE now mentions Stop. The rerun's race records the winner's task, as the first launch's race does; a first task another start replaced says so. TaskInfo gains created_unix. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/runtime/tests.rs | 1 + app/src-tauri/src/aws/tasks.rs | 3 + app/src-tauri/src/aws/tasks/tests.rs | 1 + app/src-tauri/src/host/aws_host.rs | 73 ++++++++++++++++---- app/src-tauri/src/host/aws_host/tests.rs | 86 +++++++++++++++++++++++- 5 files changed, 151 insertions(+), 13 deletions(-) diff --git a/app/src-tauri/src/aws/runtime/tests.rs b/app/src-tauri/src/aws/runtime/tests.rs index f89dbe8..85fcf45 100644 --- a/app/src-tauri/src/aws/runtime/tests.rs +++ b/app/src-tauri/src/aws/runtime/tests.rs @@ -278,6 +278,7 @@ fn live(id: &str) -> TaskInfo { runtime_id: None, container_instance_arn: None, exec_enabled: true, + created_unix: None, exec_agent_running: false, exit_code: None, owner: Some(USER.into()), diff --git a/app/src-tauri/src/aws/tasks.rs b/app/src-tauri/src/aws/tasks.rs index 18c451f..e23abb5 100644 --- a/app/src-tauri/src/aws/tasks.rs +++ b/app/src-tauri/src/aws/tasks.rs @@ -71,6 +71,8 @@ pub struct TaskInfo { /// off on a RunTask that has to wait for an EC2 instance (verified live, /// phase 7), and such a task can never be reached. pub exec_enabled: bool, + /// When ECS created the task (Unix seconds), if it says. + pub created_unix: Option, /// The `workspace` container's exit code, once it has one. pub exit_code: Option, /// Its `triple-c:owner` / `triple-c:project` tags (DescribeTasks with @@ -121,6 +123,7 @@ pub(crate) fn task_info(t: &Task) -> TaskInfo { runtime_id: workspace.and_then(|c| c.runtime_id()).map(str::to_string), container_instance_arn: t.container_instance_arn().map(str::to_string), exec_enabled: t.enable_execute_command(), + created_unix: t.created_at().map(|d| d.secs()), exec_agent_running: workspace.is_some_and(|c| { c.managed_agents().iter().any(|a| { a.name() == Some(&ManagedAgentName::ExecuteCommandAgent) diff --git a/app/src-tauri/src/aws/tasks/tests.rs b/app/src-tauri/src/aws/tasks/tests.rs index f65133c..fbd7f22 100644 --- a/app/src-tauri/src/aws/tasks/tests.rs +++ b/app/src-tauri/src/aws/tasks/tests.rs @@ -66,6 +66,7 @@ fn info(id: &str, last: &str) -> TaskInfo { runtime_id: None, container_instance_arn: None, exec_enabled: true, + created_unix: None, exec_agent_running: false, exit_code: None, owner: Some(USER.into()), diff --git a/app/src-tauri/src/host/aws_host.rs b/app/src-tauri/src/host/aws_host.rs index 8bac289..038f2db 100644 --- a/app/src-tauri/src/host/aws_host.rs +++ b/app/src-tauri/src/host/aws_host.rs @@ -544,9 +544,39 @@ pub const EXEC_OFF: &str = "ECS started the task with ECS Exec turned off, so Tr const STOP_WAIT: Duration = Duration::from_secs(3 * 60); /// A start found the project's task with ECS Exec off and still waiting for -/// an instance: another start is bringing one up. +/// an instance, recently started: another start is bringing one up. pub const INSTANCE_RACE: &str = "Another start of this workspace is bringing up an EC2 \ - instance; try again in a minute (once it is up, Start connects to it)"; + instance; try again in a minute (once it is up, Start connects to it), or Stop the \ + workspace to cancel it"; + +/// The stop reason of a task a start replaced (one with ECS Exec off). +pub const REPLACED_REASON: &str = "Replaced by another Triple-C start"; + +/// How long past the EC2 placement wait an exec-off task still waiting for +/// an instance counts as another start's, before it is taken as orphaned. +const ORPHAN_MARGIN: Duration = Duration::from_secs(2 * 60); + +/// Whether an exec-off task still waiting for an instance is older than +/// any start could still be waiting for it (`ec2_wait` + a margin): a +/// crashed start's orphan. No creation time reads as fresh. +fn is_orphaned(t: &TaskInfo, ec2_wait: WaitTiming, now_unix: i64) -> bool { + let limit = (ec2_wait.timeout + ORPHAN_MARGIN).as_secs() as i64; + t.created_unix.is_some_and(|c| now_unix - c > limit) +} + +/// Why [`rerun_once_placed`] did not give a new task. +enum RerunError { + /// A concurrent start's live task was found: record it, report + /// [`START_RACE`]. + Race(TaskInfo), + Failed(String), +} + +impl From for RerunError { + fn from(e: String) -> Self { + RerunError::Failed(e) + } +} /// Wait (at most `min(timeout, STOP_WAIT)`) until `arn` is STOPPED or gone. async fn wait_stopped(tasks: &T, cluster: &str, arn: &str, timing: WaitTiming) -> Result<(), String> { @@ -593,7 +623,7 @@ async fn rerun_once_placed( task_def_arn: &str, timing: WaitTiming, progress: &(dyn Fn(&str) + Send + Sync), -) -> Result { +) -> Result { let cluster = compute.cluster_arn.as_str(); let deadline = tokio::time::Instant::now() + timing.timeout; let wanted = [first.to_string()]; @@ -607,13 +637,21 @@ async fn rerun_once_placed( .into_iter() .find(|t| t.arn == first) else { - return Err(format!("The task {first} is no longer known to ECS; start the project again")); + return Err(format!("The task {first} is no longer known to ECS; start the project again").into()); }; if t.desired_status == "STOPPED" || t.last_status == "STOPPED" { + if t.stopped_reason.as_deref() == Some(REPLACED_REASON) { + return Err(RerunError::Failed( + "Another start of this workspace replaced this one; Start again in a minute \ + to connect to it." + .into(), + )); + } return Err(format!( "The task stopped before an EC2 instance took it ({}); start the project again.", t.stopped_reason.as_deref().unwrap_or("no reason given") - )); + ) + .into()); } if t.container_instance_arn.is_some() && t.desired_status == "RUNNING" { break; @@ -627,7 +665,8 @@ async fn rerun_once_placed( why in the group's activity in the EC2 console).", timing.timeout.as_secs() / 60, if max == 1 { "" } else { "s" } - )); + ) + .into()); } tokio::time::sleep(timing.interval).await; } @@ -643,11 +682,11 @@ async fn rerun_once_placed( .await .map_err(|e| e.to_string())?; if start.reused { - return Err(START_RACE.into()); + return Err(RerunError::Race(start.task)); } if !start.task.exec_enabled { let _ = stop_created(tasks, cluster, &start.task.arn).await; - return Err(EXEC_OFF.into()); + return Err(RerunError::Failed(EXEC_OFF.into())); } Ok(start.task) } @@ -736,14 +775,19 @@ pub async fn start_core { - let msg = if e == START_RACE { e } else { with_log_tail(tasks, &logs, &arn, e).await }; + Err(RerunError::Race(winner)) => { + // As on the first launch: the winner's task is the project's. + record_task(&winner.arn); + return Err(START_RACE.into()); + } + Err(RerunError::Failed(e)) => { + let msg = with_log_tail(tasks, &logs, &arn, e).await; if stop_created(tasks, &cluster, &arn).await { (inp.on_task)(None); } diff --git a/app/src-tauri/src/host/aws_host/tests.rs b/app/src-tauri/src/host/aws_host/tests.rs index f1a3ded..dbb972b 100644 --- a/app/src-tauri/src/host/aws_host/tests.rs +++ b/app/src-tauri/src/host/aws_host/tests.rs @@ -58,6 +58,7 @@ fn task(p: &Project, id: &str, last: &str, ready: bool) -> TaskInfo { runtime_id: ready.then(|| "rt-1".into()), container_instance_arn: None, exec_enabled: true, + created_unix: None, exec_agent_running: ready, exit_code: None, owner: Some(USER.into()), @@ -98,6 +99,8 @@ struct Fake { rotated_by_loser: bool, /// StopTask is refused (expired credentials, say). stop_fails: bool, + /// StopTask is accepted but the task never reaches STOPPED. + stop_noop: bool, /// What `on_task` was told, in order. recorded: Mutex>>, /// `group stream limit` of each log read. @@ -175,6 +178,9 @@ impl TaskApi for Fake { return Err(AwsError::Other { message: "ExpiredToken".into() }); } // As ECS does: a stopped task is no longer live. + if self.stop_noop { + return Ok(()); + } if let Some(t) = self.tasks.lock().unwrap().get_mut(arn) { t.desired_status = "STOPPED".into(); t.last_status = "STOPPED".into(); @@ -1518,6 +1524,8 @@ async fn the_cold_reruns_launch_never_doubles_another_starts_task() { let (r, _) = start(&fake, &p).await; assert_eq!(r.err().unwrap(), START_RACE); assert_eq!(fake.calls().iter().filter(|c| *c == "run").count(), 1, "{:?}", fake.calls()); + // The winner's task is recorded, as on the first launch's race. + assert_eq!(fake.recorded.lock().unwrap().last().cloned().flatten(), Some(ec2_task_arn("w1"))); } #[tokio::test] @@ -1538,6 +1546,82 @@ async fn an_execless_task_that_cannot_be_stopped_fails_the_start() { assert!(!fake.called("run")); } +fn now_unix() -> i64 { + std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs() as i64 +} + +/// An exec-off task still waiting for an instance, older than any start +/// could still be waiting (a crashed start's orphan), is replaced; a fresh +/// one is another start's. +#[tokio::test] +async fn an_orphaned_waiting_execless_task_is_replaced_and_a_fresh_one_is_left_alone() { + let mut p = ec2_project(); + p.aws.as_mut().unwrap().task_arn = Some(ec2_task_arn("old")); + let waiting = |created: i64| TaskInfo { + exec_enabled: false, + created_unix: Some(created), + ..ec2_task(&p, "old", "PROVISIONING", false, false) + }; + let fake_with = |t: TaskInfo| { + Fake { + user_record: Some(user_record_param()), + listed_by_cluster: Some(HashMap::from([(user_cluster_arn(), vec![ec2_task_arn("old")])])), + run: Some(ec2_task(&p, "new", "RUNNING", true, true)), + ..Default::default() + } + .with_task(t) + }; + let fake = fake_with(waiting(now_unix() - 3600)); + let (r, _) = start(&fake, &p).await; + assert_eq!(r.unwrap().task.arn, ec2_task_arn("new")); + assert!(fake.calls().contains(&format!("stop {} {REPLACED_REASON}", ec2_task_arn("old"))), "{:?}", fake.calls()); + + let fake = fake_with(waiting(now_unix())); + let (r, _) = start(&fake, &p).await; + let e = r.err().unwrap(); + assert_eq!(e, INSTANCE_RACE); + assert!(e.contains("Stop"), "{e}"); + assert!(!fake.called("run") && !fake.called("stop")); +} + +#[tokio::test] +async fn a_cold_start_whose_task_another_start_replaced_says_so() { + let p = ec2_project(); + let execless = |last: &str| TaskInfo { exec_enabled: false, ..ec2_task(&p, "e1", last, false, false) }; + let fake = Fake { + user_record: Some(user_record_param()), + runs: Mutex::new(vec![execless("PROVISIONING")]), + ..Default::default() + }; + *fake.script.lock().unwrap() = vec![TaskInfo { + desired_status: "STOPPED".into(), + stopped_reason: Some(REPLACED_REASON.into()), + ..execless("PROVISIONING") + }]; + let (r, _) = start(&fake, &p).await; + let e = r.err().unwrap(); + assert!(e.starts_with("Another start of this workspace replaced this one"), "{e}"); + assert_eq!(fake.calls().iter().filter(|c| *c == "run").count(), 1); +} + +#[tokio::test] +async fn an_execless_task_that_never_stops_fails_the_start_without_a_new_run() { + let mut p = ec2_project(); + p.aws.as_mut().unwrap().task_arn = Some(ec2_task_arn("old")); + let old = TaskInfo { exec_enabled: false, ..ec2_task(&p, "old", "RUNNING", false, true) }; + let fake = Fake { + user_record: Some(user_record_param()), + listed_by_cluster: Some(HashMap::from([(user_cluster_arn(), vec![ec2_task_arn("old")])])), + stop_noop: true, + ..Default::default() + } + .with_task(old); + let (r, _) = start(&fake, &p).await; + let e = r.err().unwrap(); + assert!(e.contains("did not stop in time"), "{e}"); + assert!(fake.called("stop") && !fake.called("run")); +} + #[tokio::test] async fn a_live_task_with_ecs_exec_off_is_stopped_and_replaced() { let mut p = ec2_project(); @@ -1553,7 +1637,7 @@ async fn a_live_task_with_ecs_exec_off_is_stopped_and_replaced() { let (r, _) = start(&fake, &p).await; assert_eq!(r.unwrap().task.arn, ec2_task_arn("new")); let calls = fake.calls(); - let stop = calls.iter().position(|c| *c == format!("stop {} {STOP_REASON}", ec2_task_arn("old"))).expect("the old task is stopped"); + let stop = calls.iter().position(|c| *c == format!("stop {} {REPLACED_REASON}", ec2_task_arn("old"))).expect("the old task is stopped"); assert!(stop < calls.iter().position(|c| c == "run").unwrap(), "{calls:?}"); } -- 2.52.0 From 719a75b46da305e3610cd383f3e73531e21e5b6d Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 18:19:39 -0800 Subject: [PATCH 21/29] 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 --- CLAUDE.md | 59 +++++++- aws/README.md | 45 +++++- .../specs/2026-11-13-aws-ecs-host-design.md | 131 ++++++++++++++++-- 3 files changed, 213 insertions(+), 22 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 72413c0..35d2874 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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 `--ec2-.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---u-`**, 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---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//` 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/` record, owner key — `sha256(":")`, @@ -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 diff --git a/aws/README.md b/aws/README.md index 2a69a08..beeaa0a 100644 --- a/aws/README.md +++ b/aws/README.md @@ -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---u-` 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/`, the network (`network_mode`: `public`, `private-nat`, `existing`) and, last, the record `/triple-c/environments/` (which carries the advisory `max_workspace_hours` lifetime cap, 0 = none, at most 168) | `environments//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///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---u-`, one capacity provider, an Auto Scaling group (min 0), a launch template, the instance role and profile, and the record `/triple-c/users//` | `users///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 \ **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 diff --git a/docs/superpowers/specs/2026-11-13-aws-ecs-host-design.md b/docs/superpowers/specs/2026-11-13-aws-ecs-host-design.md index 0711f0b..829b795 100644 --- a/docs/superpowers/specs/2026-11-13-aws-ecs-host-design.md +++ b/docs/superpowers/specs/2026-11-13-aws-ecs-host-design.md @@ -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, // None = Local (all existing project pub aws_placement: Option, // { region, environment } — set when host_id is an AWS connection pub aws: Option, +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, // 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//`, written by their +// onboarding module only while it has EC2 capacity; workspace users can read it): schema, +// instance_type, cluster_arn (`triple-c---u-`), 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---u-` (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---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//` (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---u-` 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 -- 2.52.0 From 8c9ffd4c4c84bb19d46cbd0d88033e9791df29cc Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 18:30:05 -0800 Subject: [PATCH 22/29] fix(aws): never attach to an exec-off EC2 task after a restart; widen the orphan margin Reconcile stops a placed or orphaned exec-off task (REPLACED_REASON, checked; the ARN is cleared only once the stop succeeded) and marks a recent one still waiting Error with its ARN kept and an 'interrupted' warning. Reattach refuses an exec-off task. ORPHAN_MARGIN is 10 minutes (clock skew). A failed EC2 record read no longer blocks attaching to a live task. One helper builds the task cluster list. Co-Authored-By: Claude Opus 5.5 --- app/src-tauri/src/aws/runtime.rs | 38 ++++-- app/src-tauri/src/host/aws_host.rs | 150 +++++++++++++++-------- app/src-tauri/src/host/aws_host/tests.rs | 96 +++++++++++++++ 3 files changed, 223 insertions(+), 61 deletions(-) diff --git a/app/src-tauri/src/aws/runtime.rs b/app/src-tauri/src/aws/runtime.rs index 8ec989a..13fa50c 100644 --- a/app/src-tauri/src/aws/runtime.rs +++ b/app/src-tauri/src/aws/runtime.rs @@ -112,6 +112,28 @@ pub fn ec2_cluster_of_task(env: &str, task_arn: &str) -> Option { .and_then(|_| cluster_arn_of_task(task_arn)) } +/// Where a project's task may be: `env_cluster` (the environment's), then +/// the user's EC2 cluster from their record, then the per-user cluster +/// `stored_task_arn` names (the record may be gone while that task runs), +/// without repeats. +pub fn project_task_clusters( + env: &str, + env_cluster: String, + ec2_cluster: Option, + stored_task_arn: Option<&str>, +) -> Vec { + let mut out = vec![env_cluster]; + for c in [ec2_cluster, stored_task_arn.and_then(|a| ec2_cluster_of_task(env, a))] + .into_iter() + .flatten() + { + if !out.contains(&c) { + out.push(c); + } + } + out +} + /// Whether the caller's task role exists in the environment: the onboarding /// signal a workspace user can read. A denied lookup is not an answer, so /// it is let through (RunTask will say what is wrong). @@ -296,18 +318,12 @@ pub async fn remove_workspace_resources = Vec::new(); for c in &clusters { if let Some(t) = diff --git a/app/src-tauri/src/host/aws_host.rs b/app/src-tauri/src/host/aws_host.rs index 038f2db..4d96423 100644 --- a/app/src-tauri/src/host/aws_host.rs +++ b/app/src-tauri/src/host/aws_host.rs @@ -32,7 +32,7 @@ use super::ContainerTarget; use crate::aws::environments::EnvironmentInfo; use crate::aws::environments::UserRecord; use crate::aws::runtime::{ - check_onboarded, cluster_arn_of_task, cluster_of_task, ec2_cluster_of_task, + check_onboarded, cluster_arn_of_task, cluster_of_task, ec2_cluster_of_task, project_task_clusters, ensure_agent_token, read_agent_token, read_environment, read_user_record, remove_workspace_resources, wait_access_point, PollTiming, RemoveRequest, RuntimeApi, SdkRuntimeApi, @@ -554,7 +554,19 @@ pub const REPLACED_REASON: &str = "Replaced by another Triple-C start"; /// How long past the EC2 placement wait an exec-off task still waiting for /// an instance counts as another start's, before it is taken as orphaned. -const ORPHAN_MARGIN: Duration = Duration::from_secs(2 * 60); +/// The task's age is ECS's `createdAt` against this machine's clock, so the +/// margin also absorbs clock skew: a local clock more than this far ahead +/// could take another start's waiting task for an orphan and replace it (the +/// other start then says so: "Another start … replaced this one"); one far +/// behind only delays the replacement. NTP-synced clocks are well inside it. +const ORPHAN_MARGIN: Duration = Duration::from_secs(10 * 60); + +/// Seconds since the Unix epoch on this machine's clock (0 if it is before). +fn now_unix() -> i64 { + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map_or(0, |d| d.as_secs() as i64) +} /// Whether an exec-off task still waiting for an instance is older than /// any start could still be waiting for it (`ec2_wait` + a margin): a @@ -691,23 +703,15 @@ async fn rerun_once_placed( Ok(start.task) } -/// Where a project's task may be: the environment's cluster, the user's EC2 -/// cluster from their record, and the per-user cluster a stored task ARN -/// names (the record may be gone while that task runs), without repeats. +/// Where a project's task may be ([`project_task_clusters`]): the +/// environment's cluster, the record's EC2 cluster, the stored task's. fn task_clusters(env: &EnvironmentInfo, record: Option<&UserRecord>, stored: Option<&str>) -> Vec { - let mut out = vec![env.cluster_arn.clone()]; - for c in [ + project_task_clusters( + &env.name, + env.cluster_arn.clone(), record.and_then(UserRecord::valid).map(|c| c.cluster_arn.clone()), - stored.and_then(|a| ec2_cluster_of_task(&env.name, a)), - ] - .into_iter() - .flatten() - { - if !out.contains(&c) { - out.push(c); - } - } - out + stored, + ) } /// The cluster (ARN) a task runs on, from its ARN. @@ -744,15 +748,19 @@ pub async fn start_core (Some(r), None), + Err(e) => { + log::warn!("Project {}: could not read the EC2 record ({e})", project.id); + (None, Some(format!("Could not read your EC2 capacity record: {e}"))) + } + } } else { - None + (None, None) }; // The EC2 wait (and its progress) for a task on a per-user cluster. let ec2_of = |task_arn: &str| { @@ -778,10 +786,7 @@ pub async fn start_core RunOn::Fargate { spot: cfg.spot }, Some(UserRecord::Valid(c)) => RunOn::Ec2(c), @@ -1314,16 +1323,8 @@ impl FindTask { .map(|p| p.environment.clone()) .unwrap_or_default(); let ok = owner_key(region, owner_user_id); - let mut clusters = vec![environment_cluster_name(&env)]; let stored = project.aws.as_ref().and_then(|a| a.task_arn.as_deref()); - for c in [ec2_cluster, stored.and_then(|a| ec2_cluster_of_task(&env, a))] - .into_iter() - .flatten() - { - if !clusters.contains(&c) { - clusters.push(c); - } - } + let clusters = project_task_clusters(&env, environment_cluster_name(&env), ec2_cluster, stored); FindTask { clusters, family: task_family(&env, &ok, &project.id), @@ -1461,9 +1462,20 @@ pub enum Reconciled { /// The task is up (or on its way): re-open the tunnel. Live(Box), /// The task stopped, or ECS no longer knows it: the project is Stopped. + /// Also an EC2 task with ECS Exec off that could never be attached to + /// (placed, or orphaned): reconcile stopped it. Gone, + /// An EC2 task with ECS Exec off, still waiting for an instance and + /// recent: a start (perhaps this app's, before a restart) was + /// interrupted mid cold start. The project is Error, its ARN kept so + /// Stop still reaches the task; [`INTERRUPTED`] says what to do. + Interrupted, } +/// What reconcile says about [`Reconciled::Interrupted`]. +pub const INTERRUPTED: &str = "A start of this workspace was interrupted while its EC2 \ + instance came up; Start again (or Stop it)."; + /// Ask ECS about a project's task: the stored ARN, else (none stored) its /// live task found by family and tags. pub async fn reconcile_task( @@ -1541,7 +1553,33 @@ pub async fn reconcile_project( find: &FindTask, ) -> Result { let arn = project.aws.as_ref().and_then(|a| a.task_arn.clone()); - let r = reconcile_task(api, arn.as_deref(), find).await?; + let mut r = reconcile_task(api, arn.as_deref(), find).await?; + // A task with ECS Exec off can never be attached to (a cold EC2 start + // the app was closed during): never Running. Placed, or too old for any + // start to still wait for it → stop it (then it's Gone); still waiting + // and recent → Interrupted, left for a Start or Stop. + if let Reconciled::Live(t) = &r { + if !t.exec_enabled { + if waiting_for_instance(t) && !is_orphaned(t, WaitTiming::ec2(), now_unix()) { + if arn.as_deref() != Some(t.arn.as_str()) { + record_task(store, &project.id, Some(&live_record(t))); + } + store.update_status(&project.id, ProjectStatus::Error)?; + return Ok(Reconciled::Interrupted); + } + log::warn!("Project {}: its task {} has ECS Exec off; stopping it", project.id, t.arn); + let cluster = cluster_of_task(&t.arn).ok_or_else(|| format!("{} is not a task ARN with a cluster", t.arn))?; + if let Err(e) = bounded_stop(api.stop_task(cluster, &t.arn, REPLACED_REASON)).await { + // It may still run: keep (or record) its ARN so Stop finds it. + if arn.as_deref() != Some(t.arn.as_str()) { + record_task(store, &project.id, Some(&live_record(t))); + } + store.update_status(&project.id, ProjectStatus::Error)?; + return Err(format!("Could not stop the workspace's unreachable task {}: {e}", t.arn)); + } + r = Reconciled::Gone; + } + } match &r { Reconciled::Gone => { store.update_status(&project.id, ProjectStatus::Stopped)?; @@ -1549,25 +1587,28 @@ pub async fn reconcile_project( } Reconciled::Live(t) => { if arn.as_deref() != Some(t.arn.as_str()) { - record_task( - store, - &project.id, - Some(&TaskRecord { - task_arn: t.arn.clone(), - access_point_id: None, - task_definition_arn: Some(t.task_definition_arn.clone()), - workspace_access_point_id: None, - }), - ); + record_task(store, &project.id, Some(&live_record(t))); } if project.status != ProjectStatus::Running { store.update_status(&project.id, ProjectStatus::Running)?; } } + Reconciled::Interrupted => {} } Ok(r) } +/// The store record of a live task reconcile found (no access points: the +/// stored ones stand). +fn live_record(t: &TaskInfo) -> TaskRecord { + TaskRecord { + task_arn: t.arn.clone(), + access_point_id: None, + task_definition_arn: Some(t.task_definition_arn.clone()), + workspace_access_point_id: None, + } +} + /// `reconcile_project_statuses` for an AWS project: decide, and when the /// task is live re-open its tunnel in the background (terminals wait for /// it through [`tunnels::wait_endpoint`]), then — copy-at-connect — copy the @@ -1630,6 +1671,10 @@ pub async fn reconcile( Ok(Reconciled::Gone) => { log::info!("Project '{}' ({}): its task is gone — set to Stopped", project.name, project.id) } + Ok(Reconciled::Interrupted) => { + log::info!("Project '{}' ({}): {INTERRUPTED}", project.name, project.id); + on_connect_warning(INTERRUPTED.to_string()); + } Err(e) => log::warn!("Project {}: could not check its task ({e}); status left as is", project.id), } } @@ -1679,6 +1724,11 @@ async fn reattach( let task = wait_ready(&api, &cluster, &task.arn, &logs, timing, |_| {}) .await .map_err(s)?; + // Reconcile never hands over an exec-off task; never wait on a tunnel + // ECS Exec can't open either. + if !task.exec_enabled { + return Err(format!("The task {} has ECS Exec off; Start the project again", task.arn)); + } let (forward, endpoint) = SsmConnector { sdk: ctx.sdk.clone() }.connect(&task, &token).await?; let tunnel = LiveTunnel { task: ecs_task(&task)?, diff --git a/app/src-tauri/src/host/aws_host/tests.rs b/app/src-tauri/src/host/aws_host/tests.rs index dbb972b..04b0b72 100644 --- a/app/src-tauri/src/host/aws_host/tests.rs +++ b/app/src-tauri/src/host/aws_host/tests.rs @@ -107,6 +107,8 @@ struct Fake { log_reads: Mutex>, /// The caller's EC2 record (absent by default). user_record: Option, + /// Reading the EC2 record fails (throttled, say). + user_record_fails: bool, /// RunTask requests, in order. run_requests: Mutex>, /// The clusters ListTasks / StopTask / DescribeTasks were asked about. @@ -263,6 +265,9 @@ impl RuntimeApi for Fake { } async fn user_record(&self, env: &str, _owner_key: &str) -> Result { self.log(format!("user-record {env}")); + if self.user_record_fails { + return Err(AwsError::Other { message: "Throttling".into() }); + } Ok(self.user_record.clone().unwrap_or(crate::aws::environments::Param::Missing)) } async fn role_exists(&self, _name: &str) -> Result { @@ -1815,3 +1820,94 @@ fn ec2_capacity_reads_as_host_settings_need_it() { assert_eq!(v, serde_json::json!({ "state": "unusable", "reason": "schema is not 1" })); assert_eq!(serde_json::to_value(ec2_capacity_from(None)).unwrap(), serde_json::json!({ "state": "unknown" })); } + +/// Reconcile never marks an exec-off task Running (an app restart during a +/// cold EC2 start): a placed or orphaned one is stopped (its ARN cleared +/// only once the stop succeeded); a recent one still waiting is Error with +/// its ARN kept. +#[tokio::test] +async fn reconcile_never_attaches_to_a_task_with_ecs_exec_off() { + let mut p = ec2_project(); + p.status = ProjectStatus::Running; + p.aws.as_mut().unwrap().task_arn = Some(ec2_task_arn("x")); + let execless = |last: &str, placed: bool, created: i64| TaskInfo { + exec_enabled: false, + created_unix: Some(created), + ..ec2_task(&p, "x", last, false, placed) + }; + let find = FindTask::new(&p, REGION, USER, Some(user_cluster_arn())); + let stopped_with_replaced = |f: &Fake| f.calls().contains(&format!("stop {} {REPLACED_REASON}", ec2_task_arn("x"))); + + // Placed: stopped, Stopped, ARN cleared. + let fake = Fake::default().with_task(execless("PENDING", true, now_unix())); + let (_d, store) = store_with(&p); + assert_eq!(reconcile_project(&fake, &store, &p, &find).await.unwrap(), Reconciled::Gone); + assert!(stopped_with_replaced(&fake), "{:?}", fake.calls()); + let after = store.get(&p.id).unwrap(); + assert_eq!(after.status, ProjectStatus::Stopped); + assert_eq!(after.aws.unwrap().task_arn, None); + + // Orphaned (still waiting, but older than any start waits): the same. + let fake = Fake::default().with_task(execless("PROVISIONING", false, now_unix() - 3600)); + let (_d, store) = store_with(&p); + assert_eq!(reconcile_project(&fake, &store, &p, &find).await.unwrap(), Reconciled::Gone); + assert!(stopped_with_replaced(&fake)); + assert_eq!(store.get(&p.id).unwrap().status, ProjectStatus::Stopped); + + // The stop fails: Error, the ARN kept. + let fake = Fake { stop_fails: true, ..Default::default() }.with_task(execless("RUNNING", true, now_unix())); + let (_d, store) = store_with(&p); + let e = reconcile_project(&fake, &store, &p, &find).await.unwrap_err(); + assert!(e.contains("Could not stop") && e.contains("ExpiredToken"), "{e}"); + let after = store.get(&p.id).unwrap(); + assert_eq!(after.status, ProjectStatus::Error); + assert_eq!(after.aws.unwrap().task_arn, Some(ec2_task_arn("x"))); + + // Recent and still waiting: Interrupted (Error), ARN kept, nothing stopped. + let fake = Fake::default().with_task(execless("PROVISIONING", false, now_unix() - 60)); + let (_d, store) = store_with(&p); + assert_eq!(reconcile_project(&fake, &store, &p, &find).await.unwrap(), Reconciled::Interrupted); + assert!(!fake.called("stop")); + let after = store.get(&p.id).unwrap(); + assert_eq!(after.status, ProjectStatus::Error); + assert_eq!(after.aws.unwrap().task_arn, Some(ec2_task_arn("x"))); + assert!(INTERRUPTED.contains("Start again")); +} + +#[test] +fn an_orphan_is_older_than_the_ec2_wait_plus_ten_minutes() { + assert_eq!(ORPHAN_MARGIN, Duration::from_secs(10 * 60)); + let p = ec2_project(); + let at = |age: i64| TaskInfo { created_unix: Some(1_000_000 - age), ..ec2_task(&p, "o", "PROVISIONING", false, false) }; + let wait = WaitTiming::ec2(); + assert!(!is_orphaned(&at(19 * 60), wait, 1_000_000)); + assert!(is_orphaned(&at(21 * 60), wait, 1_000_000)); + assert!(!is_orphaned(&TaskInfo { created_unix: None, ..at(0) }, wait, 1_000_000)); +} + +/// A failed read of the EC2 record does not stop an attach: the stored +/// task's cluster is still searched. Only a new run needs the record. +#[tokio::test] +async fn an_ec2_record_read_error_still_attaches_and_fails_only_a_new_run() { + let mut p = ec2_project(); + p.aws.as_mut().unwrap().task_arn = Some(ec2_task_arn("e8")); + let live = ec2_task(&p, "e8", "RUNNING", true, true); + let fake = Fake { + user_record_fails: true, + listed_by_cluster: Some(HashMap::from([(user_cluster_arn(), vec![live.arn.clone()])])), + ..Default::default() + } + .with_task(live); + let (r, _) = start(&fake, &p).await; + let started = r.unwrap(); + assert!(!started.created); + assert_eq!(started.task.arn, ec2_task_arn("e8")); + assert_eq!(*fake.list_clusters.lock().unwrap(), [cluster_arn(), user_cluster_arn()]); + + // Nothing live: the start fails with the read error, before any write. + let fake = Fake { user_record_fails: true, ..Default::default() }; + let (r, _) = start(&fake, &p).await; + let e = r.err().unwrap(); + assert!(e.contains("Could not read your EC2 capacity record") && e.contains("Throttling"), "{e}"); + assert!(!fake.called("put-secret") && !fake.called("run")); +} -- 2.52.0 From 8fe0810901bb2f1dd4ab3d4d4bc3461d649ab6f3 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 18:30:41 -0800 Subject: [PATCH 23/29] fix(aws): never let the user record vouch for EC2 names tagged as another owner's Co-Authored-By: Claude Opus 5.5 --- .../src/commands/environment_commands.rs | 15 +++++++++------ .../src/commands/environment_commands/tests.rs | 9 ++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src-tauri/src/commands/environment_commands.rs b/app/src-tauri/src/commands/environment_commands.rs index a1db5e9..736a346 100644 --- a/app/src-tauri/src/commands/environment_commands.rs +++ b/app/src-tauri/src/commands/environment_commands.rs @@ -338,10 +338,11 @@ pub(crate) fn resolve_ec2( /// R3 (amended): an apply with EC2 capacity would adopt (or fail on) a /// per-user cluster or Auto Scaling group named `stem` that already exists. /// Each one found must be the caller's: its `triple-c:owner` tag (the -/// module's default tags) is `owner_id`, or, failing that, the caller's -/// record names the cluster. A half-built capacity of the caller's own (a -/// failed apply that wrote no record yet) is therefore re-applied; one -/// owned by someone else, or untagged, is refused. +/// module's default tags) is `owner_id`, or, for an untagged one only, the +/// caller's record names the cluster. A half-built capacity of the caller's +/// own (a failed apply that wrote no record yet) is therefore re-applied; +/// one tagged as someone else's is always refused (a record can't vouch for +/// it), and an untagged one is refused unless the record names it. pub(crate) fn ec2_collision_refusal( stem: &str, holders: &[NameHolder], @@ -351,8 +352,10 @@ pub(crate) fn ec2_collision_refusal( let suffix = format!(":cluster/{stem}"); let recorded_here = recorded.is_some_and(|r| r.cluster_arn.ends_with(&suffix)); for h in holders { - if h.owner.as_deref() == Some(owner_id) || recorded_here { - continue; + match h.owner.as_deref() { + Some(o) if o == owner_id => continue, + None if recorded_here => continue, + _ => {} } let whose = if h.owner.is_some() { "belongs to another onboarding" diff --git a/app/src-tauri/src/commands/environment_commands/tests.rs b/app/src-tauri/src/commands/environment_commands/tests.rs index a3d404f..f3466c6 100644 --- a/app/src-tauri/src/commands/environment_commands/tests.rs +++ b/app/src-tauri/src/commands/environment_commands/tests.rs @@ -752,10 +752,13 @@ fn ec2_names_held_by_another_owner_are_refused() { assert!(e.contains("triple-c-user"), "{e}"); let e = ec2_collision_refusal(stem, &[cluster(Some(me)), group(None)], me, None).unwrap_err(); assert!(e.contains("Auto Scaling group") && e.contains("isn't tagged"), "{e}"); - // The record naming the cluster is the fallback for an untagged or - // differently tagged one. + // The record naming the cluster is the fallback for an untagged one + // only: one tagged as someone else's is refused even then. let mine = recorded("dev", "alice", 2); - assert!(ec2_collision_refusal(stem, &[cluster(None), group(Some("x"))], me, Some(&mine)).is_ok()); + assert!(ec2_collision_refusal(stem, &[cluster(None), group(None)], me, Some(&mine)).is_ok()); + assert!(ec2_collision_refusal(stem, &[cluster(None), group(Some(me))], me, Some(&mine)).is_ok()); + let e = ec2_collision_refusal(stem, &[cluster(None), group(Some("x"))], me, Some(&mine)).unwrap_err(); + assert!(e.contains("Auto Scaling group") && e.contains("another onboarding"), "{e}"); // A record naming another cluster doesn't help. assert!(ec2_collision_refusal(stem, &[cluster(None)], me, Some(&recorded("dev", "bob", 1))).is_err()); // A cluster that merely ends in the same text is not the same cluster. -- 2.52.0 From 77db6028d082d4f550332c3b83b7ba8507493af6 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 18:33:57 -0800 Subject: [PATCH 24/29] fix(aws): write logs only into the user's own streams; no log rights on the instance role The instance role (reachable from a Docker-access project's host-network container) could PutLogEvents into any user's streams. It now has no log rights: awslogs writes with the execution role (ECS_ENABLE_AWSLOGS_EXECUTIONROLE_OVERRIDE=true). The task and execution roles create streams in the environment's group but write only into log-stream:/* (every awslogs stream's prefix); the Fargate fingerprint moves deliberately. The live test asserts task logs are written. README: per-user logs, orphan clock skew, verdict wording; boundary version comments no longer mention Session Manager. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 5 ++- app/src-tauri/src/aws/live_tests.rs | 9 +++++ app/src-tauri/src/aws/tofu_modules.rs | 2 +- app/src-tauri/src/aws/tofu_modules/tests.rs | 41 ++++++++++++--------- aws/README.md | 19 +++++++++- aws/terraform/permissions-boundary/main.tf | 2 +- aws/terraform/user-onboard/ec2.tf | 8 +--- aws/terraform/user-onboard/iam.tf | 24 ++++++++++-- aws/terraform/user-onboard/main.tf | 3 ++ 9 files changed, 81 insertions(+), 32 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 35d2874..c08d04a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -406,7 +406,10 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li (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 + registering the instance into someone else's cluster. No SSM core and **no log rights** on the + instance (awslogs writes with the execution role: `ECS_ENABLE_AWSLOGS_EXECUTIONROLE_OVERRIDE`). + The task and execution roles `PutLogEvents` only into `log-stream:/*` of the shared + log group, so `log_stream_prefix` must keep starting with the owner key. 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 diff --git a/app/src-tauri/src/aws/live_tests.rs b/app/src-tauri/src/aws/live_tests.rs index 56d3626..329e391 100644 --- a/app/src-tauri/src/aws/live_tests.rs +++ b/app/src-tauri/src/aws/live_tests.rs @@ -3549,6 +3549,15 @@ log_stream_prefix, project_secret_name, task_family}; let (out, code) = sh(&target, "claude", "echo hello-from-ec2; id").await; eprintln!("RESULT agent tunnel over ECS Exec into the bridge-mode task: exit {code}: {}", out.trim()); assert_eq!(code, 0, "{out}"); + // awslogs on EC2 writes with the execution role (the instance + // role has no log rights), into the user's own streams only. + let env_rec = crate::aws::runtime::read_environment(&SdkRuntimeApi::new(&ws_cfg), &name, &account, ®ion) + .await + .expect("the environment record, as the workspace user"); + let stream = crate::aws::tasks::task_log_stream(&crate::aws::tofu_modules::log_stream_prefix(&okey, &id), &task1); + let log1 = api.log_tail(&env_rec.log_group, &stream, 20).await.expect("read task 1's log"); + eprintln!("RESULT task 1 log ({stream}): {} lines, last {:?}", log1.len(), log1.last()); + assert!(!log1.is_empty(), "task 1 wrote no log lines: awslogs could not write with the execution role"); // E8: the sandbox is forced off in the task's settings. let (settings_json, code) = sh(&target, "claude", "printenv CLAUDE_CODE_SETTINGS_JSON").await; assert_eq!(code, 0, "no CLAUDE_CODE_SETTINGS_JSON"); diff --git a/app/src-tauri/src/aws/tofu_modules.rs b/app/src-tauri/src/aws/tofu_modules.rs index e2d92f4..e843a96 100644 --- a/app/src-tauri/src/aws/tofu_modules.rs +++ b/app/src-tauri/src/aws/tofu_modules.rs @@ -22,7 +22,7 @@ pub const ENVIRONMENT_MODULE_VERSION: u32 = 2; #[allow(dead_code)] // the onboarding module's version; checked against its HCL by a test pub const ONBOARD_MODULE_VERSION: u32 = 2; /// The same for the permissions-boundary module. 2: the instance role's ECS -/// agent and Session Manager actions (phase 7, E4); an account admin +/// agent actions, on its own cluster (phase 7, E4); an account admin /// re-applies the boundary once. #[allow(dead_code)] // checked against its HCL by a test; nothing reads the tag yet pub const BOUNDARY_MODULE_VERSION: u32 = 2; diff --git a/app/src-tauri/src/aws/tofu_modules/tests.rs b/app/src-tauri/src/aws/tofu_modules/tests.rs index 0b9a8b0..6d14b85 100644 --- a/app/src-tauri/src/aws/tofu_modules/tests.rs +++ b/app/src-tauri/src/aws/tofu_modules/tests.rs @@ -1244,25 +1244,29 @@ fn exec_role_reads_only_its_owners_secrets() { json!({ "StringEquals": { "kms:ViaService": "secretsmanager.${var.region}.amazonaws.com" } }) ); - // Logs: the environment's log group only, for both roles. + // Logs, for both roles: streams are created in the environment's log + // group, but written only when they are the user's own + // (`/…`, as log_stream_prefix builds them); other users' + // streams share the group. let log_group = format!( "arn:{partition}:logs:${{var.region}}:{account}:log-group:${{local.env.log_group}}:*" ); + let own_streams = format!( + "arn:{partition}:logs:${{var.region}}:{account}:log-group:${{local.env.log_group}}:log-stream:${{var.owner_key}}/*" + ); + assert!(crate::aws::tofu_modules::log_stream_prefix("0123456789ab", "p").starts_with("0123456789ab/")); for role in ["exec", "task"] { let logs: Vec<_> = role_policies(&body, role) .iter() .flat_map(|p| statements(&jsonencoded(p, "policy"))) .filter(|s| actions(s).iter().any(|a| a.starts_with("logs:"))) .collect(); - assert_eq!(logs.len(), 1, "{role}"); - assert_eq!( - actions(&logs[0]), - BTreeSet::from([ - "logs:CreateLogStream".to_string(), - "logs:PutLogEvents".to_string() - ]) - ); - assert_eq!(expand(&logs[0]["Resource"]), log_group, "{role}"); + assert_eq!(logs.len(), 2, "{role}"); + for (action, resource) in [("logs:CreateLogStream", &log_group), ("logs:PutLogEvents", &own_streams)] { + let st = logs.iter().find(|s| actions(s).contains(action)).unwrap(); + assert_eq!(actions(st).len(), 1, "{role} {action}"); + assert_eq!(&expand(&st["Resource"]), resource, "{role} {action}"); + } } // The task role: exec channels, logs and its file system; Bedrock only @@ -2426,6 +2430,7 @@ const ONBOARD_SAMPLES: &[(&str, &str)] = &[ ), ("${var.region}", "us-west-2"), ("${var.owner_id}", "AROAEXAMPLEME:alice@example.com"), + ("${var.owner_key}", "0123456789ab"), ("${var.environment_name}", "probe"), ("${var.ec2_user_tag}", "alice"), ("${local.env.log_group}", "/triple-c/probe"), @@ -2735,8 +2740,11 @@ fn ec2_capacity_exists_only_with_an_instance_type() { } /// `sha256_prefix` of the onboarding module's non-EC2 resources as of -/// version 1 (rendered by hcl-rs, in file order). -const FARGATE_ONBOARDING_FINGERPRINT: &str = "ab948d6ab8be"; +/// version 1 (rendered by hcl-rs, in file order), with one deliberate change +/// since: the task and execution roles write logs only into the user's own +/// streams (`/*`; was the whole log group). A role-policy update +/// in place; awslogs streams were always under that prefix. +const FARGATE_ONBOARDING_FINGERPRINT: &str = "ff89c565c117"; #[test] fn ec2_names_are_the_shared_names() { @@ -2967,6 +2975,9 @@ fn the_launch_template_is_pinned() { // Bridge tasks (R2) get task-role credentials from the agent's // endpoint; IMDS stays out of their reach at hop limit 1. "ECS_ENABLE_TASK_IAM_ROLE=true\n", + // awslogs writes with the task's execution role (its own streams + // only), so the instance role needs no log rights. + "ECS_ENABLE_AWSLOGS_EXECUTIONROLE_OVERRIDE=true\n", ] { assert!( user_data.contains(needle), @@ -3164,9 +3175,7 @@ fn the_instance_role_is_ec2s_and_runs_only_the_ecs_agent() { if a == "ecs:DiscoverPollEndpoint" || a == "ecr:GetAuthorizationToken" { assert_eq!(resources, vec!["*".to_string()], "{a}"); } - if a.starts_with("logs:") { - assert_eq!(resources, vec!["${local.log_group_arn}".to_string()], "{a}"); - } + assert!(!a.starts_with("logs:"), "the instance role writes no logs: {a}"); granted.insert(a); } } @@ -3182,8 +3191,6 @@ fn the_instance_role_is_ec2s_and_runs_only_the_ecs_agent() { "ecr:BatchGetImage", "ecr:GetDownloadUrlForLayer", "ecr:BatchCheckLayerAvailability", - "logs:CreateLogStream", - "logs:PutLogEvents", ] .into_iter() .map(String::from) diff --git a/aws/README.md b/aws/README.md index beeaa0a..a4e7a5e 100644 --- a/aws/README.md +++ b/aws/README.md @@ -588,7 +588,9 @@ aws iam attach-user-policy --user-name \ 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 ✓: +service-linked roles as the admin (the test account had both). The other points below were +checked live; each one's mark gives its verdict (✓ as expected, ✗→fixed found wrong and fixed, +— not verified): - ✓ **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 @@ -638,6 +640,21 @@ service-linked roles as the admin (the test account had both). Everything else b ps` works as `claude`), so its user can start a host-network container and read IMDS (and so the instance role). That is accepted too: Docker access is root on the user's own instance, and the boundary keeps that role on the user's own cluster. +- **Logs are written per user.** All users' tasks log into the environment's one log group + `/triple-c/`. The instance role has **no** log rights: the template sets + `ECS_ENABLE_AWSLOGS_EXECUTIONROLE_OVERRIDE=true`, so the awslogs driver writes with the task's + execution role (the live run asserts the task's log has lines). The task and execution roles may + create streams in the group but `PutLogEvents` only into `log-stream:/*`, the prefix + every awslogs stream of theirs has (`///`), so no + user's container, instance or host-network container can write into another user's streams. + This also changed the version-1 (Fargate) task and execution role policies, in place. +- **Orphaned cold-start tasks and clock skew.** A task with ECS Exec off still waiting for an + instance counts as another start's (the start says so and waits) until it is older than the EC2 + placement wait (10 min) plus `ORPHAN_MARGIN` (10 min); after that a start or the app's startup + reconcile replaces it as an orphan. Its age is ECS's `createdAt` against the local clock, so a + local clock running more than 10 minutes fast could replace another machine's start mid cold + start (that start then reports it was replaced; Start again connects). A slow clock only + delays the replacement. **Phase 6** diff --git a/aws/terraform/permissions-boundary/main.tf b/aws/terraform/permissions-boundary/main.tf index 64b82eb..c53c16e 100644 --- a/aws/terraform/permissions-boundary/main.tf +++ b/aws/terraform/permissions-boundary/main.tf @@ -3,7 +3,7 @@ locals { # BOUNDARY_MODULE_VERSION in app/src-tauri/src/aws/tofu_modules.rs. - # 2: the instance role's ECS agent and Session Manager actions (phase 7). + # 2: the instance role's ECS agent actions, on its own cluster (phase 7). template_version = 2 } diff --git a/aws/terraform/user-onboard/ec2.tf b/aws/terraform/user-onboard/ec2.tf index e5c26ec..bf62950 100644 --- a/aws/terraform/user-onboard/ec2.tf +++ b/aws/terraform/user-onboard/ec2.tf @@ -127,13 +127,6 @@ resource "aws_iam_role_policy" "instance" { "arn:${local.partition}:ecr:${var.region}:${local.account}:repository/triple-c/*", ] }, - { - # The awslogs driver runs in the instance's Docker daemon. - Sid = "WriteEnvironmentLogs" - Effect = "Allow" - Action = ["logs:CreateLogStream", "logs:PutLogEvents"] - Resource = local.log_group_arn - }, ] }) } @@ -194,6 +187,7 @@ resource "aws_launch_template" "ec2" { cat >>/etc/ecs/ecs.config <<'EOF' ECS_CLUSTER=${aws_ecs_cluster.ec2[0].name} ECS_ENABLE_TASK_IAM_ROLE=true + ECS_ENABLE_AWSLOGS_EXECUTIONROLE_OVERRIDE=true EOF EOT ) diff --git a/aws/terraform/user-onboard/iam.tf b/aws/terraform/user-onboard/iam.tf index 3b3caa4..8478b1f 100644 --- a/aws/terraform/user-onboard/iam.tf +++ b/aws/terraform/user-onboard/iam.tf @@ -37,11 +37,19 @@ resource "aws_iam_role_policy" "task" { Resource = "*" }, { - Sid = "WriteEnvironmentLogs" + # CreateLogStream is authorized on the log group; writing only into + # the user's own streams (other users' are in the same group). + Sid = "CreateEnvironmentLogStreams" Effect = "Allow" - Action = ["logs:CreateLogStream", "logs:PutLogEvents"] + Action = ["logs:CreateLogStream"] Resource = local.log_group_arn }, + { + Sid = "WriteOwnLogStreams" + Effect = "Allow" + Action = ["logs:PutLogEvents"] + Resource = local.own_log_streams_arn + }, { Sid = "MountOwnFileSystem" Effect = "Allow" @@ -115,11 +123,19 @@ resource "aws_iam_role_policy" "exec" { } }, { - Sid = "WriteEnvironmentLogs" + # CreateLogStream is authorized on the log group; writing only into + # the user's own streams (other users' are in the same group). + Sid = "CreateEnvironmentLogStreams" Effect = "Allow" - Action = ["logs:CreateLogStream", "logs:PutLogEvents"] + Action = ["logs:CreateLogStream"] Resource = local.log_group_arn }, + { + Sid = "WriteOwnLogStreams" + Effect = "Allow" + Action = ["logs:PutLogEvents"] + Resource = local.own_log_streams_arn + }, ] }) } diff --git a/aws/terraform/user-onboard/main.tf b/aws/terraform/user-onboard/main.tf index 33edf21..9b5881a 100644 --- a/aws/terraform/user-onboard/main.tf +++ b/aws/terraform/user-onboard/main.tf @@ -16,6 +16,9 @@ locals { boundary_arn = "arn:${local.partition}:iam::${local.account}:policy/triple-c-permissions-boundary" log_group_arn = "arn:${local.partition}:logs:${var.region}:${local.account}:log-group:${local.env.log_group}:*" + # The user's own streams in it: every awslogs stream of theirs is + # `///` (log_stream_prefix). + own_log_streams_arn = "arn:${local.partition}:logs:${var.region}:${local.account}:log-group:${local.env.log_group}:log-stream:${var.owner_key}/*" } provider "aws" { -- 2.52.0 From 1d1e356fcd4395815aa6163324864fbe737c2660 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 18:37:07 -0800 Subject: [PATCH 25/29] fix(aws): EC2 host settings polish HostSection says what a launch-type switch changed besides the type, checks the saved reservations against the instance type once on load, and is re-indented. The EC2 capacity cache keeps none/unusable for one minute only. RuntimeSection's VPN hint on EC2 speaks of an ECS task on the user's instance. Joining over an incomplete onboarding with no record warns that None removes half-built EC2 capacity, and starts from the capacity last chosen in this run when there is one. Co-Authored-By: Claude Opus 5.5 --- .../projects/home/config/AwsConfig.test.tsx | 67 ++++- .../projects/home/config/HostSection.tsx | 260 ++++++++++-------- .../projects/home/config/RuntimeSection.tsx | 3 +- .../settings/hosts/EnvironmentsPanel.test.tsx | 42 +++ .../settings/hosts/EnvironmentsPanel.tsx | 28 +- .../settings/hosts/JoinEnvironmentModal.tsx | 18 +- .../settings/hosts/environmentFormat.ts | 4 +- app/src/lib/awsWorkspace.ts | 22 ++ app/src/lib/ec2Capacity.test.ts | 25 +- app/src/lib/ec2Capacity.ts | 19 +- 10 files changed, 357 insertions(+), 131 deletions(-) diff --git a/app/src/components/projects/home/config/AwsConfig.test.tsx b/app/src/components/projects/home/config/AwsConfig.test.tsx index b6e4b12..164ba05 100644 --- a/app/src/components/projects/home/config/AwsConfig.test.tsx +++ b/app/src/components/projects/home/config/AwsConfig.test.tsx @@ -40,6 +40,7 @@ beforeEach(() => { clearEnvironmentMaxHoursCache(); clearEc2CapacityCache(); awsEc2Capacity.mockImplementation(async () => NO_EC2); + ec2FitProblem.mockImplementation(async () => null); }); function toggle(name: string) { @@ -722,14 +723,21 @@ describe("HostSection — launch type (EC2)", () => { it("checks the reservations with the backend's fit rule before saving", async () => { awsEc2Capacity.mockImplementation(async () => M7I); - ec2FitProblem.mockResolvedValueOnce("This project reserves 1024 CPU units and 8000 MiB of memory, more than …"); + ec2FitProblem.mockImplementation(async (config) => + (config as { memory_mib: number }).memory_mib === 8000 + ? "This project reserves 1024 CPU units and 8000 MiB of memory, more than …" + : null, + ); renderHost(ec2Project()); await waitFor(() => expect(screen.getByText(/Up to 1920/)).toBeInTheDocument()); + // The load-time check found the stored 4096 MiB fits: no alert. + await waitFor(() => expect(ec2FitProblem).toHaveBeenCalledTimes(1)); + expect(screen.queryByRole("alert")).toBeNull(); const mem = screen.getByLabelText("Memory reservation (MiB)"); fireEvent.change(mem, { target: { value: "8000" } }); fireEvent.blur(mem); await waitFor(() => expect(screen.getByRole("alert")).toHaveTextContent(/more than/)); - expect(ec2FitProblem).toHaveBeenCalledWith(expect.objectContaining({ cpu: 1024, memory_mib: 8000 }), "m7i.large"); + expect(ec2FitProblem).toHaveBeenLastCalledWith(expect.objectContaining({ cpu: 1024, memory_mib: 8000 }), "m7i.large"); expect(save).not.toHaveBeenCalled(); fireEvent.change(mem, { target: { value: "6000" } }); @@ -743,6 +751,55 @@ describe("HostSection — launch type (EC2)", () => { await waitFor(() => expect(screen.getByRole("alert")).toHaveTextContent(/positive whole numbers/)); }); + it("warns on load when the saved reservations no longer fit the instance type, once", async () => { + awsEc2Capacity.mockImplementation(async () => M7I); + ec2FitProblem.mockImplementation(async () => "This project reserves 4096 CPU units …, more than an m7i.large"); + const p = ec2Project(); + p.aws = { ...p.aws!, cpu: 4096 }; + const { rerender } = renderHost(p); + await waitFor(() => + expect(screen.getByRole("alert")).toHaveTextContent(/saved reservations no longer fit: .*more than an m7i.large/), + ); + expect(ec2FitProblem).toHaveBeenCalledWith(expect.objectContaining({ cpu: 4096 }), "m7i.large"); + rerender(); + await act(async () => {}); + expect(ec2FitProblem).toHaveBeenCalledTimes(1); + expect(save).not.toHaveBeenCalled(); + cleanup(); + + // Fargate projects, and EC2 without a known instance type, aren't checked. + ec2FitProblem.mockClear(); + renderHost(awsProject()); + await waitFor(() => expect(ec2Segment()).toBeEnabled()); + cleanup(); + clearEc2CapacityCache(); + awsEc2Capacity.mockImplementation(async () => NO_EC2); + renderHost(ec2Project()); + await waitFor(() => expect(screen.getByText(/can't start on EC2 now/)).toBeInTheDocument()); + expect(ec2FitProblem).not.toHaveBeenCalled(); + }); + + it("says what a launch-type switch changed besides the type", async () => { + awsEc2Capacity.mockImplementation(async () => M7I); + const p = awsProject(); + p.aws = { ...p.aws!, cpu: 4096, memory_mib: 16384, spot: true, gateway_sidecar: true }; + renderHost(p); + await waitFor(() => expect(ec2Segment()).toBeEnabled()); + fireEvent.click(ec2Segment()); + expect(await screen.findByRole("status")).toHaveTextContent( + "Switched to EC2: CPU 4096 → 1920 units, memory 16384 → 7373 MiB, Spot turned off, LLM gateway sidecar turned off.", + ); + cleanup(); + + const back = ec2Project({ allow_docker_access: true, vpn_support_enabled: true }); + back.aws = { ...back.aws!, cpu: 1920, memory_mib: 7373 }; + renderHost(back); + fireEvent.click(screen.getByRole("radio", { name: "Fargate" })); + expect(await screen.findByRole("status")).toHaveTextContent( + "Switched to Fargate: CPU 1920 → 1024 units, memory 7373 → 7168 MiB, Docker access turned off, VPN support turned off.", + ); + }); + it("prices an EC2 project as the user's instance type", async () => { awsEc2Capacity.mockImplementation(async () => M7I); useAppState.setState({ @@ -767,6 +824,12 @@ describe("RuntimeSection on EC2", () => { expect(toggle("Sandbox mode")).toHaveAttribute("aria-checked", "false"); expect(screen.getByText(/root on your own instance/)).toBeInTheDocument(); expect(screen.getByText(/Off on AWS for now/)).toBeInTheDocument(); + // The VPN hint speaks of an ECS task on the user's instance, not of + // recreating a container or its volumes. + const vpn = screen.getByText(/VPN client \(PIA, WireGuard, OpenVPN\)/); + expect(vpn).toHaveTextContent(/an ECS task on your own EC2 instance/); + expect(vpn).toHaveTextContent(/next start/); + expect(vpn).not.toHaveTextContent(/recreates the container|volumes/); }); }); diff --git a/app/src/components/projects/home/config/HostSection.tsx b/app/src/components/projects/home/config/HostSection.tsx index 4cb6ec0..828db3f 100644 --- a/app/src/components/projects/home/config/HostSection.tsx +++ b/app/src/components/projects/home/config/HostSection.tsx @@ -28,6 +28,7 @@ import { EC2_NO_CAPACITY, EC2_NO_SIDECAR, EC2_SCALE_TO_ZERO_NOTE, + launchTypeChanges, launchTypePatch, type Ec2Limits, FARGATE_CPUS, @@ -96,6 +97,8 @@ export default function HostSection({ project, save, disabled }: Props) { const [setupProblem, setSetupProblem] = useState(null); // The environment's advisory lifetime cap (Q8), from its record. const [maxHours, setMaxHours] = useState(null); + // What the last launch-type switch changed besides the type (M6). + const [switchNote, setSwitchNote] = useState(null); useEffect(() => { setCpuText(String(aws.cpu)); @@ -115,6 +118,27 @@ export default function HostSection({ project, save, disabled }: Props) { : null; const ec2Reason = ec2Unavailable(capacity); + // Once the instance type is known, check the stored reservations against + // it (Rust's fit rule): an instance type changed at onboarding, or a + // record that came back after a save, can leave them too big. + const checkedFit = useRef(null); + useEffect(() => { + if (!ec2 || !compute) return; + const key = `${project.id}:${compute.instance_type}`; + if (checkedFit.current === key) return; + checkedFit.current = key; + let cancelled = false; + commands + .ec2FitProblem(latest.current.value, compute.instance_type) + .then((problem) => { + if (!cancelled && problem) setMemoryProblem(`The saved reservations no longer fit: ${problem}`); + }) + .catch(() => {}); // The start checks again. + return () => { + cancelled = true; + }; + }, [ec2, compute, project.id]); + useEffect(() => { setSetupScript(aws.setup_script ?? ""); }, [aws.setup_script]); @@ -188,11 +212,10 @@ export default function HostSection({ project, save, disabled }: Props) { const switchLaunchType = (launch_type: LaunchType) => { if (launch_type === latest.current.value.launch_type) return; setMemoryProblem(null); - const { aws: next, ...also } = launchTypePatch( - { ...project, aws: latest.current.value }, - launch_type, - limits, - ); + const before = { ...project, aws: latest.current.value }; + const patch = launchTypePatch(before, launch_type, limits); + setSwitchNote(launchTypeChanges(before, patch)); + const { aws: next, ...also } = patch; void saveAws(next!, also); }; @@ -313,6 +336,11 @@ export default function HostSection({ project, save, disabled }: Props) { : ec2Reason}

)} + {switchNote && ( +

+ {switchNote} +

+ )} {ec2 && (
    ) : ( -
    - - {(id) => ( - - )} - - { - const opts = memoryOptions(aws.cpu); - return `${formatMemory(opts[0])} to ${formatMemory(opts[opts.length - 1])} with ${formatCpu(aws.cpu)}.`; - })()} - > - {(id) => ( - <> - + + {(id) => ( + + )} + + { + const opts = memoryOptions(aws.cpu); + return `${formatMemory(opts[0])} to ${formatMemory(opts[opts.length - 1])} with ${formatCpu(aws.cpu)}.`; + })()} + > + {(id) => ( + <> + setMemory(e.target.value)} + onBlur={commitMemory} + onKeyDown={(e) => e.key === "Enter" && commitMemory()} + className={`w-32 ${inputClass}`} + /> + + {memoryOptions(aws.cpu).map((m) => ( + + + )} + +
    + + Architecture + + void saveAws({ arch })} + segments={[ + { value: "x86_64", label: "x86_64" }, + { value: "arm64", label: "ARM64 (Graviton)" }, + ]} + /> +
    - )} {memoryProblem && (

    @@ -504,51 +532,51 @@ export default function HostSection({ project, save, disabled }: Props) { {!ec2 && ( - <> - - {(id) => ( - setEphemeral(e.target.value)} - onBlur={commitEphemeral} - className={`w-24 ${inputClass}`} - /> - )} - - {ephemeralProblem && ( -

    - {ephemeralProblem} -

    - )} + <> + + {(id) => ( + setEphemeral(e.target.value)} + onBlur={commitEphemeral} + className={`w-24 ${inputClass}`} + /> + )} + + {ephemeralProblem && ( +

    + {ephemeralProblem} +

    + )} - void saveAws({ spot })} + hint={ + aws.wip_push_on_stop + ? "Runs on spare capacity at up to 70% off. AWS may reclaim it with two minutes' notice; the work-in-progress push below still runs." + : "Runs on spare capacity at up to 70% off. AWS may reclaim it with two minutes' notice, and with the work-in-progress push below off, unpushed work is lost." + } + control={ + void saveAws({ spot })} + /> + } /> - } - /> - + )}
    diff --git a/app/src/components/projects/home/config/RuntimeSection.tsx b/app/src/components/projects/home/config/RuntimeSection.tsx index b9bef91..22ba3c7 100644 --- a/app/src/components/projects/home/config/RuntimeSection.tsx +++ b/app/src/components/projects/home/config/RuntimeSection.tsx @@ -7,6 +7,7 @@ import ClaudeCodeSettingsEditor from "../../ClaudeCodeSettingsEditor"; import AuthBridgeRow from "./AuthBridgeRow"; import { EC2_DOCKER_ACCESS_NOTE, + EC2_VPN_HINT, NOT_ON_AWS, SANDBOX_OFF_ON_AWS, isAwsProject, @@ -84,7 +85,7 @@ export default function RuntimeSection({ { expect(within(dialog).getByText("This removes your EC2 capacity (m7g.xlarge) in dev.")).toBeInTheDocument(); }); + it("an incomplete onboarding with no record warns that None removes half-built EC2 capacity", async () => { + backend( + () => scan({ environments: [env({ onboarding: { state: "incomplete", lock: null, ec2: null } })] }), + (cmd) => { + if (cmd === "list_ec2_instance_types") return instanceTable; + throw new Error(`unexpected ${cmd}`); + }, + ); + render(); + await open(); + fireEvent.click(await screen.findByRole("button", { name: "Join dev" })); + const dialog = screen.getByRole("dialog", { name: "Join dev" }); + expect(within(dialog).getByRole("alert")).toHaveTextContent( + /didn't finish, and it may have built part of your EC2 capacity. Choosing None removes anything it built/, + ); + fireEvent.click(within(dialog).getByRole("radio", { name: "My own EC2 instances" })); + expect(within(dialog).queryByText(/Choosing None removes/)).toBeNull(); + }); + + it("with no record, the join starts from the EC2 capacity last chosen here", async () => { + invoke.mockImplementation(async (cmd: string) => { + if (cmd === "list_ec2_instance_types") return instanceTable; + throw new Error(`unexpected ${cmd}`); + }); + render( + null} + onClose={() => {}} + />, + ); + const dialog = screen.getByRole("dialog", { name: "Join dev" }); + expect((within(dialog).getByLabelText("Your triple-c-user value") as HTMLInputElement).value).toBe("alice"); + expect(within(dialog).queryByText(/Choosing None removes/)).toBeNull(); + }); + it("a joined workspace user's capacity change is a bundle starting from their record", async () => { backend( () => scan({ environments: [env({ onboarding: { state: "joined", ec2: compute({ max_instances: 1 }) } })] }), diff --git a/app/src/components/settings/hosts/EnvironmentsPanel.tsx b/app/src/components/settings/hosts/EnvironmentsPanel.tsx index 157f99a..fbce0e6 100644 --- a/app/src/components/settings/hosts/EnvironmentsPanel.tsx +++ b/app/src/components/settings/hosts/EnvironmentsPanel.tsx @@ -16,6 +16,7 @@ import type { AwsError, DetectedEnvironment, Ec2Choice, + Ec2Compute, EnvironmentScan, HostConnection, LockInfo, @@ -114,7 +115,15 @@ type Bundle = { recordedEc2?: UserCompute | null; }; /** A self-onboarding (or its re-apply) waiting for its EC2 choice. */ -type JoinOf = { region: string; name: string; stateKey: string; recorded: UserCompute | null; reapply: boolean }; +type JoinOf = { + region: string; + name: string; + stateKey: string; + recorded: UserCompute | null; + reapply: boolean; + incomplete: boolean; + lastChoice: Ec2Compute | null; +}; /** The caller's recorded EC2 capacity in `e`, if any. */ const recordedEc2 = (e: DetectedEnvironment): UserCompute | null => @@ -163,6 +172,9 @@ export default function EnvironmentsPanel({ } | null>(null); const [bundle, setBundle] = useState(null); const [joinOf, setJoinOf] = useState(null); + // The EC2 capacity last chosen per environment in this run of the app: an + // onboarding that didn't finish has no record to start from. + const lastEc2 = useRef(new Map()); const [copyNote, setCopyNote] = useState(null); const request = useRef(0); const followed = useRef(new Set()); @@ -273,6 +285,8 @@ export default function EnvironmentsPanel({ stateKey: onboardingStateKey(e.name, found.owner_key), recorded, reapply: e.onboarding?.state === "joined", + incomplete: e.onboarding?.state === "incomplete", + lastChoice: lastEc2.current.get(rowKey(found.region, e.name)) ?? null, }); } else { setBundle({ @@ -284,8 +298,14 @@ export default function EnvironmentsPanel({ }); } }; - const runJoin = (j: JoinOf, ec2: Ec2Choice) => - launch(j.region, j.name, j.stateKey, `Joining ${j.name}`, () => onboardAwsUser(connection.id, j.region, j.name, ec2)); + const runJoin = (j: JoinOf, ec2: Ec2Choice) => { + const key = rowKey(j.region, j.name); + if (ec2.kind === "ec2") { + const { kind: _kind, ...c } = ec2; + lastEc2.current.set(key, c); + } else lastEc2.current.delete(key); + return launch(j.region, j.name, j.stateKey, `Joining ${j.name}`, () => onboardAwsUser(connection.id, j.region, j.name, ec2)); + }; const rowRuns = (name: string) => Object.values(runs).filter((r) => r.region === current?.region && runEnvironment(r.stateKey) === name); @@ -696,6 +716,8 @@ export default function EnvironmentsPanel({ region={joinOf.region} recorded={joinOf.recorded} reapply={joinOf.reapply} + incomplete={joinOf.incomplete} + lastChoice={joinOf.lastChoice} onJoin={(ec2) => runJoin(joinOf, ec2)} onClose={() => setJoinOf(null)} /> diff --git a/app/src/components/settings/hosts/JoinEnvironmentModal.tsx b/app/src/components/settings/hosts/JoinEnvironmentModal.tsx index 15fb042..006fd72 100644 --- a/app/src/components/settings/hosts/JoinEnvironmentModal.tsx +++ b/app/src/components/settings/hosts/JoinEnvironmentModal.tsx @@ -1,6 +1,6 @@ import { useState } from "react"; import { awsErrorMessage } from "../../../lib/aws-error"; -import type { AwsError, Ec2Choice, UserCompute } from "../../../lib/types"; +import type { AwsError, Ec2Choice, Ec2Compute, UserCompute } from "../../../lib/types"; import Button from "../../ui/Button"; import Modal from "../../ui/Modal"; import Ec2CapacityFields from "./Ec2CapacityFields"; @@ -16,6 +16,8 @@ export default function JoinEnvironmentModal({ region, recorded, reapply, + incomplete = false, + lastChoice = null, onJoin, onClose, }: { @@ -25,11 +27,17 @@ export default function JoinEnvironmentModal({ recorded: UserCompute | null; /** Already joined: this changes the onboarding's EC2 capacity. */ reapply: boolean; + /** The last onboarding didn't finish (it may have built EC2 capacity + * before writing the record). */ + incomplete?: boolean; + /** The EC2 capacity last chosen here in this run of the app, if any: + * the starting point when there is no record. */ + lastChoice?: Ec2Compute | null; /** Starts the run; resolves to the command's error, or null once started. */ onJoin: (ec2: Ec2Choice) => Promise; onClose: () => void; }) { - const [draft, setDraft] = useState(() => ec2DraftFrom(recorded)); + const [draft, setDraft] = useState(() => ec2DraftFrom(recorded ?? lastChoice)); const [submitting, setSubmitting] = useState(false); const [error, setError] = useState(null); const picked = ec2FromDraft(draft); @@ -74,6 +82,12 @@ export default function JoinEnvironmentModal({ This removes your EC2 capacity ({recorded.instance_type}) in {environment}.

    )} + {incomplete && !recorded && !draft.enabled && ( +

    + Your last onboarding in {environment} didn't finish, and it may have built part of your EC2 capacity. + Choosing None removes anything it built; to keep it, choose your own EC2 instances with the same values. +

    + )} {error && (

    {awsErrorMessage(error)} diff --git a/app/src/components/settings/hosts/environmentFormat.ts b/app/src/components/settings/hosts/environmentFormat.ts index 551d41e..5edf734 100644 --- a/app/src/components/settings/hosts/environmentFormat.ts +++ b/app/src/components/settings/hosts/environmentFormat.ts @@ -110,7 +110,9 @@ export interface Ec2Draft { } /** The picker's start: the recorded capacity (a re-apply keeps it), or none. */ -export function ec2DraftFrom(recorded: UserCompute | null | undefined): Ec2Draft { +export function ec2DraftFrom( + recorded: Pick | null | undefined, +): Ec2Draft { return recorded ? { enabled: true, instanceType: recorded.instance_type, maxInstances: recorded.max_instances, userTag: recorded.user_tag } : { enabled: false, instanceType: "", maxInstances: 1, userTag: "" }; diff --git a/app/src/lib/awsWorkspace.ts b/app/src/lib/awsWorkspace.ts index 68b0896..6914bd8 100644 --- a/app/src/lib/awsWorkspace.ts +++ b/app/src/lib/awsWorkspace.ts @@ -291,6 +291,25 @@ export function launchTypePatch( return patch; } +/** + * What a launch-type switch's [`launchTypePatch`] changed beyond the launch + * type, as one short line for Host settings (null: nothing else changed). + */ +export function launchTypeChanges(before: Project, patch: Partial): string | null { + const was = before.aws!; + const now = patch.aws!; + const changes: string[] = []; + if (now.cpu !== was.cpu) changes.push(`CPU ${was.cpu} → ${now.cpu} units`); + if (now.memory_mib !== was.memory_mib) changes.push(`memory ${was.memory_mib} → ${now.memory_mib} MiB`); + if (was.spot && !now.spot) changes.push("Spot turned off"); + if (was.gateway_sidecar && !now.gateway_sidecar) changes.push("LLM gateway sidecar turned off"); + if (before.allow_docker_access && patch.allow_docker_access === false) changes.push("Docker access turned off"); + if (before.vpn_support_enabled && patch.vpn_support_enabled === false) changes.push("VPN support turned off"); + if (changes.length === 0) return null; + const to = now.launch_type === "ec2" ? "EC2" : "Fargate"; + return `Switched to ${to}: ${changes.join(", ")}.`; +} + /** Mirrors Rust `aws::workspace::EC2_NO_SIDECAR`. */ export const EC2_NO_SIDECAR = "The LLM gateway sidecar is not available on EC2 yet: turn it off, or run the project on Fargate"; @@ -300,4 +319,7 @@ export const EC2_SCALE_TO_ZERO_NOTE = "Your instances scale to zero when no workspace is running, so the first start after idle boots an instance — about 3 minutes."; export const EC2_DOCKER_ACCESS_NOTE = "Docker access mounts your instance's Docker socket: that is root on your own instance, which nobody else's workspace runs on."; +/** RuntimeSection's VPN hint for an EC2 project: an ECS task, not a container the app recreates. */ +export const EC2_VPN_HINT = + "Grants NET_ADMIN, the /dev/net/tun device and src_valid_mark so a VPN client (PIA, WireGuard, OpenVPN) can build a tunnel inside the workspace, an ECS task on your own EC2 instance. Anything in the workspace can then reconfigure the task's own network stack; the instance's is untouched. Applies on the project's next start."; export const EC2_NO_CAPACITY = "Ask an admin to add EC2 capacity to your onboarding"; diff --git a/app/src/lib/ec2Capacity.test.ts b/app/src/lib/ec2Capacity.test.ts index a646916..c4d2581 100644 --- a/app/src/lib/ec2Capacity.test.ts +++ b/app/src/lib/ec2Capacity.test.ts @@ -18,7 +18,12 @@ vi.mock("./tauri-commands", () => ({ awsEc2Capacity: (id: string) => awsEc2Capacity(id), })); -import { EC2_CAPACITY_TTL_MS, clearEc2CapacityCache, ec2Capacity } from "./ec2Capacity"; +import { + EC2_CAPACITY_SHORT_TTL_MS, + EC2_CAPACITY_TTL_MS, + clearEc2CapacityCache, + ec2Capacity, +} from "./ec2Capacity"; describe("ec2Capacity", () => { beforeEach(() => { @@ -36,6 +41,24 @@ describe("ec2Capacity", () => { expect(awsEc2Capacity).toHaveBeenCalledTimes(3); }); + it("keeps none and unusable for a minute only, ec2 for ten", async () => { + expect(EC2_CAPACITY_SHORT_TTL_MS).toBe(60 * 1000); + expect(EC2_CAPACITY_TTL_MS).toBe(10 * 60 * 1000); + for (const answer of [{ state: "none" }, { state: "unusable", reason: "x" }] as Ec2Capacity[]) { + clearEc2CapacityCache(); + awsEc2Capacity.mockClear(); + awsEc2Capacity.mockResolvedValueOnce(answer); + expect(await ec2Capacity("p1", "c1", "eu-west-1", "dev", 0)).toEqual(answer); + await ec2Capacity("p1", "c1", "eu-west-1", "dev", EC2_CAPACITY_SHORT_TTL_MS - 1); + expect(awsEc2Capacity).toHaveBeenCalledTimes(1); + expect(await ec2Capacity("p1", "c1", "eu-west-1", "dev", EC2_CAPACITY_SHORT_TTL_MS)).toEqual(EC2); + expect(awsEc2Capacity).toHaveBeenCalledTimes(2); + // The ec2 answer that replaced it is kept for the long TTL. + await ec2Capacity("p1", "c1", "eu-west-1", "dev", EC2_CAPACITY_TTL_MS); + expect(awsEc2Capacity).toHaveBeenCalledTimes(2); + } + }); + it("keeps none, but not unknown or a rejection", async () => { awsEc2Capacity.mockResolvedValueOnce({ state: "none" }); expect(await ec2Capacity("p1", "c1", "eu-west-1", "dev", 0)).toEqual({ state: "none" }); diff --git a/app/src/lib/ec2Capacity.ts b/app/src/lib/ec2Capacity.ts index ab508ea..b421b32 100644 --- a/app/src/lib/ec2Capacity.ts +++ b/app/src/lib/ec2Capacity.ts @@ -4,9 +4,13 @@ import type { Ec2Capacity, Project } from "./types"; /** How long a user's EC2 capacity is reused before AWS is asked again. */ export const EC2_CAPACITY_TTL_MS = 10 * 60 * 1000; +/** The same for any other answer (`none`, `unusable`): an admin adding or + * fixing the capacity shows up within a minute. */ +export const EC2_CAPACITY_SHORT_TTL_MS = 60 * 1000; interface Entry { at: number; + ttl: number; value: Promise; } @@ -16,8 +20,10 @@ const cache = new Map(); /** * `aws_ec2_capacity`, cached per (connection, region, environment) for - * [`EC2_CAPACITY_TTL_MS`]. A read in flight is shared; an `unknown` answer - * (offline, slow) or a rejection is not kept, so the next mount asks again. + * [`EC2_CAPACITY_TTL_MS`] when the answer is `ec2`, and + * [`EC2_CAPACITY_SHORT_TTL_MS`] for `none` or `unusable`. A read in flight + * is shared; an `unknown` answer (offline, slow) or a rejection is not + * kept, so the next mount asks again. */ export function ec2Capacity( projectId: string, @@ -28,14 +34,17 @@ export function ec2Capacity( ): Promise { const key = JSON.stringify([connectionId, region, environment]); const hit = cache.get(key); - if (hit && now - hit.at < EC2_CAPACITY_TTL_MS) return hit.value; + if (hit && now - hit.at < hit.ttl) return hit.value; const value = Promise.resolve().then(() => commands.awsEc2Capacity(projectId)); - const entry = { at: now, value }; + const entry: Entry = { at: now, ttl: EC2_CAPACITY_TTL_MS, value }; cache.set(key, entry); const forget = () => { if (cache.get(key) === entry) cache.delete(key); }; - value.then((c) => c.state === "unknown" && forget(), forget); + value.then((c) => { + if (c.state === "unknown") forget(); + else if (c.state !== "ec2") entry.ttl = EC2_CAPACITY_SHORT_TTL_MS; + }, forget); return value; } -- 2.52.0 From d85292ea000143e8983f94feb71a3b4db0b38344 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 18:40:12 -0800 Subject: [PATCH 26/29] fix(aws): add the EC2 root volume to the cost estimate; name public IPv4 The EC2 estimate adds the 50 GiB gp3 root volume at the region's gp3 GB-month price (Pricing API, cached per region like the instance price; fixture recorded 2026-11-16). The note says whether it is included and that a public-mode environment's IPv4 address adds $0.005/hour. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 4 +- app/src-tauri/src/aws/pricing.rs | 80 ++++++++++++++++++- .../ebs-gp3-get-products-us-west-2.json | 6 ++ app/src-tauri/src/aws/pricing/tests.rs | 41 +++++++++- app/src-tauri/src/aws/tofu_modules/tests.rs | 3 +- app/src-tauri/src/commands/host_commands.rs | 20 +++-- .../projects/home/AwsCostEstimate.test.tsx | 16 +++- .../projects/home/AwsCostEstimate.tsx | 4 + app/src/lib/types.ts | 3 + 9 files changed, 159 insertions(+), 18 deletions(-) create mode 100644 app/src-tauri/src/aws/pricing/fixtures/ebs-gp3-get-products-us-west-2.json diff --git a/CLAUDE.md b/CLAUDE.md index c08d04a..afe1084 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -389,7 +389,9 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li `None` ("Estimate unavailable"), a failed region isn't re-asked for 5 min, a stale cache still answers. 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 `--ec2-.json` - with the same rules — the instance's price, not the reservations. + with the same rules — the instance's price, not the reservations — plus the 50 GiB gp3 root volume + (`GP3_FILTERS`, `--ebs-gp3.json`, best effort: without it the note says it's missing; + `EC2_ROOT_VOLUME_GIB` is pinned to `ec2.tf`). A public IPv4 address ($0.005/h) is only in the note. **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: diff --git a/app/src-tauri/src/aws/pricing.rs b/app/src-tauri/src/aws/pricing.rs index ca4bc15..23eec2e 100644 --- a/app/src-tauri/src/aws/pricing.rs +++ b/app/src-tauri/src/aws/pricing.rs @@ -65,6 +65,22 @@ pub const EC2_FILTERS: &[(&str, &str, &str)] = &[ ("TERM_MATCH", "licenseModel", "No License required"), ]; +/// `GetProducts` filters for gp3 EBS storage in `{region}`. Verified against +/// the live API (2026-11-16): one row (`USW2-EBS:VolumeUsage.gp3`, $0.08 per +/// GB-month). +pub const GP3_FILTERS: &[(&str, &str, &str)] = &[ + ("TERM_MATCH", "regionCode", "{region}"), + ("TERM_MATCH", "productFamily", "Storage"), + ("TERM_MATCH", "volumeApiName", "gp3"), +]; + +/// The EC2 instance's root volume (`ec2.tf`'s `volume_size`, gp3), billed +/// while the instance exists. +pub const EC2_ROOT_VOLUME_GIB: u32 = 50; + +/// Hours in a billing month, as AWS converts GB-month prices. +pub const HOURS_PER_MONTH: f64 = 730.0; + /// One `GetProducts` query: a service and its filters, values filled in. #[derive(Debug, Clone, PartialEq)] pub struct Query { @@ -100,6 +116,14 @@ pub fn ec2_query(region: &str, instance_type: &str) -> Query { } } +/// The gp3 storage price of `region` ([`GP3_FILTERS`]). +pub fn gp3_query(region: &str) -> Query { + Query { + service_code: EC2_SERVICE_CODE, + filters: fill(GP3_FILTERS, &[("region", region)]), + } +} + /// One architecture's on-demand rates in a region, in USD. #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] pub struct FargateRates { @@ -131,13 +155,17 @@ impl RegionRates { /// usually cheaper); EFS is billed per GB-month, not per hour /// (`efs_billed_separately`). `ec2_instance`: the figure is the user's EC2 /// instance's hourly price, whatever the project reserves of it, and -/// instances scale to zero when no workspace is running (E10). +/// instances scale to zero when no workspace is running (E10); +/// `root_volume_included`: it also has the instance's 50 GiB gp3 root +/// volume (when its price could be read). An instance's public IPv4 +/// address (public-mode environments) is never in it. #[derive(Debug, Clone, Copy, PartialEq, Serialize)] pub struct HourlyEstimate { pub usd_per_hour: f64, pub note_spot: bool, pub efs_billed_separately: bool, pub ec2_instance: bool, + pub root_volume_included: bool, } pub fn estimate(cfg: &AwsWorkspaceConfig, rates: &FargateRates) -> HourlyEstimate { @@ -151,21 +179,44 @@ pub fn estimate(cfg: &AwsWorkspaceConfig, rates: &FargateRates) -> HourlyEstimat note_spot: cfg.spot, efs_billed_separately: cfg.storage != StorageMode::Ephemeral, ec2_instance: false, + root_volume_included: false, } } /// An EC2 project's estimate: its instance's on-demand hourly price — the /// instance is billed whole while it runs, so the reservations, the -/// ephemeral size and Spot (none on EC2) change nothing. -pub fn estimate_ec2(cfg: &AwsWorkspaceConfig, instance_usd_per_hour: f64) -> HourlyEstimate { +/// ephemeral size and Spot (none on EC2) change nothing — plus its +/// [`EC2_ROOT_VOLUME_GIB`] gp3 root volume at `gp3_usd_per_gb_month` (per +/// hour, over [`HOURS_PER_MONTH`]) when that price is known. +pub fn estimate_ec2( + cfg: &AwsWorkspaceConfig, + instance_usd_per_hour: f64, + gp3_usd_per_gb_month: Option, +) -> HourlyEstimate { + let root = gp3_usd_per_gb_month.map(|p| f64::from(EC2_ROOT_VOLUME_GIB) * p / HOURS_PER_MONTH); HourlyEstimate { - usd_per_hour: instance_usd_per_hour, + usd_per_hour: instance_usd_per_hour + root.unwrap_or(0.0), note_spot: false, efs_billed_separately: cfg.storage != StorageMode::Ephemeral, ec2_instance: true, + root_volume_included: root.is_some(), } } +/// The gp3 storage price per GB-month in a [`GP3_FILTERS`] price list for +/// `region`; `None` when no row matches. +pub fn parse_gp3_price(region: &str, items: &[String]) -> Option { + items.iter().find_map(|item| { + let product = serde_json::from_str::(item).ok()?; + let attrs = &product["product"]["attributes"]; + let is = |k: &str, v: &str| attrs[k].as_str() == Some(v); + if !(is("regionCode", region) && is("volumeApiName", "gp3")) { + return None; + } + on_demand_usd(&product).filter(|p| *p > 0.0) + }) +} + /// The on-demand hourly price of `instance_type` (Linux, shared tenancy) in /// an `AmazonEC2` price list for `region`. The filters already narrow it to /// one row; the attributes are checked again so a looser answer can't price @@ -385,6 +436,12 @@ impl CacheKey { file: format!("{region}--ec2-{instance_type}.json"), } } + fn gp3(region: &str) -> Self { + Self { + key: format!("{region} gp3"), + file: format!("{region}--ebs-gp3.json"), + } + } } /// A cache file. `key` was `region` before EC2 prices were cached too (an @@ -553,6 +610,21 @@ impl RatesCache { .await } + /// [`Self::rates_with`] for `region`'s gp3 storage price per GB-month + /// (an EC2 instance's root volume). + pub async fn gp3_price_with>( + &self, + api: impl Future>, + region: &str, + now: SystemTime, + ) -> Option { + let parse = |items: &[String]| { + parse_gp3_price(region, items).ok_or_else(|| format!("no gp3 price for {region} in the price list")) + }; + self.cached::(&CacheKey::gp3(region), api, gp3_query(region), parse, now) + .await + } + /// Fresh cache, else a fetch of `query` (client build included, within /// [`FETCH_TIMEOUT`]) parsed by `parse` that refreshes the cache, else /// the stale cache, else `None`; a key whose fetch failed is not asked diff --git a/app/src-tauri/src/aws/pricing/fixtures/ebs-gp3-get-products-us-west-2.json b/app/src-tauri/src/aws/pricing/fixtures/ebs-gp3-get-products-us-west-2.json new file mode 100644 index 0000000..39ab9a1 --- /dev/null +++ b/app/src-tauri/src/aws/pricing/fixtures/ebs-gp3-get-products-us-west-2.json @@ -0,0 +1,6 @@ +{ + "PriceList": [ + "{\"product\":{\"productFamily\":\"Storage\",\"attributes\":{\"maxThroughputvolume\":\"2000 MiB/s\",\"volumeType\":\"General Purpose\",\"maxIopsvolume\":\"80000\",\"usagetype\":\"USW2-EBS:VolumeUsage.gp3\",\"locationType\":\"AWS Region\",\"maxVolumeSize\":\"64 TiB\",\"storageMedia\":\"SSD-backed\",\"regionCode\":\"us-west-2\",\"servicecode\":\"AmazonEC2\",\"volumeApiName\":\"gp3\",\"location\":\"US West (Oregon)\",\"servicename\":\"Amazon Elastic Compute Cloud\",\"operation\":\"\",\"group\":\"EBS Storage\"},\"sku\":\"BB8UJWJ4XPFJB95G\"},\"serviceCode\":\"AmazonEC2\",\"terms\":{\"OnDemand\":{\"BB8UJWJ4XPFJB95G.JRTCKXETXF\":{\"priceDimensions\":{\"BB8UJWJ4XPFJB95G.JRTCKXETXF.6YS6EN2CT7\":{\"unit\":\"GB-Mo\",\"endRange\":\"Inf\",\"description\":\"$0.08 per GB-month of General Purpose (gp3) provisioned storage - US West (Oregon)\",\"appliesTo\":[],\"rateCode\":\"BB8UJWJ4XPFJB95G.JRTCKXETXF.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.0800000000\"}}},\"sku\":\"BB8UJWJ4XPFJB95G\",\"effectiveDate\":\"2026-11-01T00:00:00Z\",\"offerTermCode\":\"JRTCKXETXF\",\"termAttributes\":{}}}},\"version\":\"20261114012926\",\"publicationDate\":\"2026-11-14T01:29:26Z\"}" + ], + "FormatVersion": "aws_v1" +} diff --git a/app/src-tauri/src/aws/pricing/tests.rs b/app/src-tauri/src/aws/pricing/tests.rs index 30a9fe6..f36a338 100644 --- a/app/src-tauri/src/aws/pricing/tests.rs +++ b/app/src-tauri/src/aws/pricing/tests.rs @@ -514,15 +514,16 @@ fn the_ec2_filters_name_linux_shared_tenancy_on_demand_for_the_type() { #[test] fn an_ec2_estimate_is_the_instances_price_whatever_the_reservations() { - let small = estimate_ec2(&ec2_cfg(512, 1024, StorageMode::Ephemeral), M7I_LARGE); - let big = estimate_ec2(&ec2_cfg(1920, 7373, StorageMode::Ephemeral), M7I_LARGE); + let small = estimate_ec2(&ec2_cfg(512, 1024, StorageMode::Ephemeral), M7I_LARGE, None); + let big = estimate_ec2(&ec2_cfg(1920, 7373, StorageMode::Ephemeral), M7I_LARGE, None); assert!(close(small.usd_per_hour, 0.1008) && close(big.usd_per_hour, 0.1008)); assert!(small.ec2_instance && !small.note_spot && !small.efs_billed_separately); + assert!(!small.root_volume_included); // Ephemeral size and Spot don't apply on EC2; EFS is still billed apart. let mut c = ec2_cfg(1024, 4096, StorageMode::Hybrid); c.ephemeral_gib = 200; c.spot = true; - let e = estimate_ec2(&c, M7G_LARGE); + let e = estimate_ec2(&c, M7G_LARGE, None); assert!(close(e.usd_per_hour, 0.0816)); assert!(e.efs_billed_separately && !e.note_spot && e.ec2_instance); // Fargate estimates say they are not an instance's. @@ -612,3 +613,37 @@ fn a_fargate_cache_file_written_before_ec2_prices_still_reads() { std::fs::write(c.dir().join("us-west-2.json"), old.to_string()).unwrap(); assert_eq!(c.read("us-west-2", at(T0)), Some((RATES, true))); } + +const GP3_FIXTURE: &str = include_str!("fixtures/ebs-gp3-get-products-us-west-2.json"); + +fn gp3_items() -> Vec { + let v: Value = serde_json::from_str(GP3_FIXTURE).unwrap(); + v["PriceList"].as_array().unwrap().iter().map(|s| s.as_str().unwrap().to_string()).collect() +} + +/// The root volume (50 GiB gp3, `ec2.tf`) is in an EC2 estimate when its +/// price is known: $0.08/GB-month in us-west-2 (recorded 2026-11-16) is +/// 50 × 0.08 / 730 ≈ $0.0055/h on top of the instance. +#[test] +fn an_ec2_estimate_adds_the_gp3_root_volume_when_its_price_is_known() { + assert_eq!(parse_gp3_price("us-west-2", &gp3_items()), Some(0.08)); + assert_eq!(parse_gp3_price("eu-west-1", &gp3_items()), None, "another region's row"); + assert_eq!(parse_gp3_price("us-west-2", &ec2_items()), None, "not a gp3 row"); + let e = estimate_ec2(&ec2_cfg(1024, 4096, StorageMode::Ephemeral), M7I_LARGE, Some(0.08)); + assert!(close(e.usd_per_hour, 0.1008 + 50.0 * 0.08 / 730.0), "{}", e.usd_per_hour); + assert!(e.root_volume_included && e.ec2_instance); + assert_eq!(gp3_query("us-west-2").service_code, "AmazonEC2"); +} + +#[tokio::test] +async fn the_gp3_price_is_fetched_once_and_cached_per_region() { + let (_d, c) = cache(); + let api = FakeApi::answering(vec![Ok(Page { items: gp3_items(), next_token: None })]); + let price = c.gp3_price_with::(async { Some(&api) }, "us-west-2", at(T0)).await; + assert_eq!(price, Some(0.08)); + assert_eq!(api.queries.lock().unwrap()[0], gp3_query("us-west-2")); + assert!(c.dir().join("us-west-2--ebs-gp3.json").is_file()); + let again = c.gp3_price_with::(async { Some(&api) }, "us-west-2", at(T0 + 1)).await; + assert_eq!(again, Some(0.08)); + assert_eq!(api.calls(), 1); +} diff --git a/app/src-tauri/src/aws/tofu_modules/tests.rs b/app/src-tauri/src/aws/tofu_modules/tests.rs index 6d14b85..0c903e6 100644 --- a/app/src-tauri/src/aws/tofu_modules/tests.rs +++ b/app/src-tauri/src/aws/tofu_modules/tests.rs @@ -2936,7 +2936,8 @@ fn the_launch_template_is_pinned() { let ebs = &one_block(bdm, "ebs").body; assert_eq!( attr(ebs, "volume_size"), - Some(&Expression::Number(50.into())) + Some(&Expression::Number(crate::aws::pricing::EC2_ROOT_VOLUME_GIB.into())), + "the cost estimate prices this root volume" ); assert_eq!( attr(ebs, "volume_type"), diff --git a/app/src-tauri/src/commands/host_commands.rs b/app/src-tauri/src/commands/host_commands.rs index b1a5172..c02e8fa 100644 --- a/app/src-tauri/src/commands/host_commands.rs +++ b/app/src-tauri/src/commands/host_commands.rs @@ -372,15 +372,21 @@ async fn cost_estimate( }; if config.launch_type == LaunchType::Ec2 { let instance_type = instance_type.filter(|t| ec2_instance_spec(t).is_some())?; - let price = match cache.read_ec2(®ion, instance_type, now) { - Some((price, true)) => price, - _ => { - cache - .ec2_price_with::(api(), ®ion, instance_type, now) - .await? + let instance = async { + match cache.read_ec2(®ion, instance_type, now) { + Some((price, true)) => Some(price), + _ => { + cache + .ec2_price_with::(api(), ®ion, instance_type, now) + .await + } } }; - return Some(pricing::estimate_ec2(config, price)); + // The root volume's price is best effort: without it the estimate + // is the instance's alone (and says so). + let gp3 = cache.gp3_price_with::(api(), ®ion, now); + let (price, gp3) = tokio::join!(instance, gp3); + return Some(pricing::estimate_ec2(config, price?, gp3)); } let rates = match cache.read(®ion, now) { Some((rates, true)) => Some(rates), diff --git a/app/src/components/projects/home/AwsCostEstimate.test.tsx b/app/src/components/projects/home/AwsCostEstimate.test.tsx index d108c83..4d43dd8 100644 --- a/app/src/components/projects/home/AwsCostEstimate.test.tsx +++ b/app/src/components/projects/home/AwsCostEstimate.test.tsx @@ -46,6 +46,7 @@ describe("AwsCostEstimate", () => { note_spot: false, efs_billed_separately: false, ec2_instance: false, + root_volume_included: false, }); const c = config(); render(); @@ -63,6 +64,7 @@ describe("AwsCostEstimate", () => { note_spot: true, efs_billed_separately: true, ec2_instance: false, + root_volume_included: false, }); render( { }); it("asks once per settled change of a cost field, not for unrelated edits", async () => { - awsCostEstimate.mockResolvedValue({ usd_per_hour: 0.1, note_spot: false, efs_billed_separately: false, ec2_instance: false }); + awsCostEstimate.mockResolvedValue({ usd_per_hour: 0.1, note_spot: false, efs_billed_separately: false, ec2_instance: false, root_volume_included: false }); const { rerender } = render(); await settle(); expect(awsCostEstimate).toHaveBeenCalledTimes(1); @@ -118,8 +120,16 @@ describe("AwsCostEstimate", () => { expect(awsCostEstimate.mock.calls[1][2].cpu).toBe(4096); }); + it("says when an EC2 estimate lacks the root volume's price", async () => { + awsCostEstimate.mockResolvedValue({ usd_per_hour: 0.1008, note_spot: false, efs_billed_separately: false, ec2_instance: true, root_volume_included: false }); + render(); + await settle(); + expect(screen.getByText(/Its 50 GiB gp3 root volume \(about \$4 a month\) is not included/)).toBeInTheDocument(); + expect(screen.getByText(/public IPv4 address adds/)).toBeInTheDocument(); + }); + it("prices an EC2 project as its instance type, and says instances scale to zero", async () => { - awsCostEstimate.mockResolvedValue({ usd_per_hour: 0.1008, note_spot: false, efs_billed_separately: true, ec2_instance: true }); + awsCostEstimate.mockResolvedValue({ usd_per_hour: 0.1008, note_spot: false, efs_billed_separately: true, ec2_instance: true, root_volume_included: true }); const c = config({ launch_type: "ec2", storage: "hybrid" }); const { rerender } = render( , @@ -129,6 +139,8 @@ describe("AwsCostEstimate", () => { expect(screen.getByText("≈ $0.10/hour")).toBeInTheDocument(); expect(screen.getByText(/Instances scale to zero when no workspace is running/)).toBeInTheDocument(); expect(screen.getByText(/EFS storage is billed separately/)).toBeInTheDocument(); + expect(screen.getByText(/Includes its 50 GiB gp3 root volume/)).toBeInTheDocument(); + expect(screen.getByText(/public IPv4 address adds \$0.005\/hour/)).toBeInTheDocument(); expect(screen.queryByText(/While the task runs/)).toBeNull(); // The reservations don't change an instance's price: no new call. rerender( diff --git a/app/src/components/projects/home/AwsCostEstimate.tsx b/app/src/components/projects/home/AwsCostEstimate.tsx index f4f5d95..cb17cd8 100644 --- a/app/src/components/projects/home/AwsCostEstimate.tsx +++ b/app/src/components/projects/home/AwsCostEstimate.tsx @@ -76,6 +76,10 @@ export default function AwsCostEstimate({ connectionId, region, config, instance {estimate?.ec2_instance && (

    While your instance runs. Instances scale to zero when no workspace is running. + {estimate.root_volume_included + ? " Includes its 50 GiB gp3 root volume." + : " Its 50 GiB gp3 root volume (about $4 a month) is not included."} + {" In an environment with public networking, the instance's public IPv4 address adds $0.005/hour."} {estimate.efs_billed_separately && " EFS storage is billed separately."}

    )} diff --git a/app/src/lib/types.ts b/app/src/lib/types.ts index 8b52d4f..b74b86b 100644 --- a/app/src/lib/types.ts +++ b/app/src/lib/types.ts @@ -1283,6 +1283,9 @@ export interface HourlyEstimate { /** EC2 (E10): the user's instance's on-demand price, whatever the project * reserves of it; instances scale to zero when no workspace is running. */ ec2_instance: boolean; + /** EC2: the figure includes the instance's 50 GiB gp3 root volume (its + * price could be read). A public IPv4 address is never in it. */ + root_volume_included: boolean; } export type Verdict = "allowed" | "denied" | "unverified"; -- 2.52.0 From 6fa7ef56053fa97f363baea4f3dca9ce2a9fcbbe Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 18:44:47 -0800 Subject: [PATCH 27/29] docs(aws): record phase 7 live run 7 (log scoping) Co-Authored-By: Claude Opus 5.5 --- aws/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/README.md b/aws/README.md index a4e7a5e..ad0a425 100644 --- a/aws/README.md +++ b/aws/README.md @@ -895,4 +895,4 @@ the guard runs. | Removal | ✓ `remove_aws_resources(…, true)` after stop 2: Ok (task, secret, access point) | | Re-apply without EC2, instance still up | ✓ `prepare_onboarding(…, None)` then the apply as the environment admin, 79 s: "0 added, 0 changed, 9 destroyed". The provider drained the group (the instance was InService, scale-in protected) and deleted it; after the apply no group, no live instance, capacity provider INACTIVE, cluster INACTIVE, launch template gone, instance profile and role gone, the user record Absent (as the workspace user). No denied action | | Offboard and destroy | ✓ as the environment admin: onboarding destroy (9) and environment destroy (15) with no denied action; the account admin's boundary destroy after | -| Runs and cleanup | Five runs. Run 1: the `InstanceTypes` denial. Run 2: ECS Exec off on the cold start. Run 3: inspection over SSM (Session Manager core attached by hand to the instance role, boundary removed, both undone before the teardown), the ECS Exec diagnosis and the in-task checks. Run 4: everything to the scale-in, which the guard could not finish because the credentials expired. Run 5, `TRIPLEC_E2E_PHASE7_SHORT=1` (life cycle only): passed in 577 s. Run 6 (short, after the review fixes: the rerun's launch through `find_or_run`, exactly one live task after the cold start, `sandbox.enabled = false` in the task's settings): passed in 583 s, with a cold start of 222 s and a warm one of 19 s. Every run's guard, or by hand with tofu destroy from the run's work folders once the credentials were renewed, left nothing: the final inventory of us-west-2 has no instance, group, launch template, Triple-C capacity provider, cluster, `triple-c*` role, policy or instance profile, `/triple-c` parameter, log group, ECR repository, file system, secret, task definition, VPC, state bucket or boundary. The environments' KMS keys are pending deletion (7 days). Spend: about 1.5 m7i.large instance-hours plus minutes of EFS and public IPv4, under $0.30 | +| Runs and cleanup | Five runs. Run 1: the `InstanceTypes` denial. Run 2: ECS Exec off on the cold start. Run 3: inspection over SSM (Session Manager core attached by hand to the instance role, boundary removed, both undone before the teardown), the ECS Exec diagnosis and the in-task checks. Run 4: everything to the scale-in, which the guard could not finish because the credentials expired. Run 5, `TRIPLEC_E2E_PHASE7_SHORT=1` (life cycle only): passed in 577 s. Run 6 (short, after the review fixes: the rerun's launch through `find_or_run`, exactly one live task after the cold start, `sandbox.enabled = false` in the task's settings): passed in 583 s, with a cold start of 222 s and a warm one of 19 s. Run 7 (short, after the final review's log scoping: no log rights on the instance role, `PutLogEvents` only into `/*` for the task and execution roles): passed in 527 s, cold start 182 s, warm 19 s, and task 1's awslogs stream had its lines (written with the execution role). Every run's guard, or by hand with tofu destroy from the run's work folders once the credentials were renewed, left nothing: the final inventory of us-west-2 has no instance, group, launch template, Triple-C capacity provider, cluster, `triple-c*` role, policy or instance profile, `/triple-c` parameter, log group, ECR repository, file system, secret, task definition, VPC, state bucket or boundary. The environments' KMS keys are pending deletion (7 days). Spend: about 1.5 m7i.large instance-hours plus minutes of EFS and public IPv4, under $0.30 | -- 2.52.0 From 70cfa6b7577d98523aea30ddd4ec1e22857764e7 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 16 Nov 2026 19:01:28 -0800 Subject: [PATCH 28/29] test(aws): Fargate logs under the narrowed scope Co-Authored-By: Claude Opus 5.5 --- aws/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/aws/README.md b/aws/README.md index ad0a425..0ed1d94 100644 --- a/aws/README.md +++ b/aws/README.md @@ -810,6 +810,7 @@ and the secret and removes the ECR policy; then the fixture destroys the modules | Bubblewrap (P9) | ✗ `bwrap --unshare-user` fails: "No permissions to create new namespace" (kernel 6.1, `max_user_namespaces` 16384, no `CAP_SYS_ADMIN` on Fargate). The sandbox stays off on AWS | | A revision per configuration | turning idle stop on adds a secret key, so the next start registers a new revision (by design) | | Removal (R8) | ✓ final run: `remove_aws_resources` succeeds; the secret is scheduled for deletion, the access point deleted, the revision left ACTIVE. Since R10 the secret is deleted without a recovery window (the test now asserts it is gone) | +| Logs under the narrowed scope (2026-11-16, after phase 7's review) | ✓ re-run with the task and execution roles' `PutLogEvents` limited to `log-stream:/*` (`CreateLogStream` on the group): passed in 913 s; awslogs wrote both tasks' streams (the test reads and asserts task 1's and task 2's stop lines), cold start 109 s, idle stop exit 75; nothing left but the test secret already pending deletion | | Cleanup | ✓ nothing `triple-c` left in us-west-2; environment KMS keys pending deletion | ### Phase 6: the cost estimate's price reads (2026-11-16) -- 2.52.0 From 05ed1c37a5aa12969edc61584b3b1f1a747516ec Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Tue, 17 Nov 2026 05:24:56 -0800 Subject: [PATCH 29/29] fix(aws): phase 7 parked minors Interrupted-start notice gets its own toast topic and headline; the launch-type switch note only shows after a successful save and is dropped by later saves; README states the CreateLogStream scoping limit. Co-Authored-By: Claude Opus 5.5 --- .../src/commands/project_commands.rs | 29 +++++++++++++ app/src-tauri/src/host/aws_host.rs | 6 ++- .../projects/home/config/AwsConfig.test.tsx | 41 +++++++++++++++++++ .../projects/home/config/HostSection.tsx | 13 +++++- aws/README.md | 4 ++ 5 files changed, 89 insertions(+), 4 deletions(-) diff --git a/app/src-tauri/src/commands/project_commands.rs b/app/src-tauri/src/commands/project_commands.rs index 3fad14f..d4e9de2 100644 --- a/app/src-tauri/src/commands/project_commands.rs +++ b/app/src-tauri/src/commands/project_commands.rs @@ -1602,6 +1602,20 @@ fn emit_connect_warning(app_handle: &tauri::AppHandle, project_id: &str, name: & let _ = app_handle.emit("workspace-warning", connect_warning_payload(project_id, name, detail)); } +/// A start that an app restart interrupted (EC2 cold start): topic "start". +fn emit_interrupted_warning(app_handle: &tauri::AppHandle, project_id: &str, name: &str, detail: &str) { + let _ = app_handle.emit("workspace-warning", interrupted_warning_payload(project_id, name, detail)); +} + +fn interrupted_warning_payload(project_id: &str, name: &str, detail: &str) -> serde_json::Value { + serde_json::json!({ + "project_id": project_id, + "message": format!("“{name}”: a start was interrupted"), + "detail": detail, + "topic": "start", + }) +} + fn connect_warning_payload(project_id: &str, name: &str, detail: &str) -> serde_json::Value { serde_json::json!({ "project_id": project_id, @@ -2209,6 +2223,10 @@ pub async fn reconcile_aws_projects( let on_ports_warning = move |detail: String| { emit_ports_warning(&ports_handle, &ports_id, &ports_name, &detail) }; + let (int_handle, int_id, int_name) = (handle.clone(), id.clone(), name.clone()); + let on_interrupted_warning = move |detail: String| { + emit_interrupted_warning(&int_handle, &int_id, &int_name, &detail) + }; let on_connect_warning = move |detail: String| emit_connect_warning(&handle, &id, &name, &detail); if tokio::time::timeout( @@ -2219,6 +2237,7 @@ pub async fn reconcile_aws_projects( store, on_connect_warning, on_ports_warning, + on_interrupted_warning, ), ) .await @@ -2249,6 +2268,16 @@ mod tests { use super::*; + #[test] + fn the_interrupted_warning_has_its_own_topic_and_headline() { + let v = interrupted_warning_payload("p1", "demo", "retry"); + assert_eq!(v["topic"], "start"); + assert_eq!(v["detail"], "retry"); + let m = v["message"].as_str().unwrap(); + assert!(m.contains("demo") && m.contains("a start was interrupted")); + assert!(!m.contains("credentials")); + } + // ── Pending-cleanup aging ──────────────────────────────────────────── #[test] diff --git a/app/src-tauri/src/host/aws_host.rs b/app/src-tauri/src/host/aws_host.rs index 4d96423..c1e65f8 100644 --- a/app/src-tauri/src/host/aws_host.rs +++ b/app/src-tauri/src/host/aws_host.rs @@ -1614,13 +1614,15 @@ fn live_record(t: &TaskInfo) -> TaskRecord { /// it through [`tunnels::wait_endpoint`]), then — copy-at-connect — copy the /// credentials in, calling `on_connect_warning` if that fails — after /// opening its port mappings (`on_ports_warning` for any that fail). Never -/// blocks on the tunnel. +/// blocks on the tunnel. `on_interrupted_warning` reports a start that an +/// app restart interrupted ([`INTERRUPTED`]), on its own toast topic. pub async fn reconcile( project: &Project, settings: &AppSettings, store: Arc, on_connect_warning: impl FnOnce(String) + Send + 'static, on_ports_warning: impl FnOnce(String) + Send + 'static, + on_interrupted_warning: impl FnOnce(String) + Send + 'static, ) { let (connection_id, region, sdk) = match project_sdk(project, settings).await { Ok(v) => v, @@ -1673,7 +1675,7 @@ pub async fn reconcile( } Ok(Reconciled::Interrupted) => { log::info!("Project '{}' ({}): {INTERRUPTED}", project.name, project.id); - on_connect_warning(INTERRUPTED.to_string()); + on_interrupted_warning(INTERRUPTED.to_string()); } Err(e) => log::warn!("Project {}: could not check its task ({e}); status left as is", project.id), } diff --git a/app/src/components/projects/home/config/AwsConfig.test.tsx b/app/src/components/projects/home/config/AwsConfig.test.tsx index 164ba05..ced7902 100644 --- a/app/src/components/projects/home/config/AwsConfig.test.tsx +++ b/app/src/components/projects/home/config/AwsConfig.test.tsx @@ -800,6 +800,47 @@ describe("HostSection — launch type (EC2)", () => { ); }); + const switchedProject = () => { + const p = awsProject(); + p.aws = { ...p.aws!, cpu: 4096, memory_mib: 16384, spot: true, gateway_sidecar: true }; + return p; + }; + + it("shows no switch note when the save was refused", async () => { + awsEc2Capacity.mockImplementation(async () => M7I); + renderHost(switchedProject()); + await waitFor(() => expect(ec2Segment()).toBeEnabled()); + save.mockResolvedValueOnce(false); + fireEvent.click(ec2Segment()); + await waitFor(() => expect(save).toHaveBeenCalled()); + await new Promise((r) => setTimeout(r, 0)); + expect(screen.queryByText(/Switched to/)).toBeNull(); + }); + + it("shows no switch note when the save fails", async () => { + awsEc2Capacity.mockImplementation(async () => M7I); + renderHost(switchedProject()); + await waitFor(() => expect(ec2Segment()).toBeEnabled()); + const unhandled = vi.fn(); + process.on("unhandledRejection", unhandled); + save.mockRejectedValueOnce(new Error("boom")); + fireEvent.click(ec2Segment()); + await waitFor(() => expect(save).toHaveBeenCalled()); + await new Promise((r) => setTimeout(r, 0)); + process.off("unhandledRejection", unhandled); + expect(screen.queryByText(/Switched to/)).toBeNull(); + }); + + it("drops the switch note when another setting is saved afterwards", async () => { + awsEc2Capacity.mockImplementation(async () => M7I); + renderHost(switchedProject()); + await waitFor(() => expect(ec2Segment()).toBeEnabled()); + fireEvent.click(ec2Segment()); + expect(await screen.findByText(/Switched to EC2/)).toBeInTheDocument(); + fireEvent.click(screen.getByRole("radio", { name: "Fargate" })); + await waitFor(() => expect(screen.queryByText(/Switched to EC2/)).toBeNull()); + }); + it("prices an EC2 project as the user's instance type", async () => { awsEc2Capacity.mockImplementation(async () => M7I); useAppState.setState({ diff --git a/app/src/components/projects/home/config/HostSection.tsx b/app/src/components/projects/home/config/HostSection.tsx index 828db3f..f6a1114 100644 --- a/app/src/components/projects/home/config/HostSection.tsx +++ b/app/src/components/projects/home/config/HostSection.tsx @@ -170,7 +170,11 @@ export default function HostSection({ project, save, disabled }: Props) { if (latest.current.base !== project.aws && latest.current.inFlight === 0) { latest.current = { base: project.aws, value: aws, inFlight: 0 }; } + // Bumped by every save: a launch-type note only shows if no later save began. + const saveSeq = useRef(0); const saveAws = async (patch: Partial, also: Partial = {}) => { + saveSeq.current += 1; + setSwitchNote(null); const l = latest.current; const next = { ...l.value, ...patch }; l.value = next; @@ -214,9 +218,14 @@ export default function HostSection({ project, save, disabled }: Props) { setMemoryProblem(null); const before = { ...project, aws: latest.current.value }; const patch = launchTypePatch(before, launch_type, limits); - setSwitchNote(launchTypeChanges(before, patch)); + const note = launchTypeChanges(before, patch); const { aws: next, ...also } = patch; - void saveAws(next!, also); + // Shown only once the save went through, and dropped by any later save. + const pending = saveAws(next!, also); + const seq = saveSeq.current; + void pending.then((ok) => { + if (ok && saveSeq.current === seq) setSwitchNote(note); + }); }; // EC2 reservations: positive whole numbers that fit the user's instance diff --git a/aws/README.md b/aws/README.md index 0ed1d94..1feff34 100644 --- a/aws/README.md +++ b/aws/README.md @@ -647,6 +647,10 @@ checked live; each one's mark gives its verdict (✓ as expected, ✗→fixed fo create streams in the group but `PutLogEvents` only into `log-stream:/*`, the prefix every awslogs stream of theirs has (`///`), so no user's container, instance or host-network container can write into another user's streams. + Known limit: `logs:CreateLogStream` is authorized against the log group ARN only (the Service + Authorization Reference lists no log-stream resource type for it), so it cannot be scoped to + `log-stream:/*`. A user can therefore create a stream under another user's prefix + but cannot write events to it (`PutLogEvents` is scoped); the worst case is an empty stream. This also changed the version-1 (Fargate) task and execution role policies, in place. - **Orphaned cold-start tasks and clock skew.** A task with ECS Exec off still waiting for an instance counts as another start's (the start says so and waits) until it is older than the EC2 -- 2.52.0