Ledger · main
You are Fable, working on Equipo (`amadan.net/oficina/equipo`), Paul's team-of-agents app. Your task: **make Equipo's CI run on amadan's hosted cloud CI, and run very fast.** Paul approved this: "Can you just do everything you need in coordination with the Amadan agent to allow you to use Amadan's hosted CI and that CI to be very fast? Amadan's our project." ## Context - **CI today:** Equipo CI runs on Paul's docs-t1 local runner, a shared and heavily loaded box. The steps are `.amadan/ci.d/*`. - **ci-speed (just merged to main c6319a5):** test caching; a 7-way shard step `30-test@7`; a quarantine step; timing budgets that only fail with `EQUIPO_CI_DEDICATED=1`. Its log is `docs/superpowers/plans/CI-PROGRESS.md`. - **Amadan's hosted cloud runner** is documented in `~/amadan.net/amadan/amadan/docs/ci-cloud-runner.md` (lanes, caps, sentinel, immutable box, arm64, tito-ci account). - **An earlier attempt found four blockers:** 1. The boxes are arm64, and Equipo pins the x86-64 codex 0.165.0 by SHA (`internal/runner/provider/codex/launcher.go`). Other fingerprinted tools are also x86-64: srt, and `~/.local/share/equipo/try/bin`. 2. Steps 35 and 36 require `/usr/bin/bwrap` 0.11.0, but the box has 0.9.0. 3. `TestNamespaceCgroupMoveKeepsMembership` needs a writable user cgroup, which the job sandbox doesn't provide. 4. Box rolls must be coordinated with the titogo work (launch template v22). ## Your part (Equipo side) 1. **Make Equipo's CI architecture-neutral.** Add arm64 pins next to the x86-64 ones for every pinned or fingerprinted tool used in tests (codex, srt, the try/bin tools, Node and ripgrep if tests use them). Verify the digests from the official releases. Tests pick the pin for `runtime.GOARCH`. Keep production pins intact. 2. **Split the host-capability tests** (exact bwrap version, cgroup move, and anything else that checks the real runner host rather than code) into one clearly named step, e.g. `.amadan/ci.d/60-runner-host`. It must only run on a real runner host. How it gets routed is up to amadan: a per-step runner requirement, a separate job, or similar. Work that out with amadan through me, platform-eb, as described below. Everything else must pass on the arm64 cloud box under amadan's job sandbox with bwrap 0.9. 3. **Make the cloud run as fast as possible:** - Measure. - Use the shard step well, and if amadan supports it, shard across lanes or boxes. - Keep test caching effective. GOCACHE persistence on the lane is amadan's; tell me what you need. - Cut slow tests: parallelise, `t.Parallel`, and shared fixtures where safe. - Target a typical change at well under 5 minutes wall time. 4. **Prove it before switching.** Run Equipo's CI on the cloud lane once amadan has added it. Until then, use the cloud box image or an arm64 container locally if you can (docker/podman on this host, arm64 via qemu if available; otherwise build-only checks with `GOARCH=arm64`). ## Coordination - The amadan-side changes are done by the Amadan agent (session `amadan-12`). I (platform-eb, the Equipo coordinator) relay between you. When you need something from amadan, write it as a numbered request in `~/.cache/tmp/equipo/fable-ci-requests.md` (append; never rewrite earlier entries), and say so in your output. I'll forward it. Answers come back in `~/.cache/tmp/equipo/fable-ci-answers.md`. Check that file whenever you're blocked. - My first message to amadan-12 already asked about per-step runner requirements, parallel steps across lanes, an `oficina/equipo` lane with `EQUIPO_CI_DEDICATED=1`, grants, and box-roll timing. ## Where - New worktree `~/amadan.net/oficina/equipo-hostedci`, branch `hosted-ci`, from main (c6319a5 or newer). - Keep a `docs/superpowers/plans/HOSTED-CI-PROGRESS.md`. - Short branch: merge to main when green with `amadan branch merge oficina/equipo hosted-ci -expect <FULL 40-char sha> -message "<subject under 80 chars>\n\n<body>"`. Never run a bare `amadan branch merge`, and never run any amadan write command without full explicit arguments. ## Hard rules - **This is a shared machine (docs-t1).** - Bind anything you start to 127.0.0.1. - No sudo. - Scratch goes in `$TMPDIR` or `~/.cache/tmp/equipo-hostedci/`. Delete only what you created, by exact path, never with globs. - Leave GOCACHE at its default. - Run heavy work with `nice -n 10`, one heavy job at a time. - Stop everything you started. - **Production is untouched.** Don't deploy the Equipo app or touch `equipo-runner*.service`. - **Never read or print anything** under `~/.local/share/equipo/accounts/*` or any credentials. - **Don't change amadan's repo or AWS yourself.** That's amadan-12's work, via requests. - **Commits:** subject under 80 characters, then a blank line, then the body, ending with `Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>`. Push via `~/.cache/tmp/equipo/agent-push.sh` (see the earlier progress logs for usage). - **Tests and reviews:** each behaviour change needs a test that fails first. No em dashes in any user-facing copy. ## When done Equipo's CI should run on the cloud lane, green and fast, with the host step routed to docs-t1, and the branch merged to main. Report in under 300 words: head SHA, before and after wall times, what moved where, what amadan changed, and open issues. If you're blocked on amadan for long, say exactly what you're waiting for.
<task-notification> <task-id>a00da0c1ecb3461fd</task-id> <tool-use-id>toolu_01XGg1D6urEe45RQq7pUnDVS</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/a00da0c1ecb3461fd.output</output-file> <status>completed</status> <summary>Agent "Map amadan CI routing features" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>All of this is checked against code on `main` (HEAD `2cb256b`) in `/home/paulca/amadan.net/amadan/amadan`. Paths below are relative to that directory unless they start with `/`. ## 1. Steps and sharding - **Which file runs.** The runner looks in `.amadan/<pipeline>.d/` first, and for push CI that is `.amadan/ci.d/`. If that directory has no steps, it falls back to an executable `.amadan/ci`, then to `make ci` if the Makefile has that target, and otherwise reports "skipped" (`internal/cli/runnerjob.go:483-497`, `:611-634`). Those two fallbacks apply only to the `ci` pipeline (`:612`). - **Discovery** (`runnerjob.go:789-827`). Entries are sorted by filename. Dotfiles and subdirectories are ignored. A file with no extension and no exec bit fails the whole job. A non-executable file with an extension (README.md) is ignored. The name `20-go-test` is shown as `go-test` (`:880-892`). - **Steps run one after another, never in parallel.** They share one timeout for the whole job. The first step that is not a success stops the run, and the remaining steps are reported `skipped` (`runnerjob.go:908-988`). - **What `NN-name@N` does.** It starts N copies of the same script at the same time, as separate processes (goroutines at `:937-949`), on the same box and in the same worktree. - Every shard runs to the end even if a sibling fails; nothing is cancelled early (`:946`). - Each shard gets `AMADAN_SHARD` (0-based), `AMADAN_SHARD_COUNT` and `AMADAN_STEP` (`:1036-1040`). - A plain `.amadan/ci` gets `AMADAN_SHARD=0` and `AMADAN_SHARD_COUNT=1` (`:516`). - N must be a canonical positive integer and at most `MaxShards = 64` (`:43`, `:854-875`). Nothing compares N to the CPU count; there is no `NumCPU` check anywhere. - Every shard is wrapped in bwrap separately (`:1033`). - A shard that prints nothing gets a "produced no output" note (`:1082`). - **Steps in parallel, or on different runners: not possible.** One job is one claim and one runner, and a runner process handles one job at a time. `serveOne` is called in a sequential loop (`runner.go:429-463`, `:776`). - **Designed, not built:** spreading shards across machines. The sharding spec lists it as a non-goal ("Fan-out across a fleet is a different design", `2026-08-18-sharded-ci-steps-design.md:211-214`). ## 2. Capabilities and pipelines - **`amadan ci requires` is one set of tags for the whole repo.** It cannot be set per pipeline or per step. - The client is `internal/cli/cirequires.go:36-66`. - It is stored as one `ci_config` row, `required_caps` (`internal/repod/store_ci_caps.go:34`, `:47-80`). - Tags must match `[a-z0-9-]+` (`cirequires.go:29`). - **How `-caps` matching works** (`internal/repod/api_ci.go:146-170` in the claim handler). - Every required tag must be among the runner's tags (`capsSatisfied`, `store_ci_caps.go:87-101`). - An empty requirement matches every runner. - A runner that is missing a tag gets `202 {"idle":true,"unmet_caps":[...]}`. The job stays queued and is never claimed and released. - The plan says so directly: "per-step/per-job requirements are NOT built" (`docs/superpowers/plans/2026-08-27-ci-runner-capabilities.md:9`). - **Can one commit's CI be split between a runner with X and a runner with Y?** No. - The `ci` pipeline is one job and runs on one runner. - You can declare extra pipelines, and each is its own job, so a different runner could claim it. But the requirement applies to the whole repo, so you cannot steer pipeline A to X and pipeline B to Y. - **How pipelines are declared** (`internal/cli/runnerpipelines.go:82-180`): - Each pipeline is a pair: a directory `.amadan/<name>.d/` and a trigger file `.amadan/<name>.on`. - Names must match `[a-z0-9-]+` (`:268`). - `ci` always exists. Its `.on` is optional, but if present it must be `push <pattern>` (`:170`). - A `.d` without an `.on`, or an `.on` without a `.d`, fails the job. - An `.on` file holds exactly one directive; blank lines and `#` comments are allowed (`internal/cli/pipelineon.go:73-94`). The four forms are `push <glob>`, `schedule <5-field cron>`, `after <pipeline> success <glob>` and `dispatch` (`:37-42`). - The runner finds the declarations at checkout. They travel back with the report from a `ci` run on the default branch, and the instance keeps a registry of them (`runner.go:851-873`, `:964`). - **Which triggers actually queue jobs:** | Trigger | Status | Where | |---|---|---| | `push` (extra pipelines) | Built. Queued after the `ci` job; the newest job per (pipeline, branch) wins | `internal/repod/store_ci_push.go:188-260` | | `schedule` | Built. Due jobs are created inside a claim | `internal/repod/store_ci.go:414` (`materialiseDueSchedules`) | | `after` | Built | `internal/repod/store_ci_after.go` | | `dispatch` | Parsed and registered only. No producer and no CLI command | `TriggerDispatch` is referenced only at `internal/repod/store_ci_register.go:59,69` | | `ci.on` pattern | Accepted, stored, and deliberately ignored. `ci` is queued on every push to every branch | `store_ci_push.go:18-43` | - **Ordering.** Pipelines other than `ci` are run one at a time per pipeline, across all branches (`internal/repod/store_ci_concurrency.go:84-88`). `ci` jobs are never blocked this way. A claim takes the oldest eligible job. - **The verdict and the merge gate come only from `ci`.** - Other pipelines write to `ci_pipeline_runs`, never to `ci_statuses` (`store_ci_push.go:84-90`). - `amadan branch merge` checks `tipCIState(head)`, which reads `ci_statuses` for the exact tip commit. It must be `success`, but only if the repo has the require-green setting turned on (`internal/repod/git_merge.go:438-64`, `:695-704`). - So the verdict is the single `ci` job's state. Within it, any failed step or shard makes the job fail, and a cancellation outranks a failure inside a sharded step (`runnerjob.go:960-985`). ## 3. Sandbox (`-isolate bwrap`) - **Exact arguments, in order** (`internal/cli/runnerisolate.go:206-234`): `bwrap --ro-bind / / --dev /dev --proc /proc --tmpfs /tmp [--tmpfs <workdir>] [--bind P P for each writable path] --tmpfs <AMADAN_HOME> --unshare-user --unshare-pid --die-with-parent -- <cmd>` - **What that means:** - **Read-only:** the whole host, including `$HOME`, `/sys`, and `/sys/fs/cgroup` (no `--unshare-cgroup`, so the host's cgroup tree is visible read-only). - **Fresh mounts:** `/proc` (new instance), `/dev`, and a private tmpfs `/tmp`. - **Hidden behind an empty tmpfs:** the whole `-workdir` (so other repos' workspaces are absent) and the runner's own credentials directory. - **Writable:** only that repo's `repoDir` plus its `cache/go-build`, `cache/go-mod` and `cache/gopath` (`runner.go:916`). - **`$HOME`:** `/home/runner`, read-only, which is why GOPATH is redirected (`runnerjob.go:1128-1133`). - **Network:** shared with the host, on purpose. There is no `--unshare-net`, and a test asserts that (`runnerisolate_test.go:244`). - **Not unshared:** IPC, UTS, cgroup. There is no seccomp filter and no `--new-session`. - **uid:** `--unshare-user` with no `--uid`, so bwrap's default applies and the runner's uid is mapped to itself (the code comment at `:181` says "not 0"). On the cloud box that uid is `runner`. - **Startup check.** The runner tries a real sandbox before starting and refuses to start if it fails (`:98-108`, `:132-134`). `oci` mode is refused as not implemented (`:136-137`). - **Nested bwrap / user namespaces inside a job:** nothing in the repo tests this. It is probably possible, because no seccomp filter or `--disable-userns` is used and the box sets `kernel.apparmor_restrict_unprivileged_userns=0` (`hack/cloud-runner-user-data.sh:63`), but it is not checked. - **Environment** (`runnerjob.go:209-255`, `:325-335`): - **Inherited:** the runner's whole environment, minus every `AMADAN_*` variable. - **Then added:** secrets (unscoped ones plus those scoped to this pipeline, never `AMADAN_*` names), then `AMADAN_CI=1`, `AMADAN_COMMIT`, `AMADAN_BRANCH`, `AMADAN_PIPELINE`, `AMADAN_TRIGGER`, `AMADAN_HUB`, the per-repo `GOCACHE` and `GOMODCACHE`. - **Under bwrap only:** `GOPATH=<repo>/cache/gopath`, with `$GOPATH/bin` put in front of `PATH`. - Plus `AMADAN_STEP`, `AMADAN_SHARD` and `AMADAN_SHARD_COUNT`. - **Not set by amadan:** `CI` and `GOFLAGS`. A `GOFLAGS` is only present if the runner's own environment has one; the cloud unit does not. - **HOME** comes from systemd `User=runner`. - **PATH on the cloud box:** `<repo>/cache/gopath/bin:/home/runner/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin` (unit file at `hack/cloud-runner-user-data.sh:625`). ## 4. Caching - **Layout.** Everything for a repo lives under `<workdir>/repos/<ns__repo>/`: a shared clone in `git/`, one worktree per branch in `wt/<branch>`, and `cache/{go-build,go-mod,gopath}` (`internal/cli/workspace.go:113-137`). On the cloud box `<workdir>` is `/var/lib/amadan-runner/<lane>`, on a persistent EBS volume. - **Persistence.** The caches survive across jobs, and per-repo is the only scope. - The runner's own `GOCACHE=/var/lib/amadan-runner/gocache` is replaced for jobs (`hack/cloud-runner-user-data.sh:630-631`). - **Worktree reuse.** The worktree for a branch is reused: `git checkout --force --detach <sha>` (`workspace.go:305`). - Untracked and ignored files are kept unless the runner was started with `-clean` (`:312-319`). - Git only rewrites files whose contents changed, so unchanged files keep their mtimes. That is standard git behaviour, not amadan code. - On a scale-to-zero cloud wake, the volume may be attached to a different box (see 6), so there will be some cache misses. - **Eviction** (all three run after each reported job, `runner.go:981-989`): - `-cache-max`: deletes a repo's whole `cache/` once it exceeds the cap (`workspace.go:576`). - `-workdir-max`: deletes whole least-recently-used repo directories until the total fits (`:486`). - Busy repos are skipped in both cases. - `-min-free`: before a job, if free space is below the floor, it runs both of the above and then drops every repo's cache. It never refuses a job (`runner.go:1018-1060`). - Branch GC removes worktrees whose branch is gone (`workspace.go:395`). ## 5. Timeouts and limits - **Job timeout.** One timeout covers the whole job, all steps and shards together. - Default is 30 minutes (`DefaultJobTimeout`, `runnerjob.go:28`). - `-timeout` sets the runner's ceiling. - `.amadan/timeout` can only lower it (`:735-763`). - There are no per-step or per-shard timeouts (a non-goal in the sharding spec). - **Other timeouts:** the `make -n ci` probe has 30 seconds (`:643`). The lease is 120 seconds, with a heartbeat every 30 seconds (`api_ci.go:24`, `runner.go:106`). A job gets 2 attempts, and a queued job goes stale after 24 hours (`store_ci.go:41-42`). - **Log limits:** - Each script, step or shard keeps the last 1 MiB of output (`MaxLogBytes`, `runnerjob.go:21`). - The whole report shares a log budget of 1 MiB across all units, weighted 8:1 toward failing units (`internal/cli/runnerbudget.go:34-62`). - Report body is capped at 4 MiB. The instance caps the decoded payload at 2 MiB (`api_ci.go:38`). - Stored logs are kept for 14 days and up to 250 MiB per repo (`internal/repod/store_ci_route.go:~295-306`). ## 6. The cloud worker - **Machine.** The launch template is not in Terraform; it was built by hand (`infrastructure/ci/worker_unmanaged.tf:44-51`). - Comments say it is a `c7g.4xlarge` on spot (`hack/ci-sentinel.sh:143`, `docs/ci-sentinel.md:347`). That is 16 Graviton vCPUs (the box's own comment says "sixteen vCPUs", `hack/cloud-runner-user-data.sh:436`). 32 GiB of RAM is AWS's published spec for that type, not stated in the repo. - It runs on arm64, with Ubuntu 24.04. - **Software installed:** - Explicitly: `git make curl ca-certificates bubblewrap gcc libc6-dev nftables` (`hack/cloud-runner-user-data.sh:43-46`, `:370`), Go `1.26.8` linux-arm64 (`:21`, `:71`), Node `22` from nodesource (`:29`, `:73-74`), and Playwright `1.62.1` with chromium headless-shell linked to `/usr/local/bin/chromium` plus full Chromium (`:250-316`). - Not installed explicitly: python3. It is most likely there because Ubuntu 24.04 server images ship 3.12, but the script does not install it. - The bubblewrap version is whatever noble ships (0.9.0, from outside knowledge; not pinned in the repo). - **Who jobs run as:** user `runner` (`:88`, `:622`). The runner's uid is blocked from the instance metadata service by nftables (`:336-410`). - **Lanes.** Each lane is a separate runner process with its own repo list (`:473-477`): - `w1`: tito/titogo - `w2`: amadan/amadan, carlos/platform, carlos/contra, dineraya/dineraya - `w4`: rastrillo/rastrillo - Each runs `amadan runner -isolate bwrap -workdir /var/lib/amadan-runner/<lane> -caps browser -caps node -cache-max … -workdir-max … -min-free 10G` (`:681`). - **Scale-to-zero:** - The sentinel checks every 15 seconds (`POLL_SECONDS=15`, `hack/ci-sentinel.sh:176`), scales to zero after 5 minutes idle (`IDLE_SECONDS=300`, `:193`), and force-stops a box after 8 hours of uptime. - It asks for one worker per queued or running job, up to `MAX_WORKERS=3` (`:153`, `docs/ci-sentinel.md:247-266`). - The fleet only grows while there is work and only ever drops straight to zero. - **Wake latency from a cold fleet:** about 15 seconds of sentinel poll plus about 100 seconds of boot until a runner is polling. About 155 seconds until a first job finishes (`docs/ci-sentinel.md:474-477`, `:737-739`). ## 7. Laptop runner vs cloud lane - **There is no priority or affinity.** Whichever eligible runner claims first wins; the claim hands out the oldest eligible job (`ClaimJob`, `store_ci.go:389`). The docs say the same: "whichever runner polls first wins the job" (`docs/ci-cloud-runner.md:171-173`). - **`requires` is the only way to steer.** If the repo requires `browser`, a laptop started without `-caps browser` sits idle on that repo. - **The cloud box only serves repos listed in its lane table**, so a repo must be added there before cloud runners will take its jobs at all. - **Jobs only queue if a runner exists.** A push queues jobs only if some runner polled that repo within the last 7 days (`internal/repod/enqueue_ci.go:23-31`, `api_ci.go:28`). ## Designed but not built (or only partly) - Steps running in parallel, and per-step or per-pipeline `requires`. Ruled out in the capabilities plan and in the trigger-file grammar. - Spreading shards across runners or the fleet. - `dispatch` trigger: no producer and no CLI command. - `ci.on` branch pattern: accepted and stored but not honoured. - `-isolate oci` and container jobs: refused at startup. - Per-repo worker pools and predictive scaling (fleet spec §4.6). ## Mismatches worth knowing about - **The infrastructure checkout is on an unmerged branch.** `/home/paulca/amadan.net/amadan/infrastructure` is on `oficina-cache-growth`, 4 commits ahead of its `main`. That branch adds `max_workers=3` and 200 GiB volumes. On that repo's `main` there is no `max_workers` variable and volumes are 100 GiB, while amadan's `main` already assumes `MAX_WORKERS=3` and 100 GiB volumes (`hack/cloud-runner-user-data.sh:482-488`). - **The pipelines spec's status table is out of date.** It says `push`'s pattern does nothing (`2026-08-24-pipelines-and-triggers-design.md:2728`). The code now has a push producer for pipelines other than `ci` (`store_ci_push.go`). The `dispatch` part of that table is still accurate.</result> <usage><subagent_tokens>158123</subagent_tokens><tool_uses>39</tool_uses><duration_ms>193099</duration_ms></usage> </task-notification>
<task-notification> <task-id>bq8xxnsla</task-id> <tool-use-id>toolu_01CieCpP9cgpxMRTRTCda4rS</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/bq8xxnsla.output</output-file> <status>completed</status> <summary>Background command "Run the whole test suite in the simulated cloud sandbox (no provider tools)" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>br3a08ro8</task-id> <tool-use-id>toolu_01G2vS3LDvuzQoqe5tnVijDW</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/br3a08ro8.output</output-file> <status>failed</status> <summary>Background command "Run the whole test suite in the simulated cloud sandbox (no provider tools)" failed with exit code 144</summary> </task-notification>
<task-notification> <task-id>ac39b00b2f8ed56cf</task-id> <tool-use-id>toolu_01VzzKSNbyy2pU2C79JYcT7F</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/ac39b00b2f8ed56cf.output</output-file> <status>completed</status> <summary>Agent "Map amadan hosted CI behaviour" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>I answered all eight questions from the code at `amadan/main` (cfbdf20). File paths are relative to the repo root. Anything that comes only from a spec, a plan, or general Amazon Linux 2023 behaviour is marked **[spec]**, **[docs]** or **[not in code]**. **Branches:** - `amadan/hosted-gcc` adds nothing beyond main. It is already merged (4c73abb installs gcc so `go test -race` works). - `amadan/hosted-dep-reads` adds two documents and no code: `docs/superpowers/specs/2026-11-10-hosted-ci-dependency-reads-design.md` (+205 lines) and `docs/superpowers/plans/2026-11-10-hosted-ci-dependency-reads.md` (+308 lines). ## 1. How a job runs on the hosted machine **User and paths** - The job runs as the user `ci`, started with `runuser -u ci -- amadan runner -hosted-job /home/ci/job.json` (`internal/dispatch/boot.sh.tmpl:72`). The boot script creates `ci` with home `/home/ci` (mode 0700) and puts it in the `docker` group (`boot.sh.tmpl:47-53`). - The work directory is `/home/ci/work` (`internal/dispatch/launch.go:85`). - The checkout is a git worktree at `/home/ci/work/repos/<ns>__<repo>/wt/<branch>`. The shared clone sits beside it at `.../git` (`internal/cli/workspace.go:155,159,166`). Branch names are cleaned to `[A-Za-z0-9._-]`; a job with no branch uses `default`. **Sandbox:** none. - `HostedJob` forces `ResolveIsolation(IsolateNone…)` (`internal/cli/runnerhosted.go:115`). The design is one machine per job, used once. - Because `ci` is in `docker`, it is effectively root (`internal/dispatch/boot.go:30`). **Environment** (`internal/cli/runnerjob.go:213-262`, applied on top of the runner's own environment with every `AMADAN_*` variable removed, `runnerjob.go:332-342`): - The repo's secrets for this pipeline come first. Secrets named `AMADAN_*` are dropped. - `AMADAN_CI=1`, `AMADAN_COMMIT`, `AMADAN_BRANCH`, `AMADAN_PIPELINE`, `AMADAN_TRIGGER`, `AMADAN_HUB`. - Each step also gets `AMADAN_STEP`, `AMADAN_SHARD`, `AMADAN_SHARD_COUNT` (`runnerjob.go:1043-1047`). - `GOCACHE=<repoDir>/cache/go-build` and `GOMODCACHE=<repoDir>/cache/go-mod` (`workspace.go:131-132`, `internal/cli/runner.go:990-991`). - `npm_config_cache=<repoDir>/cache/npm` (`runnerhosted.go:146`, `runner.go:969-970`). - **`GOPATH` is not set** under isolation "none" (`runnerjob.go:1135-1139`, `runner.go:993-997`), so it falls back to `/home/ci/go`. That directory is not cached. - `GOFLAGS`, `GOPROXY`, `GOTOOLCHAIN`, `GOPRIVATE`, `CI` and `TMPDIR` are never set anywhere in the hosted code path. Go's defaults apply (proxy.golang.org, and the toolchain setting stays at `auto`). - `PATH` comes from the boot script's `export PATH=/usr/local/go/bin:$PATH` (`boot.sh.tmpl:44`), passed through `runuser`. **[not in code]** I'm inferring that `runuser` without `-l` keeps `PATH` and resets `HOME` to `/home/ci`. **Timeouts** - The job budget is 30 minutes from the claim (`internal/hostedci/hostedci.go:27`, `runnerhosted.go:144`). - `.amadan/timeout` can lower it but never raise it (`runnerjob.go:742-770`). - Claiming must happen within `BootBudget` = 10 minutes (`hostedci.go:29`). - The guest also arms `shutdown -h +N` as a backstop (`boot.sh.tmpl:18`), and the reaper kills any instance older than 48 minutes (`hostedci.go:46`). **Steps and shards** work exactly as on a normal runner, through the same `Runner` with `OneJob` set (`runnerhosted.go:139-155`): - Steps run in sorted order. After a failure, later steps are reported as skipped. - All `@N` shards of a step run at the same time on the one machine (`runnerjob.go:935-957`), with `MaxShards` = 64 (`runnerjob.go:43`). So `30-test@7` means 7 processes on 2 vCPU by default. **Checkout depth:** shallow, depth 1, one branch. - First fetch: `git clone -q --depth 1 --branch <b>` (`internal/cli/runnertransport.go:600-603`). - It is deepened (`--unshallow`) only for an `after` job pinned to a commit that isn't present (`runnertransport.go:302-354`). - So gitleaks history scans see a single commit. `git ls-files` works normally. - `remote.origin.url` holds no credential (`runnertransport.go:520-618`). **File times:** every job is a fresh clone, so every file's mtime is the checkout time. - The build cache is keyed on content, so compiles are unaffected. - **[not in code]** From Go's own behaviour: `go test` result caching hashes the size and mtime of files a test opens (testdata, for example), and refuses to cache files modified within the last ~2 s. Tests that read repo files will therefore re-run every job. Tests that open no files can still hit the cache, because a restored `GOCACHE` holds their results. ## 2. The build cache **What is saved:** only `<repoDir>/cache/{go-build,go-mod,npm}` (`internal/cli/hostedcache.go:48`). - Anything a job writes under those directories is saved, including extra files such as `$GOCACHE/some-dir/…`. Only regular files and directories are kept; symlinks and other types are skipped (`hostedcache.go:473-528`). - `GOPATH`, `~/.cache`, Docker images and the checkout are not saved. **Format:** one `tar` piped through the `zstd` binary at `-c -3` (`hostedcache.go:416-452`), stored in S3 at: - `shared/<sha256(repo)>/<toolchain>/cache.tar.zst`, or - `branch/<sha256(repo)>/<sha256(branch)[:32]>/<toolchain>/cache.tar.zst` (`hostedci.go:250-271`). - The toolchain is `al2023-go<ver>-node22-gcc` (`boot.go:95-97`), so a Go version bump starts from an empty cache. **Scope** (`internal/dispatch/cache.go:47-74`): - Default-branch runs read and write the shared cache. - Other branches read their own branch cache first, then the shared one, and write only their branch cache. - Runs with no branch read the shared cache and write nothing. - If the default branch is unknown, a run reads branch then shared and writes branch. - Each repo is separate. Pipelines are not part of the key, so all pipelines on a branch share one cache. **When it is saved:** only when the job's verdict is `success` (`runnerhosted.go:156-160`), and only **after** the report is filed (`runner.go:1041-1054` returns first). It does not add to the time before the verdict appears. - The save has 2.5 minutes (`hostedcache.go:57`): tar plus zstd into a temp file, then one S3 POST. If it runs over, it fails and the job only logs it. **Restore:** runs **before** the claim (`runnerhosted.go:135`), so it isn't billed but it does add to the time from push to first step. - It is one streamed GET piped into `zstd -d`, then extracted by Go's tar reader into a temp directory and moved into place. It is not parallel. Timeout is 5 minutes (`hostedcache.go:53,102-235`). - **[spec]** A 151–168 MB cache restored in about 3 s, and in-region S3 ran at about 100 MB/s (`docs/superpowers/specs/2026-10-29-hosted-ci-design.md:91-95`). **Limits:** 2 GiB compressed, 6 GiB unpacked, 1,000,000 entries (`hostedci.go:61-65`). A cache over any limit is not saved and not restored. - There is no trimming code. - **[docs]** S3 deletes branch caches 14 days and the shared cache 90 days after the last save (`internal/hub/docs/ci.md:470`; `branch_cache_days`/`shared_cache_days` in the plan at line 749). **Concurrent jobs:** there is no locking or conditional write. Each save is a plain POST to the same key, so the last writer wins (inferred from `hostedcache.go:560-598`). ## 3. Machine sizes, disk, spot, boot time **`-size N`:** the syntax is `amadan ci hosted [<ns>/<repo>] [on|off] [-size N]`, and N must be a positive integer (`cmd/amadan/main.go:2689-2711`). Allowed sizes and instance types (`hostedci.go:138-144`): | vCPU | Instance type | |---|---| | 2 | c7g.large | | 4 | c7g.xlarge | | 8 | c7g.2xlarge | | 16 | c7g.4xlarge | | 32 | c7g.8xlarge | - The default is 2 (`hostedci.go:59`). - Plans limit sizes: solo {2}, team {2,4,8}, sponsored 2–32 (`internal/hub/billing_plans.go:47-53`). - **[not in code]** RAM is AWS's c7g figure of 2 GiB per vCPU, so 4 GiB on the default size. **Disk:** root volume defaults to 20 GiB gp3, encrypted (`internal/dispatch/config.go:45`, `internal/awsapi/ec2.go:108`). The real value comes from an AWS config setting (`disk_gib`) that isn't in this repo. - `/tmp`: the hosted code never mounts or changes it. **[not in code]** AL2023 mounts `/tmp` as tmpfs by default, about half of RAM, so roughly 2 GiB on c7g.large. `TMPDIR` is unset, so Go's build directory and `t.TempDir()` land there. **Spot:** one-time spot instances that terminate when interrupted (`ec2.go:95-97`). - There is no special retry. When the lease runs out, the job goes back in the queue under the queue's normal rules: `maxAttempts = 2` (`internal/repod/store_ci.go:42`), and `after` jobs get one attempt **[spec]** (design doc line 237). - If no capacity is available, the launch tries the next configured subnet (`launch.go:255-268`). **Boot time:** no number for a whole hosted run is recorded. - **[spec]** RunInstances to the user-data shell took a median 12.6 s. Installing tools at boot takes about 37 s on stock AL2023. A baked image was estimated at 15–25 s (design doc lines 88-91). - Boot-to-claim is listed as "must measure" and is still unrecorded (`docs/deploy.md:1711-1719`). - When the image setting is empty, jobs boot the newest stock AL2023 and pay the 37 s install every time (`docs/deploy.md:1625`). Whether production uses a baked image isn't visible in the repo. - The dispatcher reacts to wakes and resyncs every minute (`internal/dispatch/loop.go:104-106`). **Reuse:** each machine runs exactly one job. A warm pool is explicitly not built (`docs/superpowers/plans/2026-11-08-hosted-ci.md:867`). ## 4. What the machine image contains **Packages:** `dnf install -y git docker nodejs22 nodejs22-npm make tar zstd gcc`, plus Go from dl.google.com checked against its digest (`hack/hosted-ami.sh:157-161`, the same list in `boot.sh.tmpl:35-40`). - The Go version comes from the AWS config setting. **[docs]** It is 1.26.8 (`docs/deploy.md:1621`). - Versions of git, docker and node22 are whatever AL2023's repos ship; nothing is pinned. - python3 isn't installed explicitly. **[not in code]** AL2023's base image ships python3.9. **Docker:** `systemctl start docker` runs before the job (`boot.sh.tmpl:46`), and `ci` is in the `docker` group. **Kernel and system settings:** none. No sysctl, `user.max_user_namespaces` or cgroup configuration appears anywhere. **[not in code]** cgroup v2 is AL2023's default. ## 5. Pipelines, concurrency and verdicts **Pipelines:** each queued `ci_jobs` row, from any pipeline, is reserved and admitted on its own and gets its own machine (`internal/repod/store_ci_hosted.go:17-33`, `internal/hub/hosted_admit.go:12-31`). **Concurrency:** there is no per-repo limit. The limits are: - Per account: solo 2 jobs, team 5 jobs, sponsored 48 jobs or 96 vCPU at once (`billing_plans.go:30-53`). - Per deployment: 8 hosted runs at once (`internal/hub/hosted_config.go:51`, `config.go:46`). **Verdicts:** commit statuses, `amadan ci status` and run pages read only the push (`ci`) pipeline (`store_ci.go:1153,1252,1306` use `pushPipelineSQL`). **Per-pipeline requires:** not implemented on main. I searched all 371 remote branches and found none that implement it. `ci requires` is per repo only. ## 6. Turning hosted CI on, and keeping local runners off it **Commands:** - `amadan ci hosted <ns>/<repo> on` - `amadan ci hosted <ns>/<repo> off` - `amadan ci hosted <ns>/<repo> -size 4`, which can be combined with on/off in one call - Bare `amadan ci hosted <ns>/<repo>` shows the current state (`internal/cli/cihosted.go:22,53-88`). **Who can change it, and the checks** (`internal/hub/hosted_optin.go:15-26`): - The caller must be a writer, owner or agent. - The repo must be Public or Private (Encrypted repos are refused). - The hub must offer hosted CI. - The account must be entitled: sponsored through `AMADAN_SPONSORED_NAMESPACES`, or a Stripe subscription that is active or past_due. - Turning it off is never refused. **Local runners:** hosted CI takes the jobs exclusively. - While hosted CI serves the repo, an ordinary claim is answered "idle, hosted: true" inside the claim's own transaction (`store_ci.go:418-433`). The runner treats that as idle (`internal/cli/hub.go:2237-2241`, `runner.go:475`). A `runner -ns oficina` on a laptop will never take these jobs. - Rows reserved for hosted are skipped by the ordinary claim query (`store_ci.go:514-519`). - The one exception: if the repo requires a capability other than `node`, hosted CI doesn't serve it and the jobs go to your own runners (`hostedci.go:136`, `store_ci_hosted.go:28-33`). ## 7. Private modules and network **On main there is nothing for private module access.** - No `GOPRIVATE`, `GONOSUMDB`, netrc or `GOAUTH` setup exists, and there is no `ci readers` command. - The single-job `amj_` token can read only the job's own repo while the run is active (`internal/hub/gitproxy.go:384-389`), and the runner keeps it out of the steps' environment. - `amadan.net/...` private modules therefore fail on hosted. The spec notes "no secure protocol found". **[spec only, `hosted-dep-reads` branch]** The planned design: - The dependency repo grants read access to reader repos or accounts. - The job gets a second, read-only credential through a git credential helper in the environment, plus `GOPRIVATE=<hub host>`. - Private `?go-get=1` lookups are answered when the request carries that credential. - The interim workaround it documents is a CI secret holding a token from a dedicated reader account. **Network:** no inbound connections. Outbound is open except that port 25 and the VPC are refused by the subnet's network ACL (`boot.go:22-27`). The instance has no IAM role and uses IMDSv2 with hop limit 1. ## 8. Logs and step timings **Log limits:** - The last 1 MiB of output is kept for each single script, step or shard (`runnerjob.go:21,524,1053`). - A whole report may carry at most 1 MiB of log in total (`MaxReportLogBytes`). It is split by weight, with failing units getting 8 shares, passing units 1, and the summary 2 (`internal/cli/runnerbudget.go:34,58-61`). - The report body cap is 4 MiB (`internal/hub/ci_api.go:131`). **Timings:** each step and shard reports `started_at`/`finished_at` (`runnerjob.go:268-293`). A sharded step's time is the wall clock across its shards. You can read them in three ways: - `GET /{ns}/{repo}/-/ci/{sha}/run.json` returns `steps[].elapsed`, `steps[].shards[].elapsed`, plus `queued_at`, `started_at`, `updated_at` and `elapsed` (`internal/hub/ci_run_page.go:522-593`). The web page is `/{ns}/{repo}/-/ci/{sha}`. - `GET /api/v1/repos/{ns}/{repo}/ci/status?branch=X&logs=none|summary|failed|all` returns `steps[]` with `elapsed`, plus the queue wait. Use a bearer token (`internal/hub/ci_status_api.go:181-240`). This is what `amadan ci status -json` calls. - Per-pipeline runs: `GET /api/v1/ci/pipeline-runs`. - Time spent restoring the cache isn't in any of these, because it happens before the claim. ## Gotchas for a Go repo that wants warm caches and fast runs 1. **The build cache never shrinks, so it eventually stops saving.** Restore writes files without restoring their timestamps (`untarCache`, `hostedcache.go:290`, no `Chtimes`). Every entry looks freshly used, so Go's 5-day trim never removes anything. Once the cache passes 2 GiB compressed or 6 GiB unpacked, the save fails quietly and every later job keeps restoring the last good, increasingly stale copy. Run `go clean -cache` on the default branch now and then, or prune `$GOCACHE` yourself. 2. **Only the default branch's successful runs refresh the shared cache.** Failed runs save nothing. Two pipelines (or two pushes) on one branch overwrite each other, last writer wins. 3. **`GOPATH` isn't cached.** Anything you `go install` (gitleaks, linters) lands in `/home/ci/go/bin` and is rebuilt every job. If you want tools to persist, put them under `$GOCACHE/<dir>` or `$GOMODCACHE/...`. Those are saved, provided they are regular files and not symlinks. Add that directory to `PATH` yourself. 4. **Toolchain downloads.** `GOTOOLCHAIN` defaults to `auto`. If `go.mod`'s `toolchain` or `go` line is newer than the machine's Go (1.26.8), a toolchain is downloaded into `GOMODCACHE`. It is cached, but Go version bumps on either side still cost time. Bumping the machine's Go also changes the cache key and starts you cold. 5. **Depth-1 clone.** A gitleaks history scan sees one commit, so either use `--no-git`/working-tree mode or `git fetch --unshallow` yourself. Files with fresh mtimes defeat test result caching for any test that reads repo files. 6. **`/tmp` is probably RAM-backed (about 2 GiB on the default size).** Go's build directory, `t.TempDir()` and Docker build contexts can run out of space. Pointing `TMPDIR` at a directory under the checkout or `$HOME` is the safe choice. This one comes from AL2023 defaults, not the code. 7. **`30-test@7` on 2 vCPU and 4 GiB means 7 concurrent `go test` processes** competing for CPU and RAM. Either use `-size 8`/`16`, which your plan must allow (sponsored allows up to 32), or lower the shard count. The spec measured 4 vCPU as only 1.35× faster on a cold build. 8. **Fixed costs before the first step:** boot (~13 s), then the tool install (~37 s unless a baked image is configured), then the cache restore (single stream, about 100 MB/s), then the clone. None of it is billed, and none of it shows in step timings. 9. **Every pipeline is its own cold machine.** Only the `ci` pipeline drives the commit verdict and the merge gate. 10. **Private `amadan.net` modules don't work on hosted yet.** Use a reader-account token as a CI secret, or keep the repo on a self-hosted runner by leaving hosted CI off. With hosted CI on, local runners will not pick its jobs up. Requiring a capability hosted machines lack (anything other than `node`) also sends the jobs back to your own runners. 11. **The cache save runs after the verdict and has 2.5 minutes** for a single-threaded `zstd -3` plus one POST. A very large `go-build` can run out of time and quietly skip the save.</result> <usage><subagent_tokens>208623</subagent_tokens><tool_uses>60</tool_uses><duration_ms>302460</duration_ms></usage> </task-notification>
<task-notification> <task-id>b402n7yec</task-id> <tool-use-id>toolu_014dTdf34V2BqA5CjEbbeap6</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/b402n7yec.output</output-file> <status>completed</status> <summary>Background command "Wait for the first hosted CI run and print step timings" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bh0f5tzk1</task-id> <tool-use-id>toolu_01CTHgtoR6HVaWwhoKUH1rMX</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/bh0f5tzk1.output</output-file> <status>completed</status> <summary>Background command "Wait for the second hosted run and print a filtered log" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>boc9bycz0</task-id> <tool-use-id>toolu_01W2ecCnuXNrwVAamNtW25Wn</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/boc9bycz0.output</output-file> <status>completed</status> <summary>Background command "Wait for the third hosted run and print failures" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>b3huw3wv8</task-id> <tool-use-id>toolu_01Y5xkkzVc64GNPumFrkyd85</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/b3huw3wv8.output</output-file> <status>completed</status> <summary>Background command "Wait for run 4 on hosted and summarize it" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bfhuzefo3</task-id> <tool-use-id>toolu_01DqVby2wFzGkqNtdvRNqW7f</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/bfhuzefo3.output</output-file> <status>completed</status> <summary>Background command "Wait for the timing run and save per-test times" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bezidu53p</task-id> <tool-use-id>toolu_01LMBsXDgBUinWqygTcj7JXs</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/bezidu53p.output</output-file> <status>completed</status> <summary>Background command "Wait for run 5 and read the credential diagnostic" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>b94c1tb38</task-id> <tool-use-id>toolu_01Cpsaa8RmWm5pD1UGgzvX83</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/b94c1tb38.output</output-file> <status>completed</status> <summary>Background command "Wait for run 6 and print per-shard times, plus the equipotest measurement" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bc22961p7</task-id> <tool-use-id>toolu_01RveU5tNdCyDPeQ7UuUXSM2</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/bc22961p7.output</output-file> <status>completed</status> <summary>Background command "Wait for run 7 and print step and shard times" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>br6l0hlmi</task-id> <tool-use-id>toolu_017HRv71Z2NKDVrApnXYWpgT</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/br6l0hlmi.output</output-file> <status>completed</status> <summary>Background command "Wait for run 8 and print step and shard times" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bmt08zsq6</task-id> <tool-use-id>toolu_01VDesF3x813QQ3SB93k51zt</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/bmt08zsq6.output</output-file> <status>completed</status> <summary>Background command "Wait for run 9 and print step and shard times" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>bwh7ecae8</task-id> <tool-use-id>toolu_018vvTW4j4R4Fn3Wp25TnD3B</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-oficina-equipo/8b7180a9-7af1-484f-ab5d-1eb534ffd4ff/tasks/bwh7ecae8.output</output-file> <status>completed</status> <summary>Background command "Wait for the warm rerun and print step and shard times" completed (exit code 0)</summary> </task-notification>