AWS host phase 6: EFS, copy-at-connect, setup scripts, lifetime cap, ports, gateway sidecar, cost estimate #83

Merged
jknapp merged 33 commits from feat/aws-phase6 into main 2026-11-16 20:36:37 +00:00
33 Commits
Author SHA1 Message Date
shadowdaoandClaude Opus 5.5 0a325cb7f2 fix(aws): Host settings merge saves against the latest config and cache the environment's lifetime cap
Build App (Preview) / compute-version (pull_request) Successful in 38s
Secret Scan / scan (push) Successful in 17s
Secret Scan / scan (pull_request) Successful in 11s
Build App (Preview) / create-release (pull_request) Successful in 7s
Build App (Preview) / test (pull_request) Successful in 8m14s
Build App (Preview) / build-macos (pull_request) Successful in 6m4s
Build App (Preview) / build-windows (pull_request) Successful in 10m43s
Build Container / build-container (pull_request) Successful in 19m45s
Build App (Preview) / build-linux (pull_request) Successful in 16m22s
Build App (Preview) / prune-previews (pull_request) Successful in 9s
A save right after the setup script's blur (a toggle) spread the render-time
config and reverted the script; saves now start from the stored config plus
every patch saved since. aws_environment_max_hours is cached per connection,
region and environment for 10 minutes, so re-mounting the section does not
ask AWS again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 12:10:37 -08:00
shadowdaoandClaude Opus 5.5 ea37f8434f fix(aws): retry the copy-at-connect secret read while the secret is pending deletion
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 12:08:46 -08:00
shadowdaoandClaude Opus 5.5 544409c554 fix(aws): no Pricing client counts as a failed fetch, so the 5-minute back-off applies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 12:08:46 -08:00
shadowdaoandClaude Opus 5.5 be96b5f68f fix(aws): the copy-at-connect warning gets its own toast topic
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 12:08:46 -08:00
shadowdaoandClaude Opus 5.5 ff5ae9862b fix(aws): a waiting clone retry no longer holds the retry lock, so a later connect cannot strand it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 12:07:14 -08:00
shadowdaoandClaude Opus 5.5 9e1e72d2a4 feat(aws): setup script editor
Build App (Preview) / compute-version (pull_request) Successful in 6s
Secret Scan / scan (push) Successful in 7s
Secret Scan / scan (pull_request) Successful in 14s
Build App (Preview) / create-release (pull_request) Successful in 6s
Build App (Preview) / build-macos (pull_request) Successful in 6m3s
Build App (Preview) / test (pull_request) Successful in 8m39s
Build App (Preview) / build-windows (pull_request) Successful in 11m38s
Build Container / build-container (pull_request) Successful in 17m24s
Build App (Preview) / build-linux (pull_request) Failing after 21m19s
Build App (Preview) / prune-previews (pull_request) Skipped
HostSection gets a monospace "Setup script" textarea (saved on blur, blank
as none) with the 32 KiB UTF-8 limit checked using the backend's message,
and notes on when it runs (as claude, bash -e, after the clone, every start,
30 minutes, output in the Overview card) and what it gets under
copy-at-connect.

Also in Host settings: the environment's advisory lifetime cap (Q8), read
by a new aws_environment_max_hours command, and the copy-at-connect limits
(no CA before the first connect, removed credentials linger in a running
task, no setup re-run after a re-clone), documented in CLAUDE.md too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:59:37 -08:00
shadowdaoandClaude Opus 5.5 5388db487e fix(aws): never run two workspace-status polls at once
A read in flight blocks the visibilitychange restart, so hiding and showing
the window mid-read no longer starts a second poll chain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:59:37 -08:00
shadowdaoandClaude Opus 5.5 3bc2b41b70 test(aws): pin the 168-hour lifetime cap across Rust, TypeScript and HCL
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:56:27 -08:00
shadowdaoandClaude Opus 5.5 f3d542ba60 fix(aws): build the pricing client inside the cost estimate's 8 s bound
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:56:27 -08:00
shadowdaoandClaude Opus 5.5 66a9993e69 fix(aws): retry a secret write while its deletion finishes
After a timed-out replace (secret force-deleted, not made again) the next
start retries the create/put for up to 30 s, then says to start again in a
minute; no more advice to restore the secret in the console.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:56:26 -08:00
shadowdaoandClaude Opus 5.5 56acab1bf2 fix(aws): register the workspace follower before spawning it
begin_follow runs in spawn_follow and the token is passed in, so a quick
Stop→Start can't leave the old follower registered last.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:56:26 -08:00
shadowdaoandClaude Opus 5.5 f87edbc5df fix(aws): build the gateway sidecar payload only when preparing a task
Attaching to a running task no longer needs the provider key or gateway
models; the payload is built lazily on the prepare path only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:56:26 -08:00
shadowdaoandClaude Opus 5.5 34f8a4161d fix(container): copy-at-connect setup waits for the connect; distinct WIP refs; atomic CA swap
- start_clone_repos waits for the first connect when a setup script exists,
  not only when there are repositories, so the script sees the CA, SSH keys
  and Git credentials.
- wip_ref appends 8 hex of sha256(raw folder) when sanitising changed the
  name, so `a b` and `a_b` never share a WIP branch.
- triple-c-apply-connect moves new CA files to a temporary name and swaps
  them in; a failed move keeps the CA installed before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:50:55 -08:00
shadowdaoandClaude Sonnet 5.5 d63f484edc docs(aws): restore spec sections lost in the phase 6 docs edit
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 10:38:25 -08:00
shadowdaoandClaude Sonnet 5.5 9f0c482222 docs(aws): phase 6
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 10:37:21 -08:00
shadowdaoandClaude Opus 5.5 3cd8542670 test(aws): live phase 6 checks
a_phase6_workspace_round_trips: one environment (max_workspace_hours 1)
and one project with EFS storage, a setup script, copy-at-connect with a
CA file, a port mapping and the gateway sidecar, two task starts, then
removal with discard. Passed live in us-west-2 (results in aws/README.md
and the spec). The phase-5 setup moves into deploy_for_workspace_user;
aws_host::ensure_started_with takes the sidecar's provider key from the
caller (the live tests have no keychain). scripts/aws-e2e-workspace.sh
runs TRIPLEC_E2E_TEST when set. The guard's task-definition retirement
listed nothing (ECS familyPrefix is a whole family name); it now filters
the full list by prefix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:34:46 -08:00
shadowdaoandClaude Opus 5.5 904547b2f1 feat(aws): estimated hourly cost per workspace
Q5: aws/pricing.rs reads on-demand Fargate rates (x86 and ARM vCPU-hours,
GB-hours, ephemeral storage GB-hours) from the Price List API in us-east-1
(AmazonECS; regionCode, termType=OnDemand, usagetype CONTAINS Fargate),
caches them per region for 24 h under <data_dir>/triple-c/aws-pricing/,
and estimates a config's hourly cost (ephemeral storage billed above
20 GiB; the gateway sidecar adds nothing). aws_cost_estimate(connection_id,
region, config) never errors: denied, offline or slow (8 s) is None,
shown as "Estimate unavailable"; a failed region is not re-asked for
5 minutes and a stale cache still answers.

pricing:GetProducts on * joins workspace-user-tasks.json with its check,
a policy test, the README and a live test (passed). HostSection shows the
estimate while configuring, Overview while running, with the Spot and EFS
notes. Fixture: a recorded us-west-2 GetProducts answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 10:14:06 -08:00
shadowdaoandClaude Opus 5.5 2857b4ae7d feat(aws): optional LLM gateway sidecar
A non-essential 'gateway' container runs the digest-pinned LiteLLM image
next to the workspace (Q7): its secrets are exactly the three
TRIPLEC_GATEWAY_* keys, the config uses os.environ/ references (no key
in it), /bin/sh writes it to a 0600 file and execs LiteLLM on
127.0.0.1:4000. The workspace's ANTHROPIC_BASE_URL/AUTH_TOKEN point at
it with a master key minted per task start; under copy-at-connect that
token and the gateway keys stay in the secret (R1). Needs the
OpenAI-compatible backend and a gateway model (validated on save, start
and in the UI). Requests with the toggle off are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:57:07 -08:00
shadowdaoandClaude Opus 5.5 45aef8da7d fix(aws): serialise and diff port-mapping forwards; refuse the gateway sidecar's port
Opens hold a per-project lock and re-read the stored mappings, so
overlapping saves converge on the last one without false 'in use' errors.
Unchanged forwards keep their live connections. The sidecar's 4000 is
refused while it runs (mappings reach workspace loopback). Stored rows
that would be refused no longer block unrelated saves; they are skipped
with a warning at connect. Port-mapping logs get their own prefix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:45:37 -08:00
shadowdaoandClaude Opus 5.5 08c779ad36 feat(aws): forward port mappings to AWS workspaces
Each TCP mapping of an AWS project becomes a loopback-only listener
carried into the task over socat-over-attach (the auth bridge's
PortForward, generalised to separate host and container ports; mappings
skip the bridge's first-byte/web gate). One set per project, opened after
every connect and on a save while connected, closed with the tunnel
(stop, remove, task death, exit). A failing mapping is a workspace-warning;
UDP and reserved ports are refused on save. The Config tab offers the
editor on AWS, TCP only, "Reachable only from this machine (localhost)".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:00:56 -08:00
shadowdaoandClaude Opus 5.5 262ea041c8 fix(aws): create the secret before reading it; one staging dir per connect
- Copy-at-connect tries CreateSecret first and reads the current value only
  when the secret exists, so a first start never reads a missing secret
  (which the owner-tag condition may refuse).
- triple-c-apply-connect: --prepare makes and prints a per-connect nonce
  dir; the app uploads into it and applies exactly that dir, so concurrent
  connects never mix files. CA files move to a fixed path so an unchanged
  CA is not reinstalled.
- connect.env parsing kept a trailing '=' (base64 padding) — it was dropped.
- Pending-deletion errors from GetSecretValue are reported as such; message
  and doc-comment fixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 08:51:14 -08:00
shadowdaoandClaude Opus 5.5 820bfab25c fix(aws): copy-at-connect review fixes — lock, ~/.ssh off EFS, secret history
- triple-c-apply-connect: the background re-clone closes the apply lock's
  fd, so a later connect never waits on it; --prepare takes the lock.
- R6: under copy-at-connect Hybrid/EFS no longer link ~/.ssh to EFS; the
  copied keys vanish with the task (UI says so, and that old keys on EFS
  stay until removed).
- R7: a copy-at-connect start that finds credentials still in the secret
  force-deletes it and creates it again (retrying ~30 s while AWS finishes),
  so no AWSPREVIOUS version keeps them.
- TRIPLE_C_CUSTOM_ENV (unsalted fingerprint) left out of the secret.
- Terminals get only the credential pairs (no file reads; keychain off the
  runtime), so a bad SSH/CA file never drops the API keys.
- ConnectBundle values are Zeroizing; UI copy updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 08:43:12 -08:00
shadowdaoandClaude Opus 5.5 8510797c22 feat(aws): copy credentials at connect instead of storing them
Copy-at-connect (phase 6, Q2): with secrets_delivery copy_at_connect the
project secret keeps settings, repos and the agent token but drops
TRIPLEC_FILES and every credential pair (SECRET_ENV_KEYS and all custom
variables), marking TRIPLEC_CREDENTIALS=connect. After every connect (start,
attach, background re-attach) the app uploads the SSH/CA files and a
connect.env as root into /dev/shm/triple-c and runs the new
triple-c-apply-connect: CA install as root, SSH merge and git credential
helper as claude, a `connected` marker the first clone waits for, and a
background re-clone of failed repos only. Terminals add the pairs to their
own ExecSpec env. A failed push is a workspace-warning.

The entrypoint's CA, SSH, git-credential, Hybrid-home and clone functions
move to container/entrypoint-lib.sh (sourced first; defines only), so both
scripts run the same code; Docker behaviour is unchanged. HostSection gets
the Credentials choice with its warnings (and the gateway note, R1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 08:32:09 -08:00
shadowdaoandClaude Opus 5.5 9c888caf13 fix(aws): follow clone and setup in the background, after the start
Ruling R5: the start ends after Connecting (Running, lock released) and a
background follower (cancelled on Stop, Remove, tunnel close, app exit)
reports only a failure it saw or one on a task this start ran. A stale
Starting/Stopping AWS project loads as Error, and reconcile also checks a
Stopped one that still has a task ARN, so a crash never hides a live task.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 08:09:51 -08:00
shadowdaoandClaude Opus 5.5 6b62a2a241 feat(aws): follow clone and setup when a workspace starts
The payload carries TRIPLEC_SETUP_SCRIPT and TRIPLEC_MAX_LIFETIME_MINUTES
(environment hours x 60 when capped); the 64 KiB error names the largest
parts. After Connecting, the start follows triple-c-workspace-status through
the agent (background exec, 2 s, progress on change, 35 min cap, quiet stop
when the tunnel goes). A failed clone/setup is a workspace-warning event and
a warning toast; Overview shows an AWS status card via aws_workspace_status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 08:01:10 -08:00
shadowdaoandClaude Opus 5.5 431cdc83cb fix(container): one WIP branch per run and folder, setup chain records failed, lifetime read as decimal
Two folders sharing a remote no longer force-push over each other's
triple-c/wip/<run-id>; the folder is part of the branch name (sanitised,
check-ref-format validated, hash fallback). A setup chain that dies with
the setup still running records failed so the idle stop is not blocked.
TRIPLEC_MAX_LIFETIME_MINUTES 00 means no cap and 08 means 8. The run record
is written after the agent-token block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 07:52:12 -08:00
shadowdaoandClaude Opus 5.5 618cac1a49 feat(container): setup script, lifetime cap and one WIP branch per run
TRIPLEC_SETUP_SCRIPT runs as claude after the background clone (bash -e,
stdin /dev/null, 30 min timeout) with status/log in /run/triple-c-setup;
the idle watcher counts it as busy and enforces TRIPLEC_MAX_LIFETIME_MINUTES
(best-effort WIP push, marker lifetime, exit 76 = StopKind::LifetimeCap).
WIP pushes go to one triple-c/wip/<run-id> branch per task run, skipping an
unchanged tree. New triple-c-workspace-status prints clone + setup JSON.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 07:44:20 -08:00
shadowdaoandClaude Opus 5.5 ad447555d9 fix(aws): clone through scratch and never delete a final path
clone_repos now clones into /workspace/.triple-c-clone/<folder> and renames
into place only on success, emptying scratch at each start; nothing at a
final path is ever deleted by the clone code. Replaces the in-repo
triplec.cloning marker, whose failed unset could get a working repository
deleted on the next start. triple-c-wip-push skips the scratch folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 21:49:57 -08:00
shadowdaoandClaude Opus 5.5 5477c2cea5 feat(aws): EFS storage mode
EFS storage is Hybrid plus /workspace on a second access point of the
user's own file system, rooted at /triple-c-workspaces/<owner_key>/<project>
(a sibling of the home roots) and mounted at /workspace. The workspace
access point is found by root + owner + project tags or created, waited
for before RunTask, recorded store-owned, kept when switching to Hybrid or
Ephemeral, and deleted with the home one by a discarding removal. Hybrid
and Ephemeral task definitions are byte-identical to before (pinned
fingerprints).

The entrypoint links home state for efs as for hybrid, warns when
/workspace is not mounted, and marks a clone in progress in its own
.git/config so a clone a killed task cut short is redone on the next start
while existing repositories are still skipped.

The EFS segment is enabled in HostSection, with a note when /workspace
files remain on an access point after switching away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 21:44:17 -08:00
shadowdaoandClaude Sonnet 5.5 cbaf6209fd feat(aws): environments can cap workspace lifetime
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 21:33:54 -08:00
shadowdaoandClaude Opus 5.5 34a6edd413 feat(aws): phase 6 project settings
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 21:29:29 -08:00
shadowdaoandClaude Opus 5.5 6497dd84e9 docs(aws): phase 6 plan — lifetime cap enforced inside the workspace
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 21:24:51 -08:00
shadowdaoandClaude Opus 5.5 fd0d51219f docs(aws): phase 6 plan
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 13:56:25 -08:00