Skip to content

fix(ci): the agents run on Anthropic, because there was never a free path - #439

Merged
athvin merged 1 commit into
mainfrom
bm/gh-aw-anthropic-engine
Nov 3, 2026
Merged

athvin merged 1 commit into
mainfrom
bm/gh-aw-anthropic-engine

Conversation

@athvin

@athvin athvin commented Nov 3, 2026

Copy link
Copy Markdown
Owner

#359 shipped four agentic workflows on engine: copilot and asserted that
kept the zero-repository-secrets invariant. On their first real execution —
the run immediately after #359 landed — all four died at activation:

Error: None of the following secrets are set: COPILOT_GITHUB_TOKEN
COPILOT_GITHUB_TOKEN is required by GitHub Copilot CLI.

The generated activation job runs validate_multi_secret.sh and hard-fails
without it. gh secret list is empty, so they never had a chance to run.

There is no zero-secret engine. copilot wants COPILOT_GITHUB_TOKEN,
claude wants ANTHROPIC_API_KEY, and every other engine wants its own key.
The invariant and the feature were always mutually exclusive; #359's claim
just hid which side we were on. Since a secret is owed either way, this picks
the engine whose model and cost are selectable per workflow.

Bedrock was evaluated first and is not reachable: gh aw compile --engine bedrock answers "Must be 'agy', 'claude', 'codex', 'copilot', 'gemini', or
'pi'"
. The amazon-bedrock and AWS_BEARER_TOKEN_BEDROCK strings in the
binary belong to a generic cloud-auth layer (AWF_AUTH_{AWS,ANTHROPIC,AZURE, GCP,OIDC}_*) whose AWS members are only REGION / ROLE_ARN /
ROLE_SESSION_NAME — OIDC role assumption, no inference path.

Model per workflow, split on judgement

Workflow Model Why
dependency-upgrade-pilot claude-sonnet-5 verdicts a version range
ci-triage claude-sonnet-5 classifies a red run
generated-artifact-healer claude-haiku-4-5 re-runs a known generator
skill-freshness-auditor claude-haiku-4-5 greps prose against code

Haiku 4.5 is the cheapest current model and right for mechanical work. It is
the wrong default for the two judgement agents: #376 is the worked example of
that cost — a bump whose own release notes named the companion edit, merged
without it, three red PRs. A cheaper model reaching that verdict confidently
is worse than no agent. effort is deliberately absent everywhere; Haiku 4.5
rejects it.

dependency-upgrade-pilot also loses copilot-sdk: true, exactly as the note
it replaces predicted: that nesting existed only to obtain a proxy-aware fetch
tool, because Copilot's native web-fetch is unavailable under offline BYOK.
On engine: claude web-fetch is native.

Security review (required by safe-update mode)

gh aw compile flagged one new restricted secret and refused to proceed until
reviewed. Reviewed, then --approved:

  • ANTHROPIC_API_KEY — the only new secret. Visible to activation,
    agent and detection; not to safe_outputs or conclusion, the
    write-capable jobs.
  • Blast radius is Anthropic spend, nothing else. No agent job holds
    contents: write — extracted per-job, they carry contents: read plus
    reads. The id-token: write on the two Rust agents still mints only
    er-ci-sccache-read (GetObject/ListBucket on one bucket, no DeleteObject).
  • No new actions. setup-node@949feb24 appears as an added line but is
    already on main in these same files — a position shift, not a new
    dependency. No redirect changes.
  • Use a dedicated key, not the product's. ANTHROPIC_API_KEY is already
    the name of the frontend assistant's credential, and per
    docs/infrastructure.md §18.14 that path "sends real customer personal
    data to the Anthropic API". Reusing one value would turn a CI-side leak into
    a key that touches customer data. Mint a separate key in its own workspace.
  • Cannot fully verify, flagged for a human: whether a prompt-injected
    agent can defeat gh-aw's log masking and egress allowlist to exfiltrate the
    key. Mitigation is scoping and a spend cap, not sandbox trust.

GH_AW_MAX_DAILY_AI_CREDITS (5000) is denominated in Copilot credits and does
not bind a BYO-key run, so the spend ceiling is now whatever is configured
Anthropic-side. These fire on every dependabot push and every red CI run, so
that limit is load-bearing.

Still disabled, deliberately

All four remain disabled_manually from the triage that followed #359. They
stay that way until ANTHROPIC_API_KEY exists — re-enable with
gh workflow enable on each. staged: true is untouched on both
push-capable agents, so their first real runs still only preview.

They fail closed either way: activation failing leaves agent, detection
and safe_outputs all skipped, so a missing or revoked key costs red runs,
never an unintended write.

Verified: gh aw compile --strict 4/4 with the 2 documented target: "*"
warnings; gh aw lint 12 files clean; scripts/skills-check.sh check exit 0.

Co-Authored-By: Claude Opus 5 (1M context) [email protected]

🤖 Generated with Claude Code

…path

#359 shipped four agentic workflows on `engine: copilot` and asserted that
kept the zero-repository-secrets invariant. On their first real execution —
the run immediately after #359 landed — all four died at `activation`:

    Error: None of the following secrets are set: COPILOT_GITHUB_TOKEN
    COPILOT_GITHUB_TOKEN is required by GitHub Copilot CLI.

The generated `activation` job runs `validate_multi_secret.sh` and hard-fails
without it. `gh secret list` is empty, so they never had a chance to run.

**There is no zero-secret engine.** `copilot` wants `COPILOT_GITHUB_TOKEN`,
`claude` wants `ANTHROPIC_API_KEY`, and every other engine wants its own key.
The invariant and the feature were always mutually exclusive; #359's claim
just hid which side we were on. Since a secret is owed either way, this picks
the engine whose model and cost are selectable per workflow.

Bedrock was evaluated first and is not reachable: `gh aw compile --engine
bedrock` answers *"Must be 'agy', 'claude', 'codex', 'copilot', 'gemini', or
'pi'"*. The `amazon-bedrock` and `AWS_BEARER_TOKEN_BEDROCK` strings in the
binary belong to a generic cloud-auth layer (`AWF_AUTH_{AWS,ANTHROPIC,AZURE,
GCP,OIDC}_*`) whose AWS members are only REGION / ROLE_ARN /
ROLE_SESSION_NAME — OIDC role assumption, no inference path.

## Model per workflow, split on judgement

| Workflow | Model | Why |
|---|---|---|
| `dependency-upgrade-pilot` | `claude-sonnet-5` | verdicts a version range |
| `ci-triage` | `claude-sonnet-5` | classifies a red run |
| `generated-artifact-healer` | `claude-haiku-4-5` | re-runs a known generator |
| `skill-freshness-auditor` | `claude-haiku-4-5` | greps prose against code |

Haiku 4.5 is the cheapest current model and right for mechanical work. It is
the wrong default for the two judgement agents: #376 is the worked example of
that cost — a bump whose own release notes named the companion edit, merged
without it, three red PRs. A cheaper model reaching that verdict confidently
is worse than no agent. `effort` is deliberately absent everywhere; Haiku 4.5
rejects it.

`dependency-upgrade-pilot` also loses `copilot-sdk: true`, exactly as the note
it replaces predicted: that nesting existed only to obtain a proxy-aware fetch
tool, because Copilot's native `web-fetch` is unavailable under offline BYOK.
On `engine: claude` `web-fetch` is native.

## Security review (required by safe-update mode)

`gh aw compile` flagged one new restricted secret and refused to proceed until
reviewed. Reviewed, then `--approve`d:

- **`ANTHROPIC_API_KEY` — the only new secret.** Visible to `activation`,
  `agent` and `detection`; *not* to `safe_outputs` or `conclusion`, the
  write-capable jobs.
- **Blast radius is Anthropic spend, nothing else.** No agent job holds
  `contents: write` — extracted per-job, they carry `contents: read` plus
  reads. The `id-token: write` on the two Rust agents still mints only
  `er-ci-sccache-read` (GetObject/ListBucket on one bucket, no DeleteObject).
- **No new actions.** `setup-node@949feb24` appears as an added line but is
  already on `main` in these same files — a position shift, not a new
  dependency. No redirect changes.
- **Use a dedicated key, not the product's.** `ANTHROPIC_API_KEY` is already
  the name of the frontend assistant's credential, and per
  `docs/infrastructure.md` §18.14 that path "sends real customer personal
  data to the Anthropic API". Reusing one value would turn a CI-side leak into
  a key that touches customer data. Mint a separate key in its own workspace.
- **Cannot fully verify, flagged for a human:** whether a prompt-injected
  agent can defeat gh-aw's log masking and egress allowlist to exfiltrate the
  key. Mitigation is scoping and a spend cap, not sandbox trust.

`GH_AW_MAX_DAILY_AI_CREDITS` (5000) is denominated in Copilot credits and does
not bind a BYO-key run, so the spend ceiling is now whatever is configured
Anthropic-side. These fire on every dependabot push and every red CI run, so
that limit is load-bearing.

## Still disabled, deliberately

All four remain `disabled_manually` from the triage that followed #359. They
stay that way until `ANTHROPIC_API_KEY` exists — re-enable with
`gh workflow enable` on each. `staged: true` is untouched on both
push-capable agents, so their first real runs still only preview.

They fail closed either way: `activation` failing leaves `agent`, `detection`
and `safe_outputs` all `skipped`, so a missing or revoked key costs red runs,
never an unintended write.

Verified: `gh aw compile --strict` 4/4 with the 2 documented `target: "*"`
warnings; `gh aw lint` 12 files clean; `scripts/skills-check.sh check` exit 0.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin merged commit 80383ee into main Nov 3, 2026
28 checks passed
athvin pushed a commit that referenced this pull request Nov 3, 2026
`agent-task.yml` runs anthropics/claude-code-action in agent mode on
workflow_dispatch, one task per run, and publishes the result as a PR.

Two jobs, so the security properties come from the structure rather than
the prompt:

- `agent` holds only the workflow token (contents: write) and checkpoints
  to `agent-wip/<task>`, a branch with no PR, so checkpoints cost no CI.
  That token cannot push `.github/workflows/**` changes, so an agent
  cannot widen its own powers. No `id-token: write`: `er-ci-tf-plan`
  trusts any ref of this repo and can read Terraform state.
- `publish` runs on a fresh runner, never checks out the agent's tree,
  mints the GitHub App token at publish time (no 1-hour expiry mid-task),
  fast-forwards `agent/<task>` and opens or updates the PR as the App, so
  CI runs on it like a human's PR. Draft unless the agent reported
  `complete` and its step succeeded.

Resume continues a task from `agent-wip/<task>`; concurrency is keyed on
the task id so resumes queue instead of racing.

`scripts/agent.sh` holds the laptop helpers. `docs/agent-fleet.md`
records the design, the one-time setup, how it departs from the
originating plan (Auto Mode instead of a Karpenter install, Pod Identity
instead of IRSA, SHA-tagged immutable images, ARC on er-dev), and the
vCPU-quota prerequisite that blocks Phase 3.

This adds two stored secrets beyond #439's `ANTHROPIC_API_KEY`, both in
`main`-restricted environments rather than at repository scope; the
ci-and-supply-chain skill gains a section for this workflow (after #439's
gh-aw section, which is kept as is) and the required-checks reference is
regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MFnHDTZqHqQHUB7UwMUJY6
athvin added a commit that referenced this pull request Nov 3, 2026
…1) (#440)

`agent-task.yml` runs anthropics/claude-code-action in agent mode on
workflow_dispatch, one task per run, and publishes the result as a PR.

Two jobs, so the security properties come from the structure rather than
the prompt:

- `agent` holds only the workflow token (contents: write) and checkpoints
  to `agent-wip/<task>`, a branch with no PR, so checkpoints cost no CI.
  That token cannot push `.github/workflows/**` changes, so an agent
  cannot widen its own powers. No `id-token: write`: `er-ci-tf-plan`
  trusts any ref of this repo and can read Terraform state.
- `publish` runs on a fresh runner, never checks out the agent's tree,
  mints the GitHub App token at publish time (no 1-hour expiry mid-task),
  fast-forwards `agent/<task>` and opens or updates the PR as the App, so
  CI runs on it like a human's PR. Draft unless the agent reported
  `complete` and its step succeeded.

Resume continues a task from `agent-wip/<task>`; concurrency is keyed on
the task id so resumes queue instead of racing.

`scripts/agent.sh` holds the laptop helpers. `docs/agent-fleet.md`
records the design, the one-time setup, how it departs from the
originating plan (Auto Mode instead of a Karpenter install, Pod Identity
instead of IRSA, SHA-tagged immutable images, ARC on er-dev), and the
vCPU-quota prerequisite that blocks Phase 3.

This adds two stored secrets beyond #439's `ANTHROPIC_API_KEY`, both in
`main`-restricted environments rather than at repository scope; the
ci-and-supply-chain skill gains a section for this workflow (after #439's
gh-aw section, which is kept as is) and the required-checks reference is
regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MFnHDTZqHqQHUB7UwMUJY6
athvin pushed a commit that referenced this pull request Nov 8, 2026
…unt id

Without these the apply job plans `envs/core` with no Cloudflare auth and
`var.cloudflare_account_id` null, so r2.tf stays `count = 0` and the bucket is
never created. The apply job re-plans to a file inside itself
(`scripts/ci/tf-apply-plan.sh`) rather than consuming the plan tier's artifact,
so these reach the plan that actually lands — and the destroy guard still reads
it before anything is applied.

`CLOUDFLARE_API_TOKEN` is an **Environment** secret on `infra-apply-core`, which
is `protected_branches: true`. A pull request therefore cannot read it even by
editing this workflow. That is the property replacing the
`er-ci-sccache-read`/`-write` role split S3 had, and it is the pattern
`agent-fleet.md` already prescribes for the secrets added after #439 gave up the
zero-secret invariant: environment-scoped to `main` rather than repository-wide.

The account id is NOT a secret and is deliberately in the tree: it appears in
every dashboard URL and the S3-API endpoint is derived from it, exactly as
`rust.yml` carries the AWS account id inside `SCCACHE_BUCKET`.

Set unconditionally rather than per-matrix-leg, which is the subtle part. Only
`envs/core` declares the variable and Terraform silently ignores a `TF_VAR_` for
an undeclared one — unlike `-var`, which errors. A `matrix.key == 'core' && … ||
''` expression would be actively wrong: it yields the empty STRING on the other
legs, and `"" != null`, so `local.r2_enabled` would flip true with no account id
to use.

Known gap, bounded and recorded on the pull request: the PR plan tier has no
Cloudflare token, so R2 changes are not previewed on a pull request even though
the apply leg creates them. That is the §14.2 tradeoff `envs/dev/ses.tf` already
makes, and #908 is what closes it by giving CI a scoped read-only token.

Closes #910

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin added a commit that referenced this pull request Nov 8, 2026
…) (#912)

* infra(core): declare the R2 sccache bucket and its lifecycle rule

First half of #909. Creates the bucket; does NOT repoint `rust.yml`, which
waits until the bucket exists and the two scoped credentials are in GitHub
secrets — splitting them avoids the race where `rust.yml` on `main` runs
against a bucket whose apply has not finished.

WHY R2, after two backends that each failed differently. S3 (#350) was fast and
expensive: runners sit outside AWS, so every read is billed internet egress and
no VPC endpoint can reach it — CUR 2.0 per-resource put `er-ci-sccache` /
`DataTransfer-Out-Bytes` at $209.32 of a $211.62 November S3 total, against
$0.02 of storage. The Actions cache backend (#893) was cheap and slow: per-hit
read latency roughly doubled (0.122s -> 0.242s), and GitHub rate-limits cache
writes PER WORKFLOW RUN shared across every job, while sccache's
`GHACache::build` installs no `RetryLayer` and counts the resulting 429 instead
of retrying (mozilla/sccache#2821, unfixed in the pinned 0.19.0). The first
`main` run dropped 3,763 writes and landed 1,164 — 24% success, ~27% mean hit
rate, 25.1 minutes against 9.8 on S3.

R2 is the only option that is both: zero egress, and not GitHub's cache service
so neither the 429 bug nor the per-run quota applies. ~$2/month.

Stated plainly because it is the one regression: the Actions backend gave
cache-poisoning protection free via branch scoping — verified on #893, all
1,137 entries on `refs/pull/893/merge`, none on `main`. R2 has no OIDC and no
IAM condition keys, so that is rebuilt from two scoped tokens and a `main`-only
environment in the follow-up.

Opt-in gated on `var.cloudflare_account_id` (null by default), the `ses.tf`
pattern and its reason: without a token the provider cannot authenticate and the
WHOLE `core` plan fails, leaving every resource that does plan cleanly
unchecked. The `count`s should come out when #908 gives CI a scoped read-only
token — the gate is worth more here than for SES, because this bucket is on the
critical path of every compile job.

Two provider caveats recorded in the file rather than left to be rediscovered,
both reported by the first real plan rather than guessed: the lifecycle resource
cannot be destroyed by Terraform and does not support `import`, and `max_age` is
in SECONDS here where the S3 rule took days.

`.terraform.lock.hcl` carries linux_amd64 AND darwin_arm64 hashes for the new
provider. A lockfile written only on darwin fails CI's init on linux, and
`envs/dev` and `envs/prod` already track multiple platforms.

Closes #910

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* infra(ci): give the core apply leg the Cloudflare credential and account id

Without these the apply job plans `envs/core` with no Cloudflare auth and
`var.cloudflare_account_id` null, so r2.tf stays `count = 0` and the bucket is
never created. The apply job re-plans to a file inside itself
(`scripts/ci/tf-apply-plan.sh`) rather than consuming the plan tier's artifact,
so these reach the plan that actually lands — and the destroy guard still reads
it before anything is applied.

`CLOUDFLARE_API_TOKEN` is an **Environment** secret on `infra-apply-core`, which
is `protected_branches: true`. A pull request therefore cannot read it even by
editing this workflow. That is the property replacing the
`er-ci-sccache-read`/`-write` role split S3 had, and it is the pattern
`agent-fleet.md` already prescribes for the secrets added after #439 gave up the
zero-secret invariant: environment-scoped to `main` rather than repository-wide.

The account id is NOT a secret and is deliberately in the tree: it appears in
every dashboard URL and the S3-API endpoint is derived from it, exactly as
`rust.yml` carries the AWS account id inside `SCCACHE_BUCKET`.

Set unconditionally rather than per-matrix-leg, which is the subtle part. Only
`envs/core` declares the variable and Terraform silently ignores a `TF_VAR_` for
an undeclared one — unlike `-var`, which errors. A `matrix.key == 'core' && … ||
''` expression would be actively wrong: it yields the empty STRING on the other
legs, and `"" != null`, so `local.r2_enabled` would flip true with no account id
to use.

Known gap, bounded and recorded on the pull request: the PR plan tier has no
Cloudflare token, so R2 changes are not previewed on a pull request even though
the apply leg creates them. That is the §14.2 tradeoff `envs/dev/ses.tf` already
makes, and #908 is what closes it by giving CI a scoped read-only token.

Closes #910

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: bmoore813 <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants