Skip to content

fix(infra): the deploy role trusts GitHub's immutable subject, so the workflow can sign in - #532

Merged
allisonmahmood merged 1 commit into
mainfrom
fix/infra-deploy-role-immutable-subject
Oct 5, 2026
Merged

allisonmahmood merged 1 commit into
mainfrom
fix/infra-deploy-role-immutable-subject

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

The first production deploy (#416) failed at its first AWS step: configure-aws-credentials could not assume patchy-production-deploy ("Not authorized to perform sts:AssumeRoleWithWebIdentity"). The role trusts repo:allisonmahmood/patchy-cloud:environment:production, but this repository issues GitHub's immutable subject claims, so its tokens say repo:allisonmahmood@20662394/patchy-cloud@1347287974:environment:production and the StringEquals never matches.

The subject format. GitHub's OIDC reference gives the immutable syntax as repo:OWNER@OWNER-ID/REPO@REPO-ID:…, and says the owner and repository ids are "always included in the repo segment of the sub claim"; the rest of the subject is the context, which for a job that references an environment is environment:ENVIRONMENT-NAME. The changelog describes only the subject changing; the reference still documents the issuer as https://token.actions.githubusercontent.com, and configure-aws-credentials@v6 still requests the sts.amazonaws.com audience by default, so the provider and the aud condition are unaffected. The repository's actions/oidc/customization/sub endpoint reports use_immutable_subject: true and sub_claim_prefix: repo:allisonmahmood@20662394/patchy-cloud@1347287974, and those ids match gh api repos/allisonmahmood/patchy-cloud (owner.id, id). The ids are public.

The fix. names.ts replaces repositorySlug (used only by the trust) with githubSubjectRepo, the immutable repo segment verbatim as GitHub reports it, and the role trusts ${githubSubjectRepo}:environment:${environment}. It stays one exact StringEquals on aud and sub: same repository, same environment, no wildcard, and now also bound to the ids, so a renamed or re-registered owner or repository name cannot claim it. A new infra test pins the synthesized condition to the literal subject; it fails against the old one. docs/OPERATIONS.md says to keep the immutable subject on, since turning it off would lock the workflow out again.

After merge. The workflow cannot apply this itself, because it has to assume the role first. An administrator redeploys patchy-production-base from their shell, as in "Setting up production" step 2, then reruns the Deploy workflow.

Hit every surface. Applied: none of the code surfaces (no wire contract, CLI, dev loop, migrations, company resources, served pages or layout change). Docs: docs/OPERATIONS.md updated; ADR-0012's "trusted only for the repository's GitHub environment of the same name" still holds. No vocabulary change. Infra snapshot unchanged (it pins security groups only); the trust is pinned by the new test.

Refs #416


Made by Claude Opus 5.5 (1M context) in Claude Code, driven from T3 Code.

… workflow can sign in

The repository issues GitHub's immutable OIDC subject, which carries the
owner and repository ids, so the deploy role's name-only subject never
matched and the first production deploy could not assume it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions github-actions Bot added area:docs Touches the docs area size:s Under 100 changed lines labels Oct 5, 2026
@allisonmahmood
allisonmahmood merged commit 48153dc into main Oct 5, 2026
13 checks passed
@allisonmahmood
allisonmahmood deleted the fix/infra-deploy-role-immutable-subject branch October 5, 2026 01:49
allisonmahmood added a commit that referenced this pull request Oct 15, 2026
A pull request that touches only `packages/execution`, `apps/infra`, the
dev `scenarios/`, `t3.json` or `favicon.svg` gets no area label, because
`.github/labeler.yml` names none of them (#471, #531 and #532 went out
with no area or only `area:docs`). Triage reads the matching table in
`docs/agents/triage-labels.md`, which had the same gaps. Nothing
enforced the "change both together" note at the top of the labeler
config, so the next package would slip through the same way.

## What changed

- `packages/execution/**` and `apps/infra/**` join `area:server`.
Execution is part of the Runtime context and infra is the hosting side.
- `scenarios/**`, `t3.json` and `favicon.svg` join `area:ci`. These are
the seeds `pnpm dev up` builds environments from, plus T3 Code's project
config and icon.
- The triage table's `area:server` and `area:ci` rows now match the
globs line for line. The whole table is rewrapped because prettier pads
its columns.
- `scripts/labeler.test.ts`, which runs in `pnpm test`, reads the
labeler config's `area:*` globs. It matches each directory git lists
under `apps/` and `packages/` with minimatch and `dot: true`, the way
actions/labeler v7 does, and fails naming any directory with no area. It
probes each directory with `<dir>/package.json`: #471 touched only that
and the lockfile, and a Markdown probe would always match `area:docs`.
`minimatch` and `yaml` become root devDependencies; both were already in
the lockfile.

## What I checked by hand

The test, against deliberately broken configs:

| Change | Result |
| --- | --- |
| None | passes |
| Delete the `packages/execution/**` glob | fails: `expected [
'packages/execution' ] to deeply equal []` |
| Delete the `apps/infra/**` glob | fails: `[ 'apps/infra' ]` |
| Rename `area:server` to `server` | fails, naming its 15 directories |
| Add an untracked, unignored `packages/zz-scratch/package.json` |
fails: `[ 'packages/zz-scratch' ]` |
| Add an untracked `packages/core/zz-café.txt` (git quotes non-ASCII
paths unless `-z`) | passes |

I also ran actions/labeler's own code (`getLabelConfigs` and
`checkMatchConfigs` with `dot: true`, from its source at the SHA pinned
in `pr-labels.yml`) over `main`'s config and this branch's:

| Changed files | `main` | this branch |
| --- | --- | --- |
| `scenarios/team/scenario.json` | none | `area:ci` |
| `scenarios/brightline/patches/kudos/index.html` | none | `area:ci` |
| `t3.json` | none | `area:ci` |
| `favicon.svg` | none | `area:ci` |
| `packages/execution/src/index.ts` | none | `area:server` |
| `packages/execution/package.json` + `pnpm-lock.yaml` | none |
`area:server` |
| `apps/infra/src/index.ts` | none | `area:server` |
| `pnpm-lock.yaml` alone | none | none (as the table says) |

The label workflow runs on `pull_request_target` and reads `labeler.yml`
from `main`, so this PR's own labels come from the old config. The new
globs apply to PRs opened after this merges.

## Hit every surface

Applied: the labeler config and triage table pair. They agree on every
area changed here. Did not apply: the wire contract, CLI, dev loop (no
runner or seed change), vocabulary, migrations, company resources,
served pages, reverse states and repo layout.

Closes #498

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

---------

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

Labels

area:docs Touches the docs area size:s Under 100 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant