diff --git a/plugins/magpie-pr-management/skills/code-review/classifications/disposition-auto-merge.md b/plugins/magpie-pr-management/skills/code-review/classifications/disposition-auto-merge.md index 951d6bab0..3ab4c3172 100644 --- a/plugins/magpie-pr-management/skills/code-review/classifications/disposition-auto-merge.md +++ b/plugins/magpie-pr-management/skills/code-review/classifications/disposition-auto-merge.md @@ -9,6 +9,7 @@ Plain `APPROVE` and `FIXUP` stay in the overrides unless CI is still running; a 1. **Post the `APPROVE`** as usual — immediately, even while real CI is still running (`ci_pending_held_by_auto_merge`), provided every running check is a required one (auto-merge waits only for those; a running check that is not required keeps the CI gate); for the fixup variant, right after the push ([`disposition-fixup.md`](disposition-fixup.md) step 6). Failing CI, a rollup green from bot checks only, and workflows waiting for approval still rule it out (Golden rule 8); `ci_action` names the run to approve or re-run first. + A held run that shows up as a pending check that is not required rules it out too, and step 3 cannot release it, because `release-runs` needs an approval: follow `ci_action` and approve it through `pr-management-triage` first. 2. **Refresh the liveness read and re-run `guard`** against the head the approval was made on — save `gql-pr-liveness ` again first, so `guard` is not reading the pre-post copy. New commits since → stop; do not enable auto-merge on a head nobody reviewed. 3. **Release held workflow runs at the head.** Auto-merge only works if the required checks run, and a push — the fixup, or a contributor push the guard just saw — can leave the head's runs held in `action_required`. Read them per head (the repository-wide `runs-action-required` list is capped at 1000 and can miss them): diff --git a/plugins/magpie-pr-management/skills/pr-triage/actions/approve-workflow.md b/plugins/magpie-pr-management/skills/pr-triage/actions/approve-workflow.md index db20e4f4d..f5f3ac035 100644 --- a/plugins/magpie-pr-management/skills/pr-triage/actions/approve-workflow.md +++ b/plugins/magpie-pr-management/skills/pr-triage/actions/approve-workflow.md @@ -17,6 +17,12 @@ uv run --project /tools/pr-management pr-management triage guard appr gh api -X POST repos//actions/runs//approve ``` + GitHub accepts this only for first-time contributors' runs. A run that answers HTTP 403 *"This workflow run is not waiting for approval"* needs a full re-run instead; one that then answers *"already running"* is done: + + ```bash + gh run rerun --repo + ``` + - `proceed: false` with "already approved" → nothing to do; say so in one line, so the no-op is visible. No note is posted: CI starting is what the contributor wanted. diff --git a/plugins/magpie-security-tools/tools/pr-management/src/pr_management/code_review/disposition.py b/plugins/magpie-security-tools/tools/pr-management/src/pr_management/code_review/disposition.py index 249e45d8b..800924826 100644 --- a/plugins/magpie-security-tools/tools/pr-management/src/pr_management/code_review/disposition.py +++ b/plugins/magpie-security-tools/tools/pr-management/src/pr_management/code_review/disposition.py @@ -134,6 +134,11 @@ def pick( + ", ".join(f"`{n}`" for n in pending_not_required) + " (not a required check)" ) + # `release-runs` needs an approval, which this gate withholds, so held runs go through triage. + ci_action = ( + "wait for those checks; if their runs are waiting for workflow approval, " + "approve them (pr-management-triage); then re-run disposition" + ) elif ci_state == "EXPECTED": gates.append("CI is waiting for workflow approval — the project's real CI has not run") ci_action = "approve the waiting workflow runs (pr-management-triage), then re-run disposition" diff --git a/tools/pr-management/src/pr_management/code_review/disposition.py b/tools/pr-management/src/pr_management/code_review/disposition.py index 249e45d8b..800924826 100644 --- a/tools/pr-management/src/pr_management/code_review/disposition.py +++ b/tools/pr-management/src/pr_management/code_review/disposition.py @@ -134,6 +134,11 @@ def pick( + ", ".join(f"`{n}`" for n in pending_not_required) + " (not a required check)" ) + # `release-runs` needs an approval, which this gate withholds, so held runs go through triage. + ci_action = ( + "wait for those checks; if their runs are waiting for workflow approval, " + "approve them (pr-management-triage); then re-run disposition" + ) elif ci_state == "EXPECTED": gates.append("CI is waiting for workflow approval — the project's real CI has not run") ci_action = "approve the waiting workflow runs (pr-management-triage), then re-run disposition" diff --git a/tools/pr-management/tests/code_review/test_decisions.py b/tools/pr-management/tests/code_review/test_decisions.py index 8419c77cc..d1627729f 100644 --- a/tools/pr-management/tests/code_review/test_decisions.py +++ b/tools/pr-management/tests/code_review/test_decisions.py @@ -222,6 +222,7 @@ def test_running_ci_without_auto_merge_still_gates() -> None: {"ci_state": "EXPECTED"}, {"ci_state": "PENDING", "real_ci": False}, {"ci_state": "SUCCESS", "real_ci": False}, + {"ci_state": "PENDING", "pending_not_required": ("Workflow approval",)}, ], ) def test_ci_that_never_ran_names_the_workflow_action(ci: dict[str, Any]) -> None: