diff --git a/.github/workflows/upstreaming-controller.yml b/.github/workflows/upstreaming-controller.yml index aeac177aad5..d0a795beffa 100644 --- a/.github/workflows/upstreaming-controller.yml +++ b/.github/workflows/upstreaming-controller.yml @@ -71,10 +71,10 @@ jobs: 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]")' \ + jq -e 'any(.[]; .content == "eyes" 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 + -f content='eyes' >/dev/null # Cheap filter: unsupported events, missing labels and comments that are # not commands never reach the tick. @@ -276,6 +276,30 @@ jobs: permission-contents: read permission-issues: write + - name: Mark accepted commands complete + if: steps.policy.outputs.read_only == 'false' + env: + GH_TOKEN: ${{ steps.ledger-token.outputs.token }} + run: | + set -euo pipefail + retry_api() { + local attempt delay=1 + for attempt in 1 2 3 4; do + if gh api "$@"; then return 0; fi + [ "$attempt" -eq 4 ] && return 1 + sleep "$delay" + delay=$((delay * 2)) + done + } + jq -r '.commands[] | select(.result == "accepted") | .comment | select(type == "number")' \ + report.json | sort -nu | while read -r comment; do + reactions=$(retry_api "/repos/$GITHUB_REPOSITORY/issues/comments/$comment/reactions?per_page=100") + jq -e 'any(.[]; .content == "+1" and .user.login == "riseproject-dev[bot]")' \ + <<<"$reactions" >/dev/null || \ + retry_api -X POST "/repos/$GITHUB_REPOSITORY/issues/comments/$comment/reactions" \ + -f content='+1' >/dev/null + done + - name: Append concise lifecycle entries to tracking issues if: steps.policy.outputs.read_only == 'false' continue-on-error: true diff --git a/SESSIONLOG.md b/SESSIONLOG.md index c5c903ca365..ec6f3236c10 100644 --- a/SESSIONLOG.md +++ b/SESSIONLOG.md @@ -35,3 +35,4 @@ - Added `/upstreaming refresh` to re-investigate an existing development PR with current prompts, replace its verified dossier scope, and require a fresh worker pass carrying the full new dossier plus pending review and CI evidence. - Separated explicit explanation-only PR comments from change feedback so they are audited without revision bumps, `fix_needed` transitions, repair evidence, or misleading repair ledger text; repeated-pause rejection feedback now confirms the pause remains effective instead of repeating the submitted syntax. - Corrected paused-feedback ledger wording so actionable feedback remains visibly pending without claiming repair Work was requested while pause prevents allocation. +- Changed fast command receipt reactions from `+1` to `eyes` and added an idempotent post-state-commit `+1` only for commands accepted and durably executed by serialized reconciliation. diff --git a/upstreaming/README.md b/upstreaming/README.md index 5252e23b95f..47a4f5b3fd7 100644 --- a/upstreaming/README.md +++ b/upstreaming/README.md @@ -239,12 +239,15 @@ 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. A separate controller job promptly adds a `+1` reaction when the -first nonblank line of a new or edited tracking-issue comment starts with +one is known. A separate controller job promptly adds an `eyes` 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. +reconciliation does not delay acknowledgement. The `eyes` reaction does not +parse, authorize or apply the command; the serialized controller remains the +only command handler. After that controller accepts the command and publishes +its validated durable state commit, it idempotently adds `+1` to mark command +execution complete. Rejected commands retain `eyes` and receive the actionable +App-authored rejection reply instead of a completion reaction. 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 fc27bc6ded1..a629f73093e 100644 --- a/upstreaming/tests/test_workflow_contracts.py +++ b/upstreaming/tests/test_workflow_contracts.py @@ -190,10 +190,22 @@ def test_command_acknowledgement_is_fast_idempotent_and_not_serialized(self): 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) + self.assertIn("-f content='eyes'", script) + self.assertNotIn("-f content='+1'", script) reconcile = controller["jobs"]["reconcile"] self.assertEqual(reconcile["concurrency"]["group"], "python-wheels-upstreaming-controller") self.assertFalse(reconcile["concurrency"]["cancel-in-progress"]) + complete = next(step for step in reconcile["steps"] + if step.get("name") == "Mark accepted commands complete") + self.assertEqual(complete["if"], "steps.policy.outputs.read_only == 'false'") + self.assertIn('.commands[] | select(.result == "accepted")', complete["run"]) + self.assertIn("-f content='+1'", complete["run"]) + self.assertIn('riseproject-dev[bot]', complete["run"]) + self.assertIn("for attempt in 1 2 3 4", complete["run"]) + publish_index = next(i for i, step in enumerate(reconcile["steps"]) + if step.get("name") == "Publish one validated state-only commit on main") + complete_index = reconcile["steps"].index(complete) + self.assertGreater(complete_index, publish_index) def test_worker_brackets_untrusted_output_with_stop_commands(self): worker = source("upstreaming-worker")