Skip to content

ci: run corpus-backed audits on fork PRs via in-repo pin fallback - #2665

Merged
squid-protocol merged 1 commit into
mainfrom
chore/crucible-pin-fork-fallback
Sep 2, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
chore/crucible-pin-fork-fallback

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

The four corpus-backed audits — crucible-audit (full-precision), crucible-audit (zero-dependency), tree-sitter-accuracy-audit and tri-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 fork pull_request runs, 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_TAG in tests/_crucible_pin.py, which a fork run can read. So fall back to it when the variable is empty:

ref="${{ vars.LANGUAGE_CRUCIBLE_REF }}"
if [ -z "$ref" ]; then
  ref=$(sed -n 's/^PINNED_TAG = "\(.*\)"/\1/p' gitgalaxy/tests/_crucible_pin.py)
  echo "::notice title=Corpus pin read from the repo::..."
fi

Same escape-hatch shape as rosetta-audit.yml's vars.KEYWORD_ROSETTA_REF || 'main', but pinned exactly rather than floating on main.

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.yml gets the same fallback. It can never hit the fork case (it only runs on release/workflow_dispatch), but it had no guard at all — 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.
  • tests/_crucible_pin.py — note 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; 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 to squid-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

  • All workflow YAML parses (yaml.safe_load over .github/workflows/*.yml)
  • sed -n 's/^PINNED_TAG = "\(.*\)"/\1/p' tests/_crucible_pin.py → v1.2.0
  • Fork path simulated end-to-end in the CI workspace layout (ref="" → resolves v1.2.0); git ls-remote confirms that ref is clonable with zero credentials
  • Hard-fail path verified: a reformatted PINNED_TAG yields an empty ref and exits 1 with the new error, rather than silently cloning an empty ref
  • ruff check + ruff format --check clean on tests/_crucible_pin.py; module compiles with no SyntaxWarning
  • Verified against chore: bump Muninn action to v0.3.11 #2664's head before writing this: crucible_check.py → full_precision: PASS, zero_dependency: PASS
  • After merge: confirm the next fork PR shows these four checks running (look for the Corpus pin read from the repo notice) instead of failing at the clone step

Note 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

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]>
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 5026441 into main Sep 2, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the chore/crucible-pin-fork-fallback branch September 2, 2026 15:10
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.

1 participant