Repository navigation
π fix(automerge): verify action-sha pins resolve upstream before the pin-only exception admits them - #16435
Conversation
β¦pin-only exception admits them ClassifyPinOnlyActions returns the accepted action-sha pins; the pin-only exception resolves each against its upstream repo (tag ref with annotated-tag dereference, or ancestry of the default branch) and holds on any failure. The pin-only and DCO commit listings use the exported pkg/github.ListPRRepositoryCommits helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. hive/awaiting-ci: CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 Evidence bundle `#16435f0db2a3` sha256:d336d0774d3e81d666112fa20ac082d8e390234bc409e85f0a54ce1daa170cbf β download from the dashboard or `hivectl review evidence #16435`. |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
β¦ed-pins fixture The fixture placed two -/+ pairs back-to-back, which the bounded pin grammar correctly refuses as an interleaved replacement. Insert a context line between the pairs and widen the hunk header to 5/5 so the fixture exercises the dedup path it was written for. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Read the diff against the tree at merge-base 03b781e3 and built pkg/intent, pkg/github, pkg/github/automerge locally (tests are CI-only in this pod). Looks correct to me.
What I verified:
pkg/intent/pin_only.go:249-259βactionPinFromstripsuses:/-and splits on/withSplitN(β¦, 3), sogithub/codeql-action/init@β¦yieldsRepo="github/codeql-action"and the regex at line 20 guaranteesparts[1]exists. A malformedowner//repofalls through to"upstream repository or commit unknown"atautomerge_human_paths.go:151β fails closed, as intended.automerge_human_paths.go:155β go-github v72Git.GetRefcalls the singulargit/ref/{ref}endpoint (exact match, verified ingit_refs.go:57), not the plural prefix-matchinggit/refs/, sotags/v4cannot accidentally matchv4.1.0.automerge_human_paths.go:185-191βCompareCommits(base=pin, head=default)withahead/identicalaccepted is the right ancestry test; a fork-only SHA can never be an ancestor of the upstream default branch, so it lands indivergedand is held.automerge_stage_dco.go:109β switching toListPRRepositoryCommitsdrops nil entries, butdcoCommitStatsDetailedForAuthoralready skipped nils at line 56, so the DCO stage behaviour is unchanged.stageDCOMaxPagesis still used byautomerge_contributor_adopt.go:1201, so no dead constant.- Each caller path (sweep +
/approve) goes throughhumanMergePinOnlyExempt, and the upstream reads happen only after the classifier and commit checks pass (automerge_human_paths.go:112-121).
One behavioural note, not a defect: a bump whose comment is a moving major tag (# v4) will be held if upstream re-points v4 between the PR's push and the sweep, since the tag must equal the new SHA exactly. That is the fail-closed outcome the PR chooses, and it just falls back to the human-merge path.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
CI triage β head
|
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Why
auto_merge.human_merge_pin_onlylets a pin bump on a human-merge path through without a person. The classifier (intent.ClassifyPinOnly) is deliberately syntax only: foraction-shait checksowner/repo@<40-hex>keeps its prefix and changes the hex. But GitHub resolves auses:SHA across the whole fork network ofowner/repo, so a commit pushed to any fork ofactions/checkoutis a valid pin, and the# vNcomment is cosmetic. Without a caller-side check, one pin-shaped line could land unreviewed workflow code. The classifier's own contract says callers must prove this, and no caller did.Commit provenance (every commit authored by a trusted login, committed by
web-flowor a trusted login, GitHub-verified signature) already landed in #16400, so the first box of #16399 is ticked. This PR does the second box.What
pkg/intent: newClassifyPinOnlyActionsreturns the distinctActionPin{Repo, SHA, Version}triples it accepted.ClassifyPinOnlykeeps its signature as a thin wrapper, so existing callers and tests don't change.pkg/github/automerge: once the diff and commits pass,humanMergePinOnlyExempt(used by the sweep lanes and/approve) resolves each pin upstream:# vX[.Y[.Z]]comment,GET repos/{owner}/{repo}/git/ref/tags/vXβ¦must point at exactly the new SHA. Annotated tags are dereferenced throughgit/tags/{sha}, up to 3 levels.CompareCommits(base=newSHA, head=defaultBranch)must returnaheadoridentical, meaning newSHA is an ancestor of the upstream default branch.image-digestpins are content-addressed and are not checked. The new reads only happen after the classifier and commit checks pass, and only when the key is configured. Repos without the key behave as before.pkg/github.ListPRRepositoryCommits(ctx, *gh.Client, β¦) (commits, complete, err)is exported. The unexported(*Client).listPRRepositoryCommitsstays as a thin alias.pinOnlyCommitsTrustednow uses it and keeps its stricter behaviour: it refuses whencomplete == false(still a page past the cap), when the list is empty, or when the list doesn't end at head. The DCO stage loop also uses it with the same semantics: a capped list is judged as read and nil commits are skipped either way. The only difference is the error text, which now namesowner/repo#ninstead of the display name.automerge_contributor_adopt.gohas its own loop, which I left alone because it is out of scope.hive-merge.md, operator reference) now say the exception proves upstream anchoring, instead of listing it as an open caller obligation. There is also a changelog fragment.Tests
pin_only_test.go: accepted pins are returned, with sub-path stripped, SHA lowercased, deduped and version parsed. Image-only diffs return none, and refused diffs return nil.automerge_human_paths_test.go: fake upstream handlers cover a lightweight tag match, tag mismatch, tag 404, annotated tag dereferenced to a match or a mismatch, an unreadable annotated tag, a tag chain that is too deep, compareahead/identical(admitted),divergedand a compare API error (held), a missing default branch, and a 404 on the repo. Upstream hit counts are asserted.pr_approve_command_test.go:/approveagrees with the sweep when the upstream tag points elsewhere.pr_commits_test.go: the exported lister reportscomplete=falseat the page cap and drops nils.I didn't run builds or tests locally because they're blocked in this pod; CI is the verdict.
Closes #16399
Closes #16401
β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88