diff --git a/.github/workflows/upstreaming-controller.yml b/.github/workflows/upstreaming-controller.yml index 2b3dc39b5c1..867db6845a4 100644 --- a/.github/workflows/upstreaming-controller.yml +++ b/.github/workflows/upstreaming-controller.yml @@ -38,15 +38,44 @@ on: types: [completed] workflow_dispatch: -concurrency: - group: python-wheels-upstreaming-controller - cancel-in-progress: false - permissions: contents: read issues: read jobs: + # Fast receipt only. This job has no needs and no concurrency group, so a + # queued reconciliation run cannot delay acknowledgement. Command parsing, + # authority checks, rejection feedback and state changes remain in reconcile. + acknowledge-command: + if: github.event_name == 'issue_comment' && github.event.issue.pull_request == null + runs-on: ubuntu-latest + timeout-minutes: 2 + permissions: + contents: read + steps: + - uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + id: control-token + with: + client-id: ${{ vars.RISEPROJECT_APP_CLIENT_ID }} + private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} + owner: riseproject-dev + repositories: python-wheels + permission-issues: write + - name: Acknowledge a visible upstreaming command + env: + GH_TOKEN: ${{ steps.control-token.outputs.token }} + COMMENT_ID: ${{ github.event.comment.id }} + COMMENT_BODY: ${{ github.event.comment.body }} + run: | + set -euo pipefail + first=$(printf '%s\n' "$COMMENT_BODY" | awk 'NF { print; exit }') + [[ "$first" == /upstreaming\ * ]] || exit 0 + reactions=$(gh api "/repos/$GITHUB_REPOSITORY/issues/comments/$COMMENT_ID/reactions?per_page=100") + jq -e 'any(.[]; .content == "+1" and .user.login == "riseproject-dev[bot]")' \ + <<<"$reactions" >/dev/null || \ + gh api -X POST "/repos/$GITHUB_REPOSITORY/issues/comments/$COMMENT_ID/reactions" \ + -f content='+1' >/dev/null + # Cheap filter: unsupported events, missing labels and comments that are # not commands never reach the tick. filter: @@ -102,6 +131,9 @@ jobs: needs: filter runs-on: ubuntu-latest timeout-minutes: 15 + concurrency: + group: python-wheels-upstreaming-controller + cancel-in-progress: false environment: upstreaming-state permissions: contents: read diff --git a/SESSIONLOG.md b/SESSIONLOG.md index 14520616ab3..b45419257af 100644 --- a/SESSIONLOG.md +++ b/SESSIONLOG.md @@ -26,3 +26,4 @@ - Replaced the rejected workflow-glob approach with complete dossier path coverage and natural-language review scope extension: human-relay-backed repairs may add exact changed paths, which trusted publication verifies and persists without requiring command syntax. - Added an exact-path repair compatibility flag for live contributions whose dossiers predate mandatory path coverage; new dossiers are marked coverage-complete and cannot use the legacy allowance. - Added trusted post-publication review acknowledgements: every addressed feedback item gets a short App-authored response, inline review threads are resolved after replying, and marker/readback checks make retries idempotent. +- Added a fast ungrouped controller job that idempotently reacts `+1` to visible `/upstreaming` tracking-issue comments while leaving all parsing, authorization and command effects in serialized reconciliation. diff --git a/upstreaming/README.md b/upstreaming/README.md index 9a3b9d4d12c..bf3633531fb 100644 --- a/upstreaming/README.md +++ b/upstreaming/README.md @@ -239,7 +239,12 @@ commands** section with the current revision/head prefilled. Entries are never edited, so user commands and pipeline history remain interleaved chronologically. A rejected command receives a separate App-authored reply that quotes the exact command, pings its author, explains the rejection and shows a corrected form when -one is known. +one is known. A separate controller job promptly adds a `+1` reaction when the +first nonblank line of a new or edited tracking-issue comment starts with +`/upstreaming `. This receipt job has no concurrency group, so queued +reconciliation does not delay acknowledgement. The reaction does not parse, +authorize or apply the command; the serialized controller remains the only +command handler. Post a command as its own comment on the request issue. The issue says which contribution it applies to, so `contribution=` is optional (if given, it must diff --git a/upstreaming/tests/test_workflow_contracts.py b/upstreaming/tests/test_workflow_contracts.py index dc9b1d77b44..e1a4a999e38 100644 --- a/upstreaming/tests/test_workflow_contracts.py +++ b/upstreaming/tests/test_workflow_contracts.py @@ -176,6 +176,23 @@ def test_controller_chains_every_pipeline_completion_and_has_schedule_fallback(s self.assertIn("created", triggers["issue_comment"]["types"]) self.assertIn("github.event_name == 'workflow_run'", controller["jobs"]["filter"]["if"]) + def test_command_acknowledgement_is_fast_idempotent_and_not_serialized(self): + controller = yaml.safe_load((WF / "upstreaming-controller.yml").read_text()) + self.assertNotIn("concurrency", controller) + ack = controller["jobs"]["acknowledge-command"] + self.assertNotIn("needs", ack) + self.assertNotIn("concurrency", ack) + self.assertEqual(ack["if"], + "github.event_name == 'issue_comment' && github.event.issue.pull_request == null") + script = ack["steps"][-1]["run"] + self.assertIn("awk 'NF { print; exit }'", script) + self.assertIn("reactions?per_page=100", script) + self.assertIn('riseproject-dev[bot]', script) + self.assertIn("-f content='+1'", script) + reconcile = controller["jobs"]["reconcile"] + self.assertEqual(reconcile["concurrency"]["group"], "python-wheels-upstreaming-controller") + self.assertFalse(reconcile["concurrency"]["cancel-in-progress"]) + def test_worker_forbids_unrelated_fork_ci_debug_changes(self): worker = source("upstreaming-worker") self.assertNotIn("github", worker["tools"])