4949permissions :
5050 actions : read
5151 contents : read
52- issues : write
52+ issues : read
5353 pull-requests : read
5454
5555env :
5858 CLAWSWEEPER_MODEL : internal
5959
6060concurrency :
61- group : ${{ format('clawsweeper-assist-{0}-{1}-{2}', github.event.client_payload.target_repo || inputs.target_repo || 'openclaw/openclaw', github.event.client_payload.item_number || inputs.item_number || github.run_id , github.event.client_payload.comment_id || inputs.comment_id || github.run_id ) }}
61+ group : ${{ format('clawsweeper-assist-{0}-{1}-{2}', github.event.client_payload.target_repo || inputs.target_repo || 'openclaw/openclaw', github.event.client_payload.item_number || inputs.item_number || 'unknown' , github.event.client_payload.comment_id || inputs.comment_id || 'manual' ) }}
6262 cancel-in-progress : false
6363
6464jobs :
7272 with :
7373 sparse-checkout : scripts/dispatch-receipt-owner.sh
7474 sparse-checkout-cone-mode : false
75+ persist-credentials : false
7576
7677 - id : receipt
7778 env :
@@ -117,6 +118,7 @@ jobs:
117118 tsconfig.json
118119 tsconfig.repair.json
119120 sparse-checkout-cone-mode : false
121+ persist-credentials : false
120122
121123 - uses : ./.github/actions/setup-pnpm
122124 with :
@@ -147,7 +149,7 @@ jobs:
147149 printf '%s' "$total"
148150 }
149151
150- for attempt in $(seq 1 80); do
152+ for _ in $(seq 1 80); do
151153 active="$(active_assist_jobs)"
152154 if [ "$active" -lt "$cap" ]; then
153155 echo "proceed=true" >> "$GITHUB_OUTPUT"
@@ -165,34 +167,53 @@ jobs:
165167 if : ${{ needs.capacity.outputs.proceed == 'true' }}
166168 runs-on : ${{ vars.CLAWSWEEPER_WORKER_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }}
167169 timeout-minutes : 8
170+ outputs :
171+ generation_attempt : ${{ steps.generate.outputs.generation_attempt }}
168172 steps :
169173 - uses : actions/checkout@v7
170174 with :
175+ ref : ${{ github.sha }}
171176 filter : blob:none
177+ persist-credentials : false
178+
179+ - uses : ./.github/actions/setup-pnpm
180+ with :
181+ build-script : build
172182
173- - name : Create GitHub App token
174- id : app_token
183+ - name : Resolve validated target repository
184+ id : target
185+ env :
186+ TARGET_REPO : ${{ github.event.client_payload.target_repo || inputs.target_repo }}
187+ run : |
188+ set -euo pipefail
189+ resolved="$(node dist/clawsweeper.js assist-target --target-repo "$TARGET_REPO")"
190+ {
191+ echo "target_repo=$(jq -er '.repo' <<< "$resolved")"
192+ echo "target_repo_owner=$(jq -er '.owner' <<< "$resolved")"
193+ echo "target_repo_name=$(jq -er '.repository' <<< "$resolved")"
194+ } >> "$GITHUB_OUTPUT"
195+
196+ - name : Create read-only GitHub App token
197+ id : read_token
175198 uses : actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
176199 with :
177200 client-id : ${{ env.CLAWSWEEPER_APP_CLIENT_ID }}
178201 private-key : ${{ secrets.CLAWSWEEPER_APP_PRIVATE_KEY }}
179- owner : ${{ vars.CLAWSWEEPER_ALLOWED_OWNER || github.repository_owner }}
180- permission-issues : write
181- permission-pull-requests : write
182-
183- - uses : ./.github/actions/setup-pnpm
184- with :
185- build-script : build
202+ owner : ${{ steps.target.outputs.target_repo_owner }}
203+ repositories : ${{ steps.target.outputs.target_repo_name }}
204+ permission-issues : read
205+ permission-pull-requests : read
186206
187207 - uses : ./.github/actions/setup-codex
188208 env :
189209 OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
190210 CLAWSWEEPER_INTERNAL_MODEL : ${{ secrets.CLAWSWEEPER_MODEL }}
191211
192- - name : Answer maintainer question
212+ - name : Generate bounded assist artifact
213+ id : generate
193214 env :
194- GH_TOKEN : ${{ steps.app_token .outputs.token }}
195- TARGET_REPO : ${{ github.event.client_payload.target_repo || inputs .target_repo }}
215+ GH_TOKEN : ${{ steps.read_token .outputs.token }}
216+ TARGET_REPO : ${{ steps.target.outputs .target_repo }}
196217 ITEM_NUMBER : ${{ github.event.client_payload.item_number || inputs.item_number }}
197218 QUESTION : ${{ github.event.client_payload.question || inputs.question }}
198219 MODE : ${{ github.event.client_payload.assist.mode || github.event.client_payload.mode || inputs.mode || 'assist' }}
@@ -205,7 +226,8 @@ jobs:
205226 TIMEOUT_MS : ${{ github.event.client_payload.assist.timeout_ms || github.event.client_payload.timeout_ms || '120000' }}
206227 run : |
207228 set -euo pipefail
208- node dist/clawsweeper.js assist \
229+ test -n "$GH_TOKEN"
230+ node dist/clawsweeper.js assist-generate \
209231 --target-repo "$TARGET_REPO" \
210232 --item-number "$ITEM_NUMBER" \
211233 --question "$QUESTION" \
@@ -217,4 +239,125 @@ jobs:
217239 --codex-model "$MODEL" \
218240 --codex-reasoning-effort "$REASONING_EFFORT" \
219241 --codex-sandbox read-only \
220- --codex-timeout-ms "$TIMEOUT_MS"
242+ --codex-timeout-ms "$TIMEOUT_MS" \
243+ --run-id "$GITHUB_RUN_ID" \
244+ --run-attempt "$GITHUB_RUN_ATTEMPT" \
245+ --artifact .artifacts/assist-result.json
246+ echo "generation_attempt=$GITHUB_RUN_ATTEMPT" >> "$GITHUB_OUTPUT"
247+
248+ - name : Upload assist artifact
249+ uses : actions/upload-artifact@v7
250+ with :
251+ name : clawsweeper-assist-${{ github.run_id }}-${{ steps.generate.outputs.generation_attempt }}
252+ path : .artifacts/assist-result.json
253+ include-hidden-files : true
254+ if-no-files-found : error
255+ retention-days : 1
256+
257+ publish :
258+ name : Publish trusted assist comment
259+ needs : assist
260+ if : ${{ needs.assist.result == 'success' }}
261+ runs-on : ubuntu-latest
262+ timeout-minutes : 5
263+ steps :
264+ - uses : actions/checkout@v7
265+ with :
266+ ref : ${{ github.sha }}
267+ filter : blob:none
268+ persist-credentials : false
269+
270+ - uses : ./.github/actions/setup-pnpm
271+ with :
272+ build-script : build
273+
274+ - name : Verify exact workflow source
275+ run : test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
276+
277+ - name : Resolve validated target repository
278+ id : target
279+ env :
280+ TARGET_REPO : ${{ github.event.client_payload.target_repo || inputs.target_repo }}
281+ run : |
282+ set -euo pipefail
283+ resolved="$(node dist/clawsweeper.js assist-target --target-repo "$TARGET_REPO")"
284+ {
285+ echo "target_repo=$(jq -er '.repo' <<< "$resolved")"
286+ echo "target_repo_owner=$(jq -er '.owner' <<< "$resolved")"
287+ echo "target_repo_name=$(jq -er '.repository' <<< "$resolved")"
288+ } >> "$GITHUB_OUTPUT"
289+
290+ - name : Download assist artifact
291+ uses : actions/download-artifact@v8
292+ with :
293+ name : clawsweeper-assist-${{ github.run_id }}-${{ needs.assist.outputs.generation_attempt }}
294+ path : .artifacts/publish
295+
296+ - name : Validate untrusted assist artifact
297+ env :
298+ TARGET_REPO : ${{ steps.target.outputs.target_repo }}
299+ ITEM_NUMBER : ${{ github.event.client_payload.item_number || inputs.item_number }}
300+ QUESTION : ${{ github.event.client_payload.question || inputs.question }}
301+ MODE : ${{ github.event.client_payload.assist.mode || github.event.client_payload.mode || inputs.mode || 'assist' }}
302+ LENS : ${{ github.event.client_payload.assist.lens || github.event.client_payload.lens || inputs.lens || 'auto' }}
303+ COMMENT_ID : ${{ github.event.client_payload.comment_id || inputs.comment_id || '' }}
304+ COMMENT_URL : ${{ github.event.client_payload.comment_url || inputs.comment_url || '' }}
305+ AUTHOR : ${{ github.event.client_payload.author || inputs.author || '' }}
306+ REASONING_EFFORT : high
307+ GENERATION_ATTEMPT : ${{ needs.assist.outputs.generation_attempt }}
308+ run : |
309+ set -euo pipefail
310+ node dist/clawsweeper.js assist-validate \
311+ --artifact .artifacts/publish/assist-result.json \
312+ --target-repo "$TARGET_REPO" \
313+ --item-number "$ITEM_NUMBER" \
314+ --question "$QUESTION" \
315+ --mode "$MODE" \
316+ --lens "$LENS" \
317+ --comment-id "$COMMENT_ID" \
318+ --comment-url "$COMMENT_URL" \
319+ --author "$AUTHOR" \
320+ --codex-reasoning-effort "$REASONING_EFFORT" \
321+ --run-id "$GITHUB_RUN_ID" \
322+ --run-attempt "$GENERATION_ATTEMPT"
323+
324+ - name : Create narrow GitHub App write token
325+ id : write_token
326+ uses : actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
327+ with :
328+ client-id : ${{ env.CLAWSWEEPER_APP_CLIENT_ID }}
329+ private-key : ${{ secrets.CLAWSWEEPER_APP_PRIVATE_KEY }}
330+ owner : ${{ steps.target.outputs.target_repo_owner }}
331+ repositories : ${{ steps.target.outputs.target_repo_name }}
332+ permission-issues : write
333+ permission-pull-requests : write
334+
335+ - name : Revalidate and publish assist comment
336+ env :
337+ GH_TOKEN : ${{ steps.write_token.outputs.token }}
338+ TARGET_REPO : ${{ steps.target.outputs.target_repo }}
339+ ITEM_NUMBER : ${{ github.event.client_payload.item_number || inputs.item_number }}
340+ QUESTION : ${{ github.event.client_payload.question || inputs.question }}
341+ MODE : ${{ github.event.client_payload.assist.mode || github.event.client_payload.mode || inputs.mode || 'assist' }}
342+ LENS : ${{ github.event.client_payload.assist.lens || github.event.client_payload.lens || inputs.lens || 'auto' }}
343+ COMMENT_ID : ${{ github.event.client_payload.comment_id || inputs.comment_id || '' }}
344+ COMMENT_URL : ${{ github.event.client_payload.comment_url || inputs.comment_url || '' }}
345+ AUTHOR : ${{ github.event.client_payload.author || inputs.author || '' }}
346+ REASONING_EFFORT : high
347+ GENERATION_ATTEMPT : ${{ needs.assist.outputs.generation_attempt }}
348+ run : |
349+ set -euo pipefail
350+ test -n "$GH_TOKEN"
351+ node dist/clawsweeper.js assist-publish \
352+ --artifact .artifacts/publish/assist-result.json \
353+ --target-repo "$TARGET_REPO" \
354+ --item-number "$ITEM_NUMBER" \
355+ --question "$QUESTION" \
356+ --mode "$MODE" \
357+ --lens "$LENS" \
358+ --comment-id "$COMMENT_ID" \
359+ --comment-url "$COMMENT_URL" \
360+ --author "$AUTHOR" \
361+ --codex-reasoning-effort "$REASONING_EFFORT" \
362+ --run-id "$GITHUB_RUN_ID" \
363+ --run-attempt "$GENERATION_ATTEMPT"
0 commit comments