From 7f2f73d87f24c44fd035b15419874e2eb36c10c6 Mon Sep 17 00:00:00 2001 From: Hector Martinez Date: Wed, 7 Oct 2026 10:56:04 +0200 Subject: [PATCH] refactor(workflow)!: remove existing-pr gate on the workflow BREAKING CHANGE: this change removes the existing PR gate on the workflow. The gate exists on the pre-script for the code agent. A breaking change anyway, as now the workflows will run for longer up to that point. Signed-off-by: Hector Martinez --- .github/workflows/reusable-dispatch.yml | 62 +------------------ .../scaffold/workflow_call_alignment_test.go | 38 ------------ 2 files changed, 3 insertions(+), 97 deletions(-) diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index c293a9595a..21ff0e4522 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -110,7 +110,7 @@ jobs: issues: read pull-requests: read outputs: - stage: ${{ steps.role-check.outputs.skipped != 'true' && steps.agent-check.outputs.skipped != 'true' && steps.pr-check.outputs.skipped != 'true' && steps.route.outputs.stage || '' }} + stage: ${{ steps.role-check.outputs.skipped != 'true' && steps.agent-check.outputs.skipped != 'true' && steps.route.outputs.stage || '' }} trigger_source: ${{ steps.route.outputs.trigger_source }} event_payload: ${{ steps.payload.outputs.event_payload }} steps: @@ -421,55 +421,6 @@ jobs: echo "stage=${STAGE}" >> "${GITHUB_OUTPUT}" echo "trigger_source=${TRIGGER_SOURCE}" >> "${GITHUB_OUTPUT}" - - name: Check for existing PRs - id: pr-check - if: steps.route.outputs.stage == 'code' - env: - GH_TOKEN: ${{ github.token }} - ISSUE_NUMBER: ${{ github.event.issue.number }} - SOURCE_REPO: ${{ github.repository }} - run: | - set -euo pipefail - # Query for PRs that actually close this issue (Fixes/Closes/Resolves - # keywords), not a substring search over title/body — the latter - # false-positives on any PR that merely references the issue (#5575). - # closedByPullRequestsReferences also returns MERGED PRs regardless of - # includeClosedPrs, so filter on .state explicitly. Exclude the code- - # agent bot via __typename + login so it can re-dispatch even when it - # already has an open PR (#5974); other bots (e.g. Renovate) still - # block. See docs/contributing/bot-identities.md for the login format. - # NOTE: bot identity is checked in three places — (1) this existing-PR - # guard (GraphQL __typename), (2) the fix eligibility script - # (.defaults/.github/scripts/check-fix-eligibility.sh — gh pr view - # is_bot/login), (3) org-scaffold dispatch.yml:226 (webhook [bot]$ - # regex). See docs/contributing/bot-identities.md. - OWNER="${SOURCE_REPO%%/*}" - REPO_NAME="${SOURCE_REPO##*/}" - GQL_ERR=$(mktemp) - if ! LINKED_PRS=$(gh api graphql -f query=' - query($owner: String!, $repo: String!, $number: Int!) { - repository(owner: $owner, name: $repo) { - issue(number: $number) { - closedByPullRequestsReferences(first: 20) { - nodes { number state author { login __typename } } - } - } - } - }' -f owner="${OWNER}" -f repo="${REPO_NAME}" -F number="${ISSUE_NUMBER}" \ - --jq '[.data.repository.issue.closedByPullRequestsReferences.nodes[] - | select(.state == "OPEN") - | select(.author.__typename != "Bot" or .author.login != "fullsend-ai-coder")] - | map("#\(.number)") | join(", ")' \ - 2>"${GQL_ERR}"); then - echo "::warning::Linked-PR query failed for issue #${ISSUE_NUMBER}: $(tr '\n' ' ' < "${GQL_ERR}" | sed 's/::/__/g')" - LINKED_PRS="" - fi - rm -f "${GQL_ERR}" - if [[ -n "${LINKED_PRS}" ]]; then - echo "::notice::Skipping code dispatch — issue #${ISSUE_NUMBER} has open PR(s) ${LINKED_PRS}" - echo "skipped=true" >> "${GITHUB_OUTPUT}" - fi - - name: Validate routed stage if: steps.route.outputs.stage != '' env: @@ -571,7 +522,7 @@ jobs: - name: Check agent is enabled id: agent-check - if: steps.route.outputs.stage != '' && steps.role-check.outputs.skipped != 'true' && steps.pr-check.outputs.skipped != 'true' + if: steps.route.outputs.stage != '' && steps.role-check.outputs.skipped != 'true' env: STAGE: ${{ steps.route.outputs.stage }} run: | @@ -599,7 +550,7 @@ jobs: - name: Resolve PR head for issue_comment events id: pr-head - if: steps.route.outputs.stage != '' && steps.role-check.outputs.skipped != 'true' && steps.agent-check.outputs.skipped != 'true' && steps.pr-check.outputs.skipped != 'true' && github.event_name == 'issue_comment' && github.event.issue.pull_request + if: steps.route.outputs.stage != '' && steps.role-check.outputs.skipped != 'true' && steps.agent-check.outputs.skipped != 'true' && github.event_name == 'issue_comment' && github.event.issue.pull_request env: GH_TOKEN: ${{ github.token }} SOURCE_REPO: ${{ github.repository }} @@ -868,13 +819,6 @@ jobs: FULLSEND_WORK_ITEM_URL: ${{ fromJSON(needs.route.outputs.event_payload).issue.html_url }} FULLSEND_WORK_ITEM_KEY: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} ISSUE_NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} - # Reaches the harness pre-script inside fullsend run, which reads it - # for its --force override of the existing-PR check (pre-script - # output protocol, issue #4718). The override is not end-to-end: - # the route job's own "Check for existing PRs" step above gates - # stage=code first and does not honor --force, so a /fs-code - # --force comment is stopped before this value is ever read. - # env-quoted, never interpolated into run: blocks. COMMENT_BODY: ${{ fromJSON(needs.route.outputs.event_payload).comment.body }} REPO_FULL_NAME: ${{ github.repository }} CODE_ALLOWED_TARGET_BRANCHES: '' diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index 5244dc218d..3e9c5b0a21 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -985,9 +985,6 @@ func TestDispatchPRHeadResolution(t *testing.T) { assert.Contains(t, s, "id: pr-head", "resolve step must have id: pr-head") - assert.Contains(t, s, `steps.pr-check.outputs.skipped != 'true'`, - "resolve step if: must include pr-check guard") - assert.Contains(t, s, `'.pull_request = $pr'`, "must merge PR JSON into event_payload via jq") @@ -1003,41 +1000,6 @@ func TestDispatchPRHeadResolution(t *testing.T) { } } -// TestDispatchPRCheckBotFilter validates that the existing-PR guard in both -// dispatch workflows uses __typename + login for bot detection (not bare login -// string comparison), and includes matched PR numbers in the skip notice (#5974). -func TestDispatchPRCheckBotFilter(t *testing.T) { - type workflowCase struct { - name string - content func(t *testing.T) []byte - } - - cases := []workflowCase{ - { - "reusable-dispatch.yml", - loadRepoFile(".github/workflows/reusable-dispatch.yml"), - }, - } - - for _, wc := range cases { - t.Run(wc.name, func(t *testing.T) { - s := string(wc.content(t)) - - assert.Contains(t, s, `author { login __typename }`, - "GraphQL query must request both login and __typename for bot detection") - - assert.Contains(t, s, `select(.author.__typename != "Bot" or .author.login != "fullsend-ai-coder")`, - "bot filter must exclude only the code-agent bot via __typename + login — see docs/contributing/bot-identities.md") - - assert.Contains(t, s, `map("#\(.number)") | join(", ")`, - "jq must format PR numbers as #N, #M — bare .[].number silently truncates multi-PR notices") - - assert.Regexp(t, `::notice::.*\$\{LINKED_PRS\}`, s, - "skip notice must include the matched PR number(s)") - }) - } -} - // TestActionPRHeadSHAInput validates that action.yml declares the pr-head-sha // input and uses it in both the fullsend run step and the reconcile step. func TestActionPRHeadSHAInput(t *testing.T) {