Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
50f475e
fix(actions): report pre-agent startup failures
csoceanu Nov 9, 2026
19038f1
fix(actions): harden startup failure reporting
csoceanu Nov 9, 2026
ed40040
fix(actions): harden startup failure fallback
csoceanu Nov 9, 2026
88b005b
fix(actions): address startup failure review findings
csoceanu Nov 9, 2026
7ae5fb0
fix(actions): report additional startup failure cases
csoceanu Nov 9, 2026
d4062e0
fix(actions): isolate startup failure reporting token
csoceanu Nov 9, 2026
52f0de9
fix(actions): tighten startup failure bot matching
csoceanu Nov 9, 2026
597d33e
fix(actions): derive trusted bot role dynamically
csoceanu Nov 9, 2026
c628eb1
fix(actions): preserve startup reporter roles
csoceanu Nov 9, 2026
eef46e6
fix(actions): refine startup failure reporting
csoceanu Nov 9, 2026
89cdd25
fix(secrets): reserve workflow role name
csoceanu Nov 9, 2026
d2f9d2b
fix(actions): clean up startup failure reporting
csoceanu Nov 10, 2026
f503fee
fix(action): keep failure target pairs aligned
csoceanu Nov 11, 2026
609deb4
fix(action): align reporting roles and tokens
csoceanu Nov 11, 2026
22057b4
fix(action): harden startup failure reporting
csoceanu Nov 12, 2026
4cff973
fix(action): match startup failure run links exactly
csoceanu Nov 12, 2026
b6f8444
fix(workflow): avoid unnecessary prioritize token minting
csoceanu Nov 12, 2026
274e64b
docs: fix repository wording
csoceanu Nov 12, 2026
37f4297
fix(workflow): report harness dispatch failures
csoceanu Nov 12, 2026
04cef75
fix(actions): deduplicate harness failure comments
csoceanu Nov 12, 2026
ffdc475
fix(actions): correct startup failure reporting
csoceanu Nov 15, 2026
caeda22
fix(workflow): resolve rebase lint issues
csoceanu Nov 18, 2026
8a24500
fix(workflow): use structured harness event payload
csoceanu Nov 18, 2026
c2a86cc
fix(workflow): include vendored failure reporter
csoceanu Nov 19, 2026
c5e8497
fix(reporting): fall back when comment updates fail
csoceanu Nov 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/scripts/check-fix-eligibility-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ 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}" \
PR_NUM="123" \
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
Expand All @@ -111,6 +114,17 @@ run_test() {
return
fi

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

echo "PASS: ${name}"
}

Expand Down Expand Up @@ -187,6 +201,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
Expand All @@ -201,6 +216,14 @@ MOCKEOF
return
fi

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

echo "PASS: gh pr view failure"
}
run_test_gh_failure
Expand Down
14 changes: 14 additions & 0 deletions .github/scripts/check-fix-eligibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
13 changes: 10 additions & 3 deletions .github/scripts/pre-fetch-review-body-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -128,6 +129,12 @@ run_test() {
return
fi

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
fi

if [[ "${expected_exit}" -eq 0 ]]; then
local actual_body
actual_body="$(cat "${workspace}/review-body.txt")"
Expand Down Expand Up @@ -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"

Expand All @@ -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"
Expand Down
12 changes: 11 additions & 1 deletion .github/scripts/pre-fetch-review-body.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=<path> to GITHUB_OUTPUT.
# review_file=<path> 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
Expand All @@ -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]"
Expand All @@ -35,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).
Expand All @@ -52,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}")"
Expand All @@ -63,6 +70,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 [[ "${REVIEW_FETCH_FAILED}" != "true" && -n "${GITHUB_OUTPUT:-}" ]]; then
echo "policy_skip=true" >> "${GITHUB_OUTPUT}"
fi
exit 1
fi
echo "review_file=${REVIEW_FILE}" >> "${GITHUB_OUTPUT:-/dev/null}"
112 changes: 112 additions & 0 deletions .github/scripts/report-agent-startup-failure-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env bash
# 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"
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
if [[ "${MOCK_GRAPHQL_FAIL:-}" == "true" ]]; then
exit 1
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}" patch_fail="${11:-false}" comments_fail="${12:-false}"
local marker="<!-- fullsend:agent-startup-failure:${agent}:123"
if [[ "${stable_marker}" == "true" ]]; then
marker+=":stable"
fi
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}"
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_GRAPHQL_FAIL="${graphql_fail}"
export MOCK_PATCH_FAIL="${patch_fail}"
export MOCK_COMMENTS_FAIL="${comments_fail}"
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="${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" \
bash "${SCRIPT}" >/dev/null

local actual
actual="$(cat "${TMPDIR}/calls")"
if [[ "${actual}" == "${expected}" ]]; then
printf 'PASS: %s\n' "${name}"
else
printf 'FAIL: %s — expected %s, got %s\n' "${name}" "${expected:-no call}" "${actual:-no call}" >&2
FAILURES=$((FAILURES + 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]"
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved
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"
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"
run_case "failed cross-identity patch falls back to post" "github-actions" "fullsend-ai-review[bot]" "" "review" "marker" "post" "false" "false" "review" "true"
run_case "comments lookup failure falls back to post" "github-actions" "fullsend-ai-review[bot]" "" "review" "marker" "post" "false" "false" "review" "false" "true"

if [[ "${FAILURES}" -gt 0 ]]; then
printf '%d test(s) FAILED\n' "${FAILURES}"
exit 1
fi
printf 'All tests passed\n'
Loading
Loading