---
name: tawa-cloud-runners
description: "Self-hosted Claude Code cloud sessions (tawa-chaac, tawa-dev): starting sessions, tawa-repo, tawa-pr, linking a Claude account, manifests, draining runners. Use for cloud-runner setup or failures."
---

# Cloud Runners — Self-Hosted Claude Code Sessions

## The Short Version

A Claude Code session started on claude.ai in a **Tawa cloud environment** runs on our own
droplets, not Anthropic's. Each session is a fresh container that acts as **the developer who
started it**: their Bio-ID identity, their own Forgejo token, their own git name.

| Environment (claude.ai) | Host | Who | Can reach |
|---|---|---|---|
| `tawa-chaac` | `tawa-chaac` droplet, 143.110.237.100, platform VPC | Bio-ID `platform_admin` | Public APIs incl. Koko and the builder; prod data via `koko` |
| `tawa-dev` | `tawa-dev` droplet, 64.23.130.154, isolated VPC | Bio-ID `developer` or `platform_admin` | Public APIs only; private ranges dropped |

Code: [insureco/tawa-runner](https://git.insureco.io/insureco/tawa-runner). Host setup:
`deploy/README.md`. Health monitoring: `deploy/monitoring/README.md`.

`tawa-chaac` is the Tawa/Chaac dev environment: the runners and the Chaac worker share it. It was called `tawa-platform` until 2026-10-15 (tawa-runner#53); its manifest tier keeps the name `platform`.

One runner serves one claude.ai session at a time. **tawa-chaac runs six** (`tawa-runner@1`–`@6`),
**tawa-dev runs two**, so that many sessions can run at once per environment. A seventh session waits
until one finishes. A runner is released after 30 minutes idle or 15 minutes without output, and
systemd then starts a clean one.

**Use worktrees, not more sessions.** One session can work several repos and tasks at once:
`tawa-repo` gives each its own worktree and `claw/*` branch, and Claude can run parallel subagents
across them. Open a second session only for genuinely separate work.

Chaac (`chaac-claw.service` on tawa-chaac) does not use runner slots. It shares the droplet's
memory and CPU with them.

## Starting a session

1. claude.ai → Code → new session → pick the environment (`tawa-chaac` or `tawa-dev`).
   Leave the repository empty: the claude.ai picker is GitHub-only.
2. In the session, clone the repo you want:
   ```bash
   tawa-repo iec-builder fix-helm-lock     # clone onto claw/fix-helm-lock-<id>, install deps
   ```
3. Work as usual. Commit and push `claw/*` branches. Open and merge PRs **with `tawa-pr`**,
   which acts as you; jci-mcp's `git_pr_create` records the PR as `iec-admin`:
   ```bash
   tawa-pr create --title "fix: …" --body-file -
   tawa-pr merge <n> --delete-branch
   tawa-pr issue create --title "bug: …" --body-file -   # issues are filed as you too
   tawa-pr issue comment <n> --body "…"
   tawa-pr issue close <n> [--comment "…"]                # closed as you, not iec-admin
   ```
   The session's Forgejo token carries exactly `read:repository write:repository write:issue
   read:package read:user read:organization` (iec-builder#168): no `write:user`, no `write:organization`.
   `read:user` is what lets `tawa-pr whoami` read your login; `read:organization` lets
   `tawa-pr` / `chaac-pr` find org-level labels such as `chaac-cloud` (chaac-claw#137). Private
   `@insureco/*` npm packages install with it through the session's `~/.npmrc`. Runner tokens
   (`tawa-cli-runner-*`) and Chaac task tokens (`tawa-cli-chaac-*`) older than 13 hours are
   deleted by the builder, so a crashed session or a renamed host leaves nothing behind.
4. The container is discarded when the session ends. A Stop hook will not let the session end
   with unpushed work; anything left uncommitted is pushed to `rescue/<session>` by the
   post-session hook.

A session that fails at start prints the reason. The common ones:

| Message | Fix |
|---|---|
| `… account_not_linked` / link page URL | [Link your Claude account](#linking-a-claude-account) |
| `cannot start in tawa-<env>: no Forgejo credential for this developer` | Read the line above it. `the builder could not be reached` is a builder outage: retry when `builder.tawa.pro` is back. `the builder refused git provisioning: … (HTTP n)` names the builder's reason |
| `wrong_org` / `wrong_audience` naming `ccr:org_id` / `ccr:pool_id` | Bio-ID config does not list this environment; see `deploy/README.md` "Bio-ID config" |

**Re-dispatch.** Anthropic re-dispatches a session that **failed to start** to a runner again,
every 2–12 minutes, until it starts or someone archives it in claude.ai (on 24 Sep one session
was picked up 9 times in 2 hours). Each retry costs a container start and fails the same way
until the cause is fixed, so **archive a session that failed at start** once you have read its
reason. A session that ran and was released (30 min idle, or 15 min without output) is picked
up again only when its developer comes back to it.

## Adding a developer to an environment

Three things, all required:

1. **Anthropic**: the person is a member of the Anthropic org and can use the environment
   (claude.ai → Admin → Cloud environments).
2. **Bio-ID**: an active, verified Bio-ID user whose `userType` admits them —
   `platform_admin` for `tawa-chaac`; `developer` or `platform_admin` for `tawa-dev`.
   The type is the allowlist. Changing it takes effect at their next session start.
3. **Claude link**: they link their Claude account to Bio-ID once (next section).

They should also have run `tawa login` on a laptop at least once, so the builder has a Forgejo
user for them. To remove someone, change their Bio-ID `userType`; their next session is refused
and any live session's Forgejo token is revoked by the next session on that runner.

## Linking a Claude account

The session's identity comes from the Claude account that started it (`act.email` in the
Anthropic session token). Bio-ID maps it to a Bio-ID user only after the person links it:

1. Open <https://my.askjefferson.com/settings/claude-link> signed in with Bio-ID.
2. Start a session in either environment. An unlinked session fails at start and is listed on
   that page (when its Claude email matches yours); the session output also prints a one-time
   link URL, valid for 15 minutes.
3. Approve it, then start a new session (archive the failed one so it is not re-dispatched).

## Bumping the manifest

What a session gets beyond the base image — the Claude Code version, pinned `tawa`/`kokopelli`,
`CLAUDE.md`, settings, hooks, commands, MCP servers, env — lives in `manifests/*.json` in
tawa-runner (`base.json` shared; `platform.json`, `dev.json` per environment).

1. Edit the manifest on a `claw/*` branch (e.g. `"claudeCode": "2.1.290"` or a tool version in
   `tools`). Run `test/manifest.test.sh`.
2. Merge to `main`. On each host `tawa-runner-sync.timer` (every 2 min) runs the repo's tests
   inside the runner image and publishes the commit to `/opt/tawa-runner-live` only if they pass.
3. The **next session** applies it. No image rebuild, no restart. Check a host:
   ```bash
   ssh root@<host> 'cat /opt/tawa-runner-live/.commit; cat /var/lib/tawa-runner-sync/status.json'
   ```
   The session's startup line reads `manifest <tier> @ <commit> applied`.

A failing commit is never published; after 10 minutes unhealthy the sync opens a
**live sync unhealthy on &lt;host&gt;** issue in tawa-runner. Changes to the image itself
(OS, Node, base Claude Code) need a rebuild: `deploy/README.md` "Rebuild the image on a host".

## Rotating an environment secret

Each host holds its environment's runner secret at `/etc/claude/environment-secret` (uid 1001,
mode 0400). It never passes through a laptop or an agent.

1. In claude.ai → Admin → Cloud environments, regenerate the environment's secret and store the
   new value in the daryx vault (`daryx ssh credentials set <alias> --type secret --stdin`).
   Do not paste it anywhere else.
2. Have the vault write it to the host:
   ```bash
   daryx ssh exec tawa-chaac 'umask 077; printf %s "$S" > /etc/claude/environment-secret && chown 1001:1001 /etc/claude/environment-secret && chmod 0400 /etc/claude/environment-secret && wc -c < /etc/claude/environment-secret' --with S=<vault-alias>
   ```
3. [Drain](#draining-the-fleet) the host's runners, then start them. A runner reads the secret
   when it starts; the old one stops working as soon as Anthropic rotates it, so do steps 2–3
   promptly.

The same pattern applies to `/etc/tawa-runner/bio-client-secret` (the `tawa-runner` Bio-ID
client, vault alias `tawa-runner-bio-client-secret`).

## Draining the fleet

A runner that is stopped mid-session interrupts that session (it deregisters and Anthropic
requeues it). Drain one runner at a time, only when idle:

```bash
# idle?  "0/1 slots" = idle, "1/1" = a session is running
ssh root@<host> 'for i in 1 2; do echo "@$i $(journalctl -u tawa-runner@$i -n 50 -o cat | grep -o "[0-9]/1 slots" | tail -1)"; done'
ssh root@<host> 'systemctl stop tawa-runner@1'      # only when @1 is idle
ssh root@<host> 'systemctl start tawa-runner@1'     # back into service
```

To take a whole host out (maintenance, resize): stop each runner as it goes idle, then do the
work. Health monitoring will alert while no runner polls; that is expected. For a busy runner
that must go now, `systemctl stop` gives the session up to 100 s to stop and run its
post-session hook, which pushes uncommitted work to `rescue/<session>`.

## Health monitoring

iec-pulse probes each host every 60 s (`deploy/monitoring/` in tawa-runner) and emails the
platform alert address:

| Monitor | DOWN when |
|---|---|
| `tawa-runner-chaac`, `tawa-runner-dev` | no runner on the host has polled Anthropic for 5 min, or the heartbeat stopped |
| `tawa-runner-chaac-disk`, `tawa-runner-dev-disk` | Docker's disk (all sessions' `/workspace`) is 85% full or more |

Check a host by hand: `ssh root@<host> 'curl -s localhost:9109/health; curl -s localhost:9109/disk'`.
They are `unmanaged` pulse monitors, listed on the pulse dashboard with an **External** chip.

## What NOT to do

- Don't restart `tawa-runner@*` to "fix" a session — it interrupts whoever is on it. Check
  `0/1 slots` first.
- Don't put a secret on a host by pasting it into a shell. The vault writes it (`daryx ssh exec
  --with`).
- Don't edit `/opt/tawa-runner-live` on a host. It is overwritten from `main` every 2 minutes.
- Don't open PRs from a session with jci-mcp if attribution matters; use `tawa-pr`.
- Don't leave a session that failed at start un-archived: Anthropic keeps re-dispatching it.
- Don't add runners without checking memory. Each runner's container is capped (tawa-chaac:
  3 CPU / 4 GB, tawa-dev: 3 CPU / 6 GB, in `/etc/tawa-runner.env`). A cap is a ceiling, not a
  reservation: sessions are mostly idle, so six runners share an 8 vCPU / 16 GB droplet. Several heavy
  builds at the same moment are what contend for it. Resize or add a host when sessions start queueing
  or memory runs short, not before.
