From 50f475e19cab5922e9985ad3ffb1c7e97a874377 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Mon, 9 Nov 2026 11:11:15 +0200 Subject: [PATCH 01/25] fix(actions): report pre-agent startup failures Post a user-visible comment when an agent workflow fails before the Fullsend process starts. Include the failure category and workflow run link, while keeping the comment stable across retries. Co-authored-by: Codex Signed-off-by: csoceanu --- .../scripts/report-agent-startup-failure.sh | 63 +++++ .github/workflows/reusable-dispatch.yml | 229 ++++++++++++++++++ .github/workflows/reusable-prioritize.yml | 33 +++ action.yml | 70 ++++++ docs/reference/config-reference.md | 7 + internal/scaffold/vendorcontent.go | 15 +- internal/scaffold/vendorcontent_test.go | 1 + internal/scaffold/vendormanifest.go | 1 + .../scaffold/workflow_call_alignment_test.go | 13 + 9 files changed, 425 insertions(+), 7 deletions(-) create mode 100755 .github/scripts/report-agent-startup-failure.sh diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh new file mode 100755 index 0000000000..6071d30e2e --- /dev/null +++ b/.github/scripts/report-agent-startup-failure.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# Post or update the single user-facing comment for an agent launch that +# failed before the agent process started. This intentionally uses gh directly +# because the fullsend CLI may be the dependency that failed to install. +set -euo pipefail + +: "${GH_TOKEN:?GH_TOKEN is required}" +: "${FULLSEND_FAILURE_REPOSITORY:?FULLSEND_FAILURE_REPOSITORY is required}" +FULLSEND_FAILURE_REPOSITORY="${FULLSEND_FAILURE_REPOSITORY:-}" +FULLSEND_FAILURE_NUMBER="${FULLSEND_FAILURE_NUMBER:-}" +FULLSEND_FAILURE_AGENT="${FULLSEND_FAILURE_AGENT:-}" +FULLSEND_FAILURE_RUN_URL="${FULLSEND_FAILURE_RUN_URL:-}" +FULLSEND_FAILURE_CATEGORY="${FULLSEND_FAILURE_CATEGORY:-}" + +if [[ ! "${FULLSEND_FAILURE_REPOSITORY}" =~ ^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$ ]]; then + echo "::warning::Skipping startup failure comment: invalid repository" >&2 + exit 0 +fi +if [[ ! "${FULLSEND_FAILURE_NUMBER}" =~ ^[1-9][0-9]*$ ]]; then + echo "::warning::Skipping startup failure comment: invalid issue number" >&2 + exit 0 +fi +if [[ ! "${FULLSEND_FAILURE_AGENT}" =~ ^[A-Za-z0-9_-]+$ ]]; then + echo "::warning::Skipping startup failure comment: invalid agent" >&2 + exit 0 +fi +case "${FULLSEND_FAILURE_CATEGORY}" in + "workflow setup"|"runtime setup"|"CLI setup"|"token mint") ;; + *) + echo "::warning::Skipping startup failure comment: invalid category" >&2 + exit 0 + ;; +esac +if [[ ! "${FULLSEND_FAILURE_RUN_URL}" =~ ^https://[^/]+/.*/actions/runs/[1-9][0-9]*$ ]]; then + echo "::warning::Skipping startup failure comment: invalid workflow URL" >&2 + exit 0 +fi + +MARKER="" +BODY_FILE="${RUNNER_TEMP:-/tmp}/fullsend-agent-startup-failure.md" +{ + printf '%s\n\n' "${MARKER}" + printf '⚠️ **Fullsend %s agent did not run**\n\n' "${FULLSEND_FAILURE_AGENT}" + printf 'The agent could not start because of a **%s** failure during workflow setup.\n\n' "${FULLSEND_FAILURE_CATEGORY}" + printf '[View the workflow run](%s)\n\n' "${FULLSEND_FAILURE_RUN_URL}" +} > "${BODY_FILE}" + +BOT_LOGIN="$(gh api graphql -f query='{ viewer { login } }' --jq '.data.viewer.login')" +COMMENTS_JSON="$(gh api --paginate --slurp \ + "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/${FULLSEND_FAILURE_NUMBER}/comments")" +COMMENT_ID="$(printf '%s' "${COMMENTS_JSON}" | jq -r \ + --arg marker "${MARKER}" --arg bot "${BOT_LOGIN}" \ + 'add | map(select(.user.login == $bot and (.body | contains($marker)))) | last | .id // empty')" + +if [[ -n "${COMMENT_ID}" ]]; then + gh api --method PATCH "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/comments/${COMMENT_ID}" \ + -f body="$(<"${BODY_FILE}")" >/dev/null + echo "Updated startup failure comment ${COMMENT_ID}" +else + gh api --method POST "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/${FULLSEND_FAILURE_NUMBER}/comments" \ + -f body="$(<"${BODY_FILE}")" >/dev/null + echo "Posted startup failure comment" +fi diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index c63945eaa7..a8d9a6fe73 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -1512,6 +1512,7 @@ jobs: run: bash .github/scripts/setup-agent-env.sh - name: Run triage agent + id: run-agent uses: ./.defaults/ env: GITHUB_ISSUE_URL: ${{ fromJSON(needs.route.outputs.event_payload).issue.html_url }} @@ -1551,10 +1552,41 @@ jobs: run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ github.repository }} status-number: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} + source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} + - name: Report triage launch failure + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + env: + GH_TOKEN: ${{ github.token }} + MINT_OUTCOME: ${{ steps.app-token.outcome }} + REPOSITORY: ${{ github.repository }} + NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -euo pipefail + script=".defaults/.github/scripts/report-agent-startup-failure.sh" + [[ -f "${script}" ]] || script=".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh" + if [[ ! -f "${script}" ]]; then + script="${RUNNER_TEMP}/fullsend-agent-startup-failure.sh" + if encoded="$(gh api "repos/${{ job.workflow_repository }}/contents/.github/scripts/report-agent-startup-failure.sh?ref=${{ job.workflow_sha }}" --jq .content)"; then + printf '%s' "${encoded}" | base64 --decode > "${script}" + chmod +x "${script}" + else + echo "::warning::Startup failure reporter is unavailable" + exit 0 + fi + fi + export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" + export FULLSEND_FAILURE_NUMBER="${NUMBER}" + export FULLSEND_FAILURE_AGENT="triage" + export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" + FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" + export FULLSEND_FAILURE_CATEGORY + bash "${script}" + code: name: Code needs: route @@ -1644,6 +1676,7 @@ jobs: run: bash .github/scripts/setup-agent-env.sh - name: Run code agent + id: run-agent uses: ./.defaults/ env: GITHUB_ISSUE_URL: ${{ fromJSON(needs.route.outputs.event_payload).issue.html_url }} @@ -1687,10 +1720,41 @@ jobs: run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ github.repository }} status-number: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} + source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} + - name: Report code launch failure + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + env: + GH_TOKEN: ${{ github.token }} + MINT_OUTCOME: ${{ steps.app-token.outcome }} + REPOSITORY: ${{ github.repository }} + NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -euo pipefail + script=".defaults/.github/scripts/report-agent-startup-failure.sh" + [[ -f "${script}" ]] || script=".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh" + if [[ ! -f "${script}" ]]; then + script="${RUNNER_TEMP}/fullsend-agent-startup-failure.sh" + if encoded="$(gh api "repos/${{ job.workflow_repository }}/contents/.github/scripts/report-agent-startup-failure.sh?ref=${{ job.workflow_sha }}" --jq .content)"; then + printf '%s' "${encoded}" | base64 --decode > "${script}" + chmod +x "${script}" + else + echo "::warning::Startup failure reporter is unavailable" + exit 0 + fi + fi + export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" + export FULLSEND_FAILURE_NUMBER="${NUMBER}" + export FULLSEND_FAILURE_AGENT="code" + export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" + FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" + export FULLSEND_FAILURE_CATEGORY + bash "${script}" + review: name: Review needs: route @@ -1820,6 +1884,7 @@ jobs: run: bash .github/scripts/setup-agent-env.sh - name: Run review agent + id: run-agent uses: ./.defaults/ env: GITHUB_ISSUE_URL: ${{ fromJSON(needs.route.outputs.event_payload).issue.html_url }} @@ -1864,10 +1929,41 @@ jobs: run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ github.repository }} status-number: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} + source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} + - name: Report review launch failure + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + env: + GH_TOKEN: ${{ github.token }} + MINT_OUTCOME: ${{ steps.app-token.outcome }} + REPOSITORY: ${{ github.repository }} + NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -euo pipefail + script=".defaults/.github/scripts/report-agent-startup-failure.sh" + [[ -f "${script}" ]] || script=".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh" + if [[ ! -f "${script}" ]]; then + script="${RUNNER_TEMP}/fullsend-agent-startup-failure.sh" + if encoded="$(gh api "repos/${{ job.workflow_repository }}/contents/.github/scripts/report-agent-startup-failure.sh?ref=${{ job.workflow_sha }}" --jq .content)"; then + printf '%s' "${encoded}" | base64 --decode > "${script}" + chmod +x "${script}" + else + echo "::warning::Startup failure reporter is unavailable" + exit 0 + fi + fi + export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" + export FULLSEND_FAILURE_NUMBER="${NUMBER}" + export FULLSEND_FAILURE_AGENT="review" + export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" + FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" + export FULLSEND_FAILURE_CATEGORY + bash "${script}" + fix: name: Fix needs: route @@ -2089,6 +2185,7 @@ jobs: run: bash .github/scripts/setup-agent-env.sh - name: Run fix agent + id: run-agent uses: ./.defaults/ env: PR_NUMBER: ${{ steps.context.outputs.pr_number }} @@ -2132,10 +2229,41 @@ jobs: run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ github.repository }} status-number: ${{ steps.context.outputs.pr_number }} + source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} + - name: Report fix launch failure + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + env: + GH_TOKEN: ${{ github.token }} + MINT_OUTCOME: ${{ steps.app-token.outcome }} + REPOSITORY: ${{ github.repository }} + NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -euo pipefail + script=".defaults/.github/scripts/report-agent-startup-failure.sh" + [[ -f "${script}" ]] || script=".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh" + if [[ ! -f "${script}" ]]; then + script="${RUNNER_TEMP}/fullsend-agent-startup-failure.sh" + if encoded="$(gh api "repos/${{ job.workflow_repository }}/contents/.github/scripts/report-agent-startup-failure.sh?ref=${{ job.workflow_sha }}" --jq .content)"; then + printf '%s' "${encoded}" | base64 --decode > "${script}" + chmod +x "${script}" + else + echo "::warning::Startup failure reporter is unavailable" + exit 0 + fi + fi + export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" + export FULLSEND_FAILURE_NUMBER="${NUMBER}" + export FULLSEND_FAILURE_AGENT="fix" + export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" + FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" + export FULLSEND_FAILURE_CATEGORY + bash "${script}" + retro: name: Retro needs: route @@ -2207,6 +2335,7 @@ jobs: run: bash .github/scripts/setup-agent-env.sh - name: Run retro agent + id: run-agent uses: ./.defaults/ env: ORIGINATING_URL: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.html_url || fromJSON(needs.route.outputs.event_payload).issue.html_url }} @@ -2246,10 +2375,41 @@ jobs: run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ github.repository }} status-number: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} + source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} + - name: Report retro launch failure + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + env: + GH_TOKEN: ${{ github.token }} + MINT_OUTCOME: ${{ steps.app-token.outcome }} + REPOSITORY: ${{ github.repository }} + NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -euo pipefail + script=".defaults/.github/scripts/report-agent-startup-failure.sh" + [[ -f "${script}" ]] || script=".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh" + if [[ ! -f "${script}" ]]; then + script="${RUNNER_TEMP}/fullsend-agent-startup-failure.sh" + if encoded="$(gh api "repos/${{ job.workflow_repository }}/contents/.github/scripts/report-agent-startup-failure.sh?ref=${{ job.workflow_sha }}" --jq .content)"; then + printf '%s' "${encoded}" | base64 --decode > "${script}" + chmod +x "${script}" + else + echo "::warning::Startup failure reporter is unavailable" + exit 0 + fi + fi + export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" + export FULLSEND_FAILURE_NUMBER="${NUMBER}" + export FULLSEND_FAILURE_AGENT="retro" + export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" + FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" + export FULLSEND_FAILURE_CATEGORY + bash "${script}" + prioritize: name: Prioritize needs: route @@ -2308,6 +2468,7 @@ jobs: run: mkdir -p target-repo - name: Run prioritize agent + id: run-agent uses: ./.defaults/ env: GITHUB_ISSUE_URL: ${{ fromJSON(needs.route.outputs.event_payload).issue.html_url }} @@ -2346,8 +2507,37 @@ jobs: run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ github.repository }} status-number: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} + source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} mint-url: ${{ inputs.mint_url }} + - name: Report prioritize launch failure + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + env: + GH_TOKEN: ${{ github.token }} + REPOSITORY: ${{ github.repository }} + NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).issue.number || fromJSON(needs.route.outputs.event_payload).pull_request.number }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -euo pipefail + script=".defaults/.github/scripts/report-agent-startup-failure.sh" + [[ -f "${script}" ]] || script=".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh" + if [[ ! -f "${script}" ]]; then + script="${RUNNER_TEMP}/fullsend-agent-startup-failure.sh" + if encoded="$(gh api "repos/${{ job.workflow_repository }}/contents/.github/scripts/report-agent-startup-failure.sh?ref=${{ job.workflow_sha }}" --jq .content)"; then + printf '%s' "${encoded}" | base64 --decode > "${script}" + chmod +x "${script}" + else + echo "::warning::Startup failure reporter is unavailable" + exit 0 + fi + fi + export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" + export FULLSEND_FAILURE_NUMBER="${NUMBER}" + export FULLSEND_FAILURE_AGENT="prioritize" + export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" + export FULLSEND_FAILURE_CATEGORY="workflow setup" + bash "${script}" + harness-dispatch: name: Harness dispatch if: ${{ inputs.matrix == '' }} @@ -2564,6 +2754,11 @@ jobs: done mkdir -p .github/scripts cp "${SRC}/.github/scripts/setup-agent-env.sh" .github/scripts/setup-agent-env.sh + reporter=".defaults/.github/scripts/report-agent-startup-failure.sh" + [[ -f "${reporter}" ]] || reporter=".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh" + if [[ -f "${reporter}" ]]; then + cp "${reporter}" .github/scripts/report-agent-startup-failure.sh + fi - name: Extract repo metadata id: repo-parts @@ -2689,6 +2884,7 @@ jobs: } >> "${GITHUB_OUTPUT}" - name: Run harness agent + id: run-agent uses: ./.defaults/ env: GITHUB_ISSUE_URL: ${{ steps.dispatch-env.outputs.issue_url }} @@ -2729,10 +2925,43 @@ jobs: runner_secrets: ${{ secrets.FULLSEND_GITHUB_RUNNER_SECRETS }} version: ${{ inputs.fullsend_version || job.workflow_sha }} fullsend-dir: .fullsend + github_token: ${{ steps.app-token.outputs.token || github.token }} run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ matrix.status_repo }} status-number: ${{ matrix.status_number }} status-comment-id: ${{ matrix.event_payload.comment.id }} + source-system: ${{ fromJSON(matrix.event_payload)._normalized_event.source.system || 'github' }} + status-comment-id: ${{ fromJSON(matrix.event_payload).comment.id }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ matrix.event_payload.pull_request.head.sha || '' }} artifact-name: ${{ steps.dispatch-env.outputs.artifact_name }} + - name: Report harness launch failure + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && fromJSON(matrix.event_payload)._normalized_event.source.system != 'jira' }} + env: + GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} + MINT_OUTCOME: ${{ steps.app-token.outcome }} + REPOSITORY: ${{ matrix.status_repo }} + NUMBER: ${{ matrix.status_number }} + AGENT: ${{ matrix.agent }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -euo pipefail + script=".defaults/.github/scripts/report-agent-startup-failure.sh" + [[ -f "${script}" ]] || script=".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh" + if [[ ! -f "${script}" ]]; then + script="${RUNNER_TEMP}/fullsend-agent-startup-failure.sh" + if encoded="$(gh api "repos/${{ job.workflow_repository }}/contents/.github/scripts/report-agent-startup-failure.sh?ref=${{ job.workflow_sha }}" --jq .content)"; then + printf '%s' "${encoded}" | base64 --decode > "${script}" + chmod +x "${script}" + else + echo "::warning::Startup failure reporter is unavailable" + exit 0 + fi + fi + export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" + export FULLSEND_FAILURE_NUMBER="${NUMBER}" + export FULLSEND_FAILURE_AGENT="${AGENT}" + export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" + FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" + export FULLSEND_FAILURE_CATEGORY + bash "${script}" diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index 28e4dccbad..5ac4084814 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -171,6 +171,7 @@ jobs: run: mkdir -p target-repo - name: Run prioritize agent + id: run-agent uses: ./.defaults/ env: GITHUB_ISSUE_URL: ${{ fromJSON(inputs.event_payload).issue.html_url }} @@ -204,5 +205,37 @@ jobs: version: ${{ inputs.fullsend_version || job.workflow_sha }} fullsend-dir: .fullsend mint-url: ${{ inputs.mint_url }} + run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + status-repo: ${{ inputs.source_repo }} + status-number: ${{ fromJSON(inputs.event_payload).issue.number || fromJSON(inputs.event_payload).pull_request.number }} + source-system: ${{ fromJSON(inputs.event_payload)._normalized_event.source.system || 'github' }} gcp_wif_provider: ${{ secrets.FULLSEND_GCP_WIF_PROVIDER }} gcp_project_id: ${{ secrets.FULLSEND_GCP_PROJECT_ID }} + + - name: Report prioritize launch failure + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(inputs.event_payload)._normalized_event.source.system != 'jira' }} + env: + GH_TOKEN: ${{ github.token }} + REPOSITORY: ${{ inputs.source_repo }} + NUMBER: ${{ fromJSON(inputs.event_payload).issue.number || fromJSON(inputs.event_payload).pull_request.number }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -euo pipefail + script=".defaults/.github/scripts/report-agent-startup-failure.sh" + [[ -f "${script}" ]] || script=".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh" + if [[ ! -f "${script}" ]]; then + script="${RUNNER_TEMP}/fullsend-agent-startup-failure.sh" + if encoded="$(gh api "repos/${{ job.workflow_repository }}/contents/.github/scripts/report-agent-startup-failure.sh?ref=${{ job.workflow_sha }}" --jq .content)"; then + printf '%s' "${encoded}" | base64 --decode > "${script}" + chmod +x "${script}" + else + echo "::warning::Startup failure reporter is unavailable" + exit 0 + fi + fi + export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" + export FULLSEND_FAILURE_NUMBER="${NUMBER}" + export FULLSEND_FAILURE_AGENT="prioritize" + export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" + export FULLSEND_FAILURE_CATEGORY="workflow setup" + bash "${script}" diff --git a/action.yml b/action.yml index 83cc1fcaa3..aa46609194 100644 --- a/action.yml +++ b/action.yml @@ -41,6 +41,11 @@ inputs: status-number: description: Issue/PR number for status comments (optional). default: "" + source-system: + description: >- + Originating tracker for the event (github, gitlab, or jira). GitHub + startup-failure comments are not posted for non-GitHub-originated events. + default: github status-comment-id: description: >- ID of the comment that triggered this run via a slash command @@ -276,6 +281,7 @@ runs: fi - name: Install vendored binary + id: install-vendored if: steps.detect.outputs.install-method == 'vendored' shell: bash env: @@ -348,6 +354,7 @@ runs: echo "${RUNNER_TEMP}/fullsend" >> "${GITHUB_PATH}" - name: Clone fullsend at ref for source build + id: clone-source if: steps.detect.outputs.install-method == 'source' || steps.download-release.outcome == 'failure' shell: bash env: @@ -418,6 +425,7 @@ runs: cache-dependency-path: ${{ runner.temp }}/fullsend-src/go.sum - name: Build fullsend from source + id: build-source if: steps.detect.outputs.install-method == 'source' || steps.download-release.outcome == 'failure' shell: bash run: | @@ -429,6 +437,7 @@ runs: echo "${RUNNER_TEMP}/fullsend" >> "${GITHUB_PATH}" - name: Print fullsend version + id: print-version shell: bash run: fullsend --version @@ -458,11 +467,13 @@ runs: - name: Install Podman if: steps.sandbox-host.outputs.local == 'true' + id: install-podman shell: bash run: "$GITHUB_ACTION_PATH/.github/scripts/install-podman.sh" - name: Configure rootless Podman if: steps.sandbox-host.outputs.local == 'true' + id: configure-podman shell: bash run: | test -f /sys/fs/cgroup/cgroup.controllers || { echo "::error::cgroups v2 required"; exit 1; } @@ -497,6 +508,7 @@ runs: # a remote-gateway runner that already has the CLI skips it. - name: Install OpenShell CLI if: steps.sandbox-host.outputs.install-openshell == 'true' + id: install-openshell shell: bash run: "$GITHUB_ACTION_PATH/.github/scripts/install-openshell.sh" @@ -729,12 +741,65 @@ runs: name: ${{ inputs.artifact-name || format('fullsend-{0}', inputs.agent) }} path: ${{ steps.prepare-artifacts.outputs.dir }} + - name: Report pre-agent startup failure + if: always() && inputs.agent != '__install_only__' && inputs.source-system == 'github' && inputs.status-repo != '' && inputs.status-number != '' + shell: bash + env: + GH_TOKEN: ${{ inputs.github_token }} + AGENT: ${{ inputs.agent }} + STATUS_REPO: ${{ inputs.status-repo }} + STATUS_NUMBER: ${{ inputs.status-number }} + RUN_URL: ${{ inputs.run-url }} + JOB_STATUS: ${{ job.status }} + INSTALL_CLI_OUTCOME: ${{ steps.detect.outcome }} + VENDORED_OUTCOME: ${{ steps.install-vendored.outcome }} + DOWNLOAD_RELEASE_OUTCOME: ${{ steps.download-release.outcome }} + CLONE_SOURCE_OUTCOME: ${{ steps.clone-source.outcome }} + BUILD_SOURCE_OUTCOME: ${{ steps.build-source.outcome }} + PRINT_VERSION_OUTCOME: ${{ steps.print-version.outcome }} + PODMAN_OUTCOME: ${{ steps.install-podman.outcome }} + CONFIGURE_PODMAN_OUTCOME: ${{ steps.configure-podman.outcome }} + OPENSHELL_OUTCOME: ${{ steps.install-openshell.outcome }} + RUN_OUTCOME: ${{ steps.run.outcome }} + run: | + set -euo pipefail + if [[ "${JOB_STATUS}" == "failure" && "${RUN_OUTCOME}" == "skipped" ]]; then + FAILURE_CATEGORY="workflow setup" + if [[ "${PODMAN_OUTCOME}" == "failure" \ + || "${CONFIGURE_PODMAN_OUTCOME}" == "failure" \ + || "${OPENSHELL_OUTCOME}" == "failure" ]]; then + FAILURE_CATEGORY="runtime setup" + elif [[ "${INSTALL_CLI_OUTCOME}" == "failure" \ + || "${VENDORED_OUTCOME}" == "failure" \ + || "${DOWNLOAD_RELEASE_OUTCOME}" == "failure" \ + || "${CLONE_SOURCE_OUTCOME}" == "failure" \ + || "${BUILD_SOURCE_OUTCOME}" == "failure" \ + || "${PRINT_VERSION_OUTCOME}" == "failure" ]]; then + FAILURE_CATEGORY="CLI setup" + fi + + FULLSEND_FAILURE_REPOSITORY="${STATUS_REPO}" + FULLSEND_FAILURE_NUMBER="${STATUS_NUMBER}" + FULLSEND_FAILURE_AGENT="${AGENT}" + FULLSEND_FAILURE_RUN_URL="${RUN_URL:-${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}}" + FULLSEND_FAILURE_CATEGORY="${FAILURE_CATEGORY}" + export FULLSEND_FAILURE_REPOSITORY FULLSEND_FAILURE_NUMBER \ + FULLSEND_FAILURE_AGENT FULLSEND_FAILURE_RUN_URL \ + FULLSEND_FAILURE_CATEGORY + if "$GITHUB_ACTION_PATH/.github/scripts/report-agent-startup-failure.sh"; then + echo "FULLSEND_STARTUP_FAILURE_REPORTED=true" >> "${GITHUB_ENV}" + else + echo "::warning::Could not post pre-agent failure comment" + fi + fi + - name: Finalize orphaned status comment # Runs last (after all other always() steps) so job.status reflects # the job's true final outcome, not just the fullsend run outcome. if: always() && inputs.agent != '__install_only__' && inputs.status-repo != '' && inputs.status-number != '' && inputs.mint-url != '' shell: bash env: + GH_TOKEN: ${{ inputs.github_token }} MINT_URL: ${{ inputs.mint-url }} AGENT: ${{ inputs.agent }} STATUS_REPO: ${{ inputs.status-repo }} @@ -772,6 +837,11 @@ runs: # remains in "Started" state. This step runs unconditionally (if: # always()) to detect and finalize orphaned comments. See #2149. + if [[ "${FULLSEND_STARTUP_FAILURE_REPORTED:-}" == "true" ]]; then + echo "Startup failure was reported; skipping orphaned status reconciliation" + exit 0 + fi + # Resolve the correct commit SHA. Priority order: # 1. Explicit pr-head-sha input (per-repo workflow_call callers) # 2. Native pull_request.head.sha diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index 523332cd84..7a4b7c9ee1 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -681,6 +681,13 @@ In `enabled` mode, a hard crash or cancellation that happens before the agent could post anything at all is also surfaced after the fact: a post-job cleanup step synthesizes an "Interrupted" comment so the run doesn't silently vanish. +If workflow setup fails before the agent process starts, the dispatch workflow +posts a separate "Fullsend agent did not run" comment with the failure category +and workflow-run link. This startup-failure comment is used only for +GitHub-originated events and does not replace tracker-routed notifications for +Jira-originated events. Repeated failures update the existing startup-failure +comment instead of creating duplicates. + **Reactions.** Emoji reactions don't generate a GitHub notification, so they are a lower-noise way to show that an agent is working and how the run turned out. Unlike comments, they default to `disabled`. When `reaction.start` is diff --git a/internal/scaffold/vendorcontent.go b/internal/scaffold/vendorcontent.go index d86f1c385f..ce79797901 100644 --- a/internal/scaffold/vendorcontent.go +++ b/internal/scaffold/vendorcontent.go @@ -175,13 +175,14 @@ func isVendoredReusableWorkflow(path string) bool { // current path regardless of whether they are listed. var vendoredDefaultsScripts = map[string]bool{ ".github/scripts/check-fix-eligibility.sh": true, - ".github/scripts/count-fix-commits.jq": true, - ".github/scripts/install-openshell.sh": true, - ".github/scripts/install-podman.sh": true, - ".github/scripts/openshell-version.sh": true, - ".github/scripts/pre-fetch-review-body.sh": true, - ".github/scripts/review-diff-hash.sh": true, - ".github/scripts/retry-with-backoff.sh": true, + ".github/scripts/count-fix-commits.jq": true, + ".github/scripts/install-openshell.sh": true, + ".github/scripts/install-podman.sh": true, + ".github/scripts/openshell-version.sh": true, + ".github/scripts/pre-fetch-review-body.sh": true, + ".github/scripts/review-diff-hash.sh": true, + ".github/scripts/retry-with-backoff.sh": true, + ".github/scripts/report-agent-startup-failure.sh": true, } // vendoredDefaultsActions is the explicit allowlist of .github/actions/ diff --git a/internal/scaffold/vendorcontent_test.go b/internal/scaffold/vendorcontent_test.go index af568a73bd..9b3a9d24bc 100644 --- a/internal/scaffold/vendorcontent_test.go +++ b/internal/scaffold/vendorcontent_test.go @@ -118,6 +118,7 @@ func TestIsVendoredDefaultsInfra(t *testing.T) { assert.True(t, isVendoredDefaultsInfra(".github/scripts/install-openshell.sh")) assert.True(t, isVendoredDefaultsInfra(".github/scripts/retry-with-backoff.sh")) assert.False(t, isVendoredDefaultsInfra(".github/scripts/retry-with-backoff-test.sh")) + assert.True(t, isVendoredDefaultsInfra(".github/scripts/report-agent-startup-failure.sh")) assert.False(t, isVendoredDefaultsInfra(".github/scripts/run.sh")) assert.False(t, isVendoredDefaultsInfra(".github/scripts/check-fix-eligibility-test.sh")) assert.False(t, isVendoredDefaultsInfra(".github/scripts/count-fix-commits-test.sh")) diff --git a/internal/scaffold/vendormanifest.go b/internal/scaffold/vendormanifest.go index d3ba9b32eb..3c72cccf79 100644 --- a/internal/scaffold/vendormanifest.go +++ b/internal/scaffold/vendormanifest.go @@ -165,6 +165,7 @@ var vendoredDefaultsInfraPaths = []string{ ".github/scripts/pre-fetch-review-body.sh", ".github/scripts/review-diff-hash.sh", ".github/scripts/retry-with-backoff.sh", + ".github/scripts/report-agent-startup-failure.sh", } // enumerateVendoredPaths returns embed-derived paths for a current --vendor install layout. diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index 714f631741..a5c92288b7 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -1904,6 +1904,8 @@ func TestReusableDispatchStatusCommentPassthrough(t *testing.T) { "%s agent step must pass status-repo to action.yml", stage) assert.Contains(t, section, "status-number:", "%s agent step must pass status-number to action.yml", stage) + assert.Contains(t, section, "source-system:", + "%s agent step must pass source-system to action.yml", stage) }) } @@ -1916,6 +1918,17 @@ func TestReusableDispatchStatusCommentPassthrough(t *testing.T) { "harness-run agent step must pass status-repo to action.yml") assert.Contains(t, section, "status-number:", "harness-run agent step must pass status-number to action.yml") + assert.Contains(t, section, "source-system:", + "harness-run agent step must pass source-system to action.yml") + }) + + t.Run("standalone prioritize", func(t *testing.T) { + content, err := os.ReadFile(filepath.Join("..", "..", ".github", "workflows", "reusable-prioritize.yml")) + require.NoError(t, err) + section := extractStepSection(t, string(content), "Run prioritize agent") + assert.Contains(t, section, "status-repo:") + assert.Contains(t, section, "status-number:") + assert.Contains(t, section, "source-system:") }) } From 19038f1bcd61c353896d7f4411f5b30e68a4eb9b Mon Sep 17 00:00:00 2001 From: csoceanu Date: Mon, 9 Nov 2026 13:03:15 +0200 Subject: [PATCH 02/25] fix(actions): harden startup failure reporting Co-authored-by: Codex Signed-off-by: csoceanu --- .../scripts/report-agent-startup-failure.sh | 3 +-- .github/workflows/reusable-dispatch.yml | 14 +++++++------- .github/workflows/reusable-prioritize.yml | 18 ++++++++++++++++-- docs/reference/config-reference.md | 12 ++++++++++++ 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh index 6071d30e2e..523ce6ba68 100755 --- a/.github/scripts/report-agent-startup-failure.sh +++ b/.github/scripts/report-agent-startup-failure.sh @@ -5,7 +5,6 @@ set -euo pipefail : "${GH_TOKEN:?GH_TOKEN is required}" -: "${FULLSEND_FAILURE_REPOSITORY:?FULLSEND_FAILURE_REPOSITORY is required}" FULLSEND_FAILURE_REPOSITORY="${FULLSEND_FAILURE_REPOSITORY:-}" FULLSEND_FAILURE_NUMBER="${FULLSEND_FAILURE_NUMBER:-}" FULLSEND_FAILURE_AGENT="${FULLSEND_FAILURE_AGENT:-}" @@ -31,7 +30,7 @@ case "${FULLSEND_FAILURE_CATEGORY}" in exit 0 ;; esac -if [[ ! "${FULLSEND_FAILURE_RUN_URL}" =~ ^https://[^/]+/.*/actions/runs/[1-9][0-9]*$ ]]; then +if [[ ! "${FULLSEND_FAILURE_RUN_URL}" =~ ^https://[A-Za-z0-9.-]+/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+/actions/runs/[1-9][0-9]*$ ]]; then echo "::warning::Skipping startup failure comment: invalid workflow URL" >&2 exit 0 fi diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index a8d9a6fe73..f2ad0b7a18 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -1558,7 +1558,7 @@ jobs: pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report triage launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -1726,7 +1726,7 @@ jobs: pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report code launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -1935,7 +1935,7 @@ jobs: pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report review launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -2235,7 +2235,7 @@ jobs: pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report fix launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -2381,7 +2381,7 @@ jobs: pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report retro launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -2511,7 +2511,7 @@ jobs: mint-url: ${{ inputs.mint_url }} - name: Report prioritize launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system != 'jira' }} + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} REPOSITORY: ${{ github.repository }} @@ -2936,7 +2936,7 @@ jobs: pr-head-sha: ${{ matrix.event_payload.pull_request.head.sha || '' }} artifact-name: ${{ steps.dispatch-env.outputs.artifact_name }} - name: Report harness launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && fromJSON(matrix.event_payload)._normalized_event.source.system != 'jira' }} + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && (fromJSON(matrix.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index 5ac4084814..1fed7c02db 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -147,6 +147,15 @@ jobs: with: source_repo: ${{ inputs.source_repo }} + - name: Mint prioritize status token + id: app-token + continue-on-error: true + uses: ./.defaults/.github/actions/mint-token + with: + role: prioritize + repos: ${{ steps.repo-parts.outputs.name }} + mint_url: ${{ inputs.mint_url }} + - name: Prepare GCP credentials for an explicit CLI override if: env.FULLSEND_LEGACY_GCP_SETUP == 'true' uses: ./.defaults/.github/actions/setup-gcp @@ -204,6 +213,7 @@ jobs: runner_secrets: ${{ secrets.FULLSEND_GITHUB_RUNNER_SECRETS }} version: ${{ inputs.fullsend_version || job.workflow_sha }} fullsend-dir: .fullsend + github_token: ${{ steps.app-token.outputs.token || github.token }} mint-url: ${{ inputs.mint_url }} run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ inputs.source_repo }} @@ -213,9 +223,9 @@ jobs: gcp_project_id: ${{ secrets.FULLSEND_GCP_PROJECT_ID }} - name: Report prioritize launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && fromJSON(inputs.event_payload)._normalized_event.source.system != 'jira' }} + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(inputs.event_payload)._normalized_event.source.system || 'github') == 'github' && (inputs.source_repo == github.repository || steps.app-token.outcome == 'success') }} env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} REPOSITORY: ${{ inputs.source_repo }} NUMBER: ${{ fromJSON(inputs.event_payload).issue.number || fromJSON(inputs.event_payload).pull_request.number }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} @@ -239,3 +249,7 @@ jobs: export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" export FULLSEND_FAILURE_CATEGORY="workflow setup" bash "${script}" + + - name: Warn when cross-repository failure cannot be reported + if: ${{ always() && steps.run-agent.outcome == 'skipped' && (fromJSON(inputs.event_payload)._normalized_event.source.system || 'github') == 'github' && inputs.source_repo != github.repository && steps.app-token.outcome != 'success' }} + run: echo "::warning::Prioritize startup failure could not be reported because no token authorized for ${{ inputs.source_repo }} was available" diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index 7a4b7c9ee1..4ac7b3eaf7 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -688,6 +688,18 @@ GitHub-originated events and does not replace tracker-routed notifications for Jira-originated events. Repeated failures update the existing startup-failure comment instead of creating duplicates. +Because this fallback runs specifically when the Fullsend CLI may not have been +installed, it uses the workflow's GitHub comment API directly and does not read +`status_notifications`. Therefore, a startup-failure comment can still be +posted when status comments are disabled; this is intentional because the +comment reports that the requested agent did not run at all. + +When the startup-failure fallback has successfully posted, the action skips +orphaned-status reconciliation. No Fullsend run was started in that case, so +there is no start comment to reconcile; skipping it also prevents a second, +misleading "Interrupted" comment. Other status side effects are consequently +not run for that pre-agent failure. + **Reactions.** Emoji reactions don't generate a GitHub notification, so they are a lower-noise way to show that an agent is working and how the run turned out. Unlike comments, they default to `disabled`. When `reaction.start` is From ed40040b724502d0185e545c42c6a24cd89bd1e5 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Mon, 9 Nov 2026 13:46:17 +0200 Subject: [PATCH 03/25] fix(actions): harden startup failure fallback Co-authored-by: Codex Signed-off-by: csoceanu --- .../scripts/report-agent-startup-failure.sh | 24 +++++++++++++------ .github/workflows/reusable-dispatch.yml | 6 ++++- .github/workflows/reusable-prioritize.yml | 2 +- docs/contributing/forge-abstraction.md | 2 +- docs/reference/config-reference.md | 6 +++++ 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh index 523ce6ba68..d2bfd718fd 100755 --- a/.github/scripts/report-agent-startup-failure.sh +++ b/.github/scripts/report-agent-startup-failure.sh @@ -13,26 +13,26 @@ FULLSEND_FAILURE_CATEGORY="${FULLSEND_FAILURE_CATEGORY:-}" if [[ ! "${FULLSEND_FAILURE_REPOSITORY}" =~ ^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$ ]]; then echo "::warning::Skipping startup failure comment: invalid repository" >&2 - exit 0 + exit 1 fi if [[ ! "${FULLSEND_FAILURE_NUMBER}" =~ ^[1-9][0-9]*$ ]]; then echo "::warning::Skipping startup failure comment: invalid issue number" >&2 - exit 0 + exit 1 fi if [[ ! "${FULLSEND_FAILURE_AGENT}" =~ ^[A-Za-z0-9_-]+$ ]]; then echo "::warning::Skipping startup failure comment: invalid agent" >&2 - exit 0 + exit 1 fi case "${FULLSEND_FAILURE_CATEGORY}" in "workflow setup"|"runtime setup"|"CLI setup"|"token mint") ;; *) echo "::warning::Skipping startup failure comment: invalid category" >&2 - exit 0 + exit 1 ;; esac if [[ ! "${FULLSEND_FAILURE_RUN_URL}" =~ ^https://[A-Za-z0-9.-]+/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+/actions/runs/[1-9][0-9]*$ ]]; then echo "::warning::Skipping startup failure comment: invalid workflow URL" >&2 - exit 0 + exit 1 fi MARKER="" @@ -47,9 +47,19 @@ BODY_FILE="${RUNNER_TEMP:-/tmp}/fullsend-agent-startup-failure.md" BOT_LOGIN="$(gh api graphql -f query='{ viewer { login } }' --jq '.data.viewer.login')" COMMENTS_JSON="$(gh api --paginate --slurp \ "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/${FULLSEND_FAILURE_NUMBER}/comments")" +TRUSTED_BOT_LOGINS="${FULLSEND_FAILURE_TRUSTED_BOTS:-github-actions}" +case "${FULLSEND_FAILURE_AGENT}" in + code|fix) TRUSTED_BOT_LOGINS+=",fullsend-ai-coder" ;; + review) TRUSTED_BOT_LOGINS+=",fullsend-ai-review" ;; + triage) TRUSTED_BOT_LOGINS+=",fullsend-ai-triage" ;; + retro) TRUSTED_BOT_LOGINS+=",fullsend-ai-retro" ;; + prioritize) TRUSTED_BOT_LOGINS+=",fullsend-ai-prioritize" ;; +esac +TRUSTED_BOTS_JSON="$(jq -Rn --arg current "${BOT_LOGIN}" --arg logins "${TRUSTED_BOT_LOGINS}" \ + '[ $current ] + ($logins | split(",") | map(select(length > 0))) | unique')" COMMENT_ID="$(printf '%s' "${COMMENTS_JSON}" | jq -r \ - --arg marker "${MARKER}" --arg bot "${BOT_LOGIN}" \ - 'add | map(select(.user.login == $bot and (.body | contains($marker)))) | last | .id // empty')" + --arg marker "${MARKER}" --argjson trusted "${TRUSTED_BOTS_JSON}" \ + 'add | map(select((.user.type == "Bot") and ((.user.login) as $login | ($trusted | index($login)) != null) and (.body | contains($marker)))) | last | .id // empty')" if [[ -n "${COMMENT_ID}" ]]; then gh api --method PATCH "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/comments/${COMMENT_ID}" \ diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index f2ad0b7a18..f88064433f 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -2936,7 +2936,7 @@ jobs: pr-head-sha: ${{ matrix.event_payload.pull_request.head.sha || '' }} artifact-name: ${{ steps.dispatch-env.outputs.artifact_name }} - name: Report harness launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && (fromJSON(matrix.event_payload)._normalized_event.source.system || 'github') == 'github' }} + if: ${{ failure() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && (fromJSON(matrix.event_payload)._normalized_event.source.system || 'github') == 'github' && (matrix.status_repo == github.repository || steps.app-token.outcome == 'success') }} env: GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -2965,3 +2965,7 @@ jobs: FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" export FULLSEND_FAILURE_CATEGORY bash "${script}" + + - name: Warn when cross-repository harness failure cannot be reported + if: ${{ always() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && (fromJSON(matrix.event_payload)._normalized_event.source.system || 'github') == 'github' && matrix.status_repo != github.repository && steps.app-token.outcome != 'success' }} + run: echo "::warning::Harness startup failure could not be reported because no token authorized for the target repository was available" diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index 1fed7c02db..eda07eaf4c 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -252,4 +252,4 @@ jobs: - name: Warn when cross-repository failure cannot be reported if: ${{ always() && steps.run-agent.outcome == 'skipped' && (fromJSON(inputs.event_payload)._normalized_event.source.system || 'github') == 'github' && inputs.source_repo != github.repository && steps.app-token.outcome != 'success' }} - run: echo "::warning::Prioritize startup failure could not be reported because no token authorized for ${{ inputs.source_repo }} was available" + run: echo "::warning::Prioritize startup failure could not be reported because no token authorized for the target repository was available" diff --git a/docs/contributing/forge-abstraction.md b/docs/contributing/forge-abstraction.md index 308540e7a1..cd85fe1ae0 100644 --- a/docs/contributing/forge-abstraction.md +++ b/docs/contributing/forge-abstraction.md @@ -26,7 +26,7 @@ polls because an absent job may become visible later. **When reviewing PRs:** Flag any direct `exec.Command("gh", ...)`, raw GitHub API calls, or other forge-specific operations outside `internal/forge/github/` as a medium-severity or higher finding. This is an architectural violation, not a style preference. -**Composite action (`action.yml`):** The forge abstraction extends to `action.yml` bash scripts. New GitHub API operations in action steps should be implemented as `fullsend` CLI subcommands (under `internal/cli/`) that use `forge.Client`, not as inline `gh api` calls. Existing `gh api` calls in `action.yml` that predate this rule are grandfathered but should be migrated when touched. +**Composite action (`action.yml`):** The forge abstraction extends to `action.yml` bash scripts. New GitHub API operations in action steps should be implemented as `fullsend` CLI subcommands (under `internal/cli/`) that use `forge.Client`, not as inline `gh api` calls. Existing `gh api` calls in `action.yml` that predate this rule are grandfathered but should be migrated when touched. The startup-failure reporter is an explicit exception: it runs when installing the Fullsend CLI may itself have failed, so a CLI subcommand cannot be relied on to report that failure. It is limited to GitHub-originated events, validates its inputs, and uses the workflow token only for the target issue or pull request. ## Security considerations for destructive operations diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index 4ac7b3eaf7..dff07c5666 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -688,6 +688,12 @@ GitHub-originated events and does not replace tracker-routed notifications for Jira-originated events. Repeated failures update the existing startup-failure comment instead of creating duplicates. +The standalone prioritize workflow also supplies the status target and a +prioritize-scoped GitHub token when one can be minted. This enables the same +startup-failure reporting for cross-repository prioritize calls; if minting +fails and the target is a different repository, the workflow emits an explicit +warning because the caller's `GITHUB_TOKEN` cannot write to that repository. + Because this fallback runs specifically when the Fullsend CLI may not have been installed, it uses the workflow's GitHub comment API directly and does not read `status_notifications`. Therefore, a startup-failure comment can still be From 88b005b67d3c919cc583870e02244145b67034dc Mon Sep 17 00:00:00 2001 From: csoceanu Date: Mon, 9 Nov 2026 14:21:26 +0200 Subject: [PATCH 04/25] fix(actions): address startup failure review findings Co-authored-by: Codex Signed-off-by: csoceanu --- .../report-agent-startup-failure-test.sh | 62 +++++++++++++++++++ .../scripts/report-agent-startup-failure.sh | 14 ++++- .github/workflows/reusable-dispatch.yml | 16 ++--- .github/workflows/reusable-prioritize.yml | 6 +- action.yml | 60 ++++++++++-------- docs/guides/getting-started/operations.md | 9 +++ .../scaffold/workflow_call_alignment_test.go | 27 ++++++++ 7 files changed, 154 insertions(+), 40 deletions(-) create mode 100755 .github/scripts/report-agent-startup-failure-test.sh diff --git a/.github/scripts/report-agent-startup-failure-test.sh b/.github/scripts/report-agent-startup-failure-test.sh new file mode 100755 index 0000000000..f585668bf8 --- /dev/null +++ b/.github/scripts/report-agent-startup-failure-test.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# Tests the startup-failure reporter with REST-shaped bot identities. + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SCRIPT="${SCRIPT_DIR}/report-agent-startup-failure.sh" +TMPDIR="$(mktemp -d)" +trap 'rm -rf "${TMPDIR}"' EXIT + +MOCK_BIN="${TMPDIR}/bin" +mkdir -p "${MOCK_BIN}" +cat > "${MOCK_BIN}/gh" <<'MOCKEOF' +#!/usr/bin/env bash +set -euo pipefail + +MOCK_DIR="$(cd "$(dirname "$0")/.." && pwd)" +if [[ "$1" != "api" ]]; then + echo "unexpected gh call: $*" >&2 + exit 1 +fi + +if [[ "$*" == *"graphql"* ]]; then + printf '%s\n' "${MOCK_VIEWER_LOGIN}" +elif [[ "$*" == *"--method PATCH"* ]]; then + printf 'patch\n' >> "${MOCK_DIR}/calls" +elif [[ "$*" == *"--method POST"* ]]; then + printf 'post\n' >> "${MOCK_DIR}/calls" +else + printf '%s\n' "${MOCK_COMMENTS_JSON}" +fi +MOCKEOF +chmod +x "${MOCK_BIN}/gh" + +run_case() { + local name="$1" viewer="$2" comment_login="$3" + local marker='' + local body="${marker}\n\nold comment" + export MOCK_VIEWER_LOGIN="${viewer}" + export MOCK_COMMENTS_JSON="[[{\"id\":42,\"user\":{\"type\":\"Bot\",\"login\":\"${comment_login}\"},\"body\":\"${body}\"}]]" + : > "${TMPDIR}/calls" + + PATH="${MOCK_BIN}:${PATH}" \ + GH_TOKEN=test \ + RUNNER_TEMP="${TMPDIR}" \ + FULLSEND_FAILURE_REPOSITORY=org/repo \ + FULLSEND_FAILURE_NUMBER=123 \ + FULLSEND_FAILURE_AGENT=review \ + FULLSEND_FAILURE_RUN_URL=https://github.com/org/repo/actions/runs/123 \ + FULLSEND_FAILURE_CATEGORY="workflow setup" \ + bash "${SCRIPT}" >/dev/null + + if [[ "$(cat "${TMPDIR}/calls")" == "patch" ]]; then + printf 'PASS: %s\n' "${name}" + else + printf 'FAIL: %s — expected PATCH\n' "${name}" >&2 + return 1 + fi +} + +run_case "job token finds app-bot comment" "github-actions" "fullsend-ai-review[bot]" +run_case "app token finds job-bot comment" "fullsend-ai-review" "github-actions[bot]" diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh index d2bfd718fd..bfaa36a657 100755 --- a/.github/scripts/report-agent-startup-failure.sh +++ b/.github/scripts/report-agent-startup-failure.sh @@ -4,7 +4,10 @@ # because the fullsend CLI may be the dependency that failed to install. set -euo pipefail -: "${GH_TOKEN:?GH_TOKEN is required}" +if [[ -z "${GH_TOKEN:-}" ]]; then + echo "::warning::Skipping startup failure comment: GH_TOKEN is required" >&2 + exit 1 +fi FULLSEND_FAILURE_REPOSITORY="${FULLSEND_FAILURE_REPOSITORY:-}" FULLSEND_FAILURE_NUMBER="${FULLSEND_FAILURE_NUMBER:-}" FULLSEND_FAILURE_AGENT="${FULLSEND_FAILURE_AGENT:-}" @@ -56,10 +59,15 @@ case "${FULLSEND_FAILURE_AGENT}" in prioritize) TRUSTED_BOT_LOGINS+=",fullsend-ai-prioritize" ;; esac TRUSTED_BOTS_JSON="$(jq -Rn --arg current "${BOT_LOGIN}" --arg logins "${TRUSTED_BOT_LOGINS}" \ - '[ $current ] + ($logins | split(",") | map(select(length > 0))) | unique')" + '[ $current ] + ($logins | split(",") | map(select(length > 0))) + | map(sub("\\[bot\\]$"; "")) + | unique')" COMMENT_ID="$(printf '%s' "${COMMENTS_JSON}" | jq -r \ --arg marker "${MARKER}" --argjson trusted "${TRUSTED_BOTS_JSON}" \ - 'add | map(select((.user.type == "Bot") and ((.user.login) as $login | ($trusted | index($login)) != null) and (.body | contains($marker)))) | last | .id // empty')" + 'add | map(select((.user.type == "Bot") + and (((.user.login | sub("\\[bot\\]$"; "")) as $login + | ($trusted | index($login)) != null)) + and (.body | contains($marker)))) | last | .id // empty')" if [[ -n "${COMMENT_ID}" ]]; then gh api --method PATCH "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/comments/${COMMENT_ID}" \ diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index f88064433f..f8ec364025 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -1558,7 +1558,7 @@ jobs: pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report triage launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} + if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -1726,7 +1726,7 @@ jobs: pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report code launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} + if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -1935,7 +1935,7 @@ jobs: pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report review launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} + if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -2032,6 +2032,7 @@ jobs: git config --global user.name "${BOT_LOGIN}" - name: Block fork PRs + id: fork_guard env: GH_TOKEN: ${{ steps.app-token.outputs.token }} EVENT_PAYLOAD: ${{ needs.route.outputs.event_payload }} @@ -2131,6 +2132,7 @@ jobs: echo "iteration=${ITERATION}" >> "${GITHUB_OUTPUT}" - name: Check fix eligibility + id: eligibility env: GH_TOKEN: ${{ steps.app-token.outputs.token }} TRIGGER_SOURCE: ${{ needs.route.outputs.trigger_source }} @@ -2235,7 +2237,7 @@ jobs: pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report fix launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} + if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && steps.fork_guard.outcome != 'failure' && steps.eligibility.outcome != 'failure' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -2381,7 +2383,7 @@ jobs: pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report retro launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} + if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -2511,7 +2513,7 @@ jobs: mint-url: ${{ inputs.mint_url }} - name: Report prioritize launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} + if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} REPOSITORY: ${{ github.repository }} @@ -2936,7 +2938,7 @@ jobs: pr-head-sha: ${{ matrix.event_payload.pull_request.head.sha || '' }} artifact-name: ${{ steps.dispatch-env.outputs.artifact_name }} - name: Report harness launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && (fromJSON(matrix.event_payload)._normalized_event.source.system || 'github') == 'github' && (matrix.status_repo == github.repository || steps.app-token.outcome == 'success') }} + if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && (fromJSON(matrix.event_payload)._normalized_event.source.system || 'github') == 'github' && (matrix.status_repo == github.repository || steps.app-token.outcome == 'success') }} env: GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index eda07eaf4c..c2ffcdfe41 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -216,14 +216,14 @@ jobs: github_token: ${{ steps.app-token.outputs.token || github.token }} mint-url: ${{ inputs.mint_url }} run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - status-repo: ${{ inputs.source_repo }} - status-number: ${{ fromJSON(inputs.event_payload).issue.number || fromJSON(inputs.event_payload).pull_request.number }} + failure-repo: ${{ inputs.source_repo }} + failure-number: ${{ fromJSON(inputs.event_payload).issue.number || fromJSON(inputs.event_payload).pull_request.number }} source-system: ${{ fromJSON(inputs.event_payload)._normalized_event.source.system || 'github' }} gcp_wif_provider: ${{ secrets.FULLSEND_GCP_WIF_PROVIDER }} gcp_project_id: ${{ secrets.FULLSEND_GCP_PROJECT_ID }} - name: Report prioritize launch failure - if: ${{ failure() && steps.run-agent.outcome == 'skipped' && (fromJSON(inputs.event_payload)._normalized_event.source.system || 'github') == 'github' && (inputs.source_repo == github.repository || steps.app-token.outcome == 'success') }} + if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && (fromJSON(inputs.event_payload)._normalized_event.source.system || 'github') == 'github' && (inputs.source_repo == github.repository || steps.app-token.outcome == 'success') }} env: GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} REPOSITORY: ${{ inputs.source_repo }} diff --git a/action.yml b/action.yml index aa46609194..0959d4fec2 100644 --- a/action.yml +++ b/action.yml @@ -41,6 +41,12 @@ inputs: status-number: description: Issue/PR number for status comments (optional). default: "" + failure-repo: + description: Repository (owner/repo) for startup-failure comments (optional). + default: "" + failure-number: + description: Issue/PR number for startup-failure comments (optional). + default: "" source-system: description: >- Originating tracker for the event (github, gitlab, or jira). GitHub @@ -742,15 +748,18 @@ runs: path: ${{ steps.prepare-artifacts.outputs.dir }} - name: Report pre-agent startup failure - if: always() && inputs.agent != '__install_only__' && inputs.source-system == 'github' && inputs.status-repo != '' && inputs.status-number != '' + if: >- + failure() && !cancelled() && steps.run.outcome == 'skipped' && + inputs.agent != '__install_only__' && inputs.source-system == 'github' && + ((inputs.failure-repo != '' && inputs.failure-number != '') || + (inputs.status-repo != '' && inputs.status-number != '')) shell: bash env: GH_TOKEN: ${{ inputs.github_token }} AGENT: ${{ inputs.agent }} - STATUS_REPO: ${{ inputs.status-repo }} - STATUS_NUMBER: ${{ inputs.status-number }} + FAILURE_REPO: ${{ inputs.failure-repo || inputs.status-repo }} + FAILURE_NUMBER: ${{ inputs.failure-number || inputs.status-number }} RUN_URL: ${{ inputs.run-url }} - JOB_STATUS: ${{ job.status }} INSTALL_CLI_OUTCOME: ${{ steps.detect.outcome }} VENDORED_OUTCOME: ${{ steps.install-vendored.outcome }} DOWNLOAD_RELEASE_OUTCOME: ${{ steps.download-release.outcome }} @@ -760,37 +769,34 @@ runs: PODMAN_OUTCOME: ${{ steps.install-podman.outcome }} CONFIGURE_PODMAN_OUTCOME: ${{ steps.configure-podman.outcome }} OPENSHELL_OUTCOME: ${{ steps.install-openshell.outcome }} - RUN_OUTCOME: ${{ steps.run.outcome }} run: | set -euo pipefail - if [[ "${JOB_STATUS}" == "failure" && "${RUN_OUTCOME}" == "skipped" ]]; then - FAILURE_CATEGORY="workflow setup" - if [[ "${PODMAN_OUTCOME}" == "failure" \ + FAILURE_CATEGORY="workflow setup" + if [[ "${PODMAN_OUTCOME}" == "failure" \ || "${CONFIGURE_PODMAN_OUTCOME}" == "failure" \ || "${OPENSHELL_OUTCOME}" == "failure" ]]; then - FAILURE_CATEGORY="runtime setup" - elif [[ "${INSTALL_CLI_OUTCOME}" == "failure" \ + FAILURE_CATEGORY="runtime setup" + elif [[ "${INSTALL_CLI_OUTCOME}" == "failure" \ || "${VENDORED_OUTCOME}" == "failure" \ - || "${DOWNLOAD_RELEASE_OUTCOME}" == "failure" \ + || ("${DOWNLOAD_RELEASE_OUTCOME}" == "failure" && "${BUILD_SOURCE_OUTCOME}" != "success") \ || "${CLONE_SOURCE_OUTCOME}" == "failure" \ || "${BUILD_SOURCE_OUTCOME}" == "failure" \ || "${PRINT_VERSION_OUTCOME}" == "failure" ]]; then - FAILURE_CATEGORY="CLI setup" - fi - - FULLSEND_FAILURE_REPOSITORY="${STATUS_REPO}" - FULLSEND_FAILURE_NUMBER="${STATUS_NUMBER}" - FULLSEND_FAILURE_AGENT="${AGENT}" - FULLSEND_FAILURE_RUN_URL="${RUN_URL:-${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}}" - FULLSEND_FAILURE_CATEGORY="${FAILURE_CATEGORY}" - export FULLSEND_FAILURE_REPOSITORY FULLSEND_FAILURE_NUMBER \ - FULLSEND_FAILURE_AGENT FULLSEND_FAILURE_RUN_URL \ - FULLSEND_FAILURE_CATEGORY - if "$GITHUB_ACTION_PATH/.github/scripts/report-agent-startup-failure.sh"; then - echo "FULLSEND_STARTUP_FAILURE_REPORTED=true" >> "${GITHUB_ENV}" - else - echo "::warning::Could not post pre-agent failure comment" - fi + FAILURE_CATEGORY="CLI setup" + fi + + FULLSEND_FAILURE_REPOSITORY="${FAILURE_REPO}" + FULLSEND_FAILURE_NUMBER="${FAILURE_NUMBER}" + FULLSEND_FAILURE_AGENT="${AGENT}" + FULLSEND_FAILURE_RUN_URL="${RUN_URL:-${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}}" + FULLSEND_FAILURE_CATEGORY="${FAILURE_CATEGORY}" + export FULLSEND_FAILURE_REPOSITORY FULLSEND_FAILURE_NUMBER \ + FULLSEND_FAILURE_AGENT FULLSEND_FAILURE_RUN_URL \ + FULLSEND_FAILURE_CATEGORY + if "$GITHUB_ACTION_PATH/.github/scripts/report-agent-startup-failure.sh"; then + echo "FULLSEND_STARTUP_FAILURE_REPORTED=true" >> "${GITHUB_ENV}" + else + echo "::warning::Could not post pre-agent failure comment" fi - name: Finalize orphaned status comment diff --git a/docs/guides/getting-started/operations.md b/docs/guides/getting-started/operations.md index cda7b83539..2d2a8227a6 100644 --- a/docs/guides/getting-started/operations.md +++ b/docs/guides/getting-started/operations.md @@ -313,6 +313,12 @@ gcloud services enable \ See [`status_notifications`](../../reference/config-reference.md#status_notifications) for configuring start/completion comments and reactions. +If an agent cannot start because workflow setup fails, the GitHub fallback posts or +updates a separate startup-failure comment with the failure category and workflow +run link. This fallback is independent of `status_notifications`; after it posts +successfully, orphaned status reconciliation is skipped to avoid a duplicate +notification. + The composite action accepts optional inputs for status notifications and review reconciliation: @@ -321,6 +327,9 @@ review reconciliation: | `run-url` | URL of the CI/CD run shown in the status comment | | `status-repo` | Repository (`owner/repo`) to post status comments on | | `status-number` | Issue or PR number for status comments | +| `failure-repo` | Repository (`owner/repo`) for startup-failure comments; falls back to `status-repo` when unset | +| `failure-number` | Issue or PR number for startup-failure comments; falls back to `status-number` when unset | +| `source-system` | Originating tracker (`github`, `gitlab`, or `jira`); startup-failure comments are GitHub-only (default: `github`) | | `status-comment-id` | ID of the comment that triggered a slash-command run; when set, reactions target that comment instead of the issue/PR | | `mint-url` | URL of the token mint service used to obtain fresh tokens for posting comments | | `role` | Mint role selected by dispatch, used to reconcile an interrupted run before the agent reports its resolved role (default: empty) | diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index a5c92288b7..4f1f56e1a9 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -45,6 +45,33 @@ func TestReviewWorkflowKeepsThreadFetchAgentOwned(t *testing.T) { assert.NotContains(t, section, "HUMAN_RESOLVED_FETCH_SCRIPT:") } +// TestStartupFailureReportingGuards verifies the workflow conditions that keep +// policy skips and cancellations from being reported as setup failures. +func TestStartupFailureReportingGuards(t *testing.T) { + dispatch, err := os.ReadFile(filepath.Join("..", "..", ".github", "workflows", "reusable-dispatch.yml")) + require.NoError(t, err) + dispatchText := string(dispatch) + + for _, agent := range []string{"triage", "code", "review", "fix", "retro", "prioritize", "harness"} { + assert.Contains(t, dispatchText, "Report "+agent+" launch failure") + } + for _, line := range strings.Split(dispatchText, "\n") { + if strings.Contains(line, "if: ${{ failure()") && strings.Contains(line, "steps.run-agent.outcome") { + assert.Contains(t, line, "!cancelled()", "startup failure reporters must not run after cancellation") + } + } + assert.Contains(t, dispatchText, "id: fork_guard") + assert.Contains(t, dispatchText, "id: eligibility") + assert.Contains(t, dispatchText, "steps.fork_guard.outcome != 'failure'") + assert.Contains(t, dispatchText, "steps.eligibility.outcome != 'failure'") + + prioritize, err := os.ReadFile(filepath.Join("..", "..", ".github", "workflows", "reusable-prioritize.yml")) + require.NoError(t, err) + prioritizeText := string(prioritize) + assert.Contains(t, prioritizeText, "failure-repo: ${{ inputs.source_repo }}") + assert.NotContains(t, prioritizeText, "status-repo: ${{ inputs.source_repo }}") +} + type workflowInput struct { Required bool `yaml:"required"` Type string `yaml:"type"` From 7ae5fb0c8936850b52e7e8874b14c57805c57cc5 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Mon, 9 Nov 2026 14:40:47 +0200 Subject: [PATCH 05/25] fix(actions): report additional startup failure cases Co-authored-by: Codex Signed-off-by: csoceanu --- .github/scripts/report-agent-startup-failure.sh | 2 +- .github/workflows/reusable-dispatch.yml | 16 +++++++++++++++- .github/workflows/reusable-prioritize.yml | 6 +++++- Makefile | 1 + action.yml | 4 ++++ docs/guides/getting-started/operations.md | 1 + 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh index bfaa36a657..6d75799290 100755 --- a/.github/scripts/report-agent-startup-failure.sh +++ b/.github/scripts/report-agent-startup-failure.sh @@ -43,7 +43,7 @@ BODY_FILE="${RUNNER_TEMP:-/tmp}/fullsend-agent-startup-failure.md" { printf '%s\n\n' "${MARKER}" printf '⚠️ **Fullsend %s agent did not run**\n\n' "${FULLSEND_FAILURE_AGENT}" - printf 'The agent could not start because of a **%s** failure during workflow setup.\n\n' "${FULLSEND_FAILURE_CATEGORY}" + printf 'The agent could not start because of a **%s** failure.\n\n' "${FULLSEND_FAILURE_CATEGORY}" printf '[View the workflow run](%s)\n\n' "${FULLSEND_FAILURE_RUN_URL}" } > "${BODY_FILE}" diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index f8ec364025..3af1c6f6ae 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -1554,6 +1554,7 @@ jobs: status-number: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} + failure-trusted-bots: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} @@ -1562,6 +1563,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} + FULLSEND_FAILURE_TRUSTED_BOTS: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} REPOSITORY: ${{ github.repository }} NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} @@ -1722,6 +1724,7 @@ jobs: status-number: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} + failure-trusted-bots: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} @@ -1730,6 +1733,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} + FULLSEND_FAILURE_TRUSTED_BOTS: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} REPOSITORY: ${{ github.repository }} NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} @@ -1931,6 +1935,7 @@ jobs: status-number: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} + failure-trusted-bots: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} @@ -1939,6 +1944,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} + FULLSEND_FAILURE_TRUSTED_BOTS: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} REPOSITORY: ${{ github.repository }} NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} @@ -2233,14 +2239,16 @@ jobs: status-number: ${{ steps.context.outputs.pr_number }} source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} + failure-trusted-bots: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report fix launch failure - if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && steps.fork_guard.outcome != 'failure' && steps.eligibility.outcome != 'failure' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} + if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && steps.fork_guard.outcome != 'failure' && steps.eligibility.outcome != 'failure' && steps.review-body.outcome != 'failure' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} + FULLSEND_FAILURE_TRUSTED_BOTS: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} REPOSITORY: ${{ github.repository }} NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} @@ -2379,6 +2387,7 @@ jobs: status-number: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(needs.route.outputs.event_payload).comment.id }} + failure-trusted-bots: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} @@ -2387,6 +2396,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} + FULLSEND_FAILURE_TRUSTED_BOTS: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} REPOSITORY: ${{ github.repository }} NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.number || fromJSON(needs.route.outputs.event_payload).issue.number }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} @@ -2510,12 +2520,14 @@ jobs: status-repo: ${{ github.repository }} status-number: ${{ fromJSON(needs.route.outputs.event_payload).issue.number }} source-system: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github' }} + failure-trusted-bots: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} mint-url: ${{ inputs.mint_url }} - name: Report prioritize launch failure if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} + FULLSEND_FAILURE_TRUSTED_BOTS: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} REPOSITORY: ${{ github.repository }} NUMBER: ${{ fromJSON(needs.route.outputs.event_payload).issue.number || fromJSON(needs.route.outputs.event_payload).pull_request.number }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} @@ -2934,6 +2946,7 @@ jobs: status-comment-id: ${{ matrix.event_payload.comment.id }} source-system: ${{ fromJSON(matrix.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(matrix.event_payload).comment.id }} + failure-trusted-bots: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ matrix.event_payload.pull_request.head.sha || '' }} artifact-name: ${{ steps.dispatch-env.outputs.artifact_name }} @@ -2942,6 +2955,7 @@ jobs: env: GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} + FULLSEND_FAILURE_TRUSTED_BOTS: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} REPOSITORY: ${{ matrix.status_repo }} NUMBER: ${{ matrix.status_number }} AGENT: ${{ matrix.agent }} diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index c2ffcdfe41..1f9b13fd7e 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -219,6 +219,7 @@ jobs: failure-repo: ${{ inputs.source_repo }} failure-number: ${{ fromJSON(inputs.event_payload).issue.number || fromJSON(inputs.event_payload).pull_request.number }} source-system: ${{ fromJSON(inputs.event_payload)._normalized_event.source.system || 'github' }} + failure-trusted-bots: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} gcp_wif_provider: ${{ secrets.FULLSEND_GCP_WIF_PROVIDER }} gcp_project_id: ${{ secrets.FULLSEND_GCP_PROJECT_ID }} @@ -226,6 +227,8 @@ jobs: if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && (fromJSON(inputs.event_payload)._normalized_event.source.system || 'github') == 'github' && (inputs.source_repo == github.repository || steps.app-token.outcome == 'success') }} env: GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} + MINT_OUTCOME: ${{ steps.app-token.outcome }} + FULLSEND_FAILURE_TRUSTED_BOTS: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} REPOSITORY: ${{ inputs.source_repo }} NUMBER: ${{ fromJSON(inputs.event_payload).issue.number || fromJSON(inputs.event_payload).pull_request.number }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} @@ -247,7 +250,8 @@ jobs: export FULLSEND_FAILURE_NUMBER="${NUMBER}" export FULLSEND_FAILURE_AGENT="prioritize" export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" - export FULLSEND_FAILURE_CATEGORY="workflow setup" + FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" + export FULLSEND_FAILURE_CATEGORY bash "${script}" - name: Warn when cross-repository failure cannot be reported diff --git a/Makefile b/Makefile index a53613904b..e4e9e0f2e1 100644 --- a/Makefile +++ b/Makefile @@ -197,6 +197,7 @@ script-test: $(call run-timed,bash .github/scripts/count-fix-commits-test.sh) $(call run-timed,bash .github/scripts/pre-fetch-review-body-test.sh) $(call run-timed,bash .github/scripts/review-diff-hash-test.sh) + $(call run-timed,bash .github/scripts/report-agent-startup-failure-test.sh) $(call run-timed,bash .github/scripts/retry-with-backoff-test.sh) $(call run-timed,bash scripts/check-agents-gate-pin-test.sh) $(call run-timed,bash scripts/semgrep-scan-test.sh) diff --git a/action.yml b/action.yml index 0959d4fec2..bd7cb43be5 100644 --- a/action.yml +++ b/action.yml @@ -47,6 +47,9 @@ inputs: failure-number: description: Issue/PR number for startup-failure comments (optional). default: "" + failure-trusted-bots: + description: Comma-separated custom bot login prefixes trusted for startup-failure comments (optional). + default: "" source-system: description: >- Originating tracker for the event (github, gitlab, or jira). GitHub @@ -759,6 +762,7 @@ runs: AGENT: ${{ inputs.agent }} FAILURE_REPO: ${{ inputs.failure-repo || inputs.status-repo }} FAILURE_NUMBER: ${{ inputs.failure-number || inputs.status-number }} + FULLSEND_FAILURE_TRUSTED_BOTS: ${{ inputs.failure-trusted-bots }} RUN_URL: ${{ inputs.run-url }} INSTALL_CLI_OUTCOME: ${{ steps.detect.outcome }} VENDORED_OUTCOME: ${{ steps.install-vendored.outcome }} diff --git a/docs/guides/getting-started/operations.md b/docs/guides/getting-started/operations.md index 2d2a8227a6..ce4fc5cb94 100644 --- a/docs/guides/getting-started/operations.md +++ b/docs/guides/getting-started/operations.md @@ -329,6 +329,7 @@ review reconciliation: | `status-number` | Issue or PR number for status comments | | `failure-repo` | Repository (`owner/repo`) for startup-failure comments; falls back to `status-repo` when unset | | `failure-number` | Issue or PR number for startup-failure comments; falls back to `status-number` when unset | +| `failure-trusted-bots` | Comma-separated custom bot login prefixes trusted for startup-failure comment deduplication (optional) | | `source-system` | Originating tracker (`github`, `gitlab`, or `jira`); startup-failure comments are GitHub-only (default: `github`) | | `status-comment-id` | ID of the comment that triggered a slash-command run; when set, reactions target that comment instead of the issue/PR | | `mint-url` | URL of the token mint service used to obtain fresh tokens for posting comments | From d4062e083a2f8628028263b1679cc4c0c601d6af Mon Sep 17 00:00:00 2001 From: csoceanu Date: Mon, 9 Nov 2026 14:57:59 +0200 Subject: [PATCH 06/25] fix(actions): isolate startup failure reporting token Co-authored-by: Codex Signed-off-by: csoceanu --- .github/scripts/report-agent-startup-failure-test.sh | 5 ++++- .github/scripts/report-agent-startup-failure.sh | 5 +++-- .github/workflows/reusable-dispatch.yml | 3 ++- .github/workflows/reusable-prioritize.yml | 3 ++- action.yml | 8 +++++++- docs/contributing/forge-abstraction.md | 2 +- docs/guides/getting-started/operations.md | 1 + docs/reference/config-reference.md | 11 +++++++---- internal/scaffold/workflow_call_alignment_test.go | 10 ++++++++-- 9 files changed, 35 insertions(+), 13 deletions(-) diff --git a/.github/scripts/report-agent-startup-failure-test.sh b/.github/scripts/report-agent-startup-failure-test.sh index f585668bf8..f7da64867b 100755 --- a/.github/scripts/report-agent-startup-failure-test.sh +++ b/.github/scripts/report-agent-startup-failure-test.sh @@ -33,7 +33,7 @@ MOCKEOF chmod +x "${MOCK_BIN}/gh" run_case() { - local name="$1" viewer="$2" comment_login="$3" + local name="$1" viewer="$2" comment_login="$3" trusted_bots="${4:-}" local marker='' local body="${marker}\n\nold comment" export MOCK_VIEWER_LOGIN="${viewer}" @@ -46,6 +46,7 @@ run_case() { FULLSEND_FAILURE_REPOSITORY=org/repo \ FULLSEND_FAILURE_NUMBER=123 \ FULLSEND_FAILURE_AGENT=review \ + FULLSEND_FAILURE_TRUSTED_BOTS="${trusted_bots}" \ FULLSEND_FAILURE_RUN_URL=https://github.com/org/repo/actions/runs/123 \ FULLSEND_FAILURE_CATEGORY="workflow setup" \ bash "${SCRIPT}" >/dev/null @@ -60,3 +61,5 @@ run_case() { run_case "job token finds app-bot comment" "github-actions" "fullsend-ai-review[bot]" run_case "app token finds job-bot comment" "fullsend-ai-review" "github-actions[bot]" +run_case "custom app set finds job-bot comment" "acme-review" "github-actions[bot]" "acme" +run_case "job token finds custom app-set comment" "github-actions" "acme-review[bot]" "acme" diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh index 6d75799290..fb4febe112 100755 --- a/.github/scripts/report-agent-startup-failure.sh +++ b/.github/scripts/report-agent-startup-failure.sh @@ -50,7 +50,7 @@ BODY_FILE="${RUNNER_TEMP:-/tmp}/fullsend-agent-startup-failure.md" BOT_LOGIN="$(gh api graphql -f query='{ viewer { login } }' --jq '.data.viewer.login')" COMMENTS_JSON="$(gh api --paginate --slurp \ "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/${FULLSEND_FAILURE_NUMBER}/comments")" -TRUSTED_BOT_LOGINS="${FULLSEND_FAILURE_TRUSTED_BOTS:-github-actions}" +TRUSTED_BOT_LOGINS="github-actions${FULLSEND_FAILURE_TRUSTED_BOTS:+,${FULLSEND_FAILURE_TRUSTED_BOTS}}" case "${FULLSEND_FAILURE_AGENT}" in code|fix) TRUSTED_BOT_LOGINS+=",fullsend-ai-coder" ;; review) TRUSTED_BOT_LOGINS+=",fullsend-ai-review" ;; @@ -66,7 +66,8 @@ COMMENT_ID="$(printf '%s' "${COMMENTS_JSON}" | jq -r \ --arg marker "${MARKER}" --argjson trusted "${TRUSTED_BOTS_JSON}" \ 'add | map(select((.user.type == "Bot") and (((.user.login | sub("\\[bot\\]$"; "")) as $login - | ($trusted | index($login)) != null)) + | any($trusted[]; . as $prefix + | ($login == $prefix or ($login | startswith($prefix + "-")))))) and (.body | contains($marker)))) | last | .id // empty')" if [[ -n "${COMMENT_ID}" ]]; then diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 3af1c6f6ae..8ad1426803 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -2939,7 +2939,8 @@ jobs: runner_secrets: ${{ secrets.FULLSEND_GITHUB_RUNNER_SECRETS }} version: ${{ inputs.fullsend_version || job.workflow_sha }} fullsend-dir: .fullsend - github_token: ${{ steps.app-token.outputs.token || github.token }} + github_token: ${{ github.token }} + failure-token: ${{ steps.app-token.outputs.token || github.token }} run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ matrix.status_repo }} status-number: ${{ matrix.status_number }} diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index 1f9b13fd7e..57277daac6 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -213,7 +213,8 @@ jobs: runner_secrets: ${{ secrets.FULLSEND_GITHUB_RUNNER_SECRETS }} version: ${{ inputs.fullsend_version || job.workflow_sha }} fullsend-dir: .fullsend - github_token: ${{ steps.app-token.outputs.token || github.token }} + github_token: ${{ github.token }} + failure-token: ${{ steps.app-token.outputs.token || github.token }} mint-url: ${{ inputs.mint_url }} run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} failure-repo: ${{ inputs.source_repo }} diff --git a/action.yml b/action.yml index bd7cb43be5..878e68cc1b 100644 --- a/action.yml +++ b/action.yml @@ -50,6 +50,12 @@ inputs: failure-trusted-bots: description: Comma-separated custom bot login prefixes trusted for startup-failure comments (optional). default: "" + failure-token: + description: >- + Optional token used only for startup-failure reporting. Keep github_token + as the workflow token so installation, cloning, provider credentials, and + fullsend run do not receive a reporting-only App token. + default: "" source-system: description: >- Originating tracker for the event (github, gitlab, or jira). GitHub @@ -758,7 +764,7 @@ runs: (inputs.status-repo != '' && inputs.status-number != '')) shell: bash env: - GH_TOKEN: ${{ inputs.github_token }} + GH_TOKEN: ${{ inputs.failure-token || inputs.github_token }} AGENT: ${{ inputs.agent }} FAILURE_REPO: ${{ inputs.failure-repo || inputs.status-repo }} FAILURE_NUMBER: ${{ inputs.failure-number || inputs.status-number }} diff --git a/docs/contributing/forge-abstraction.md b/docs/contributing/forge-abstraction.md index cd85fe1ae0..2598a6e992 100644 --- a/docs/contributing/forge-abstraction.md +++ b/docs/contributing/forge-abstraction.md @@ -26,7 +26,7 @@ polls because an absent job may become visible later. **When reviewing PRs:** Flag any direct `exec.Command("gh", ...)`, raw GitHub API calls, or other forge-specific operations outside `internal/forge/github/` as a medium-severity or higher finding. This is an architectural violation, not a style preference. -**Composite action (`action.yml`):** The forge abstraction extends to `action.yml` bash scripts. New GitHub API operations in action steps should be implemented as `fullsend` CLI subcommands (under `internal/cli/`) that use `forge.Client`, not as inline `gh api` calls. Existing `gh api` calls in `action.yml` that predate this rule are grandfathered but should be migrated when touched. The startup-failure reporter is an explicit exception: it runs when installing the Fullsend CLI may itself have failed, so a CLI subcommand cannot be relied on to report that failure. It is limited to GitHub-originated events, validates its inputs, and uses the workflow token only for the target issue or pull request. +**Composite action (`action.yml`):** The forge abstraction extends to `action.yml` bash scripts. New GitHub API operations in action steps should be implemented as `fullsend` CLI subcommands (under `internal/cli/`) that use `forge.Client`, not as inline `gh api` calls. Existing `gh api` calls in `action.yml` that predate this rule are grandfathered but should be migrated when touched. The startup-failure reporter is an explicit exception: it runs when installing the Fullsend CLI may itself have failed, so a CLI subcommand cannot be relied on to report that failure. It is limited to GitHub-originated events, validates its inputs, and uses the workflow token—or a separately supplied role token for an authorized cross-repository target—only for the target issue or pull request. The role token is passed through the dedicated reporting input and is not used for installation, cloning, provider credentials, or `fullsend run`. ## Security considerations for destructive operations diff --git a/docs/guides/getting-started/operations.md b/docs/guides/getting-started/operations.md index ce4fc5cb94..a42d0c44c7 100644 --- a/docs/guides/getting-started/operations.md +++ b/docs/guides/getting-started/operations.md @@ -330,6 +330,7 @@ review reconciliation: | `failure-repo` | Repository (`owner/repo`) for startup-failure comments; falls back to `status-repo` when unset | | `failure-number` | Issue or PR number for startup-failure comments; falls back to `status-number` when unset | | `failure-trusted-bots` | Comma-separated custom bot login prefixes trusted for startup-failure comment deduplication (optional) | +| `failure-token` | Optional token used only for startup-failure reporting; the normal `github_token` remains the workflow token | | `source-system` | Originating tracker (`github`, `gitlab`, or `jira`); startup-failure comments are GitHub-only (default: `github`) | | `status-comment-id` | ID of the comment that triggered a slash-command run; when set, reactions target that comment instead of the issue/PR | | `mint-url` | URL of the token mint service used to obtain fresh tokens for posting comments | diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index dff07c5666..070fe5bfb3 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -689,10 +689,13 @@ Jira-originated events. Repeated failures update the existing startup-failure comment instead of creating duplicates. The standalone prioritize workflow also supplies the status target and a -prioritize-scoped GitHub token when one can be minted. This enables the same -startup-failure reporting for cross-repository prioritize calls; if minting -fails and the target is a different repository, the workflow emits an explicit -warning because the caller's `GITHUB_TOKEN` cannot write to that repository. +prioritize-scoped GitHub token only to the startup-failure reporter when one +can be minted. The normal `github_token` input remains the workflow token for +installation, cloning, provider credentials, and `fullsend run`. This enables +the same startup-failure reporting for cross-repository prioritize calls; if +minting fails and the target is a different repository, the workflow emits an +explicit warning because the caller's `GITHUB_TOKEN` cannot write to that +repository. Because this fallback runs specifically when the Fullsend CLI may not have been installed, it uses the workflow's GitHub comment API directly and does not read diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index 4f1f56e1a9..2372a5fa7d 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -1947,15 +1947,21 @@ func TestReusableDispatchStatusCommentPassthrough(t *testing.T) { "harness-run agent step must pass status-number to action.yml") assert.Contains(t, section, "source-system:", "harness-run agent step must pass source-system to action.yml") + assert.Contains(t, section, "github_token: ${{ github.token }}", + "harness-run must keep the workflow token as github_token") + assert.Contains(t, section, "failure-token: ${{ steps.app-token.outputs.token || github.token }}", + "harness-run must pass the minted token only to failure reporting") }) t.Run("standalone prioritize", func(t *testing.T) { content, err := os.ReadFile(filepath.Join("..", "..", ".github", "workflows", "reusable-prioritize.yml")) require.NoError(t, err) section := extractStepSection(t, string(content), "Run prioritize agent") - assert.Contains(t, section, "status-repo:") - assert.Contains(t, section, "status-number:") + assert.Contains(t, section, "failure-repo:") + assert.Contains(t, section, "failure-number:") assert.Contains(t, section, "source-system:") + assert.Contains(t, section, "github_token: ${{ github.token }}") + assert.Contains(t, section, "failure-token: ${{ steps.app-token.outputs.token || github.token }}") }) } From 52f0de95825af5db6426234825a69f00340a209a Mon Sep 17 00:00:00 2001 From: csoceanu Date: Mon, 9 Nov 2026 16:43:26 +0200 Subject: [PATCH 07/25] fix(actions): tighten startup failure bot matching Co-authored-by: Codex Signed-off-by: csoceanu --- .../report-agent-startup-failure-test.sh | 13 +++++++--- .../scripts/report-agent-startup-failure.sh | 24 +++++++++++++------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.github/scripts/report-agent-startup-failure-test.sh b/.github/scripts/report-agent-startup-failure-test.sh index f7da64867b..5e7e56b7ae 100755 --- a/.github/scripts/report-agent-startup-failure-test.sh +++ b/.github/scripts/report-agent-startup-failure-test.sh @@ -33,9 +33,12 @@ MOCKEOF chmod +x "${MOCK_BIN}/gh" run_case() { - local name="$1" viewer="$2" comment_login="$3" trusted_bots="${4:-}" + local name="$1" viewer="$2" comment_login="$3" trusted_bots="${4:-}" body_prefix="${5:-marker}" expected="${6:-patch}" local marker='' local body="${marker}\n\nold comment" + if [[ "${body_prefix}" == "embedded" ]]; then + body="old comment\n\n${marker}" + fi export MOCK_VIEWER_LOGIN="${viewer}" export MOCK_COMMENTS_JSON="[[{\"id\":42,\"user\":{\"type\":\"Bot\",\"login\":\"${comment_login}\"},\"body\":\"${body}\"}]]" : > "${TMPDIR}/calls" @@ -51,10 +54,12 @@ run_case() { FULLSEND_FAILURE_CATEGORY="workflow setup" \ bash "${SCRIPT}" >/dev/null - if [[ "$(cat "${TMPDIR}/calls")" == "patch" ]]; then + local actual + actual="$(cat "${TMPDIR}/calls")" + if [[ "${actual}" == "${expected}" ]]; then printf 'PASS: %s\n' "${name}" else - printf 'FAIL: %s — expected PATCH\n' "${name}" >&2 + printf 'FAIL: %s — expected %s, got %s\n' "${name}" "${expected:-no call}" "${actual:-no call}" >&2 return 1 fi } @@ -63,3 +68,5 @@ run_case "job token finds app-bot comment" "github-actions" "fullsend-ai-review[ run_case "app token finds job-bot comment" "fullsend-ai-review" "github-actions[bot]" run_case "custom app set finds job-bot comment" "acme-review" "github-actions[bot]" "acme" run_case "job token finds custom app-set comment" "github-actions" "acme-review[bot]" "acme" +run_case "lookalike app is not trusted" "github-actions" "acme-reviewer[bot]" "acme" "marker" "post" +run_case "marker must start the comment" "github-actions" "fullsend-ai-review[bot]" "" "embedded" "post" diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh index fb4febe112..f78c6cb19e 100755 --- a/.github/scripts/report-agent-startup-failure.sh +++ b/.github/scripts/report-agent-startup-failure.sh @@ -50,7 +50,7 @@ BODY_FILE="${RUNNER_TEMP:-/tmp}/fullsend-agent-startup-failure.md" BOT_LOGIN="$(gh api graphql -f query='{ viewer { login } }' --jq '.data.viewer.login')" COMMENTS_JSON="$(gh api --paginate --slurp \ "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/${FULLSEND_FAILURE_NUMBER}/comments")" -TRUSTED_BOT_LOGINS="github-actions${FULLSEND_FAILURE_TRUSTED_BOTS:+,${FULLSEND_FAILURE_TRUSTED_BOTS}}" +TRUSTED_BOT_LOGINS="github-actions" case "${FULLSEND_FAILURE_AGENT}" in code|fix) TRUSTED_BOT_LOGINS+=",fullsend-ai-coder" ;; review) TRUSTED_BOT_LOGINS+=",fullsend-ai-review" ;; @@ -58,17 +58,27 @@ case "${FULLSEND_FAILURE_AGENT}" in retro) TRUSTED_BOT_LOGINS+=",fullsend-ai-retro" ;; prioritize) TRUSTED_BOT_LOGINS+=",fullsend-ai-prioritize" ;; esac -TRUSTED_BOTS_JSON="$(jq -Rn --arg current "${BOT_LOGIN}" --arg logins "${TRUSTED_BOT_LOGINS}" \ - '[ $current ] + ($logins | split(",") | map(select(length > 0))) +# FULLSEND_FAILURE_TRUSTED_BOTS contains app-set prefixes (for example, +# "fullsend-ai" or "acme"), not arbitrary login prefixes. Expand each set to +# the known agent identities so a lookalike app cannot update this comment. +TRUSTED_BOTS_JSON="$(jq -Rn \ + --arg current "${BOT_LOGIN}" \ + --arg logins "${TRUSTED_BOT_LOGINS}" \ + --arg app_sets "${FULLSEND_FAILURE_TRUSTED_BOTS:-}" \ + '[ $current ] + + ($logins | split(",") | map(select(length > 0))) + + ($app_sets | split(",") | map(select(length > 0) + | . as $set + | ["coder", "review", "triage", "retro", "prioritize"] + | map($set + "-" + .)) | add) | map(sub("\\[bot\\]$"; "")) | unique')" COMMENT_ID="$(printf '%s' "${COMMENTS_JSON}" | jq -r \ --arg marker "${MARKER}" --argjson trusted "${TRUSTED_BOTS_JSON}" \ 'add | map(select((.user.type == "Bot") - and (((.user.login | sub("\\[bot\\]$"; "")) as $login - | any($trusted[]; . as $prefix - | ($login == $prefix or ($login | startswith($prefix + "-")))))) - and (.body | contains($marker)))) | last | .id // empty')" + and ((.user.login | sub("\\[bot\\]$"; "")) as $login + | (($trusted | index($login)) != null)) + and (.body | startswith($marker)))) | last | .id // empty')" if [[ -n "${COMMENT_ID}" ]]; then gh api --method PATCH "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/comments/${COMMENT_ID}" \ From 597d33e28ba8e23c6a394f4318a097a714ad79c9 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Mon, 9 Nov 2026 17:03:36 +0200 Subject: [PATCH 08/25] fix(actions): derive trusted bot role dynamically Co-authored-by: Codex Signed-off-by: csoceanu --- .../report-agent-startup-failure-test.sh | 8 +++++--- .../scripts/report-agent-startup-failure.sh | 18 ++++++++---------- .github/workflows/reusable-dispatch.yml | 2 ++ action.yml | 6 ++++-- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/scripts/report-agent-startup-failure-test.sh b/.github/scripts/report-agent-startup-failure-test.sh index 5e7e56b7ae..e163f83e18 100755 --- a/.github/scripts/report-agent-startup-failure-test.sh +++ b/.github/scripts/report-agent-startup-failure-test.sh @@ -33,7 +33,7 @@ MOCKEOF chmod +x "${MOCK_BIN}/gh" run_case() { - local name="$1" viewer="$2" comment_login="$3" trusted_bots="${4:-}" body_prefix="${5:-marker}" expected="${6:-patch}" + local name="$1" viewer="$2" comment_login="$3" trusted_bots="${4:-}" role="${5:-review}" body_prefix="${6:-marker}" expected="${7:-patch}" local marker='' local body="${marker}\n\nold comment" if [[ "${body_prefix}" == "embedded" ]]; then @@ -49,6 +49,7 @@ run_case() { FULLSEND_FAILURE_REPOSITORY=org/repo \ FULLSEND_FAILURE_NUMBER=123 \ FULLSEND_FAILURE_AGENT=review \ + FULLSEND_FAILURE_ROLE="${role}" \ FULLSEND_FAILURE_TRUSTED_BOTS="${trusted_bots}" \ FULLSEND_FAILURE_RUN_URL=https://github.com/org/repo/actions/runs/123 \ FULLSEND_FAILURE_CATEGORY="workflow setup" \ @@ -68,5 +69,6 @@ run_case "job token finds app-bot comment" "github-actions" "fullsend-ai-review[ run_case "app token finds job-bot comment" "fullsend-ai-review" "github-actions[bot]" run_case "custom app set finds job-bot comment" "acme-review" "github-actions[bot]" "acme" run_case "job token finds custom app-set comment" "github-actions" "acme-review[bot]" "acme" -run_case "lookalike app is not trusted" "github-actions" "acme-reviewer[bot]" "acme" "marker" "post" -run_case "marker must start the comment" "github-actions" "fullsend-ai-review[bot]" "" "embedded" "post" +run_case "non-listed role is trusted" "github-actions" "acme-scribe[bot]" "acme" "scribe" +run_case "lookalike app is not trusted" "github-actions" "acme-reviewer[bot]" "acme" "review" "marker" "post" +run_case "marker must start the comment" "github-actions" "fullsend-ai-review[bot]" "" "review" "embedded" "post" diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh index f78c6cb19e..6f9e422bc4 100755 --- a/.github/scripts/report-agent-startup-failure.sh +++ b/.github/scripts/report-agent-startup-failure.sh @@ -11,6 +11,7 @@ fi FULLSEND_FAILURE_REPOSITORY="${FULLSEND_FAILURE_REPOSITORY:-}" FULLSEND_FAILURE_NUMBER="${FULLSEND_FAILURE_NUMBER:-}" FULLSEND_FAILURE_AGENT="${FULLSEND_FAILURE_AGENT:-}" +FULLSEND_FAILURE_ROLE="${FULLSEND_FAILURE_ROLE:-${FULLSEND_FAILURE_AGENT}}" FULLSEND_FAILURE_RUN_URL="${FULLSEND_FAILURE_RUN_URL:-}" FULLSEND_FAILURE_CATEGORY="${FULLSEND_FAILURE_CATEGORY:-}" @@ -26,6 +27,10 @@ if [[ ! "${FULLSEND_FAILURE_AGENT}" =~ ^[A-Za-z0-9_-]+$ ]]; then echo "::warning::Skipping startup failure comment: invalid agent" >&2 exit 1 fi +if [[ ! "${FULLSEND_FAILURE_ROLE}" =~ ^[A-Za-z0-9_-]+$ ]]; then + echo "::warning::Skipping startup failure comment: invalid role" >&2 + exit 1 +fi case "${FULLSEND_FAILURE_CATEGORY}" in "workflow setup"|"runtime setup"|"CLI setup"|"token mint") ;; *) @@ -50,14 +55,7 @@ BODY_FILE="${RUNNER_TEMP:-/tmp}/fullsend-agent-startup-failure.md" BOT_LOGIN="$(gh api graphql -f query='{ viewer { login } }' --jq '.data.viewer.login')" COMMENTS_JSON="$(gh api --paginate --slurp \ "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/${FULLSEND_FAILURE_NUMBER}/comments")" -TRUSTED_BOT_LOGINS="github-actions" -case "${FULLSEND_FAILURE_AGENT}" in - code|fix) TRUSTED_BOT_LOGINS+=",fullsend-ai-coder" ;; - review) TRUSTED_BOT_LOGINS+=",fullsend-ai-review" ;; - triage) TRUSTED_BOT_LOGINS+=",fullsend-ai-triage" ;; - retro) TRUSTED_BOT_LOGINS+=",fullsend-ai-retro" ;; - prioritize) TRUSTED_BOT_LOGINS+=",fullsend-ai-prioritize" ;; -esac +TRUSTED_BOT_LOGINS="github-actions,fullsend-ai-${FULLSEND_FAILURE_ROLE}" # FULLSEND_FAILURE_TRUSTED_BOTS contains app-set prefixes (for example, # "fullsend-ai" or "acme"), not arbitrary login prefixes. Expand each set to # the known agent identities so a lookalike app cannot update this comment. @@ -65,12 +63,12 @@ TRUSTED_BOTS_JSON="$(jq -Rn \ --arg current "${BOT_LOGIN}" \ --arg logins "${TRUSTED_BOT_LOGINS}" \ --arg app_sets "${FULLSEND_FAILURE_TRUSTED_BOTS:-}" \ + --arg role "${FULLSEND_FAILURE_ROLE}" \ '[ $current ] + ($logins | split(",") | map(select(length > 0))) + ($app_sets | split(",") | map(select(length > 0) | . as $set - | ["coder", "review", "triage", "retro", "prioritize"] - | map($set + "-" + .)) | add) + | [$set + "-" + $role]) | add) | map(sub("\\[bot\\]$"; "")) | unique')" COMMENT_ID="$(printf '%s' "${COMMENTS_JSON}" | jq -r \ diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 8ad1426803..e714be7935 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -2960,6 +2960,7 @@ jobs: REPOSITORY: ${{ matrix.status_repo }} NUMBER: ${{ matrix.status_number }} AGENT: ${{ matrix.agent }} + ROLE: ${{ matrix.role }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | set -euo pipefail @@ -2978,6 +2979,7 @@ jobs: export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" export FULLSEND_FAILURE_NUMBER="${NUMBER}" export FULLSEND_FAILURE_AGENT="${AGENT}" + export FULLSEND_FAILURE_ROLE="${ROLE}" export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" export FULLSEND_FAILURE_CATEGORY diff --git a/action.yml b/action.yml index 878e68cc1b..33bed1f5f8 100644 --- a/action.yml +++ b/action.yml @@ -48,7 +48,7 @@ inputs: description: Issue/PR number for startup-failure comments (optional). default: "" failure-trusted-bots: - description: Comma-separated custom bot login prefixes trusted for startup-failure comments (optional). + description: Comma-separated custom app-set prefixes used to derive trusted startup-failure bot identities (optional). default: "" failure-token: description: >- @@ -582,6 +582,7 @@ runs: shell: bash env: AGENT: ${{ inputs.agent }} + ROLE: ${{ inputs.role || inputs.agent }} FULLSEND_DIR: ${{ inputs.fullsend-dir }} TARGET_REPO: ${{ inputs.target-repo }} GH_TOKEN: ${{ inputs.github_token }} @@ -798,10 +799,11 @@ runs: FULLSEND_FAILURE_REPOSITORY="${FAILURE_REPO}" FULLSEND_FAILURE_NUMBER="${FAILURE_NUMBER}" FULLSEND_FAILURE_AGENT="${AGENT}" + FULLSEND_FAILURE_ROLE="${ROLE}" FULLSEND_FAILURE_RUN_URL="${RUN_URL:-${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}}" FULLSEND_FAILURE_CATEGORY="${FAILURE_CATEGORY}" export FULLSEND_FAILURE_REPOSITORY FULLSEND_FAILURE_NUMBER \ - FULLSEND_FAILURE_AGENT FULLSEND_FAILURE_RUN_URL \ + FULLSEND_FAILURE_AGENT FULLSEND_FAILURE_ROLE FULLSEND_FAILURE_RUN_URL \ FULLSEND_FAILURE_CATEGORY if "$GITHUB_ACTION_PATH/.github/scripts/report-agent-startup-failure.sh"; then echo "FULLSEND_STARTUP_FAILURE_REPORTED=true" >> "${GITHUB_ENV}" From c628eb16b54a2894effe1b6e75390416687cd5bc Mon Sep 17 00:00:00 2001 From: csoceanu Date: Mon, 9 Nov 2026 17:28:21 +0200 Subject: [PATCH 09/25] fix(actions): preserve startup reporter roles Co-authored-by: Codex Signed-off-by: csoceanu --- .github/workflows/reusable-dispatch.yml | 2 ++ action.yml | 1 + internal/scaffold/workflow_call_alignment_test.go | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index e714be7935..4b6b291e99 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -1754,6 +1754,7 @@ jobs: export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" export FULLSEND_FAILURE_NUMBER="${NUMBER}" export FULLSEND_FAILURE_AGENT="code" + export FULLSEND_FAILURE_ROLE="coder" export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" export FULLSEND_FAILURE_CATEGORY @@ -2269,6 +2270,7 @@ jobs: export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" export FULLSEND_FAILURE_NUMBER="${NUMBER}" export FULLSEND_FAILURE_AGENT="fix" + export FULLSEND_FAILURE_ROLE="coder" export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" export FULLSEND_FAILURE_CATEGORY diff --git a/action.yml b/action.yml index 33bed1f5f8..6d18793ce4 100644 --- a/action.yml +++ b/action.yml @@ -767,6 +767,7 @@ runs: env: GH_TOKEN: ${{ inputs.failure-token || inputs.github_token }} AGENT: ${{ inputs.agent }} + ROLE: ${{ inputs.role || inputs.agent }} FAILURE_REPO: ${{ inputs.failure-repo || inputs.status-repo }} FAILURE_NUMBER: ${{ inputs.failure-number || inputs.status-number }} FULLSEND_FAILURE_TRUSTED_BOTS: ${{ inputs.failure-trusted-bots }} diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index 2372a5fa7d..2337b2fa8c 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -64,6 +64,8 @@ func TestStartupFailureReportingGuards(t *testing.T) { assert.Contains(t, dispatchText, "id: eligibility") assert.Contains(t, dispatchText, "steps.fork_guard.outcome != 'failure'") assert.Contains(t, dispatchText, "steps.eligibility.outcome != 'failure'") + assert.GreaterOrEqual(t, strings.Count(dispatchText, `export FULLSEND_FAILURE_ROLE="coder"`), 2, + "code and fix reporters must use the shared coder bot role") prioritize, err := os.ReadFile(filepath.Join("..", "..", ".github", "workflows", "reusable-prioritize.yml")) require.NoError(t, err) @@ -1744,6 +1746,8 @@ func TestActionReconcileStatusUsesSuppliedRoleFallback(t *testing.T) { "action.yml must declare the optional role supplied by matrix dispatch") assert.Contains(t, s, "SUPPLIED_ROLE: ${{ inputs.role }}", "reconcile step must receive the supplied role") + assert.Contains(t, s, "ROLE: ${{ inputs.role || inputs.agent }}", + "startup failure reporter must receive a role even when the run step is skipped") assert.Contains(t, s, "RESOLVED_ROLE=\"${HARNESS_ROLE:-${SUPPLIED_ROLE:-${AGENT}}}\"", "reconciliation must use the supplied role when an early failure prevents the harness from reporting one") } From eef46e6cdae03f4cec77fa9c1d9e1eca2a26c631 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Mon, 9 Nov 2026 17:33:11 +0200 Subject: [PATCH 10/25] fix(actions): refine startup failure reporting Co-authored-by: Codex Signed-off-by: csoceanu --- .github/scripts/report-agent-startup-failure-test.sh | 1 + .github/scripts/report-agent-startup-failure.sh | 2 +- .github/workflows/reusable-prioritize.yml | 6 +++++- docs/guides/getting-started/operations.md | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/scripts/report-agent-startup-failure-test.sh b/.github/scripts/report-agent-startup-failure-test.sh index e163f83e18..6cd7b87ba7 100755 --- a/.github/scripts/report-agent-startup-failure-test.sh +++ b/.github/scripts/report-agent-startup-failure-test.sh @@ -70,5 +70,6 @@ run_case "app token finds job-bot comment" "fullsend-ai-review" "github-actions[ run_case "custom app set finds job-bot comment" "acme-review" "github-actions[bot]" "acme" run_case "job token finds custom app-set comment" "github-actions" "acme-review[bot]" "acme" run_case "non-listed role is trusted" "github-actions" "acme-scribe[bot]" "acme" "scribe" +run_case "custom app-set whitespace is trimmed" "github-actions" "acme-scribe[bot]" " acme " "scribe" run_case "lookalike app is not trusted" "github-actions" "acme-reviewer[bot]" "acme" "review" "marker" "post" run_case "marker must start the comment" "github-actions" "fullsend-ai-review[bot]" "" "review" "embedded" "post" diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh index 6f9e422bc4..7d82d1e3a0 100755 --- a/.github/scripts/report-agent-startup-failure.sh +++ b/.github/scripts/report-agent-startup-failure.sh @@ -66,7 +66,7 @@ TRUSTED_BOTS_JSON="$(jq -Rn \ --arg role "${FULLSEND_FAILURE_ROLE}" \ '[ $current ] + ($logins | split(",") | map(select(length > 0))) - + ($app_sets | split(",") | map(select(length > 0) + + ($app_sets | split(",") | map(gsub("^\\s+|\\s+$"; "") | select(length > 0) | . as $set | [$set + "-" + $role]) | add) | map(sub("\\[bot\\]$"; "")) diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index 57277daac6..050e5a564e 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -251,7 +251,11 @@ jobs: export FULLSEND_FAILURE_NUMBER="${NUMBER}" export FULLSEND_FAILURE_AGENT="prioritize" export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" - FULLSEND_FAILURE_CATEGORY="$([[ "${MINT_OUTCOME}" == "failure" ]] && echo 'token mint' || echo 'workflow setup')" + if [[ "${MINT_OUTCOME}" == "failure" && "${REPOSITORY}" != "${GITHUB_REPOSITORY}" ]]; then + FULLSEND_FAILURE_CATEGORY="token mint" + else + FULLSEND_FAILURE_CATEGORY="workflow setup" + fi export FULLSEND_FAILURE_CATEGORY bash "${script}" diff --git a/docs/guides/getting-started/operations.md b/docs/guides/getting-started/operations.md index a42d0c44c7..50c836f7ef 100644 --- a/docs/guides/getting-started/operations.md +++ b/docs/guides/getting-started/operations.md @@ -329,7 +329,7 @@ review reconciliation: | `status-number` | Issue or PR number for status comments | | `failure-repo` | Repository (`owner/repo`) for startup-failure comments; falls back to `status-repo` when unset | | `failure-number` | Issue or PR number for startup-failure comments; falls back to `status-number` when unset | -| `failure-trusted-bots` | Comma-separated custom bot login prefixes trusted for startup-failure comment deduplication (optional) | +| `failure-trusted-bots` | Comma-separated GitHub App set names (as in `FULLSEND_APP_SET`); each is expanded to the `-` bot identity for startup-failure comment deduplication (optional) | | `failure-token` | Optional token used only for startup-failure reporting; the normal `github_token` remains the workflow token | | `source-system` | Originating tracker (`github`, `gitlab`, or `jira`); startup-failure comments are GitHub-only (default: `github`) | | `status-comment-id` | ID of the comment that triggered a slash-command run; when set, reactions target that comment instead of the issue/PR | From 89cdd2511b970099e71b3dbc6d27397f6558b6d1 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Mon, 9 Nov 2026 18:00:52 +0200 Subject: [PATCH 11/25] fix(secrets): reserve workflow role name Co-authored-by: Codex Signed-off-by: csoceanu --- internal/cli/runner_secrets.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/runner_secrets.go b/internal/cli/runner_secrets.go index 0e32eb86e8..980483d8e8 100644 --- a/internal/cli/runner_secrets.go +++ b/internal/cli/runner_secrets.go @@ -67,7 +67,7 @@ var workflowSetEnvNames = []string{ "JIRA_USER_EMAIL", "MINT_REPOS", "MINT_URL", "ORIGINATING_URL", "PRE_AGENT_HEAD", "PRIOR_REVIEW_FILE", "PRIOR_REVIEW_PROVENANCE", "PRIOR_REVIEW_SHA", "PR_HEAD_SHA", "PR_NUMBER", "REPO_FULL_NAME", - "RETRO_COMMENT", "REVIEW_BODY_FILE", "STATUS_COMMENT_ID", "STATUS_NUMBER", + "RETRO_COMMENT", "REVIEW_BODY_FILE", "ROLE", "STATUS_COMMENT_ID", "STATUS_NUMBER", "STATUS_REPO", "STATUS_RUN_URL", "TARGET_BRANCH", "TARGET_REPO", "TRIGGER_SOURCE", "GIT_BOT_EMAIL", "OPENSHELL_VERSION", "OPENSHELL_SHA", "TARGET_REPO_DIR", From d2f9d2b64dcba191d3db08f7587d5f37e96ca95e Mon Sep 17 00:00:00 2001 From: csoceanu Date: Tue, 10 Nov 2026 09:57:49 +0200 Subject: [PATCH 12/25] fix(actions): clean up startup failure reporting Co-authored-by: Codex Signed-off-by: csoceanu --- .github/workflows/reusable-dispatch.yml | 5 ----- action.yml | 1 - docs/guides/getting-started/operations.md | 4 +++- docs/reference/config-reference.md | 10 ++++++---- internal/cli/runner_secrets.go | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 4b6b291e99..322751ef6a 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -2770,11 +2770,6 @@ jobs: done mkdir -p .github/scripts cp "${SRC}/.github/scripts/setup-agent-env.sh" .github/scripts/setup-agent-env.sh - reporter=".defaults/.github/scripts/report-agent-startup-failure.sh" - [[ -f "${reporter}" ]] || reporter=".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh" - if [[ -f "${reporter}" ]]; then - cp "${reporter}" .github/scripts/report-agent-startup-failure.sh - fi - name: Extract repo metadata id: repo-parts diff --git a/action.yml b/action.yml index 6d18793ce4..240085b441 100644 --- a/action.yml +++ b/action.yml @@ -582,7 +582,6 @@ runs: shell: bash env: AGENT: ${{ inputs.agent }} - ROLE: ${{ inputs.role || inputs.agent }} FULLSEND_DIR: ${{ inputs.fullsend-dir }} TARGET_REPO: ${{ inputs.target-repo }} GH_TOKEN: ${{ inputs.github_token }} diff --git a/docs/guides/getting-started/operations.md b/docs/guides/getting-started/operations.md index 50c836f7ef..cd0757d542 100644 --- a/docs/guides/getting-started/operations.md +++ b/docs/guides/getting-started/operations.md @@ -315,7 +315,9 @@ See [`status_notifications`](../../reference/config-reference.md#status_notifica If an agent cannot start because workflow setup fails, the GitHub fallback posts or updates a separate startup-failure comment with the failure category and workflow -run link. This fallback is independent of `status_notifications`; after it posts +run link. This fallback applies only to GitHub-originated events; pre-agent +failures from Jira- and GitLab-originated events are currently not reported by +this path. It is independent of `status_notifications`; after it posts successfully, orphaned status reconciliation is skipped to avoid a duplicate notification. diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index 070fe5bfb3..858d4a84af 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -683,10 +683,12 @@ step synthesizes an "Interrupted" comment so the run doesn't silently vanish. If workflow setup fails before the agent process starts, the dispatch workflow posts a separate "Fullsend agent did not run" comment with the failure category -and workflow-run link. This startup-failure comment is used only for -GitHub-originated events and does not replace tracker-routed notifications for -Jira-originated events. Repeated failures update the existing startup-failure -comment instead of creating duplicates. +and workflow-run link. This startup-failure comment is emitted only for +GitHub-originated events. Pre-agent failures from Jira- and GitLab-originated +events are currently not reported by this fallback; tracker-specific +startup-failure reporting is tracked in [#9256](https://github.com/fullsend-ai/fullsend/issues/9256). +Repeated failures update the existing startup-failure comment instead of +creating duplicates. The standalone prioritize workflow also supplies the status target and a prioritize-scoped GitHub token only to the startup-failure reporter when one diff --git a/internal/cli/runner_secrets.go b/internal/cli/runner_secrets.go index 980483d8e8..0e32eb86e8 100644 --- a/internal/cli/runner_secrets.go +++ b/internal/cli/runner_secrets.go @@ -67,7 +67,7 @@ var workflowSetEnvNames = []string{ "JIRA_USER_EMAIL", "MINT_REPOS", "MINT_URL", "ORIGINATING_URL", "PRE_AGENT_HEAD", "PRIOR_REVIEW_FILE", "PRIOR_REVIEW_PROVENANCE", "PRIOR_REVIEW_SHA", "PR_HEAD_SHA", "PR_NUMBER", "REPO_FULL_NAME", - "RETRO_COMMENT", "REVIEW_BODY_FILE", "ROLE", "STATUS_COMMENT_ID", "STATUS_NUMBER", + "RETRO_COMMENT", "REVIEW_BODY_FILE", "STATUS_COMMENT_ID", "STATUS_NUMBER", "STATUS_REPO", "STATUS_RUN_URL", "TARGET_BRANCH", "TARGET_REPO", "TRIGGER_SOURCE", "GIT_BOT_EMAIL", "OPENSHELL_VERSION", "OPENSHELL_SHA", "TARGET_REPO_DIR", From f503feef97c1b4604b2d07391c7a932196c444b0 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Wed, 11 Nov 2026 10:58:29 +0200 Subject: [PATCH 13/25] fix(action): keep failure target pairs aligned Co-authored-by: Codex Signed-off-by: csoceanu --- action.yml | 4 ++-- internal/scaffold/workflow_call_alignment_test.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 240085b441..1c95cb55bf 100644 --- a/action.yml +++ b/action.yml @@ -767,8 +767,8 @@ runs: GH_TOKEN: ${{ inputs.failure-token || inputs.github_token }} AGENT: ${{ inputs.agent }} ROLE: ${{ inputs.role || inputs.agent }} - FAILURE_REPO: ${{ inputs.failure-repo || inputs.status-repo }} - FAILURE_NUMBER: ${{ inputs.failure-number || inputs.status-number }} + FAILURE_REPO: ${{ inputs.failure-repo != '' && inputs.failure-number != '' && inputs.failure-repo || inputs.status-repo }} + FAILURE_NUMBER: ${{ inputs.failure-repo != '' && inputs.failure-number != '' && inputs.failure-number || inputs.status-number }} FULLSEND_FAILURE_TRUSTED_BOTS: ${{ inputs.failure-trusted-bots }} RUN_URL: ${{ inputs.run-url }} INSTALL_CLI_OUTCOME: ${{ steps.detect.outcome }} diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index 2337b2fa8c..b7dc25d4e1 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -1748,6 +1748,10 @@ func TestActionReconcileStatusUsesSuppliedRoleFallback(t *testing.T) { "reconcile step must receive the supplied role") assert.Contains(t, s, "ROLE: ${{ inputs.role || inputs.agent }}", "startup failure reporter must receive a role even when the run step is skipped") + assert.Contains(t, s, "FAILURE_REPO: ${{ inputs.failure-repo != '' && inputs.failure-number != '' && inputs.failure-repo || inputs.status-repo }}", + "startup failure reporter must select the failure repository and number as a pair") + assert.Contains(t, s, "FAILURE_NUMBER: ${{ inputs.failure-repo != '' && inputs.failure-number != '' && inputs.failure-number || inputs.status-number }}", + "startup failure reporter must select the failure repository and number as a pair") assert.Contains(t, s, "RESOLVED_ROLE=\"${HARNESS_ROLE:-${SUPPLIED_ROLE:-${AGENT}}}\"", "reconciliation must use the supplied role when an early failure prevents the harness from reporting one") } From 609deb483085aa6295ea03b80644ab678d48bce6 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Wed, 11 Nov 2026 16:44:42 +0200 Subject: [PATCH 14/25] fix(action): align reporting roles and tokens Co-authored-by: Codex Signed-off-by: csoceanu --- .github/workflows/reusable-dispatch.yml | 2 ++ action.yml | 1 - internal/scaffold/workflow_call_alignment_test.go | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 322751ef6a..f8ac8ba5ce 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -1710,6 +1710,7 @@ jobs: FULLSEND_INFERENCE_GATEWAY_API_KEY: ${{ secrets.FULLSEND_INFERENCE_GATEWAY_API_KEY }} with: agent: code + role: coder gcp_wif_provider: ${{ secrets.FULLSEND_GCP_WIF_PROVIDER }} gcp_project_id: ${{ secrets.FULLSEND_GCP_PROJECT_ID }} jira-token: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system == 'jira' && secrets.FULLSEND_JIRA_TOKEN || '' }} @@ -2226,6 +2227,7 @@ jobs: FULLSEND_INFERENCE_GATEWAY_API_KEY: ${{ secrets.FULLSEND_INFERENCE_GATEWAY_API_KEY }} with: agent: fix + role: coder gcp_wif_provider: ${{ secrets.FULLSEND_GCP_WIF_PROVIDER }} gcp_project_id: ${{ secrets.FULLSEND_GCP_PROJECT_ID }} jira-token: ${{ fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system == 'jira' && secrets.FULLSEND_JIRA_TOKEN || '' }} diff --git a/action.yml b/action.yml index 1c95cb55bf..20e2ec4ec2 100644 --- a/action.yml +++ b/action.yml @@ -817,7 +817,6 @@ runs: if: always() && inputs.agent != '__install_only__' && inputs.status-repo != '' && inputs.status-number != '' && inputs.mint-url != '' shell: bash env: - GH_TOKEN: ${{ inputs.github_token }} MINT_URL: ${{ inputs.mint-url }} AGENT: ${{ inputs.agent }} STATUS_REPO: ${{ inputs.status-repo }} diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index b7dc25d4e1..05d7c9cb62 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -1754,6 +1754,8 @@ func TestActionReconcileStatusUsesSuppliedRoleFallback(t *testing.T) { "startup failure reporter must select the failure repository and number as a pair") assert.Contains(t, s, "RESOLVED_ROLE=\"${HARNESS_ROLE:-${SUPPLIED_ROLE:-${AGENT}}}\"", "reconciliation must use the supplied role when an early failure prevents the harness from reporting one") + assert.NotContains(t, s, " GH_TOKEN: ${{ inputs.github_token }}\n MINT_URL:", + "status reconciliation mints its own token and must not receive the workflow token") } func TestActionReconcileStatusSupportsOlderCLIs(t *testing.T) { @@ -1971,6 +1973,15 @@ func TestReusableDispatchStatusCommentPassthrough(t *testing.T) { assert.Contains(t, section, "github_token: ${{ github.token }}") assert.Contains(t, section, "failure-token: ${{ steps.app-token.outputs.token || github.token }}") }) + + for _, agent := range []string{"code", "fix"} { + t.Run(agent+" uses coder role for startup reporting", func(t *testing.T) { + section := extractStepSection(t, s, "Run "+agent+" agent") + assert.Contains(t, section, "agent: "+agent) + assert.Contains(t, section, "role: coder", + "the %s composite path must use the coder identity for startup-failure deduplication", agent) + }) + } } // TestShimPerRepoProjectNumberPassthrough validates that the per-repo shim From 22057b4545ea64ddd3f8d33505de4af08f2c8261 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Thu, 12 Nov 2026 12:25:59 +0200 Subject: [PATCH 15/25] fix(action): harden startup failure reporting Signed-off-by: csoceanu Co-authored-by: Codex --- .../report-agent-startup-failure-test.sh | 29 ++++++++++++++++++- .../scripts/report-agent-startup-failure.sh | 7 +++-- docs/guides/getting-started/operations.md | 4 ++- docs/reference/config-reference.md | 6 ++-- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.github/scripts/report-agent-startup-failure-test.sh b/.github/scripts/report-agent-startup-failure-test.sh index 6cd7b87ba7..e3f8daff0b 100755 --- a/.github/scripts/report-agent-startup-failure-test.sh +++ b/.github/scripts/report-agent-startup-failure-test.sh @@ -21,6 +21,9 @@ if [[ "$1" != "api" ]]; then fi if [[ "$*" == *"graphql"* ]]; then + if [[ "${MOCK_GRAPHQL_FAIL:-}" == "true" ]]; then + exit 1 + fi printf '%s\n' "${MOCK_VIEWER_LOGIN}" elif [[ "$*" == *"--method PATCH"* ]]; then printf 'patch\n' >> "${MOCK_DIR}/calls" @@ -35,9 +38,11 @@ chmod +x "${MOCK_BIN}/gh" run_case() { local name="$1" viewer="$2" comment_login="$3" trusted_bots="${4:-}" role="${5:-review}" body_prefix="${6:-marker}" expected="${7:-patch}" local marker='' - local body="${marker}\n\nold comment" + local body="${marker}\n\nold comment\n\n[View the workflow run](https://github.com/org/repo/actions/runs/123)" if [[ "${body_prefix}" == "embedded" ]]; then body="old comment\n\n${marker}" + elif [[ "${body_prefix}" == "old-run" ]]; then + body="${marker}\n\nold comment\n\n[View the workflow run](https://github.com/org/repo/actions/runs/99)" fi export MOCK_VIEWER_LOGIN="${viewer}" export MOCK_COMMENTS_JSON="[[{\"id\":42,\"user\":{\"type\":\"Bot\",\"login\":\"${comment_login}\"},\"body\":\"${body}\"}]]" @@ -73,3 +78,25 @@ run_case "non-listed role is trusted" "github-actions" "acme-scribe[bot]" "acme" run_case "custom app-set whitespace is trimmed" "github-actions" "acme-scribe[bot]" " acme " "scribe" run_case "lookalike app is not trusted" "github-actions" "acme-reviewer[bot]" "acme" "review" "marker" "post" run_case "marker must start the comment" "github-actions" "fullsend-ai-review[bot]" "" "review" "embedded" "post" +run_case "different run posts a new historical comment" "github-actions" "fullsend-ai-review[bot]" "" "review" "old-run" "post" + +export MOCK_VIEWER_LOGIN="github-actions" +export MOCK_GRAPHQL_FAIL=true +export MOCK_COMMENTS_JSON='[[{"id":42,"user":{"type":"Bot","login":"fullsend-ai-review[bot]"},"body":"\n\nold comment\n\n[View the workflow run](https://github.com/org/repo/actions/runs/123)"}]]' +: > "${TMPDIR}/calls" +PATH="${MOCK_BIN}:${PATH}" \ + GH_TOKEN=test \ + RUNNER_TEMP="${TMPDIR}" \ + FULLSEND_FAILURE_REPOSITORY=org/repo \ + FULLSEND_FAILURE_NUMBER=123 \ + FULLSEND_FAILURE_AGENT=review \ + FULLSEND_FAILURE_ROLE=review \ + FULLSEND_FAILURE_RUN_URL=https://github.com/org/repo/actions/runs/123 \ + FULLSEND_FAILURE_CATEGORY="workflow setup" \ + bash "${SCRIPT}" >/dev/null +if [[ "$(cat "${TMPDIR}/calls")" == "patch" ]]; then + printf 'PASS: GraphQL viewer failure does not prevent reporting\n' +else + printf 'FAIL: GraphQL viewer failure did not report\n' >&2 + exit 1 +fi diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh index 7d82d1e3a0..b399ab781a 100755 --- a/.github/scripts/report-agent-startup-failure.sh +++ b/.github/scripts/report-agent-startup-failure.sh @@ -52,7 +52,7 @@ BODY_FILE="${RUNNER_TEMP:-/tmp}/fullsend-agent-startup-failure.md" printf '[View the workflow run](%s)\n\n' "${FULLSEND_FAILURE_RUN_URL}" } > "${BODY_FILE}" -BOT_LOGIN="$(gh api graphql -f query='{ viewer { login } }' --jq '.data.viewer.login')" +BOT_LOGIN="$(gh api graphql -f query='{ viewer { login } }' --jq '.data.viewer.login' 2>/dev/null || true)" COMMENTS_JSON="$(gh api --paginate --slurp \ "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/${FULLSEND_FAILURE_NUMBER}/comments")" TRUSTED_BOT_LOGINS="github-actions,fullsend-ai-${FULLSEND_FAILURE_ROLE}" @@ -72,11 +72,12 @@ TRUSTED_BOTS_JSON="$(jq -Rn \ | map(sub("\\[bot\\]$"; "")) | unique')" COMMENT_ID="$(printf '%s' "${COMMENTS_JSON}" | jq -r \ - --arg marker "${MARKER}" --argjson trusted "${TRUSTED_BOTS_JSON}" \ + --arg marker "${MARKER}" --arg run_url "${FULLSEND_FAILURE_RUN_URL}" \ + --argjson trusted "${TRUSTED_BOTS_JSON}" \ 'add | map(select((.user.type == "Bot") and ((.user.login | sub("\\[bot\\]$"; "")) as $login | (($trusted | index($login)) != null)) - and (.body | startswith($marker)))) | last | .id // empty')" + and (.body | startswith($marker) and contains($run_url)))) | last | .id // empty')" if [[ -n "${COMMENT_ID}" ]]; then gh api --method PATCH "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/comments/${COMMENT_ID}" \ diff --git a/docs/guides/getting-started/operations.md b/docs/guides/getting-started/operations.md index cd0757d542..2998a4f170 100644 --- a/docs/guides/getting-started/operations.md +++ b/docs/guides/getting-started/operations.md @@ -315,7 +315,9 @@ See [`status_notifications`](../../reference/config-reference.md#status_notifica If an agent cannot start because workflow setup fails, the GitHub fallback posts or updates a separate startup-failure comment with the failure category and workflow -run link. This fallback applies only to GitHub-originated events; pre-agent +run link. Retries of the same workflow run update that comment, while a later +workflow run posts a new historical comment. A later successful run does not +remove the historical failure comment. This fallback applies only to GitHub-originated events; pre-agent failures from Jira- and GitLab-originated events are currently not reported by this path. It is independent of `status_notifications`; after it posts successfully, orphaned status reconciliation is skipped to avoid a duplicate diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index 858d4a84af..a453757d5b 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -687,8 +687,10 @@ and workflow-run link. This startup-failure comment is emitted only for GitHub-originated events. Pre-agent failures from Jira- and GitLab-originated events are currently not reported by this fallback; tracker-specific startup-failure reporting is tracked in [#9256](https://github.com/fullsend-ai/fullsend/issues/9256). -Repeated failures update the existing startup-failure comment instead of -creating duplicates. +Retries of the same workflow run update the existing startup-failure comment +instead of creating duplicates. A later workflow run posts a new comment so +the historical failure and its workflow-run link are preserved; a later +successful run does not remove that historical comment. The standalone prioritize workflow also supplies the status target and a prioritize-scoped GitHub token only to the startup-failure reporter when one From 4cff9733f380db1867feea646ec70248809f4ff8 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Thu, 12 Nov 2026 13:19:42 +0200 Subject: [PATCH 16/25] fix(action): match startup failure run links exactly Signed-off-by: csoceanu Co-authored-by: Codex --- .github/scripts/report-agent-startup-failure-test.sh | 3 +++ .github/scripts/report-agent-startup-failure.sh | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/scripts/report-agent-startup-failure-test.sh b/.github/scripts/report-agent-startup-failure-test.sh index e3f8daff0b..2a9028378b 100755 --- a/.github/scripts/report-agent-startup-failure-test.sh +++ b/.github/scripts/report-agent-startup-failure-test.sh @@ -43,6 +43,8 @@ run_case() { body="old comment\n\n${marker}" elif [[ "${body_prefix}" == "old-run" ]]; then body="${marker}\n\nold comment\n\n[View the workflow run](https://github.com/org/repo/actions/runs/99)" + elif [[ "${body_prefix}" == "prefix-run" ]]; then + body="${marker}\n\nold comment\n\n[View the workflow run](https://github.com/org/repo/actions/runs/1234)" fi export MOCK_VIEWER_LOGIN="${viewer}" export MOCK_COMMENTS_JSON="[[{\"id\":42,\"user\":{\"type\":\"Bot\",\"login\":\"${comment_login}\"},\"body\":\"${body}\"}]]" @@ -79,6 +81,7 @@ run_case "custom app-set whitespace is trimmed" "github-actions" "acme-scribe[bo run_case "lookalike app is not trusted" "github-actions" "acme-reviewer[bot]" "acme" "review" "marker" "post" run_case "marker must start the comment" "github-actions" "fullsend-ai-review[bot]" "" "review" "embedded" "post" run_case "different run posts a new historical comment" "github-actions" "fullsend-ai-review[bot]" "" "review" "old-run" "post" +run_case "prefix-matching run posts a new historical comment" "github-actions" "fullsend-ai-review[bot]" "" "review" "prefix-run" "post" export MOCK_VIEWER_LOGIN="github-actions" export MOCK_GRAPHQL_FAIL=true diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh index b399ab781a..27f7e69ee6 100755 --- a/.github/scripts/report-agent-startup-failure.sh +++ b/.github/scripts/report-agent-startup-failure.sh @@ -72,12 +72,13 @@ TRUSTED_BOTS_JSON="$(jq -Rn \ | map(sub("\\[bot\\]$"; "")) | unique')" COMMENT_ID="$(printf '%s' "${COMMENTS_JSON}" | jq -r \ - --arg marker "${MARKER}" --arg run_url "${FULLSEND_FAILURE_RUN_URL}" \ + --arg marker "${MARKER}" \ + --arg run_link "[View the workflow run](${FULLSEND_FAILURE_RUN_URL})" \ --argjson trusted "${TRUSTED_BOTS_JSON}" \ 'add | map(select((.user.type == "Bot") and ((.user.login | sub("\\[bot\\]$"; "")) as $login | (($trusted | index($login)) != null)) - and (.body | startswith($marker) and contains($run_url)))) | last | .id // empty')" + and (.body | startswith($marker) and contains($run_link)))) | last | .id // empty')" if [[ -n "${COMMENT_ID}" ]]; then gh api --method PATCH "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/comments/${COMMENT_ID}" \ From b6f844498e5952fe60fb8725a1eca76753a81377 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Thu, 12 Nov 2026 13:40:57 +0200 Subject: [PATCH 17/25] fix(workflow): avoid unnecessary prioritize token minting Signed-off-by: csoceanu Co-authored-by: Codex --- .github/workflows/reusable-prioritize.yml | 1 + docs/reference/config-reference.md | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable-prioritize.yml b/.github/workflows/reusable-prioritize.yml index 050e5a564e..619a438c9d 100644 --- a/.github/workflows/reusable-prioritize.yml +++ b/.github/workflows/reusable-prioritize.yml @@ -150,6 +150,7 @@ jobs: - name: Mint prioritize status token id: app-token continue-on-error: true + if: ${{ (fromJSON(inputs.event_payload)._normalized_event.source.system || 'github') == 'github' && inputs.source_repo != github.repository }} uses: ./.defaults/.github/actions/mint-token with: role: prioritize diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index a453757d5b..a99e31fd0f 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -692,9 +692,11 @@ instead of creating duplicates. A later workflow run posts a new comment so the historical failure and its workflow-run link are preserved; a later successful run does not remove that historical comment. -The standalone prioritize workflow also supplies the status target and a -prioritize-scoped GitHub token only to the startup-failure reporter when one -can be minted. The normal `github_token` input remains the workflow token for +The standalone prioritize workflow also supplies the status target and, for +GitHub-originated calls targeting a different repository, mints a +prioritize-scoped GitHub token only for the startup-failure reporter. Same- +repository calls use the workflow token and non-GitHub calls do not mint this +reporting token. The normal `github_token` input remains the workflow token for installation, cloning, provider credentials, and `fullsend run`. This enables the same startup-failure reporting for cross-repository prioritize calls; if minting fails and the target is a different repository, the workflow emits an From 274e64bfcedbd545bb52f5123f482f15cb1a7247 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Thu, 12 Nov 2026 14:11:23 +0200 Subject: [PATCH 18/25] docs: fix repository wording Signed-off-by: csoceanu Co-authored-by: Codex --- docs/reference/config-reference.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index a99e31fd0f..df89cb9a2b 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -694,8 +694,8 @@ successful run does not remove that historical comment. The standalone prioritize workflow also supplies the status target and, for GitHub-originated calls targeting a different repository, mints a -prioritize-scoped GitHub token only for the startup-failure reporter. Same- -repository calls use the workflow token and non-GitHub calls do not mint this +prioritize-scoped GitHub token only for the startup-failure reporter. +Same-repository calls use the workflow token and non-GitHub calls do not mint this reporting token. The normal `github_token` input remains the workflow token for installation, cloning, provider credentials, and `fullsend run`. This enables the same startup-failure reporting for cross-repository prioritize calls; if From 37f42979028a11a462585bc83958652fe4c4c2f4 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Thu, 12 Nov 2026 15:52:52 +0200 Subject: [PATCH 19/25] fix(workflow): report harness dispatch failures Signed-off-by: csoceanu Co-authored-by: Codex --- .github/workflows/reusable-dispatch.yml | 33 ++++++++++++++++++- .../scaffold/workflow_call_alignment_test.go | 2 ++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index f8ac8ba5ce..2c4c8b6f6b 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -2564,7 +2564,8 @@ jobs: actions: write contents: read id-token: write - pull-requests: read + issues: write + pull-requests: write outputs: matrix: ${{ steps.dispatch.outputs.matrix }} steps: @@ -2719,6 +2720,36 @@ jobs: echo "${DELIM}" } >> "${GITHUB_OUTPUT}" + - name: Report harness dispatch failure + if: ${{ failure() && !cancelled() && steps.dispatch.outcome != 'success' && (github.event.issue.number != '' || github.event.pull_request.number != '') }} + env: + GH_TOKEN: ${{ github.token }} + FULLSEND_FAILURE_REPOSITORY: ${{ github.repository }} + FULLSEND_FAILURE_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} + FULLSEND_FAILURE_AGENT: harness + FULLSEND_FAILURE_ROLE: harness + FULLSEND_FAILURE_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + FULLSEND_FAILURE_CATEGORY: workflow setup + FULLSEND_FAILURE_TRUSTED_BOTS: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} + run: | + set -euo pipefail + script=".defaults/.github/scripts/report-agent-startup-failure.sh" + [[ -f "${script}" ]] || script=".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh" + if [[ ! -f "${script}" ]]; then + script="${RUNNER_TEMP}/fullsend-agent-startup-failure.sh" + if encoded="$(gh api "repos/${{ job.workflow_repository }}/contents/.github/scripts/report-agent-startup-failure.sh?ref=${{ job.workflow_sha }}" --jq .content)"; then + printf '%s' "${encoded}" | base64 --decode > "${script}" + chmod +x "${script}" + else + echo "::warning::Startup failure reporter is unavailable" + exit 0 + fi + fi + export FULLSEND_FAILURE_REPOSITORY FULLSEND_FAILURE_NUMBER \ + FULLSEND_FAILURE_AGENT FULLSEND_FAILURE_ROLE FULLSEND_FAILURE_RUN_URL \ + FULLSEND_FAILURE_CATEGORY FULLSEND_FAILURE_TRUSTED_BOTS + bash "${script}" + harness-run: name: Harness run (${{ matrix.agent }}) needs: [harness-dispatch] diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index 05d7c9cb62..a64ee88c19 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -55,6 +55,8 @@ func TestStartupFailureReportingGuards(t *testing.T) { for _, agent := range []string{"triage", "code", "review", "fix", "retro", "prioritize", "harness"} { assert.Contains(t, dispatchText, "Report "+agent+" launch failure") } + assert.Contains(t, dispatchText, "Report harness dispatch failure") + assert.Contains(t, dispatchText, "steps.dispatch.outcome != 'success'") for _, line := range strings.Split(dispatchText, "\n") { if strings.Contains(line, "if: ${{ failure()") && strings.Contains(line, "steps.run-agent.outcome") { assert.Contains(t, line, "!cancelled()", "startup failure reporters must not run after cancellation") From 04cef75f4938d9ef7099709189aa3dda007eeefe Mon Sep 17 00:00:00 2001 From: csoceanu Date: Thu, 12 Nov 2026 16:22:48 +0200 Subject: [PATCH 20/25] fix(actions): deduplicate harness failure comments Use stable harness markers and neutral wording for repeated dispatch failures. Distinguish policy skips from operational failures and tighten permissions. Co-authored-by: Codex Signed-off-by: csoceanu --- .github/scripts/check-fix-eligibility-test.sh | 14 ++++++ .github/scripts/check-fix-eligibility.sh | 14 ++++++ .github/scripts/pre-fetch-review-body-test.sh | 13 ++++-- .github/scripts/pre-fetch-review-body.sh | 10 ++++- .../report-agent-startup-failure-test.sh | 43 +++++++++---------- .../scripts/report-agent-startup-failure.sh | 22 ++++++++-- .github/workflows/reusable-dispatch.yml | 29 ++++++++----- .../scaffold/workflow_call_alignment_test.go | 41 +++++++++--------- 8 files changed, 124 insertions(+), 62 deletions(-) diff --git a/.github/scripts/check-fix-eligibility-test.sh b/.github/scripts/check-fix-eligibility-test.sh index 3e93fff0d3..32493c927b 100755 --- a/.github/scripts/check-fix-eligibility-test.sh +++ b/.github/scripts/check-fix-eligibility-test.sh @@ -97,6 +97,7 @@ run_test() { SOURCE_REPO="org/repo" \ GH_TOKEN="fake" \ FULLSEND_APP_SET="${app_set}" \ + GITHUB_OUTPUT="${TMPDIR}/eligibility-output" \ bash "${SCRIPT}" 2>&1) || actual_exit=$? if [[ "${actual_exit}" -ne "${expected_exit}" ]]; then @@ -111,6 +112,12 @@ run_test() { return fi + if [[ "${expected_exit}" -eq 1 ]] && ! grep -qx "policy_skip=true" "${TMPDIR}/eligibility-output"; then + echo "FAIL: ${name} — expected policy_skip=true output" + FAILURES=$((FAILURES + 1)) + return + fi + echo "PASS: ${name}" } @@ -187,6 +194,7 @@ MOCKEOF PR_NUM="999" \ SOURCE_REPO="org/repo" \ GH_TOKEN="fake" \ + GITHUB_OUTPUT="${TMPDIR}/eligibility-output" \ bash "${SCRIPT}" 2>&1) || actual_exit=$? if [[ "${actual_exit}" -ne 1 ]]; then @@ -201,6 +209,12 @@ MOCKEOF return fi + if ! grep -qx "policy_skip=false" "${TMPDIR}/eligibility-output"; then + echo "FAIL: gh pr view failure — expected policy_skip=false output" + FAILURES=$((FAILURES + 1)) + return + fi + echo "PASS: gh pr view failure" } run_test_gh_failure diff --git a/.github/scripts/check-fix-eligibility.sh b/.github/scripts/check-fix-eligibility.sh index 507535b5ea..3d16a7c572 100755 --- a/.github/scripts/check-fix-eligibility.sh +++ b/.github/scripts/check-fix-eligibility.sh @@ -10,9 +10,21 @@ # # Exits 0 if fix should proceed, 1 if it should be skipped. # Emits GitHub Actions annotations (::warning::) for skip reasons. +# Emits policy_skip=true only for intentional policy skips; operational errors +# leave policy_skip=false so the caller can report the startup failure. set -euo pipefail +if [[ -n "${GITHUB_OUTPUT:-}" ]]; then + echo "policy_skip=false" >> "${GITHUB_OUTPUT}" +fi + +mark_policy_skip() { + if [[ -n "${GITHUB_OUTPUT:-}" ]]; then + echo "policy_skip=true" >> "${GITHUB_OUTPUT}" + fi +} + # Only gate bot-triggered runs; human /fs-fix always proceeds. if [[ ! "${TRIGGER_SOURCE}" =~ \[bot\]$ ]]; then exit 0 @@ -25,6 +37,7 @@ PR_INFO=$(gh pr view "${PR_NUM}" --repo "${SOURCE_REPO}" \ HAS_NO_FIX=$(echo "${PR_INFO}" | jq -r '.labels | any(. == "fullsend-no-fix")') if [[ "${HAS_NO_FIX}" == "true" ]]; then echo "::warning::PR #${PR_NUM} has 'fullsend-no-fix' label — skipping bot-triggered fix" + mark_policy_skip exit 1 fi @@ -70,6 +83,7 @@ if [[ "${KNOWN_CODER}" != "true" ]]; then HAS_FIX_LABEL=$(echo "${PR_INFO}" | jq -r '.labels | any(. == "fullsend-fix")') if [[ "${HAS_FIX_LABEL}" != "true" ]]; then echo "::warning::PR #${PR_NUM} (author: ${PR_LOGIN_SAFE}, is_bot: ${PR_IS_BOT_SAFE}) is not the coder bot and lacks 'fullsend-fix' label — skipping bot-triggered fix" + mark_policy_skip exit 1 fi fi diff --git a/.github/scripts/pre-fetch-review-body-test.sh b/.github/scripts/pre-fetch-review-body-test.sh index f430df6423..8fcc9adfa3 100755 --- a/.github/scripts/pre-fetch-review-body-test.sh +++ b/.github/scripts/pre-fetch-review-body-test.sh @@ -94,9 +94,10 @@ chmod +x "${MOCK_BIN}/gh" # $4 — expected review body (exact; ignored when expected exit is non-zero) # $5 — expected output substring (optional) # $6 — FULLSEND_APP_SET override (optional; default custom-prefix) +# $7 — expected policy_skip output (optional) run_test() { local name="$1" expected_exit="$2" trigger="$3" expected_body="$4" - local expected_output="${5:-}" app_set="${6-custom-prefix}" + local expected_output="${5:-}" app_set="${6-custom-prefix}" expected_policy="${7:-false}" local workspace="${TMPDIR}/workspace" rm -rf "${workspace}" mkdir -p "${workspace}" @@ -128,6 +129,12 @@ run_test() { return fi + if ! grep -qx "policy_skip=${expected_policy}" "${TMPDIR}/github-output"; then + echo "FAIL: ${name} — expected policy_skip=${expected_policy} output" + FAILURES=$((FAILURES + 1)) + return + fi + if [[ "${expected_exit}" -eq 0 ]]; then local actual_body actual_body="$(cat "${workspace}/review-body.txt")" @@ -213,7 +220,7 @@ reset_pages filler 30 1 | write_page 1 filler 15 31 | write_page 2 run_test "no match fails bot-triggered run" 1 "${ORG_BOT}" "" \ - "Bot-triggered run but review body is empty" + "Bot-triggered run but review body is empty" "custom-prefix" "true" run_test "no match proceeds for human trigger" 0 "human-user" "" \ "Pre-fetched review body: 1 bytes" @@ -226,7 +233,7 @@ reset_pages review 1 "${ORG_BOT}" "CHANGES_REQUESTED" "unreachable" | write_page 1 touch "${TMPDIR}/fail" run_test "API failure warns and fails bot-triggered run" 1 "${ORG_BOT}" "" \ - "::warning::Failed to fetch reviews for PR #123: HTTP 502: Bad Gateway" + "::warning::Failed to fetch reviews for PR #123: HTTP 502: Bad Gateway" "custom-prefix" "false" run_test "API failure warns and proceeds for human trigger" 0 "human-user" "" \ "::warning::Failed to fetch reviews for PR #123" rm -f "${TMPDIR}/fail" diff --git a/.github/scripts/pre-fetch-review-body.sh b/.github/scripts/pre-fetch-review-body.sh index c0e837e308..7c7abd8e10 100755 --- a/.github/scripts/pre-fetch-review-body.sh +++ b/.github/scripts/pre-fetch-review-body.sh @@ -14,7 +14,8 @@ # # Writes the body of the latest CHANGES_REQUESTED review submitted by a # recognized review bot to ${GITHUB_WORKSPACE}/review-body.txt and emits -# review_file= to GITHUB_OUTPUT. +# review_file= to GITHUB_OUTPUT. Emits policy_skip=true only when a +# bot-triggered run has no review body to act on. # # Reviews are fetched across every API page. The reviews endpoint returns # 30 reviews per page by default (100 at most), so on a PR with many @@ -25,6 +26,10 @@ set -euo pipefail +if [[ -n "${GITHUB_OUTPUT:-}" ]]; then + echo "policy_skip=false" >> "${GITHUB_OUTPUT}" +fi + REVIEW_FILE="${GITHUB_WORKSPACE:-.}/review-body.txt" REVIEW_BOT="${ORG_NAME}-review[bot]" SHARED_REVIEW_BOT="fullsend-ai-review[bot]" @@ -63,6 +68,9 @@ if [[ "${BYTE_COUNT}" -gt "${MAX_REVIEW_BYTES}" ]]; then fi if [[ "${TRIGGER_SOURCE}" =~ \[bot\]$ && "${BYTE_COUNT}" -le 1 ]]; then echo "::error::Bot-triggered run but review body is empty — nothing to fix" + if [[ -n "${GITHUB_OUTPUT:-}" ]]; then + echo "policy_skip=true" >> "${GITHUB_OUTPUT}" + fi exit 1 fi echo "review_file=${REVIEW_FILE}" >> "${GITHUB_OUTPUT:-/dev/null}" diff --git a/.github/scripts/report-agent-startup-failure-test.sh b/.github/scripts/report-agent-startup-failure-test.sh index 2a9028378b..e1918e458d 100755 --- a/.github/scripts/report-agent-startup-failure-test.sh +++ b/.github/scripts/report-agent-startup-failure-test.sh @@ -1,7 +1,11 @@ #!/usr/bin/env bash -# Tests the startup-failure reporter with REST-shaped bot identities. +# report-agent-startup-failure-test.sh — Tests for report-agent-startup-failure.sh +# +# Run from the repo root: +# bash .github/scripts/report-agent-startup-failure-test.sh set -euo pipefail +FAILURES=0 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT="${SCRIPT_DIR}/report-agent-startup-failure.sh" @@ -36,8 +40,12 @@ MOCKEOF chmod +x "${MOCK_BIN}/gh" run_case() { - local name="$1" viewer="$2" comment_login="$3" trusted_bots="${4:-}" role="${5:-review}" body_prefix="${6:-marker}" expected="${7:-patch}" - local marker='' + local name="$1" viewer="$2" comment_login="$3" trusted_bots="${4:-}" role="${5:-review}" body_prefix="${6:-marker}" expected="${7:-patch}" graphql_fail="${8:-false}" stable_marker="${9:-false}" agent="${10:-review}" + local marker="' local body="${marker}\n\nold comment\n\n[View the workflow run](https://github.com/org/repo/actions/runs/123)" if [[ "${body_prefix}" == "embedded" ]]; then body="old comment\n\n${marker}" @@ -47,6 +55,7 @@ run_case() { body="${marker}\n\nold comment\n\n[View the workflow run](https://github.com/org/repo/actions/runs/1234)" fi export MOCK_VIEWER_LOGIN="${viewer}" + export MOCK_GRAPHQL_FAIL="${graphql_fail}" export MOCK_COMMENTS_JSON="[[{\"id\":42,\"user\":{\"type\":\"Bot\",\"login\":\"${comment_login}\"},\"body\":\"${body}\"}]]" : > "${TMPDIR}/calls" @@ -55,8 +64,9 @@ run_case() { RUNNER_TEMP="${TMPDIR}" \ FULLSEND_FAILURE_REPOSITORY=org/repo \ FULLSEND_FAILURE_NUMBER=123 \ - FULLSEND_FAILURE_AGENT=review \ + FULLSEND_FAILURE_AGENT="${agent}" \ FULLSEND_FAILURE_ROLE="${role}" \ + FULLSEND_FAILURE_STABLE_MARKER="${stable_marker}" \ FULLSEND_FAILURE_TRUSTED_BOTS="${trusted_bots}" \ FULLSEND_FAILURE_RUN_URL=https://github.com/org/repo/actions/runs/123 \ FULLSEND_FAILURE_CATEGORY="workflow setup" \ @@ -68,7 +78,7 @@ run_case() { printf 'PASS: %s\n' "${name}" else printf 'FAIL: %s — expected %s, got %s\n' "${name}" "${expected:-no call}" "${actual:-no call}" >&2 - return 1 + FAILURES=$((FAILURES + 1)) fi } @@ -82,24 +92,11 @@ run_case "lookalike app is not trusted" "github-actions" "acme-reviewer[bot]" "a run_case "marker must start the comment" "github-actions" "fullsend-ai-review[bot]" "" "review" "embedded" "post" run_case "different run posts a new historical comment" "github-actions" "fullsend-ai-review[bot]" "" "review" "old-run" "post" run_case "prefix-matching run posts a new historical comment" "github-actions" "fullsend-ai-review[bot]" "" "review" "prefix-run" "post" +run_case "GraphQL viewer failure does not prevent reporting" "github-actions" "fullsend-ai-review[bot]" "" "review" "marker" "patch" "true" +run_case "stable harness marker updates a prior run" "github-actions" "fullsend-ai-harness[bot]" "" "harness" "old-run" "patch" "false" "true" "harness" -export MOCK_VIEWER_LOGIN="github-actions" -export MOCK_GRAPHQL_FAIL=true -export MOCK_COMMENTS_JSON='[[{"id":42,"user":{"type":"Bot","login":"fullsend-ai-review[bot]"},"body":"\n\nold comment\n\n[View the workflow run](https://github.com/org/repo/actions/runs/123)"}]]' -: > "${TMPDIR}/calls" -PATH="${MOCK_BIN}:${PATH}" \ - GH_TOKEN=test \ - RUNNER_TEMP="${TMPDIR}" \ - FULLSEND_FAILURE_REPOSITORY=org/repo \ - FULLSEND_FAILURE_NUMBER=123 \ - FULLSEND_FAILURE_AGENT=review \ - FULLSEND_FAILURE_ROLE=review \ - FULLSEND_FAILURE_RUN_URL=https://github.com/org/repo/actions/runs/123 \ - FULLSEND_FAILURE_CATEGORY="workflow setup" \ - bash "${SCRIPT}" >/dev/null -if [[ "$(cat "${TMPDIR}/calls")" == "patch" ]]; then - printf 'PASS: GraphQL viewer failure does not prevent reporting\n' -else - printf 'FAIL: GraphQL viewer failure did not report\n' >&2 +if [[ "${FAILURES}" -gt 0 ]]; then + printf '%d test(s) FAILED\n' "${FAILURES}" exit 1 fi +printf 'All tests passed\n' diff --git a/.github/scripts/report-agent-startup-failure.sh b/.github/scripts/report-agent-startup-failure.sh index 27f7e69ee6..34aed2fdb4 100755 --- a/.github/scripts/report-agent-startup-failure.sh +++ b/.github/scripts/report-agent-startup-failure.sh @@ -14,6 +14,8 @@ FULLSEND_FAILURE_AGENT="${FULLSEND_FAILURE_AGENT:-}" FULLSEND_FAILURE_ROLE="${FULLSEND_FAILURE_ROLE:-${FULLSEND_FAILURE_AGENT}}" FULLSEND_FAILURE_RUN_URL="${FULLSEND_FAILURE_RUN_URL:-}" FULLSEND_FAILURE_CATEGORY="${FULLSEND_FAILURE_CATEGORY:-}" +FULLSEND_FAILURE_SUMMARY="${FULLSEND_FAILURE_SUMMARY:-}" +FULLSEND_FAILURE_STABLE_MARKER="${FULLSEND_FAILURE_STABLE_MARKER:-false}" if [[ ! "${FULLSEND_FAILURE_REPOSITORY}" =~ ^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$ ]]; then echo "::warning::Skipping startup failure comment: invalid repository" >&2 @@ -38,16 +40,28 @@ case "${FULLSEND_FAILURE_CATEGORY}" in exit 1 ;; esac +if [[ "${FULLSEND_FAILURE_STABLE_MARKER}" != "true" && "${FULLSEND_FAILURE_STABLE_MARKER}" != "false" ]]; then + echo "::warning::Skipping startup failure comment: invalid stable-marker flag" >&2 + exit 1 +fi if [[ ! "${FULLSEND_FAILURE_RUN_URL}" =~ ^https://[A-Za-z0-9.-]+/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+/actions/runs/[1-9][0-9]*$ ]]; then echo "::warning::Skipping startup failure comment: invalid workflow URL" >&2 exit 1 fi -MARKER="" +MARKER="" BODY_FILE="${RUNNER_TEMP:-/tmp}/fullsend-agent-startup-failure.md" { printf '%s\n\n' "${MARKER}" - printf '⚠️ **Fullsend %s agent did not run**\n\n' "${FULLSEND_FAILURE_AGENT}" + if [[ -n "${FULLSEND_FAILURE_SUMMARY}" ]]; then + printf '⚠️ **%s**\n\n' "${FULLSEND_FAILURE_SUMMARY}" + else + printf '⚠️ **Fullsend %s agent did not run**\n\n' "${FULLSEND_FAILURE_AGENT}" + fi printf 'The agent could not start because of a **%s** failure.\n\n' "${FULLSEND_FAILURE_CATEGORY}" printf '[View the workflow run](%s)\n\n' "${FULLSEND_FAILURE_RUN_URL}" } > "${BODY_FILE}" @@ -74,11 +88,13 @@ TRUSTED_BOTS_JSON="$(jq -Rn \ COMMENT_ID="$(printf '%s' "${COMMENTS_JSON}" | jq -r \ --arg marker "${MARKER}" \ --arg run_link "[View the workflow run](${FULLSEND_FAILURE_RUN_URL})" \ + --arg stable "${FULLSEND_FAILURE_STABLE_MARKER}" \ --argjson trusted "${TRUSTED_BOTS_JSON}" \ 'add | map(select((.user.type == "Bot") and ((.user.login | sub("\\[bot\\]$"; "")) as $login | (($trusted | index($login)) != null)) - and (.body | startswith($marker) and contains($run_link)))) | last | .id // empty')" + and (.body | startswith($marker) + and ($stable == "true" or contains($run_link))))) | last | .id // empty')" if [[ -n "${COMMENT_ID}" ]]; then gh api --method PATCH "repos/${FULLSEND_FAILURE_REPOSITORY}/issues/comments/${COMMENT_ID}" \ diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 2c4c8b6f6b..7523415e15 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -2047,10 +2047,12 @@ jobs: SOURCE_REPO: ${{ github.repository }} PR_NUM_INPUT: '' run: | + echo "policy_skip=false" >> "${GITHUB_OUTPUT}" HEAD_REPO="$(echo "${EVENT_PAYLOAD}" | jq -r '.pull_request.head.repo.full_name // empty')" BASE_REPO="$(echo "${EVENT_PAYLOAD}" | jq -r '.pull_request.base.repo.full_name // empty')" if [[ -n "${HEAD_REPO}" && -n "${BASE_REPO}" && "${HEAD_REPO}" != "${BASE_REPO}" ]]; then echo "::error::Fork PRs are not allowed to trigger the fix agent" + echo "policy_skip=true" >> "${GITHUB_OUTPUT}" exit 1 fi if [[ -z "${HEAD_REPO}" && -z "${BASE_REPO}" ]]; then @@ -2065,6 +2067,7 @@ jobs: fi if [[ "${IS_FORK}" == "true" ]]; then echo "::error::Fork PRs are not allowed to trigger the fix agent" + echo "policy_skip=true" >> "${GITHUB_OUTPUT}" exit 1 fi fi @@ -2247,7 +2250,7 @@ jobs: pr-head-sha: ${{ fromJSON(needs.route.outputs.event_payload).pull_request.head.sha || '' }} - name: Report fix launch failure - if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && steps.fork_guard.outcome != 'failure' && steps.eligibility.outcome != 'failure' && steps.review-body.outcome != 'failure' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} + if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && steps.fork_guard.outputs.policy_skip != 'true' && steps.eligibility.outputs.policy_skip != 'true' && steps.review-body.outputs.policy_skip != 'true' && (fromJSON(needs.route.outputs.event_payload)._normalized_event.source.system || 'github') == 'github' }} env: GH_TOKEN: ${{ github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -2554,6 +2557,8 @@ jobs: export FULLSEND_FAILURE_AGENT="prioritize" export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" export FULLSEND_FAILURE_CATEGORY="workflow setup" + export FULLSEND_FAILURE_SUMMARY="Harness dispatch failed; agents may not have run" + export FULLSEND_FAILURE_STABLE_MARKER="true" bash "${script}" harness-dispatch: @@ -2564,8 +2569,10 @@ jobs: actions: write contents: read id-token: write + # Callers must grant issues: write for startup-failure comments and + # pull-requests: read for harness event inspection. issues: write - pull-requests: write + pull-requests: read outputs: matrix: ${{ steps.dispatch.outputs.matrix }} steps: @@ -2724,13 +2731,10 @@ jobs: if: ${{ failure() && !cancelled() && steps.dispatch.outcome != 'success' && (github.event.issue.number != '' || github.event.pull_request.number != '') }} env: GH_TOKEN: ${{ github.token }} - FULLSEND_FAILURE_REPOSITORY: ${{ github.repository }} - FULLSEND_FAILURE_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} - FULLSEND_FAILURE_AGENT: harness - FULLSEND_FAILURE_ROLE: harness - FULLSEND_FAILURE_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - FULLSEND_FAILURE_CATEGORY: workflow setup FULLSEND_FAILURE_TRUSTED_BOTS: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} + REPOSITORY: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | set -euo pipefail script=".defaults/.github/scripts/report-agent-startup-failure.sh" @@ -2745,9 +2749,12 @@ jobs: exit 0 fi fi - export FULLSEND_FAILURE_REPOSITORY FULLSEND_FAILURE_NUMBER \ - FULLSEND_FAILURE_AGENT FULLSEND_FAILURE_ROLE FULLSEND_FAILURE_RUN_URL \ - FULLSEND_FAILURE_CATEGORY FULLSEND_FAILURE_TRUSTED_BOTS + export FULLSEND_FAILURE_REPOSITORY="${REPOSITORY}" + export FULLSEND_FAILURE_NUMBER="${NUMBER}" + export FULLSEND_FAILURE_AGENT="harness" + export FULLSEND_FAILURE_ROLE="harness" + export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" + export FULLSEND_FAILURE_CATEGORY="workflow setup" bash "${script}" harness-run: diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index a64ee88c19..0023f81dd3 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -64,8 +64,11 @@ func TestStartupFailureReportingGuards(t *testing.T) { } assert.Contains(t, dispatchText, "id: fork_guard") assert.Contains(t, dispatchText, "id: eligibility") - assert.Contains(t, dispatchText, "steps.fork_guard.outcome != 'failure'") - assert.Contains(t, dispatchText, "steps.eligibility.outcome != 'failure'") + assert.Contains(t, dispatchText, "steps.fork_guard.outputs.policy_skip != 'true'") + assert.Contains(t, dispatchText, "steps.eligibility.outputs.policy_skip != 'true'") + assert.Contains(t, dispatchText, "steps.review-body.outputs.policy_skip != 'true'") + assert.Contains(t, dispatchText, `FULLSEND_FAILURE_SUMMARY="Harness dispatch failed; agents may not have run"`) + assert.Contains(t, dispatchText, `FULLSEND_FAILURE_STABLE_MARKER="true"`) assert.GreaterOrEqual(t, strings.Count(dispatchText, `export FULLSEND_FAILURE_ROLE="coder"`), 2, "code and fix reporters must use the shared coder bot role") @@ -74,6 +77,21 @@ func TestStartupFailureReportingGuards(t *testing.T) { prioritizeText := string(prioritize) assert.Contains(t, prioritizeText, "failure-repo: ${{ inputs.source_repo }}") assert.NotContains(t, prioritizeText, "status-repo: ${{ inputs.source_repo }}") + section := extractStepSection(t, prioritizeText, "Run prioritize agent") + assert.Contains(t, section, "failure-repo:") + assert.Contains(t, section, "failure-number:") + assert.Contains(t, section, "source-system:") + assert.Contains(t, section, "github_token: ${{ github.token }}") + assert.Contains(t, section, "failure-token: ${{ steps.app-token.outputs.token || github.token }}") + + for _, agent := range []string{"code", "fix"} { + t.Run(agent+" uses coder role for startup reporting", func(t *testing.T) { + section := extractStepSection(t, dispatchText, "Run "+agent+" agent") + assert.Contains(t, section, "agent: "+agent) + assert.Contains(t, section, "role: coder", + "the %s composite path must use the coder identity for startup-failure deduplication", agent) + }) + } } type workflowInput struct { @@ -1965,25 +1983,6 @@ func TestReusableDispatchStatusCommentPassthrough(t *testing.T) { "harness-run must pass the minted token only to failure reporting") }) - t.Run("standalone prioritize", func(t *testing.T) { - content, err := os.ReadFile(filepath.Join("..", "..", ".github", "workflows", "reusable-prioritize.yml")) - require.NoError(t, err) - section := extractStepSection(t, string(content), "Run prioritize agent") - assert.Contains(t, section, "failure-repo:") - assert.Contains(t, section, "failure-number:") - assert.Contains(t, section, "source-system:") - assert.Contains(t, section, "github_token: ${{ github.token }}") - assert.Contains(t, section, "failure-token: ${{ steps.app-token.outputs.token || github.token }}") - }) - - for _, agent := range []string{"code", "fix"} { - t.Run(agent+" uses coder role for startup reporting", func(t *testing.T) { - section := extractStepSection(t, s, "Run "+agent+" agent") - assert.Contains(t, section, "agent: "+agent) - assert.Contains(t, section, "role: coder", - "the %s composite path must use the coder identity for startup-failure deduplication", agent) - }) - } } // TestShimPerRepoProjectNumberPassthrough validates that the per-repo shim From ffdc4752620de031a507f3e05bef657facd07376 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Sun, 15 Nov 2026 12:30:47 +0200 Subject: [PATCH 21/25] fix(actions): correct startup failure reporting Keep review API failures reportable and scope stable harness comments to the harness-dispatch fallback. Co-authored-by: Codex Signed-off-by: csoceanu --- .github/scripts/pre-fetch-review-body-test.sh | 2 +- .github/scripts/pre-fetch-review-body.sh | 4 +++- .github/workflows/reusable-dispatch.yml | 4 ++-- docs/guides/getting-started/operations.md | 6 ++++-- docs/reference/config-reference.md | 9 ++++++--- internal/scaffold/workflow_call_alignment_test.go | 8 ++++++-- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/scripts/pre-fetch-review-body-test.sh b/.github/scripts/pre-fetch-review-body-test.sh index 8fcc9adfa3..cc9997a0d0 100755 --- a/.github/scripts/pre-fetch-review-body-test.sh +++ b/.github/scripts/pre-fetch-review-body-test.sh @@ -129,7 +129,7 @@ run_test() { return fi - if ! grep -qx "policy_skip=${expected_policy}" "${TMPDIR}/github-output"; then + if [[ "$(grep '^policy_skip=' "${TMPDIR}/github-output" | tail -n 1)" != "policy_skip=${expected_policy}" ]]; then echo "FAIL: ${name} — expected policy_skip=${expected_policy} output" FAILURES=$((FAILURES + 1)) return diff --git a/.github/scripts/pre-fetch-review-body.sh b/.github/scripts/pre-fetch-review-body.sh index 7c7abd8e10..a35f587db9 100755 --- a/.github/scripts/pre-fetch-review-body.sh +++ b/.github/scripts/pre-fetch-review-body.sh @@ -40,6 +40,7 @@ fi ERR_FILE="$(mktemp)" trap 'rm -f "${ERR_FILE}"' EXIT +REVIEW_FETCH_FAILED=false # Collect every page before selecting: `last` must run over the combined # review list, not per page (see docs/contributing/shell-scripting.md). @@ -57,6 +58,7 @@ if ! gh api --paginate "repos/${SOURCE_REPO}/pulls/${PR_NUM}/reviews?per_page=10 ERR_MSG="$(head -c 500 "${ERR_FILE}" | tr '\r\n' ' ')" echo "::warning::Failed to fetch reviews for PR #${PR_NUM}: ${ERR_MSG//::/__}" echo "" > "${REVIEW_FILE}" + REVIEW_FETCH_FAILED=true fi BYTE_COUNT="$(wc -c < "${REVIEW_FILE}")" @@ -68,7 +70,7 @@ if [[ "${BYTE_COUNT}" -gt "${MAX_REVIEW_BYTES}" ]]; then fi if [[ "${TRIGGER_SOURCE}" =~ \[bot\]$ && "${BYTE_COUNT}" -le 1 ]]; then echo "::error::Bot-triggered run but review body is empty — nothing to fix" - if [[ -n "${GITHUB_OUTPUT:-}" ]]; then + if [[ "${REVIEW_FETCH_FAILED}" != "true" && -n "${GITHUB_OUTPUT:-}" ]]; then echo "policy_skip=true" >> "${GITHUB_OUTPUT}" fi exit 1 diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 7523415e15..385ed5f799 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -2557,8 +2557,6 @@ jobs: export FULLSEND_FAILURE_AGENT="prioritize" export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" export FULLSEND_FAILURE_CATEGORY="workflow setup" - export FULLSEND_FAILURE_SUMMARY="Harness dispatch failed; agents may not have run" - export FULLSEND_FAILURE_STABLE_MARKER="true" bash "${script}" harness-dispatch: @@ -2755,6 +2753,8 @@ jobs: export FULLSEND_FAILURE_ROLE="harness" export FULLSEND_FAILURE_RUN_URL="${RUN_URL}" export FULLSEND_FAILURE_CATEGORY="workflow setup" + export FULLSEND_FAILURE_SUMMARY="Harness dispatch failed; agents may not have run" + export FULLSEND_FAILURE_STABLE_MARKER="true" bash "${script}" harness-run: diff --git a/docs/guides/getting-started/operations.md b/docs/guides/getting-started/operations.md index 2998a4f170..34231cf608 100644 --- a/docs/guides/getting-started/operations.md +++ b/docs/guides/getting-started/operations.md @@ -316,8 +316,10 @@ See [`status_notifications`](../../reference/config-reference.md#status_notifica If an agent cannot start because workflow setup fails, the GitHub fallback posts or updates a separate startup-failure comment with the failure category and workflow run link. Retries of the same workflow run update that comment, while a later -workflow run posts a new historical comment. A later successful run does not -remove the historical failure comment. This fallback applies only to GitHub-originated events; pre-agent +workflow run posts a new historical comment. Harness-dispatch failures are the +exception: repeated pre-dispatch failures update one stable comment per issue +or PR to avoid comment spam. A later successful run does not remove the +historical failure comment. This fallback applies only to GitHub-originated events; pre-agent failures from Jira- and GitLab-originated events are currently not reported by this path. It is independent of `status_notifications`; after it posts successfully, orphaned status reconciliation is skipped to avoid a duplicate diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index df89cb9a2b..f96201ba95 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -688,9 +688,12 @@ GitHub-originated events. Pre-agent failures from Jira- and GitLab-originated events are currently not reported by this fallback; tracker-specific startup-failure reporting is tracked in [#9256](https://github.com/fullsend-ai/fullsend/issues/9256). Retries of the same workflow run update the existing startup-failure comment -instead of creating duplicates. A later workflow run posts a new comment so -the historical failure and its workflow-run link are preserved; a later -successful run does not remove that historical comment. +instead of creating duplicates. A later workflow run normally posts a new +comment so the historical failure and its workflow-run link are preserved; a +later successful run does not remove that historical comment. Harness-dispatch +failures are the exception: because they can recur on every forwarded event +before any agent is selected, they update one stable comment per issue or PR +with neutral wording that agents may not have run. The standalone prioritize workflow also supplies the status target and, for GitHub-originated calls targeting a different repository, mints a diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index 0023f81dd3..a3f6c5cae6 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -67,8 +67,12 @@ func TestStartupFailureReportingGuards(t *testing.T) { assert.Contains(t, dispatchText, "steps.fork_guard.outputs.policy_skip != 'true'") assert.Contains(t, dispatchText, "steps.eligibility.outputs.policy_skip != 'true'") assert.Contains(t, dispatchText, "steps.review-body.outputs.policy_skip != 'true'") - assert.Contains(t, dispatchText, `FULLSEND_FAILURE_SUMMARY="Harness dispatch failed; agents may not have run"`) - assert.Contains(t, dispatchText, `FULLSEND_FAILURE_STABLE_MARKER="true"`) + harnessFailureSection := extractStepSection(t, dispatchText, "Report harness dispatch failure") + assert.Contains(t, harnessFailureSection, `FULLSEND_FAILURE_SUMMARY="Harness dispatch failed; agents may not have run"`) + assert.Contains(t, harnessFailureSection, `FULLSEND_FAILURE_STABLE_MARKER="true"`) + prioritizeFailureSection := extractStepSection(t, dispatchText, "Report prioritize launch failure") + assert.NotContains(t, prioritizeFailureSection, "FULLSEND_FAILURE_SUMMARY=") + assert.NotContains(t, prioritizeFailureSection, "FULLSEND_FAILURE_STABLE_MARKER=") assert.GreaterOrEqual(t, strings.Count(dispatchText, `export FULLSEND_FAILURE_ROLE="coder"`), 2, "code and fix reporters must use the shared coder bot role") From caeda22d529870dd79000faf4ee649ba6cc952f7 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Wed, 18 Nov 2026 11:08:03 +0200 Subject: [PATCH 22/25] fix(workflow): resolve rebase lint issues Remove the duplicate harness status input and preserve gofmt output after rebasing onto main. Co-authored-by: Codex Signed-off-by: csoceanu --- .github/workflows/reusable-dispatch.yml | 1 - internal/scaffold/vendorcontent.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 385ed5f799..b68749b418 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -2981,7 +2981,6 @@ jobs: run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ matrix.status_repo }} status-number: ${{ matrix.status_number }} - status-comment-id: ${{ matrix.event_payload.comment.id }} source-system: ${{ fromJSON(matrix.event_payload)._normalized_event.source.system || 'github' }} status-comment-id: ${{ fromJSON(matrix.event_payload).comment.id }} failure-trusted-bots: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} diff --git a/internal/scaffold/vendorcontent.go b/internal/scaffold/vendorcontent.go index ce79797901..946d789d39 100644 --- a/internal/scaffold/vendorcontent.go +++ b/internal/scaffold/vendorcontent.go @@ -174,7 +174,7 @@ func isVendoredReusableWorkflow(path string) bool { // and scripts/renovate/update-openshell-sha.sh) must stay at their // current path regardless of whether they are listed. var vendoredDefaultsScripts = map[string]bool{ - ".github/scripts/check-fix-eligibility.sh": true, + ".github/scripts/check-fix-eligibility.sh": true, ".github/scripts/count-fix-commits.jq": true, ".github/scripts/install-openshell.sh": true, ".github/scripts/install-podman.sh": true, From 8a24500119e0214549cd99df2ede5f454bd7c4c6 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Wed, 18 Nov 2026 11:38:22 +0200 Subject: [PATCH 23/25] fix(workflow): use structured harness event payload Avoid invalid fromJSON expressions for matrix event payloads and lock the object contract in the scaffold test. Co-authored-by: Codex Signed-off-by: csoceanu --- .github/workflows/reusable-dispatch.yml | 8 ++++---- internal/scaffold/workflow_call_alignment_test.go | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index b68749b418..95ff8223df 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -2981,14 +2981,14 @@ jobs: run-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} status-repo: ${{ matrix.status_repo }} status-number: ${{ matrix.status_number }} - source-system: ${{ fromJSON(matrix.event_payload)._normalized_event.source.system || 'github' }} - status-comment-id: ${{ fromJSON(matrix.event_payload).comment.id }} + source-system: ${{ matrix.event_payload._normalized_event.source.system || 'github' }} + status-comment-id: ${{ matrix.event_payload.comment.id }} failure-trusted-bots: ${{ vars.FULLSEND_APP_SET || 'fullsend-ai' }} mint-url: ${{ inputs.mint_url }} pr-head-sha: ${{ matrix.event_payload.pull_request.head.sha || '' }} artifact-name: ${{ steps.dispatch-env.outputs.artifact_name }} - name: Report harness launch failure - if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && (fromJSON(matrix.event_payload)._normalized_event.source.system || 'github') == 'github' && (matrix.status_repo == github.repository || steps.app-token.outcome == 'success') }} + if: ${{ failure() && !cancelled() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && (matrix.event_payload._normalized_event.source.system || 'github') == 'github' && (matrix.status_repo == github.repository || steps.app-token.outcome == 'success') }} env: GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} MINT_OUTCOME: ${{ steps.app-token.outcome }} @@ -3022,5 +3022,5 @@ jobs: bash "${script}" - name: Warn when cross-repository harness failure cannot be reported - if: ${{ always() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && (fromJSON(matrix.event_payload)._normalized_event.source.system || 'github') == 'github' && matrix.status_repo != github.repository && steps.app-token.outcome != 'success' }} + if: ${{ always() && steps.run-agent.outcome == 'skipped' && matrix.status_number != '' && (matrix.event_payload._normalized_event.source.system || 'github') == 'github' && matrix.status_repo != github.repository && steps.app-token.outcome != 'success' }} run: echo "::warning::Harness startup failure could not be reported because no token authorized for the target repository was available" diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index a3f6c5cae6..c0c406a032 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -67,6 +67,10 @@ func TestStartupFailureReportingGuards(t *testing.T) { assert.Contains(t, dispatchText, "steps.fork_guard.outputs.policy_skip != 'true'") assert.Contains(t, dispatchText, "steps.eligibility.outputs.policy_skip != 'true'") assert.Contains(t, dispatchText, "steps.review-body.outputs.policy_skip != 'true'") + assert.NotContains(t, dispatchText, "fromJSON(matrix.event_payload)", + "matrix.event_payload is already a structured object") + assert.Contains(t, dispatchText, "source-system: ${{ matrix.event_payload._normalized_event.source.system || 'github' }}") + assert.Contains(t, dispatchText, "status-comment-id: ${{ matrix.event_payload.comment.id }}") harnessFailureSection := extractStepSection(t, dispatchText, "Report harness dispatch failure") assert.Contains(t, harnessFailureSection, `FULLSEND_FAILURE_SUMMARY="Harness dispatch failed; agents may not have run"`) assert.Contains(t, harnessFailureSection, `FULLSEND_FAILURE_STABLE_MARKER="true"`) From c2a86ccab945f277b42bdd5281a5fa3736bf6eb9 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Thu, 19 Nov 2026 09:29:23 +0200 Subject: [PATCH 24/25] fix(workflow): include vendored failure reporter Ensure harness-dispatch sparse checkouts include both vendored reporter paths and cover them in scaffold validation. Co-authored-by: Codex Signed-off-by: csoceanu --- .github/workflows/reusable-dispatch.yml | 2 ++ internal/scaffold/workflow_call_alignment_test.go | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 95ff8223df..1522b887a0 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -2592,7 +2592,9 @@ jobs: /OWNERS_ALIASES .defaults/action.yml .defaults/.github/actions/install-fullsend-cli/ + .defaults/.github/scripts/report-agent-startup-failure.sh .fullsend/.defaults/action.yml + .fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh sparse-checkout-cone-mode: false - name: Detect registered harness triggers diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index c0c406a032..116ddc8028 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -71,6 +71,18 @@ func TestStartupFailureReportingGuards(t *testing.T) { "matrix.event_payload is already a structured object") assert.Contains(t, dispatchText, "source-system: ${{ matrix.event_payload._normalized_event.source.system || 'github' }}") assert.Contains(t, dispatchText, "status-comment-id: ${{ matrix.event_payload.comment.id }}") + harnessDispatchStart := strings.Index(dispatchText, "\n harness-dispatch:\n") + harnessRunStart := strings.Index(dispatchText, "\n harness-run:\n") + require.NotEqual(t, -1, harnessDispatchStart, "harness-dispatch job must be present") + require.NotEqual(t, -1, harnessRunStart, "harness-run job must be present") + harnessDispatchText := dispatchText[harnessDispatchStart:harnessRunStart] + harnessCheckoutSection := extractStepSection(t, harnessDispatchText, "Checkout caller repository") + assert.Contains(t, harnessCheckoutSection, + ".defaults/.github/scripts/report-agent-startup-failure.sh", + "harness-dispatch sparse checkout must include the vendored reporter") + assert.Contains(t, harnessCheckoutSection, + ".fullsend/.defaults/.github/scripts/report-agent-startup-failure.sh", + "harness-dispatch sparse checkout must include the .fullsend vendored reporter") harnessFailureSection := extractStepSection(t, dispatchText, "Report harness dispatch failure") assert.Contains(t, harnessFailureSection, `FULLSEND_FAILURE_SUMMARY="Harness dispatch failed; agents may not have run"`) assert.Contains(t, harnessFailureSection, `FULLSEND_FAILURE_STABLE_MARKER="true"`) From c5e8497826d2a3f0a56f815ca1d71e0e3d6cc1c9 Mon Sep 17 00:00:00 2001 From: csoceanu Date: Thu, 19 Nov 2026 15:43:52 +0200 Subject: [PATCH 25/25] fix(reporting): fall back when comment updates fail Keep startup-failure reporting user-visible when comment lookup or cross-identity PATCH operations fail, and validate the final policy-skip output in eligibility tests. Co-authored-by: Codex Signed-off-by: csoceanu --- .github/scripts/check-fix-eligibility-test.sh | 17 +++++++++---- .../report-agent-startup-failure-test.sh | 12 +++++++++- .../scripts/report-agent-startup-failure.sh | 24 ++++++++++++------- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/.github/scripts/check-fix-eligibility-test.sh b/.github/scripts/check-fix-eligibility-test.sh index 32493c927b..bdebd086f5 100755 --- a/.github/scripts/check-fix-eligibility-test.sh +++ b/.github/scripts/check-fix-eligibility-test.sh @@ -90,6 +90,8 @@ run_test() { local mock_bin mock_bin=$(build_mock "${is_bot}" "${login}" "${labels}") + : > "${TMPDIR}/eligibility-output" + local actual_exit=0 output output=$(PATH="${mock_bin}:${PATH}" \ TRIGGER_SOURCE="${trigger}" \ @@ -112,8 +114,13 @@ run_test() { return fi - if [[ "${expected_exit}" -eq 1 ]] && ! grep -qx "policy_skip=true" "${TMPDIR}/eligibility-output"; then - echo "FAIL: ${name} — expected policy_skip=true output" + local expected_policy=false actual_policy + if [[ "${expected_exit}" -eq 1 ]]; then + expected_policy=true + fi + actual_policy="$(grep '^policy_skip=' "${TMPDIR}/eligibility-output" | tail -n 1 || true)" + if [[ "${actual_policy}" != "policy_skip=${expected_policy}" ]]; then + echo "FAIL: ${name} — expected final policy_skip=${expected_policy} output" FAILURES=$((FAILURES + 1)) return fi @@ -209,8 +216,10 @@ MOCKEOF return fi - if ! grep -qx "policy_skip=false" "${TMPDIR}/eligibility-output"; then - echo "FAIL: gh pr view failure — expected policy_skip=false output" + local actual_policy + actual_policy="$(grep '^policy_skip=' "${TMPDIR}/eligibility-output" | tail -n 1 || true)" + if [[ "${actual_policy}" != "policy_skip=false" ]]; then + echo "FAIL: gh pr view failure — expected final policy_skip=false output" FAILURES=$((FAILURES + 1)) return fi diff --git a/.github/scripts/report-agent-startup-failure-test.sh b/.github/scripts/report-agent-startup-failure-test.sh index e1918e458d..e80c5ee076 100755 --- a/.github/scripts/report-agent-startup-failure-test.sh +++ b/.github/scripts/report-agent-startup-failure-test.sh @@ -30,17 +30,23 @@ if [[ "$*" == *"graphql"* ]]; then fi printf '%s\n' "${MOCK_VIEWER_LOGIN}" elif [[ "$*" == *"--method PATCH"* ]]; then + if [[ "${MOCK_PATCH_FAIL:-}" == "true" ]]; then + exit 1 + fi printf 'patch\n' >> "${MOCK_DIR}/calls" elif [[ "$*" == *"--method POST"* ]]; then printf 'post\n' >> "${MOCK_DIR}/calls" else + if [[ "${MOCK_COMMENTS_FAIL:-}" == "true" ]]; then + exit 1 + fi printf '%s\n' "${MOCK_COMMENTS_JSON}" fi MOCKEOF chmod +x "${MOCK_BIN}/gh" run_case() { - local name="$1" viewer="$2" comment_login="$3" trusted_bots="${4:-}" role="${5:-review}" body_prefix="${6:-marker}" expected="${7:-patch}" graphql_fail="${8:-false}" stable_marker="${9:-false}" agent="${10:-review}" + local name="$1" viewer="$2" comment_login="$3" trusted_bots="${4:-}" role="${5:-review}" body_prefix="${6:-marker}" expected="${7:-patch}" graphql_fail="${8:-false}" stable_marker="${9:-false}" agent="${10:-review}" patch_fail="${11:-false}" comments_fail="${12:-false}" local marker="