Repository navigation
🔒 fix(contributor-lane): check removed tests before an owner approval releases the workflow fence - #15027
Conversation
… releases the workflow fence contributorLaneDiffReason names only its first fence, workflow-path before tests-removed, and workflowFenceReleased (hivecommons#14664) lifts the workflow fence alone. A contributor PR that edited .github/workflows/** and deleted tests therefore merged on a trusted merger's approval of the workflow change, with the test removal never checked. The lane now checks the test-deletion fence on its own (contributorLaneTestsRemovedReason) when the first fence is workflow-path, and stops at contributor-lane:tests-removed, which no approval overrides, before any release is read or its audit comment posted. contributorLaneDiffReason keeps its order, so the adoption fence still names workflow-path for such a head. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@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 |
|
@Danathar this PR is back in your court ( Failing checks:
Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path. Your relay session received this as a |
|
hive/check-report (head 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Read the diff against v6 and the callers. This looks correct to me, and it only tightens the gate.
Verified mechanism. At v6, contributorLaneDiffReason (src/pkg/github/automerge/automerge_contributor_lane.go:1077-1082) returns contributor-lane:workflow-path from its first loop before the test-deletion loop runs, and workflowFenceReleased (automerge_contributor_workflow_approval.go:72) releases exactly that reason. So in evaluateContributorLanePR (automerge_contributor_lane.go:1249-1255) a trusted approval on a head that edits .github/workflows/** and deletes a test went straight on to the remaining gates. The new check runs contributorLaneTestsRemovedReason before workflowFenceReleased is called, so no comments are read and no hive:workflow-approval marker is posted for a head that won't merge. contributorLaneDiffReason itself is unchanged in result and order, so the other callers (automerge_contributor_adopt.go:278, automerge_contributor_held_runs.go:65, pr_approve_command.go:86) behave as before. The new test case asserts wantReason: contributorLaneReasonTestsRemoved with an APPROVED review on the head, which fails without the check.
One low follow-up, not a blocker. The operator-facing asks still read only the first fence. pr_approve_command.go:86-88 tells a /hive approve sender that a trusted merger's GitHub Approve "releases" a workflow-path head, and the ApprovalReleasesFence wording landed in #15026 does the same for the 085 entry comment. For a head that both edits workflows and removes tests, that approval is now accepted and the lane then stops at contributor-lane:tests-removed — the approver is told the wrong next step. The PR body for #15026 already lists this as "one fence per head"; worth a small follow-up that has those asks consult contributorLaneTestsRemovedReason too.
Security note for the record: this changes merge-policy code, but in the restrictive direction only (an approval releases less than before); nothing becomes mergeable that was not.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. |
There was a problem hiding this comment.
Intent alignment — the diff does what the title and body say (read at head 77dc4ad): evaluateContributorLanePR now checks contributorLaneTestsRemovedReason before workflowFenceReleased when the first fence is workflow-path (src/pkg/github/automerge/automerge_contributor_lane.go:1262-1266), contributorLaneDiffReason's result/order are unchanged (:1077-1083), and the new test asserts reason, zero merges and zero hive:workflow-approval markers (automerge_contributor_workflow_approval_test.go:171-182, 209-227). No scope creep.
One advisory follow-up (low, not blocking): the /hive approve reply at src/pkg/github/automerge/pr_approve_command.go:88-89 still keys on diffReason == contributorLaneReasonWorkflowPath alone and tells the author that a trusted merger's Approve review will make "the lane merge once CI and the other gates are clear". For a head that edits workflows and removes tests, that promise is now false — the lane stops at contributor-lane:tests-removed. Routing such a head to the existing "requires a person to merge manually" reply on line 91 keeps the message truthful:
if len(intent.HumanMergePathMatches(files, patterns)) == 0 && diffReason == contributorLaneReasonWorkflowPath && contributorLaneTestsRemovedReason(files) == "" && c.currentContributorLanePolicy().OwnerApprovalReleasesWorkflowFence {
— hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Correctness review (head 77dc4ad) — the lane fix is correct and the new case covers it (automerge_contributor_lane.go:1259-1263; harness asserts reason, merges == 0 and no hive:workflow-approval marker at automerge_contributor_workflow_approval_test.go:209-227). contributorLaneDiffReason's output is unchanged, so adoptionDiffRefusal, automerge_contributor_held_runs.go:65 and the adopt-path fence checks keep their behaviour.
One advisory gap this PR opens, not a blocker:
/hive approve reply now promises a merge the lane will refuse — src/pkg/github/automerge/pr_approve_command.go:88-89 keys the "a trusted merger approves the head and the lane merges" caption on diffReason == contributorLaneReasonWorkflowPath alone. After this PR a workflow-path head that also removes tests stops at contributor-lane:tests-removed, so that caption sends the owner to approve a head that cannot merge; the generic "a maintainer must merge manually" reply at :91-92 is the accurate one. Suggested fix:
if len(intent.HumanMergePathMatches(files, patterns)) == 0 && diffReason == contributorLaneReasonWorkflowPath && contributorLaneTestsRemovedReason(files) == "" && c.currentContributorLanePolicy().OwnerApprovalReleasesWorkflowFence {
— hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Re the review finding raised by the correctness, intent-alignment and first reviews on
The other point in the first review (the 085 entry wording from #15026) is in that PR's code, not this branch, so it is left for that PR or backlog item #15034. |
|
Correction to my comment above: this PR merged at |
…orkflow head that removes tests (#15048) The /hive approve reply keyed its "a trusted merger's Approve review lets the lane merge" caption on the workflow-path fence alone. Since #15027 the lane checks removed tests before the owner-approval release, so a head that edits workflows and removes tests stops at tests-removed, and that caption sent the owner to approve a head the lane will not merge. Such a head now gets the manual-merge reply. Raised by the hive review of #15027 (backlog #15034); the fix was pushed to #15027's branch seconds after it merged, so it lands here. Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <Danathar@users.noreply.github.com> Co-authored-by: Danathar <Danathar@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Summary
An owner's approval of a workflow-file change could merge a contributor PR that also deletes tests.
contributorLaneDiffReason(pkg/github/automerge/automerge_contributor_lane.go) checks the diff fences in order and returns the first it finds:contributor-lane:workflow-pathbeforecontributor-lane:tests-removed. Since #14664 / #14672,workflowFenceReleasedlets a trusted merger's approval on the current head release the workflow-path fence. When it did, the lane went straight on to the other gates. A head that edited.github/workflows/**and removed tests merged on that approval, and its test removal was never checked, although tests-removed is a rule no approval overrides (manualMergeRuleReasonFor).I found this while reviewing a fix for contradictory 085 notes (#15026). No PR is known to have merged this way.
Change
contributorLaneDiffReason's test-deletion check is split out ascontributorLaneTestsRemovedReason.contributorLaneDiffReasoncalls it, so its result and order are unchanged.contributor-lane:tests-removed. No approval is read and nohive:workflow-approvalaudit comment is posted for a head that will not merge.contributorLaneDiffReason(adoptionDiffRefusal), so its fence for such a head is still workflow-path, and a fork's workflow edits are still never published upstream.hive-merge.md(the fence bullet) andoperator-reference.md(the toggle row).changelog.d/security-lane-tests-removed-after-fence-release.md.Testing
From
src/,TZ=UTC,-count=1:go test ./pkg/github/automerge/ ./pkg/stageengine/...passes.gofmtis clean.check-docs-citations.py,check-docs-links.pyandcheck-changelog-fragment.sh v6pass.New case in
TestContributorLaneWorkflowFenceOwnerApproval, "approval does not release a head that also removes a test": a workflow edit plus a removedwidget_test.go, with a trusted merger'sAPPROVEDreview on the head. The reason iscontributor-lane:tests-removed, there is no merge and no audit marker. Every existing case passes unchanged.Mutation check: with the new check disabled, the new case fails. Restored from a backup copy.
Contributor checklist
changelog.d/security-lane-tests-removed-after-fence-release.md.v6.src/docs/hive-merge.md,src/docs/operator-reference.md).🤖 Generated with Claude Code
https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1