Skip to content

fix(infra): this repo is PRIVATE, and lock the destroy guard with a test - #362

Merged
athvin merged 1 commit into
mainfrom
bm/infra-private-repo-and-guard-tests
Nov 1, 2026
Merged

athvin merged 1 commit into
mainfrom
bm/infra-private-repo-and-guard-tests

Conversation

@athvin

@athvin athvin commented Oct 31, 2026

Copy link
Copy Markdown
Owner

Two things, both found by looking at what #360 actually shipped rather than at the diff.

1. The repository is private, and five files said otherwise

gh repo view --json visibility → PRIVATE. I had propagated "public repository" into the plan-step comment, docs/infrastructure.md §14.2, the infra-platform skill, and — worst — the PR comment template, so that sentence renders onto every infra PR. Two pre-existing claims in ci-terraform.tf and ses.tf, plus two in sccache.tf, said the same.

Every decision those comments justify stays correct, so none of this is a word swap. Each needed its premise replaced:

Decision Old premise What it actually rests on
-refresh=false on the plan tier "the whole internet reads the build log" the plan role is assumable from any PR branch, a PR can edit the workflow it runs under, and the log needs no AWS access to read, is readable by every collaborator, and persists in the run history. Private narrows who, not whether.
zero repository secrets "a key in a PUBLIC repo's secrets" the argument never depended on visibility — secrets aren't readable by anonymous visitors on a public repo either. It is that a static key doesn't expire, is reachable by every workflow rather than one job, and is rotated only by someone remembering to.
the sccache writer split "this repository is PUBLIC" poisoning now needs a collaborator rather than anyone, which narrows who can attempt it without closing the path — and poisoning outlives the credential that planted it, which is why it earns a second role.

Left alone deliberately: six rust.yml sccache comments, and build-cost.md's runner-cost paragraph claiming standard minutes are free — materially wrong on a private repo, with real cost implications. Both files belong to #359, which is in flight and already corrects one line of build-cost.md. Sweeping them here would only conflict with it; I'll do it as a small follow-up once #359 lands.

2. The destroy guard had never refused anything in CI

Every real apply has planned 0 to destroy, so the one mechanism between a merge and an unattended production teardown had its refusal path verified exactly once, by hand, by me. That is the state this repo keeps getting burned by — a gate nobody has watched fail is indistinguishable from a gate that cannot fail.

scripts/ci/tf-helpers-test.sh asserts 31 behaviours of the three helpers against fixtures:

  • the guard's refusal, the ALLOW-DESTROY override, the fail-closed branch, and the Plan: 1 to import, …, 3 to destroy form a full-line pattern would miss
  • the metadata parser across exit codes 0/1/2
  • the comment's 65536-character cap under four oversized plans, the truncation notice, the ~~~~ fence surviving a triple-backtick inside plan text, and that a plan-only stack never gets the "merging applies this" warning

No toolchain, no credentials, no network, no terraform binary — pure shell, 5-minute job, runnable locally as bash scripts/ci/tf-helpers-test.sh.

apply gates on it, which is the reason it's a CI job and not a local convenience: a broken guard stops the apply instead of being discovered by it.

Verification

  • The suite is mutation-checked. Breaking the guard's refusal (exit 1→exit 0), its fail-closed branch, the metadata parser's import handling, the comment cap, or the plan-only warning skip each turns it red with the matching assertion named. Helpers restored byte-identical (cmp) afterwards and the suite confirmed green again.
  • The first mutation run reported a false CAUGHT from a sed that matched nothing — so the mutations are now applied by assertion (assert old in s) rather than by a regex that can silently no-op.
  • terraform fmt -check -recursive, actionlint across all four workflows, scripts/skills-check.sh all green.

One bug in the test itself, worth recording because it's the same class the suite exists to catch: the "names ALLOW-DESTROY in the refusal" assertion piped the guard into grep -q. With pipefail on, the pipeline returned the guard's own exit 1 — the behaviour under test — so the assertion read false however correct the message was, and grep -q would have SIGPIPEd the guard on the way. Captured into a variable and matched with case instead.

required-checks.md will conflict with #359 — both PRs add a job, and it's generated. Whoever merges second re-runs scripts/skills-check.sh regen.

🤖 Generated with Claude Code

Two things, both found by looking at what the last PR actually shipped.

**The repository is private, and five files said otherwise.**
`gh repo view --json visibility` returns PRIVATE. I had propagated "public
repository" into the plan-step comment, `docs/infrastructure.md` §14.2, the
infra-platform skill, and — worst — the PR comment template, which renders
that sentence onto every infra PR. Two pre-existing claims in
`ci-terraform.tf` and `ses.tf`, plus two in `sccache.tf`, said the same.

Every decision those comments justify stays correct, so none of them is a
word swap; each needed its premise replaced:

- `-refresh=false` on the plan tier: the path was never "the whole
  internet reads the log", it is that the plan role is assumable from any
  PR branch, a PR can edit the workflow it runs under, and the resulting
  build log needs no AWS access to read, is readable by every
  collaborator, and persists in the run history. Private narrows who, not
  whether.
- zero repository secrets: the argument never depended on visibility —
  secrets are not readable by anonymous visitors on a public repo either.
  It is that a static key does not expire, is reachable by every workflow
  rather than one job, and is rotated only by someone remembering to.
- the sccache writer split: cache poisoning now has to come from a
  collaborator rather than from anyone, which narrows who can attempt it
  without closing the path — and poisoning outlives the credential that
  planted it, which is why it is worth a second role.

Left alone deliberately: six `rust.yml` sccache comments and
`build-cost.md`'s runner-cost paragraph, which claims standard minutes are
free — materially wrong on a private repo. Both files belong to #359,
which is in flight and already corrects one line of build-cost.md. Sweeping
them here would only conflict with it.

**The destroy guard had never refused anything in CI.** Every real apply
has planned `0 to destroy`, so the one mechanism between a merge and an
unattended production teardown had its refusal path verified exactly once,
by hand, by me. That is the state this repo keeps getting burned by — a
gate nobody has watched fail is indistinguishable from a gate that cannot.

`scripts/ci/tf-helpers-test.sh` asserts 31 behaviours of the three helpers
against fixtures: the refusal, the `ALLOW-DESTROY` override, the
fail-closed branch, the import-form summary a full-line pattern would miss,
the 65536-character comment cap, the backtick-in-plan-text fence, and that
a plan-only stack never gets the "merging applies this" warning. No
toolchain, no credentials, no network, no terraform binary.

`apply` now gates on it, which is the reason it is a CI job and not a local
convenience: a broken guard stops the apply instead of being discovered by
it.

The suite is mutation-checked — breaking the guard's refusal, its
fail-closed branch, the metadata parser's import handling, the comment cap
or the plan-only warning skip each turns it red. The first attempt at that
check reported a false CAUGHT from a `sed` that matched nothing, which is
why the mutations are applied by assertion now.

One bug in the test itself, worth recording because it is the same class
the suite exists to catch: the "names ALLOW-DESTROY in the refusal"
assertion piped the guard into `grep -q`. With `pipefail` on, the pipeline
returned the guard's own exit 1 — the behaviour under test — so the
assertion read false however correct the message was, and `grep -q` would
have SIGPIPEd the guard on the way. Captured and matched with `case`
instead.

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

Copy link
Copy Markdown
Contributor

terraform plan

2574a56 · run log and full plans

env add change destroy
state-backend (plan only) 0 0 0
core 0 0 0
dev 0 0 0
prod 0 0 0

Planned with -refresh=false, so this is the config-versus-state diff and
not out-of-band drift. That is a security choice, not a speed one: a refreshing
plan reads secret values, and the plan role is assumable from any PR branch —
which can edit the workflow it runs under. Drift is caught at apply time, which
refreshes fully.

@athvin
athvin merged commit 55f9732 into main Nov 1, 2026
26 checks passed
athvin added a commit that referenced this pull request Nov 1, 2026
…g the Rust gate (#366)

The tail of #362, which corrected the "public repository" claim in the
files it owned and deliberately left `rust.yml` and `build-cost.md` to
#359. #359 has corrected one line of `build-cost.md` and is still open, so
these are the remaining ones — the edits sit in different hunks from its,
and a rebase either way is clean.

**`rust.yml`'s six sccache comments.** The cache-poisoning argument stands;
only its premise moves. Poisoning outlives the credential that planted it,
which is why writes are restricted to `main` — and the repository being
private means the branch has to come from a collaborator rather than from
anyone at all. Narrower, not closed.

**`build-cost.md` claimed "its minutes are free, because standard
GitHub-hosted runners are free for public repositories" and that the bill
for all of this CI is zero.** That is materially wrong on a private repo:
the runtime this whole file measures is a cost, not only a wait. Two
downstream conclusions moved with it — an organisation on the Team plan
trades one metered rate for another rather than giving up a free one, which
is a smaller step than it read; and the usual objection to self-hosted
runners (a fork PR executing arbitrary code) mostly does not apply, so what
remains is the ordinary compromised-collaborator case and the runner
wanting its own least-privileged identity.

No replacement figure is asserted. The allowance and consumption are
account settings rather than repository state, and
`gh api /users/{user}/settings/billing/actions` needs a `user` scope this
session does not hold — so the text says where to read them instead of
substituting one unverified number for another.

**`.github/workflows/infra.yml` joins `rust.yml`'s detect denylist**, with
`scripts/ci/tf-*` which was already exempt in `infra.yml`'s own detect but
not here. An infra-only PR was paying the full ~40-minute backend gate —
`test` plus the DuckLake e2e — and `infra.yml` defines no Rust job and
cannot affect the workspace build. Every infra PR in this series paid it.

Named FILE BY FILE and not as `^\.github/workflows/`: `rust.yml`,
`frontend.yml` and `images.yml` must keep triggering the gates they define,
or a change to a gate would stop reporting on exactly the PR most likely to
break it. Simulated over nine shapes — infra.yml alone, with terraform, and
with a tf helper all skip; rust.yml, frontend.yml, images.yml, docs,
`scripts/ci/actionlint.sh`, and infra.yml+rust all still run.

`rust/deny.toml`'s "Public repo" is left alone: it describes
`github.com/athvin/feather-flow`, the ff-analysis dependency, which really
is public (checked).

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