@@ -696,6 +696,7 @@ jobs:
696696 if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.target.outputs.target_enabled == 'true' }}
697697 id: live-item
698698 env:
699+ CLAIM_DECISION: ${{ steps.claim-exact-review-queue.outputs.decision }}
699700 GH_TOKEN: ${{ steps.target-read-token.outputs.token }}
700701 TARGET_REPO: ${{ steps.target.outputs.target_repo }}
701702 ITEM_NUMBER: ${{ steps.target.outputs.item_number }}
@@ -704,11 +705,47 @@ jobs:
704705 set -euo pipefail
705706 test -n "$GH_TOKEN"
706707 target_branch="$CLAIM_TARGET_BRANCH"
707- if ! printf '%s' "$target_branch" | grep -Eq '^[A-Za-z0-9_.\/-]+$'; then
708- echo "Invalid target branch for $TARGET_REPO: $target_branch" >&2
709- exit 1
708+ branch_is_usable() {
709+ local branch="$1"
710+ [ -n "$branch" ] &&
711+ printf '%s' "$branch" | grep -Eq '^[A-Za-z0-9_.\/-]+$' &&
712+ ! printf '%s' "$branch" | grep -Eq '^[0-9]+$' &&
713+ [[ "$branch" != *".."* ]]
714+ }
715+ if ! branch_is_usable "$target_branch"; then
716+ queued_target_branch="$target_branch"
717+ branch_error="$(mktemp)"
718+ if ! target_branch="$(gh api "repos/$TARGET_REPO" --jq '.default_branch // empty' 2>"$branch_error")" ||
719+ ! branch_is_usable "$target_branch"; then
720+ echo "::warning::Unable to resolve a usable default branch for $TARGET_REPO after queued target branch '$queued_target_branch' was rejected; releasing the claim for retry."
721+ cat "$branch_error" >&2
722+ rm -f "$branch_error"
723+ retry_at="$(node -e 'process.stdout.write(new Date(Date.now() + 5 * 60_000).toISOString())')"
724+ {
725+ echo "admission_retry=true"
726+ echo "retry_at=$retry_at"
727+ echo "proceed=false"
728+ echo "terminal_noop=false"
729+ echo "terminal_missing=false"
730+ echo "guarded_open=false"
731+ echo "guarded_open_action="
732+ } >> "$GITHUB_OUTPUT"
733+ exit 0
734+ fi
735+ rm -f "$branch_error"
736+ echo "::warning::Resolved invalid queued target branch '$queued_target_branch' to default branch '$target_branch' for $TARGET_REPO."
710737 fi
711- echo "target_branch=$target_branch" >> "$GITHUB_OUTPUT"
738+ effective_decision="$(CLAIM_DECISION="$CLAIM_DECISION" TARGET_BRANCH="$target_branch" node <<'NODE'
739+ const decision = JSON.parse(process.env.CLAIM_DECISION || "{}");
740+ decision.targetBranch = process.env.TARGET_BRANCH;
741+ process.stdout.write(JSON.stringify(decision));
742+ NODE
743+ )"
744+ {
745+ echo "admission_retry=false"
746+ echo "target_branch=$target_branch"
747+ echo "decision=$effective_decision"
748+ } >> "$GITHUB_OUTPUT"
712749 live_item_error="$(mktemp)"
713750 if ! live_item="$(gh api "repos/$TARGET_REPO/issues/$ITEM_NUMBER" 2>"$live_item_error")"; then
714751 if grep -Eqi 'HTTP 404|Not Found' "$live_item_error" && gh api "repos/$TARGET_REPO" >/dev/null; then
@@ -760,7 +797,7 @@ jobs:
760797 esac
761798
762799 - name: Create target write token
763- if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.live-item.outcome == 'success' }}
800+ if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.live-item.outcome == 'success' && steps.live-item.outputs.admission_retry != 'true' }}
764801 id: target-write-token
765802 continue-on-error: true
766803 uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
@@ -777,7 +814,7 @@ jobs:
777814
778815 - uses: ./.github/actions/setup-pnpm
779816 id: setup-pnpm
780- if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.live-item.outcome == 'success' }}
817+ if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.live-item.outcome == 'success' && steps.live-item.outputs.admission_retry != 'true' }}
781818 with:
782819 build-script: ${{ steps.live-item.outputs.proceed == 'true' && 'build:all' || 'build:repair' }}
783820
@@ -1208,12 +1245,12 @@ jobs:
12081245
12091246 - name: Create exact review artifact bundle
12101247 id: create-exact-review-bundle
1211- if: ${{ always() && steps.claim-exact-review-queue.outputs.claimed == 'true' && !cancelled() && steps.target.outputs.target_enabled == 'true' && steps.live-item.outcome == 'success' && steps.setup-pnpm.outcome == 'success' && steps.review-exact-event-item.outputs.superseded != 'true' && (steps.live-item.outputs.proceed != 'true' || (steps.review-exact-event-item.outcome == 'success' && steps.review-exact-event-item.outputs.retry_at == '')) }}
1248+ if: ${{ always() && steps.claim-exact-review-queue.outputs.claimed == 'true' && !cancelled() && steps.target.outputs.target_enabled == 'true' && steps.live-item.outcome == 'success' && steps.live-item.outputs.admission_retry != 'true' && steps. setup-pnpm.outcome == 'success' && steps.review-exact-event-item.outputs.superseded != 'true' && (steps.live-item.outputs.proceed != 'true' || (steps.review-exact-event-item.outcome == 'success' && steps.review-exact-event-item.outputs.retry_at == '')) }}
12121249 env:
12131250 EXACT_REVIEW_ACTION_LEDGER_ROOT: ${{ env.CLAWSWEEPER_ACTION_LEDGER_OUTPUT_ROOT }}
12141251 EXACT_REVIEW_BUNDLE_DIR: .artifacts/exact-review-bundle
12151252 EXACT_REVIEW_CLAIM_GENERATION: ${{ steps.claim-exact-review-queue.outputs.claim_generation }}
1216- EXACT_REVIEW_DECISION: ${{ steps.claim-exact-review-queue .outputs.decision }}
1253+ EXACT_REVIEW_DECISION: ${{ steps.live-item .outputs.decision }}
12171254 EXACT_REVIEW_GENERATION_ATTEMPT: ${{ github.run_attempt }}
12181255 EXACT_REVIEW_ITEM_KEY: ${{ steps.claim-exact-review-queue.outputs.item_key }}
12191256 EXACT_REVIEW_ITEM_KIND: ${{ fromJSON(steps.claim-exact-review-queue.outputs.decision).itemKind }}
@@ -1297,7 +1334,7 @@ jobs:
12971334 if: ${{ always() && steps.claim-exact-review-queue.outputs.claimed == 'true' && !cancelled() && steps.upload-exact-review-bundle.outcome == 'success' }}
12981335 env:
12991336 ARTIFACT_NAME: ${{ steps.create-exact-review-bundle.outputs.artifact_name }}
1300- CLAIM_DECISION: ${{ steps.claim-exact-review-queue .outputs.decision }}
1337+ CLAIM_DECISION: ${{ steps.live-item .outputs.decision }}
13011338 CLAIM_GENERATION: ${{ steps.claim-exact-review-queue.outputs.claim_generation }}
13021339 ITEM_KEY: ${{ steps.claim-exact-review-queue.outputs.item_key }}
13031340 LEASE_REVISION: ${{ steps.claim-exact-review-queue.outputs.lease_revision }}
@@ -1443,6 +1480,7 @@ jobs:
14431480 id: exact-review-generation-result
14441481 if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && always() }}
14451482 env:
1483+ ADMISSION_RETRY: ${{ steps.live-item.outputs.admission_retry }}
14461484 TARGET_ENABLED: ${{ steps.target.outputs.target_enabled }}
14471485 LIVE_OUTCOME: ${{ steps.live-item.outcome }}
14481486 REVIEW_OUTCOME: ${{ steps.review-exact-event-item.outcome }}
@@ -1452,7 +1490,11 @@ jobs:
14521490 DIRECT_PUBLICATION_ACCEPTED: ${{ steps.direct-exact-review-publication.outputs.accepted }}
14531491 run: |
14541492 outcome=failure
1455- if [ "$TARGET_ENABLED" = "false" ]; then
1493+ requeue_latest=false
1494+ if [ "$ADMISSION_RETRY" = "true" ]; then
1495+ outcome=success
1496+ requeue_latest=true
1497+ elif [ "$TARGET_ENABLED" = "false" ]; then
14561498 outcome=success
14571499 elif [ "$RESERVATION_STATUS" = "superseded" ] || [ "$REVIEW_SUPERSEDED" = "true" ]; then
14581500 outcome=success
@@ -1462,6 +1504,7 @@ jobs:
14621504 outcome=success
14631505 fi
14641506 echo "outcome=$outcome" >> "$GITHUB_OUTPUT"
1507+ echo "requeue_latest=$requeue_latest" >> "$GITHUB_OUTPUT"
14651508
14661509 - name: Complete exact-review queue lease
14671510 id: complete-exact-review-queue
@@ -1475,7 +1518,8 @@ jobs:
14751518 QUEUE_LEASE_ID: ${{ steps.claim-exact-review-queue.outputs.lease_id }}
14761519 QUEUE_LEASE_REVISION: ${{ steps.claim-exact-review-queue.outputs.lease_revision }}
14771520 QUEUE_URL: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
1478- RETRY_AT: ${{ steps.reserve-exact-review-lease.outputs.retry_at || steps.review-exact-event-item.outputs.retry_at }}
1521+ REQUEUE_LATEST: ${{ steps.exact-review-generation-result.outputs.requeue_latest }}
1522+ RETRY_AT: ${{ steps.live-item.outputs.retry_at || steps.reserve-exact-review-lease.outputs.retry_at || steps.review-exact-event-item.outputs.retry_at }}
14791523 RUN_ATTEMPT: ${{ github.run_attempt }}
14801524 run: |
14811525 set -euo pipefail
@@ -1500,6 +1544,7 @@ jobs:
15001544 const outcome = ["success", "cancelled", "failure"].includes(primaryOutcome)
15011545 ? primaryOutcome
15021546 : "failure";
1547+ const requeueLatest = process.env.REQUEUE_LATEST === "true";
15031548 const retryAt = String(process.env.RETRY_AT || "").trim();
15041549 process.stdout.write(JSON.stringify({
15051550 lease_id: process.env.QUEUE_LEASE_ID,
@@ -1513,6 +1558,7 @@ jobs:
15131558 run_id: process.env.GITHUB_RUN_ID,
15141559 run_attempt: runAttempt,
15151560 outcome,
1561+ ...(requeueLatest ? { requeue_latest: true } : {}),
15161562 ...(retryAt ? { retry_at: retryAt } : {}),
15171563 }));
15181564 ')"
@@ -2988,18 +3034,29 @@ jobs:
29883034 working-directory: clawsweeper
29893035 env:
29903036 CLAWSWEEPER_WEBHOOK_SECRET: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
3037+ GH_TOKEN: ${{ steps.target-read-token.outputs.token || github.token }}
29913038 QUEUE_URL: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
29923039 run: |
29933040 set -euo pipefail
29943041 lane="normal_backfill"
29953042 if [ "${{ steps.mode.outputs.hot_intake }}" = "true" ]; then
29963043 lane="hot_intake"
29973044 fi
3045+ target_repo="${{ steps.target.outputs.target_repo }}"
3046+ target_branch="$(gh api "repos/$target_repo" --jq '.default_branch // empty')"
3047+ if [ -z "$target_branch" ] ||
3048+ ! printf '%s' "$target_branch" | grep -Eq '^[A-Za-z0-9_.\/-]+$' ||
3049+ printf '%s' "$target_branch" | grep -Eq '^[0-9]+$' ||
3050+ [[ "$target_branch" == *".."* ]]; then
3051+ echo "Invalid default branch for scheduled target $target_repo: $target_branch" >&2
3052+ exit 1
3053+ fi
3054+ echo "::notice::Scheduled review payloads will use default branch '$target_branch' for $target_repo."
29983055 result="$(pnpm run --silent repair:scheduled-review-enqueue -- \
29993056 --plan plan.json \
30003057 --lane "$lane" \
3001- --target-repo "${{ steps.target.outputs. target_repo }} " \
3002- --target-branch "${{ steps.target.outputs. target_branch }} " \
3058+ --target-repo "$target_repo" \
3059+ --target-branch "$target_branch" \
30033060 --queue-url "$QUEUE_URL" \
30043061 --delivery-prefix "scheduled:${{ github.run_id }}:${{ github.run_attempt }}")"
30053062 jq -e '.offered >= .attempted and .attempted >= (.queued + .deduped + .shed + .rejected)' <<<"$result" >/dev/null
0 commit comments