Repository navigation
ci: run corpus-backed audits on fork PRs via in-repo pin fallback - #2665
Merged
Merged
Conversation
The four corpus-backed audits -- crucible-audit (both modes),
tree-sitter-accuracy-audit and tri-comparison-audit -- failed instantly on
every PR raised from a fork, before any code was exercised. They clone
language-crucible at `${{ vars.LANGUAGE_CRUCIBLE_REF }}`, and GitHub
withholds repository variables (like secrets) from fork `pull_request` runs,
so the ref resolved to an empty string and the guard exited 1.
The corpus repo is public and clones with no credentials, so the only thing a
fork run actually lacked was the ref *string* -- which is already committed
here as PINNED_TAG in tests/_crucible_pin.py, readable on a fork run. Fall
back to it when the variable is empty. Same escape-hatch shape as
rosetta-audit.yml's `vars.KEYWORD_ROSETTA_REF || 'main'`, but pinned exactly
rather than floating on main.
Fork contributors now get real signal from these audits instead of noise, and
maintainers stop hand-verifying every fork PR from a branch in this repo.
Also:
- Give release-crucible-archive.yml the same fallback. It can never hit the
fork case, but it had no guard at all, so a deleted or renamed variable
would have made `git clone --branch ""` the failure mode and blanked the
tag out of the archive PR body. The resolved ref now goes through
$GITHUB_ENV so the body cites the ref actually used.
- Note in tests/_crucible_pin.py that PINNED_TAG is now a real CI input, not
just a human-facing constant: the assignment must stay on one line in its
current literal form or the sed fallback silently breaks. Docstring made
raw so the embedded sed expression does not trip W605.
- Rewrite CONTRIBUTING.md's "Checks that cannot run on fork PRs" section,
which told contributors to ignore these four checks. They are trustworthy
on a fork PR now.
No behavior change when the repository variable is present, which is every
run from a branch in this repo.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The four corpus-backed audits —
crucible-audit (full-precision),crucible-audit (zero-dependency),tree-sitter-accuracy-auditandtri-comparison-audit— fail instantly on every PR raised from a fork, before any code is exercised. They clone language-crucible at${{ vars.LANGUAGE_CRUCIBLE_REF }}, and GitHub withholds repository variables (like secrets) from forkpull_requestruns, so the ref resolves to an empty string and the guard exits 1. #2664 is the latest instance.The key observation: the corpus repo is public and clones with no credentials. The only thing a fork run actually lacks is the ref string — and that string is already committed here as
PINNED_TAGintests/_crucible_pin.py, which a fork run can read. So fall back to it when the variable is empty:Same escape-hatch shape as
rosetta-audit.yml'svars.KEYWORD_ROSETTA_REF || 'main', but pinned exactly rather than floating onmain.Fork contributors get real signal from these audits instead of noise, and maintainers stop hand-verifying every fork PR from a branch in this repo.
Also in this PR
release-crucible-archive.ymlgets the same fallback. It can never hit the fork case (it only runs onrelease/workflow_dispatch), but it had no guard at all — a deleted or renamed variable would have madegit clone --branch ""the failure mode and blanked the tag out of the archive PR body. The resolved ref now goes through$GITHUB_ENVso the body cites the ref actually used.tests/_crucible_pin.py— note thatPINNED_TAGis now a real CI input, not just a human-facing constant. The assignment must stay on one line in its current literal form or the sed fallback silently breaks; reformatting it (black-style wrapping, single quotes, a type annotation) is the hazard. Docstring made raw so the embedded sed expression does not trip ruff's W605.CONTRIBUTING.md— the "Checks that cannot run on fork PRs" section told contributors to ignore these four checks. Rewritten as "Corpus-backed checks": they are trustworthy on a fork PR now.Security note
Deliberately not
pull_request_target, which would run fork code with a write-scoped token against a repo whose whole job is scanning untrusted input. These jobs consume no secrets, and the clone URL stays hardcoded tosquid-protocol/language-crucible. The worst a malicious fork PR can do is point the corpus at a different ref of that same public repo and make its own audit fail.Test plan
yaml.safe_loadover.github/workflows/*.yml)sed -n 's/^PINNED_TAG = "\(.*\)"/\1/p' tests/_crucible_pin.py→v1.2.0ref=""→ resolvesv1.2.0);git ls-remoteconfirms that ref is clonable with zero credentialsPINNED_TAGyields an emptyrefand exits 1 with the new error, rather than silently cloning an empty refruff check+ruff format --checkclean ontests/_crucible_pin.py; module compiles with noSyntaxWarningcrucible_check.py→full_precision: PASS,zero_dependency: PASSCorpus pin read from the reponotice) instead of failing at the clone stepNote that this PR is itself from a branch in this repo, so its own audits take the unchanged variable path — the fallback is exercised by the simulation above, and for real by the next fork PR.
🤖 Generated with Claude Code