Own the CAA gate: a reusable workflow and a Go program in this repository - #2
Draft
gafferongames wants to merge 1 commit into
Draft
Own the CAA gate: a reusable workflow and a Go program in this repository#2gafferongames wants to merge 1 commit into
gafferongames wants to merge 1 commit into
Conversation
…tory The gate ran on contributor-assistant/github-action, a third-party action whose repository is archived at v2.6.1. This replaces it with an organization-owned reusable workflow that every library repository calls. .github/workflows/caa.yml holds a pull request until its author appears in the signature ledger, asks an unsigned author to sign, records the signature when the author posts the exact sentence, and sets a commit status named caa on every run so branch protection has one whatever the verdict. A reusable workflow necessarily names its Actions check after the caller's job, so the name branch protection watches is now the commit status rather than the check. tools/caa carries the logic. The ledger keeps the shape it already has, so every signature recorded before this still counts, and a round trip through the program is byte for byte the file it read. Two tokens, never crossed: the ledger write uses CAA_LEDGER_TOKEN, which needs contents read and write on this repository and nothing else; every other call uses the calling repository's GITHUB_TOKEN with pull-requests write, statuses write, and contents read. The pull request's head is never checked out, and no value from an event payload reaches a command line. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Replaces the archived third-party CAA action with a reusable workflow and a Go
program this organization owns.
The gate ran on
contributor-assistant/github-action@v2.6.1. That repository isarchived, v2.6.1 (2024-09-26) is its last release, and it holds a personal
access token with write on every library repository. This is the owner half of
that: same behavior, code we own, and a credential that reaches one repository.
What lands
.github/workflows/caa.yml,on: workflow_call. Every library repositorycalls it from its own
cla.yml. All inputs have defaults, so a caller passesonly the secret.
tools/caa, the logic, run asgo run ./tools/caa. Go 1.26 viasetup-go,pinned by SHA, as is
checkout. No dependencies outside the standard library..github/workflows/ci.yml, runninggofmt,go vetandgo test ./....Behavior
pull_request_targetsuccesspull_request_targetsuccesspull_request_targetfailureissue_commenton a pull requestsuccessissue_commenton a pull requestfailureissue_commenton a pull requestsuccessissue_commenton a pull requestissue_commenton a plain issueA signature is the whole comment body, ignoring surrounding whitespace and
capitalization. A body carrying any other text is not a signature, which is what
the old action did too.
Three things worth reading before you approve.
organization ruleset
Require CAA signaturerequires a status check namedcaaon the default branch of eleven repositories:netcode,reliable,serialize,yojimbo,fixed3d,netcode.go,netcode.rs,reliable.go,reliable.rs,serialize.goandserialize.rs. That nameis satisfied today by the Actions job check. A reusable workflow names its
check after the caller, so that check becomes
caa / caa. The programtherefore sets a commit status named
caaon every run, whatever theverdict. A required check name matches a commit status as readily as a check
run, so the ruleset needs no change and must not be touched.
schemais notin that ruleset, which is why it is the right first caller: if the status
does not appear as expected, nothing is blocked while we find out.
old action listed every commit author on the pull request. This is the
narrower rule you specified. A pull request carrying a commit authored by
somebody else passes on the author's signature alone.
recheckmagic word: after a signature is recorded by hand, any commentturns the status green. Nothing else re-evaluates an open pull request.
The credential
One fine-grained personal access token, created once:
mas-bandwidthmas-bandwidth/.githubmetadata beyond the mandatory read, not pull requests, not issues, not
actions.
Store it once, as an organization secret named
CAA_LEDGER_TOKEN, withrepository access granted to the calling repositories. No per-repository secret
is created. The caller passes it through explicitly rather than with
secrets: inherit, so the reusable workflow sees that one secret and no other.Everything else uses the calling repository's
GITHUB_TOKEN:pull-requests: writeto post the ask,statuses: writeto set the gate,contents: readforcheckoutto fetch this repository'stools/caaat the called workflow's owncommit. The pull request's head is never checked out, and no value out of an
event payload reaches a command line.
If an organization-installed GitHub App with contents write on this repository
alone is easier for you to manage than a PAT, it fits the same slot: the
workflow only needs a token in
CAA_LEDGER_TOKENthat can writesignatures/caa.json.Rollout
CAA_LEDGER_TOKEN, grantingit to
schemaand to the eleven repositories in the ruleset above.uses:lineto that SHA. Watch one pull request through the gate.
yojimbofirst, one at atime, confirming the
caastatus appears on a pull request in each beforemoving to the next.
CLA_SIGNATURES_TOKENand delete thesecret from every repository and from the organization.
Not in this pass
cla.ymlin the other eleven repositories:netcode,reliable,serialize,yojimbo,fixed3d,netcode.go,netcode.rs,reliable.go,reliable.rs,serialize.goandserialize.rs. All eleven carry the samefile, byte for byte, and differ from schema's only in that schema pins the
archived action by SHA. Each is a one file follow-up once schema is proven.
the README says how.
Testing
go test ./...covers ledger parsing, a byte for byte round trip of the realledger so existing signatures stay valid, the exact sentence match, the author
check, the idempotent append, and the negative control that the sentence from
another user signs nothing. Each of those was confirmed to go red when the rule
it guards is removed. The program was also run end to end against a stub API for
all four event shapes, confirming the two tokens never cross.
🤖 Generated with Claude Code