3232 name : BM Bossbot Review
3333 if : github.event.pull_request.draft != true
3434 runs-on : ubuntu-latest
35+ outputs :
36+ pr_number : ${{ steps.pr.outputs.pr_number }}
37+ head_ref : ${{ steps.pr.outputs.head_ref }}
3538
3639 steps :
3740 - name : Checkout trusted base ref
@@ -83,13 +86,21 @@ jobs:
8386 metadata="${RUNNER_TEMP}/bm-bossbot-pr.json"
8487 diff_file="${RUNNER_TEMP}/bm-bossbot-pr.diff"
8588 prompt_file="${RUNNER_TEMP}/bm-bossbot-prompt.md"
89+ review_file="${RUNNER_TEMP}/bm-bossbot-review.json"
90+ max_diff_bytes=120000
8691
8792 gh pr view "${PR_NUMBER}" \
8893 --repo "${GITHUB_REPOSITORY}" \
8994 --json number,title,body,author,headRefName,headRefOid,baseRefName,labels,files,commits,reviewDecision,mergeStateStatus,isDraft \
9095 > "${metadata}"
9196 gh pr diff "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" --patch > "${diff_file}"
9297
98+ diff_bytes="$(wc -c < "${diff_file}" | tr -d '[:space:]')"
99+ diff_truncated=false
100+ if [ "${diff_bytes}" -gt "${max_diff_bytes}" ]; then
101+ diff_truncated=true
102+ fi
103+
93104 cat .github/basic-memory/bm-bossbot-review.md > "${prompt_file}"
94105 {
95106 echo ""
@@ -103,16 +114,42 @@ jobs:
103114 echo "### Diff"
104115 echo ""
105116 echo '```diff'
106- head -c 120000 "${diff_file}"
117+ if [ "${diff_truncated}" = "true" ]; then
118+ echo "[Diff omitted: ${diff_bytes} bytes exceeds BM Bossbot's ${max_diff_bytes} byte review limit.]"
119+ else
120+ cat "${diff_file}"
121+ fi
107122 echo ""
108123 echo '```'
109124 } >> "${prompt_file}"
110125
126+ if [ "${diff_truncated}" = "true" ]; then
127+ jq -n \
128+ --arg sha "${HEAD_SHA}" \
129+ --argjson bytes "${diff_bytes}" \
130+ --argjson max_bytes "${max_diff_bytes}" \
131+ '{
132+ reviewed_head_sha: $sha,
133+ review_complete: false,
134+ verdict: "needs_human",
135+ blocking_findings: [
136+ {
137+ title: "Diff exceeds BM Bossbot review limit",
138+ body: "The PR diff is \($bytes) bytes, exceeding the deterministic \($max_bytes) byte review limit. A human review is required or the PR must be split before BM Bossbot can approve."
139+ }
140+ ],
141+ nonblocking_findings: [],
142+ summary: "BM Bossbot did not approve because the PR diff exceeded the deterministic review limit."
143+ }' > "${review_file}"
144+ fi
145+
111146 echo "prompt_file=${prompt_file}" >> "${GITHUB_OUTPUT}"
112- echo "review_file=${RUNNER_TEMP}/bm-bossbot-review.json" >> "${GITHUB_OUTPUT}"
147+ echo "review_file=${review_file}" >> "${GITHUB_OUTPUT}"
148+ echo "diff_truncated=${diff_truncated}" >> "${GITHUB_OUTPUT}"
113149
114150 - name : Run BM Bossbot review with Codex
115151 id : codex
152+ if : steps.context.outputs.diff_truncated != 'true'
116153 uses : openai/codex-action@v1
117154 with :
118155 openai-api-key : ${{ secrets.OPENAI_API_KEY }}
@@ -133,13 +170,31 @@ jobs:
133170 --repo "${GITHUB_REPOSITORY}" \
134171 --run-url "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
135172
173+ assets :
174+ name : BM Bossbot Assets
175+ needs : review
176+ if : needs.review.result == 'success'
177+ runs-on : ubuntu-latest
178+ permissions :
179+ contents : write
180+ pull-requests : write
181+
182+ steps :
183+ - name : Checkout trusted base ref
184+ uses : actions/checkout@v6
185+ with :
186+ ref : ${{ github.event.pull_request.base.ref || github.ref }}
187+ fetch-depth : 1
188+
189+ - name : Set up uv
190+ uses : astral-sh/setup-uv@v3
191+
136192 - name : Generate non-gating PR infographic
137- if : success()
138193 continue-on-error : true
139194 env :
140195 OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
141196 GH_TOKEN : ${{ github.token }}
142- PR_NUMBER : ${{ steps.pr .outputs.pr_number }}
197+ PR_NUMBER : ${{ needs.review .outputs.pr_number }}
143198 run : |
144199 set -euo pipefail
145200 gh pr view "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" --json body --jq '.body // ""' > "${RUNNER_TEMP}/bm-bossbot-pr-body.md"
@@ -150,12 +205,11 @@ jobs:
150205 --output "docs/assets/infographics/pr-${PR_NUMBER}.webp"
151206
152207 - name : Publish non-gating PR infographic
153- if : success()
154208 continue-on-error : true
155209 env :
156210 GH_TOKEN : ${{ github.token }}
157- PR_NUMBER : ${{ steps.pr .outputs.pr_number }}
158- HEAD_REF : ${{ steps.pr .outputs.head_ref }}
211+ PR_NUMBER : ${{ needs.review .outputs.pr_number }}
212+ HEAD_REF : ${{ needs.review .outputs.head_ref }}
159213 run : |
160214 set -euo pipefail
161215 asset_path="docs/assets/infographics/pr-${PR_NUMBER}.webp"
0 commit comments