Skip to content

Commit 3d2a878

Browse files
steipetePeter Steinberger
andauthored
fix: restore automatic high-confidence OpenClaw bug repairs (#972)
* fix: restore automatic high-confidence OpenClaw bug repairs * fix: prevent automatic bug-repair backlog starvation * fix: bound bug repair dispatch and retry transient state failures * perf: hydrate one canonical issue record for automatic bug repair * fix: recover starved bug workers and malformed canonical records * fix: release stale publication handoff reservations * fix: ignore only confirmed closed historical fix pull requests * fix: accelerate bug repair and fence bulk-filed issue races * test: recognize focused cluster worker state hydration --------- Co-authored-by: Peter Steinberger <[email protected]>
1 parent 12af8b7 commit 3d2a878

43 files changed

Lines changed: 2445 additions & 216 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/actions/setup-state/action.yml‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ inputs:
5353
description: Optional comma/newline-separated record repository slugs.
5454
required: false
5555
default: ""
56+
records-item-number:
57+
description: Hydrate only this canonical issue record instead of the complete repository snapshot.
58+
required: false
59+
default: ""
5660
records-secret:
5761
description: HMAC secret used for canonical Worker hydration.
5862
required: false
@@ -113,6 +117,7 @@ runs:
113117
node-version: ${{ inputs.node-version }}
114118

115119
- name: Resolve canonical record snapshot cache key
120+
if: ${{ inputs.records-item-number == '' }}
116121
id: records-snapshot
117122
shell: bash
118123
env:
@@ -123,7 +128,7 @@ runs:
123128
run: node "${{ inputs.worktree-path }}/scripts/prepare-worker-record-cache.ts"
124129

125130
- name: Restore canonical record snapshot
126-
if: ${{ steps.records-snapshot.outputs.available == 'true' }}
131+
if: ${{ inputs.records-item-number == '' && steps.records-snapshot.outputs.available == 'true' }}
127132
uses: actions/cache@v6
128133
with:
129134
path: ${{ inputs.worktree-path }}/.artifacts/worker-records-cache
@@ -145,6 +150,7 @@ runs:
145150
CLAWSWEEPER_RECORDS_URL: ${{ inputs.records-url }}
146151
CLAWSWEEPER_RECORDS_REPO_SLUGS: ${{ inputs.records-repo-slugs }}
147152
CLAWSWEEPER_RECORDS_SECRET: ${{ inputs.records-secret }}
153+
RECORDS_ITEM_NUMBER: ${{ inputs.records-item-number }}
148154
CLAWSWEEPER_RECORDS_CACHE_DIR: ${{ inputs.worktree-path }}/.artifacts/worker-records-cache
149155
CLAWSWEEPER_BLOBS_CACHE_DIR: ${{ inputs.worktree-path }}/.artifacts/worker-blobs-cache
150156
HYDRATE_STATE_BLOBS: ${{ inputs.hydrate-state-blobs }}
@@ -164,4 +170,7 @@ runs:
164170
false) hydrate_args+=(--skip-git-state) ;;
165171
*) echo "hydrate-git-state must be true or false" >&2; exit 2 ;;
166172
esac
173+
if [ -n "$RECORDS_ITEM_NUMBER" ]; then
174+
hydrate_args+=(--records-item-number "$RECORDS_ITEM_NUMBER")
175+
fi
167176
node "${{ inputs.worktree-path }}/scripts/hydrate-state.ts" "${hydrate_args[@]}"

‎.github/workflows/exact-review-batch-publish.yml‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ jobs:
137137
env:
138138
CLAWSWEEPER_WEBHOOK_SECRET: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
139139
GH_TOKEN: ${{ github.token }}
140+
AUTO_IMPLEMENT_ISSUES: ${{ vars.CLAWSWEEPER_AUTO_IMPLEMENT_ISSUES }}
141+
MAX_DISPATCH: ${{ vars.CLAWSWEEPER_AUTO_IMPLEMENT_MAX_DISPATCH_PER_SWEEP || '' }}
140142
CLAWSWEEPER_COMMENT_LOOKBACK_MINUTES: ${{ vars.CLAWSWEEPER_COMMENT_LOOKBACK_MINUTES || '180' }}
141143
CLAWSWEEPER_COMMENT_MAX_COMMENTS: ${{ vars.CLAWSWEEPER_COMMENT_MAX_COMMENTS || '1000' }}
142144
run: |
@@ -162,6 +164,17 @@ jobs:
162164
pnpm run --silent repair:exact-review-batch commit
163165
test ! -f "$heartbeat_failed"
164166
receipt_path="$(dirname "$EXACT_REVIEW_BATCH_MANIFEST")/state-receipt.json"
167+
remaining_implementations="$MAX_DISPATCH"
168+
if [ -z "$remaining_implementations" ]; then
169+
if ! remaining_implementations="$(pnpm run --silent workflow -- limit issue_implementation.dispatches_per_sweep_default)"; then
170+
echo "::warning::Unable to resolve the automatic issue implementation dispatch limit; scheduled backfill will retry."
171+
remaining_implementations=0
172+
fi
173+
fi
174+
if ! [[ "$remaining_implementations" =~ ^[0-9]+$ ]] || [ "$remaining_implementations" -gt 100 ]; then
175+
echo "::warning::Invalid automatic issue implementation dispatch limit; scheduled backfill will retry."
176+
remaining_implementations=0
177+
fi
165178
jq -c '.items[]' "$EXACT_REVIEW_BATCH_MANIFEST" | while IFS= read -r item; do
166179
test ! -f "$heartbeat_failed"
167180
outcome_path="$(jq -r '.outcomePath' <<<"$item")"
@@ -231,6 +244,31 @@ jobs:
231244
exit "$github_apply_status"
232245
fi
233246
fi
247+
if [ "$AUTO_IMPLEMENT_ISSUES" = "1" ] &&
248+
[ "$remaining_implementations" -gt 0 ] &&
249+
[ "$target_repo" = "openclaw/openclaw" ] &&
250+
[ "$(jq -r '.decision.itemKind' <<<"$item")" = "issue" ] &&
251+
jq -e '.kind == "eligible"' "$outcome_path" >/dev/null; then
252+
report_path="${outcome_path%.json}.report.md"
253+
if [ -f "$report_path" ]; then
254+
if implementation_output="$(node scripts/dispatch-issue-implementation-candidates.mjs \
255+
--target-repo "$target_repo" \
256+
--item-number "$item_number" \
257+
--artifact-dir "$(dirname "$report_path")" \
258+
--max-dispatch "$remaining_implementations")"; then
259+
printf '%s\n' "$implementation_output"
260+
if dispatched="$(printf '%s\n' "$implementation_output" | tail -n 1 | jq -er '.dispatched')" &&
261+
[[ "$dispatched" =~ ^[01]$ ]]; then
262+
remaining_implementations=$((remaining_implementations - dispatched))
263+
else
264+
echo "::warning::Automatic issue implementation returned an invalid dispatch count; stopping batch dispatch."
265+
remaining_implementations=0
266+
fi
267+
else
268+
echo "::warning::Automatic issue implementation dispatch failed; scheduled backfill will retry."
269+
fi
270+
fi
271+
fi
234272
temporary="${outcome_path}.tmp"
235273
jq '.postEffectsComplete = true' "$outcome_path" > "$temporary"
236274
mv "$temporary" "$outcome_path"

‎.github/workflows/repair-cluster-worker.yml‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,23 @@ jobs:
223223
exit 1
224224
fi
225225
echo "target_owner=$owner" >> "$GITHUB_OUTPUT"
226+
job_file="${JOB_PATH##*/}"
227+
owner_slug="$(printf '%s' "$owner" | tr '[:upper:]' '[:lower:]')"
228+
if [[ "$job_file" == "issue-${owner_slug}-"*.md ]]; then
229+
issue_target="${job_file#issue-${owner_slug}-}"
230+
issue_target="${issue_target%.md}"
231+
item_number="${issue_target##*-}"
232+
repository="${issue_target%-${item_number}}"
233+
if ! [[ "$item_number" =~ ^[1-9][0-9]*$ ]] ||
234+
! [[ "$repository" =~ ^[A-Za-z0-9_.-]+$ ]]; then
235+
echo "Invalid issue implementation target: $job_file" >&2
236+
exit 1
237+
fi
238+
{
239+
echo "target_slug=${owner_slug}-${repository}"
240+
echo "records_item_number=$item_number"
241+
} >> "$GITHUB_OUTPUT"
242+
fi
226243
227244
- name: Create GitHub App token
228245
id: app_token
@@ -255,6 +272,8 @@ jobs:
255272
with:
256273
coordinator-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
257274
records-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
275+
records-repo-slugs: ${{ steps.target.outputs.target_slug || '' }}
276+
records-item-number: ${{ steps.target.outputs.records_item_number || '' }}
258277
records-secret: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
259278
hydrate-state-blobs: "false"
260279
token: ${{ steps.state-token.outputs.token }}
@@ -480,7 +499,8 @@ jobs:
480499
CLAWSWEEPER_ALLOW_EXECUTE: ${{ needs.cluster.outputs.allow_execute == '1' && '1' || '0' }}
481500
CLAWSWEEPER_ALLOW_FIX_PR: ${{ needs.cluster.outputs.allow_fix_pr == '1' && '1' || '0' }}
482501
CLAWSWEEPER_ALLOW_MERGE: ${{ needs.cluster.outputs.allow_merge || '0' }}
483-
CLAWSWEEPER_CODEX_REASONING_EFFORT: ${{ vars.CLAWSWEEPER_CODEX_REASONING_EFFORT || 'high' }}
502+
CLAWSWEEPER_OPENCLAW_MODEL: ${{ contains(inputs.job, '/inbox/issue-') && format('openai/{0}', vars.CLAWSWEEPER_FIX_PR_MODEL || 'gpt-5.6-sol') || secrets.CLAWSWEEPER_OPENCLAW_MODEL }}
503+
CLAWSWEEPER_CODEX_REASONING_EFFORT: ${{ contains(inputs.job, '/inbox/issue-') && (vars.CLAWSWEEPER_FIX_PR_REASONING_EFFORT || 'xhigh') || vars.CLAWSWEEPER_CODEX_REASONING_EFFORT || 'high' }}
484504
CLAWSWEEPER_CODEX_REVIEW_ATTEMPTS: ${{ vars.CLAWSWEEPER_CODEX_REVIEW_ATTEMPTS || '4' }}
485505
CLAWSWEEPER_FIX_CODEX_TIMEOUT_MS: ${{ vars.CLAWSWEEPER_FIX_CODEX_TIMEOUT_MS || '1800000' }}
486506
CLAWSWEEPER_FIX_STEP_TIMEOUT_MS: ${{ vars.CLAWSWEEPER_FIX_STEP_TIMEOUT_MS || '4200000' }}
@@ -520,6 +540,23 @@ jobs:
520540
exit 1
521541
fi
522542
echo "target_owner=$owner" >> "$GITHUB_OUTPUT"
543+
job_file="${JOB_PATH##*/}"
544+
owner_slug="$(printf '%s' "$owner" | tr '[:upper:]' '[:lower:]')"
545+
if [[ "$job_file" == "issue-${owner_slug}-"*.md ]]; then
546+
issue_target="${job_file#issue-${owner_slug}-}"
547+
issue_target="${issue_target%.md}"
548+
item_number="${issue_target##*-}"
549+
repository="${issue_target%-${item_number}}"
550+
if ! [[ "$item_number" =~ ^[1-9][0-9]*$ ]] ||
551+
! [[ "$repository" =~ ^[A-Za-z0-9_.-]+$ ]]; then
552+
echo "Invalid issue implementation target: $job_file" >&2
553+
exit 1
554+
fi
555+
{
556+
echo "target_slug=${owner_slug}-${repository}"
557+
echo "records_item_number=$item_number"
558+
} >> "$GITHUB_OUTPUT"
559+
fi
523560
524561
- name: Create GitHub App token
525562
id: target_write_token
@@ -556,6 +593,8 @@ jobs:
556593
with:
557594
coordinator-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
558595
records-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
596+
records-repo-slugs: ${{ steps.target.outputs.target_slug || '' }}
597+
records-item-number: ${{ steps.target.outputs.records_item_number || '' }}
559598
records-secret: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
560599
hydrate-state-blobs: "false"
561600
token: ${{ steps.state-token.outputs.token }}
@@ -600,7 +639,7 @@ jobs:
600639
if: ${{ env.CLAWSWEEPER_RUNNER != 'openclaw' && steps.check_job.outputs.job_exists == '1' }}
601640
env:
602641
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
603-
CLAWSWEEPER_INTERNAL_MODEL: ${{ secrets.CLAWSWEEPER_MODEL }}
642+
CLAWSWEEPER_INTERNAL_MODEL: ${{ contains(inputs.job, '/inbox/issue-') && (vars.CLAWSWEEPER_FIX_PR_MODEL || 'gpt-5.6-sol') || secrets.CLAWSWEEPER_MODEL }}
604643
with:
605644
cache-suffix: target-pnpm
606645
codex-home: ${{ steps.codex_session.outputs.codex_home }}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Backfill automatic OpenClaw bug fixes
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "7/10 * * * *"
7+
8+
permissions:
9+
actions: write
10+
contents: read
11+
12+
concurrency:
13+
group: automatic-openclaw-issue-implementation-backfill
14+
cancel-in-progress: false
15+
16+
jobs:
17+
backfill:
18+
if: ${{ vars.CLAWSWEEPER_AUTO_IMPLEMENT_ISSUES == '1' }}
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 15
21+
steps:
22+
- uses: actions/checkout@v7
23+
with:
24+
ref: main
25+
filter: blob:none
26+
fetch-depth: 1
27+
persist-credentials: false
28+
29+
- uses: ./.github/actions/setup-pnpm
30+
with:
31+
build-script: build:repair
32+
33+
- name: Create state token
34+
id: state-token
35+
uses: ./.github/actions/create-state-token
36+
with:
37+
client-id: Iv23liOECG0slfuhz093
38+
private-key: ${{ secrets.CLAWSWEEPER_APP_PRIVATE_KEY }}
39+
40+
- uses: ./.github/actions/setup-state
41+
with:
42+
coordinator-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
43+
coordinator-class: cluster_intake
44+
records-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
45+
records-secret: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
46+
records-repo-slugs: openclaw-openclaw
47+
hydrate-state-blobs: "false"
48+
token: ${{ steps.state-token.outputs.token }}
49+
sparse-checkout: |
50+
jobs
51+
results
52+
53+
- name: Dispatch bounded high-confidence bug candidates
54+
env:
55+
GH_TOKEN: ${{ github.token }}
56+
MAX_DISPATCH: ${{ vars.CLAWSWEEPER_AUTO_IMPLEMENT_MAX_DISPATCH_PER_SWEEP || '' }}
57+
run: |
58+
node scripts/dispatch-issue-implementation-candidates.mjs \
59+
--target-repo openclaw/openclaw \
60+
--report-dir records/openclaw-openclaw/items

‎.github/workflows/repair-issue-implementation-intake.yml‎

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ jobs:
162162
- uses: ./.github/actions/setup-state
163163
with:
164164
coordinator-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
165+
coordinator-class: cluster_intake
165166
records-url: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
166167
records-secret: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
167168
records-repo-slugs: ${{ steps.target.outputs.target_slug }}
169+
records-item-number: ${{ github.event.inputs.item_number || github.event.client_payload.item_number }}
168170
hydrate-state-blobs: "false"
169171
token: ${{ steps.state-token.outputs.token }}
170172
fetch-depth: 1
@@ -176,7 +178,7 @@ jobs:
176178
id: prepare
177179
env:
178180
GH_TOKEN: ${{ steps.target-token.outputs.token }}
179-
ENABLED: ${{ github.event.inputs.enabled || github.event.client_payload.enabled || vars.CLAWSWEEPER_AUTO_IMPLEMENT_REPRO_BUGS || 'false' }}
181+
ENABLED: ${{ github.event.inputs.enabled || github.event.client_payload.enabled || vars.CLAWSWEEPER_AUTO_IMPLEMENT_ISSUES || 'false' }}
180182
TARGET_REPO: ${{ github.event.inputs.target_repo || github.event.client_payload.target_repo || 'openclaw/openclaw' }}
181183
ITEM_NUMBER: ${{ github.event.inputs.item_number || github.event.client_payload.item_number }}
182184
CANDIDATE_KIND: ${{ github.event.inputs.candidate_kind || github.event.client_payload.candidate_kind || 'strict_bug' }}
@@ -210,12 +212,18 @@ jobs:
210212
CLAWSWEEPER_WEBHOOK_SECRET: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
211213
run: |
212214
set -euo pipefail
213-
pnpm run repair:publish-main -- \
214-
--message "chore: record issue implementation intake" \
215-
--path jobs \
216-
--path results \
217-
--max-attempts 12 \
218-
--push-attempts 4
215+
for attempt in 1 2 3; do
216+
if pnpm run repair:publish-main -- \
217+
--message "chore: record issue implementation intake" \
218+
--path jobs \
219+
--path results \
220+
--max-attempts 12 \
221+
--push-attempts 4; then
222+
exit 0
223+
fi
224+
[ "$attempt" -lt 3 ] || exit 1
225+
sleep "$((attempt * 3))"
226+
done
219227
220228
- name: Publish automatic implementation queue status
221229
if: ${{ steps.prepare.outputs.should_repair == 'true' }}
@@ -232,25 +240,49 @@ jobs:
232240
--run-url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
233241
234242
- name: Dispatch repair worker
235-
if: ${{ steps.prepare.outputs.should_repair == 'true' }}
243+
if: ${{ steps.prepare.outputs.should_repair == 'true' || steps.prepare.outputs.existing_job_path != '' }}
236244
env:
237245
GH_TOKEN: ${{ steps.dispatch-token.outputs.token }}
238246
MAX_LIVE_WORKERS: ${{ vars.CLAWSWEEPER_AUTO_IMPLEMENT_MAX_LIVE_WORKERS || '' }}
239247
RUNNER: ${{ github.event.inputs.runner || github.event.client_payload.runner || vars.CLAWSWEEPER_WORKER_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }}
240248
EXECUTION_RUNNER: ${{ github.event.inputs.execution_runner || github.event.client_payload.execution_runner || vars.CLAWSWEEPER_EXECUTION_RUNNER || 'blacksmith-16vcpu-ubuntu-2404' }}
241249
MODEL: internal
250+
JOB_PATH: ${{ steps.prepare.outputs.job_path || steps.prepare.outputs.existing_job_path }}
242251
run: |
243252
set -euo pipefail
244253
cap_args=()
245254
if [ -n "$MAX_LIVE_WORKERS" ]; then
246255
cap_args=(--max-live-workers "$MAX_LIVE_WORKERS")
247256
fi
248257
git pull --rebase --autostash
249-
pnpm run repair:dispatch -- "${{ steps.prepare.outputs.job_path }}" \
258+
pnpm run repair:dispatch -- "$JOB_PATH" \
250259
--mode autonomous \
251260
--wait-for-capacity \
252261
"${cap_args[@]}" \
253262
--runner "$RUNNER" \
254263
--execution-runner "$EXECUTION_RUNNER" \
255264
--model "$MODEL" \
256265
--ref main
266+
267+
- name: Record successful repair worker dispatch
268+
if: ${{ steps.prepare.outputs.should_repair == 'true' || steps.prepare.outputs.existing_job_path != '' }}
269+
env:
270+
CLAWSWEEPER_WEBHOOK_SECRET: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
271+
AUDIT_PATH: ${{ steps.prepare.outputs.audit_path }}
272+
JOB_PATH: ${{ steps.prepare.outputs.job_path || steps.prepare.outputs.existing_job_path }}
273+
run: |
274+
set -euo pipefail
275+
pnpm run repair:issue-implementation-intake -- mark-dispatched \
276+
--audit-path "$AUDIT_PATH" \
277+
--job-path "$JOB_PATH"
278+
for attempt in 1 2 3; do
279+
if pnpm run repair:publish-main -- \
280+
--message "chore: record issue implementation worker dispatch" \
281+
--path "$AUDIT_PATH" \
282+
--max-attempts 12 \
283+
--push-attempts 4; then
284+
exit 0
285+
fi
286+
[ "$attempt" -lt 3 ] || exit 1
287+
sleep "$((attempt * 3))"
288+
done

0 commit comments

Comments
 (0)