Skip to content

🔒 fix(contributor-lane): check removed tests before an owner approval releases the workflow fence - #15027

Merged
hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/lane-tests-removed-after-fence-release
Oct 28, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
hivecommons:v6from
Danathar:fix/lane-tests-removed-after-fence-release

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

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-path before contributor-lane:tests-removed. Since #14664 / #14672, workflowFenceReleased lets 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 as contributorLaneTestsRemovedReason. contributorLaneDiffReason calls it, so its result and order are unchanged.
  • In the lane, when the first fence is workflow-path, the tests-removed fence is checked on its own before any release is read. A head that also removes tests stops at contributor-lane:tests-removed. No approval is read and no hive:workflow-approval audit comment is posted for a head that will not merge.
  • Unchanged:
    • Adoption still reads contributorLaneDiffReason (adoptionDiffRefusal), so its fence for such a head is still workflow-path, and a fork's workflow edits are still never published upstream.
    • A head that only edits workflow files is released by an approval as before.
  • Docs: hive-merge.md (the fence bullet) and operator-reference.md (the toggle row).
  • Changelog: 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.
  • gofmt is clean.
  • check-docs-citations.py, check-docs-links.py and check-changelog-fragment.sh v6 pass.

New case in TestContributorLaneWorkflowFenceOwnerApproval, "approval does not release a head that also removes a test": a workflow edit plus a removed widget_test.go, with a trusted merger's APPROVED review on the head. The reason is contributor-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: changelog.d/security-lane-tests-removed-after-fence-release.md.
  • Targets v6.
  • The title uses the emoji convention.
  • Commits include DCO sign-off.
  • Docs updated (src/docs/hive-merge.md, src/docs/operator-reference.md).
  • No secrets, credentials or local runtime state are committed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

… 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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 28, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign danathar for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 28, 2026
@hivecommons-hive hivecommons-hive Bot added author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@Danathar this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Failing checks:

  • check-failure

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 fix-pr task; your current task is parked (claim kept alive) until this PR is green.

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act and removed stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

hive/check-report (head 77dc4ad; base v6): the red is infrastructure, not the diff. build-and-test died downloading a module — github.com/charmbracelet/colorprofile@v0.3.2: read https://proxy.golang.org/...: stream error: stream ID 49; INTERNAL_ERROR; received from peer. No code change is needed; a fresh head (e.g. git fetch upstream v6 && git rebase upstream/v6 on fix/lane-tests-removed-after-fence-release, then push with the same sign-off) re-runs CI. This hive cannot re-run checks or push to your fork.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: 071a132

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

Conflicts are checked with every PR merged onto the current tip of v6, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#14939 📖 docs(v6): behind fork leaves the lane front at once; serialized lane readiness row from the dd406b3 re-run same files src/docs/operator-reference.md
#15035 🐛 fix(automerge): hold merges whose closing keywords would close the wrong thing same files src/pkg/github/automerge/automerge_contributor_lane.go

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act labels Oct 28, 2026
@hivecommons-hive hivecommons-hive Bot added stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@hivecommons-hive hivecommons-hive Bot removed the stage/072-returned-to-contributor Contributor PR: CI red, changes requested or conflicting; diagnosis posted, author must act label Oct 28, 2026
@hivecommons-hive hivecommons-hive Bot added the stage/050-review-pending Review swarm requested; awaiting a verdict for the current head label Oct 28, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no findings from this perspective.

— hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Hive filed review findings that do not block this PR as backlog items:

Cap: 10 backlog item(s) per PR per day.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@hivecommons-hive
hivecommons-hive Bot merged commit 46d58b7 into hivecommons:v6 Oct 28, 2026
92 of 104 checks passed
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#1502777dc4ad` sha256:9e2d23204b982aad6a9f4593dfc965a3b1e29abeaddee3edd33e1ef3b1a7b509 — download from the dashboard or `hivectl review evidence #15027`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @Danathar holds role owner and GitHub permission maintain on repo; CI green at 77dc4ad.

@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 28, 2026
@Danathar

Copy link
Copy Markdown
Contributor Author

Re the review finding raised by the correctness, intent-alignment and first reviews on 77dc4ad (the /hive approve reply at src/pkg/github/automerge/pr_approve_command.go:88 still promising an owner-approval merge for a workflow head that also removes tests): verified and fixed in 590d65e.

  • The workflow-fence caption now also requires contributorLaneTestsRemovedReason(files) == "", as suggested, so such a head falls through to the "requires a person to merge manually" reply.
  • TestPRApproveReply gains two cases with OwnerApprovalReleasesWorkflowFence on: workflow-only still gets the owner-approval caption, workflow + a removed _test.go gets the manual reply. Dropping the new condition fails the second case.
  • The changelog fragment notes the reply change.

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.

@Danathar

Copy link
Copy Markdown
Contributor Author

Correction to my comment above: this PR merged at 77dc4ad (18:08:10Z) a few seconds before 590d65e reached the branch, so that commit is not in v6. The /hive approve caption gap is still open and is tracked by backlog item #15034; the commit on the fork branch can be reused for a follow-up PR.

hivecommons-hive Bot pushed a commit that referenced this pull request Oct 28, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/clanker A contributor's own hive authored this PR under their login dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant