Skip to content

Commit 6eeb028

Browse files
fix: harden scaled review scheduling
1 parent 6b3a2ce commit 6eeb028

13 files changed

Lines changed: 736 additions & 74 deletions

‎.github/workflows/sweep.yml‎

Lines changed: 69 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -908,10 +908,32 @@ jobs:
908908
codex_timeout_seconds=$(((CODEX_TIMEOUT_MS + 999) / 1000))
909909
media_preprocessing_reserve_seconds=480
910910
review_timeout_ms=$(((codex_timeout_seconds + media_preprocessing_reserve_seconds + 180) * 1000))
911-
reservation="$(pnpm run --silent reserve-review-lease -- \
912-
--target-repo "$TARGET_REPO" \
913-
--item-number "$ITEM_NUMBER" \
914-
--review-timeout-ms "$review_timeout_ms")"
911+
reservation=""
912+
reservation_error="$(mktemp)"
913+
trap 'rm -f "$reservation_error"' EXIT
914+
for attempt in 1 2 3 4 5; do
915+
: > "$reservation_error"
916+
if reservation="$(pnpm run --silent reserve-review-lease -- \
917+
--target-repo "$TARGET_REPO" \
918+
--item-number "$ITEM_NUMBER" \
919+
--review-timeout-ms "$review_timeout_ms" 2>"$reservation_error")"; then
920+
break
921+
else
922+
reserve_exit=$?
923+
fi
924+
if ! grep -Eqi '(exact-review queue authority changed|review revision changed|could not (confirm|identify).+review lease).+retry required' "$reservation_error"; then
925+
cat "$reservation_error" >&2
926+
exit "$reserve_exit"
927+
fi
928+
if [ "$attempt" -eq 5 ]; then
929+
echo "::notice::Exact-review reservation contention did not settle after 5 attempts; queue authority moved on, so this run is a successful no-op."
930+
reservation='{"status":"superseded"}'
931+
break
932+
fi
933+
delay_seconds=$((attempt * 2 + RANDOM % 4))
934+
echo "::notice::Exact-review reservation contention on attempt $attempt/5; retrying in ${delay_seconds}s."
935+
sleep "$delay_seconds"
936+
done
915937
echo "$reservation"
916938
RESERVATION="$reservation" node <<'NODE'
917939
const fs = require("node:fs");
@@ -935,16 +957,26 @@ jobs:
935957
append("retry_at", new Date(retryAt).toISOString());
936958
process.exit(0);
937959
}
960+
if (reservation.status === "superseded") {
961+
append("status", "superseded");
962+
process.exit(0);
963+
}
938964
process.exit(1);
939965
NODE
940966
941967
# At-least-once queue delivery can overlap an exact-head review that is already
942968
# running. The durable queue owns retry, so lease contention is deferred work.
943969
- name: Defer exact review while same-head lease is held
944-
if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && steps.reserve-exact-review-lease.outputs.status == 'held' }}
970+
if: ${{ steps.claim-exact-review-queue.outputs.claimed == 'true' && (steps.reserve-exact-review-lease.outputs.status == 'held' || steps.reserve-exact-review-lease.outputs.status == 'superseded') }}
945971
env:
972+
RESERVATION_STATUS: ${{ steps.reserve-exact-review-lease.outputs.status }}
946973
RETRY_AT: ${{ steps.reserve-exact-review-lease.outputs.retry_at }}
947-
run: echo "::notice::Another exact-head review is already active; retry deferred until $RETRY_AT."
974+
run: |
975+
if [ "$RESERVATION_STATUS" = "superseded" ]; then
976+
echo "::notice::Exact-review queue authority moved to another worker; this run completed as a successful no-op."
977+
else
978+
echo "::notice::Another exact-head review is already active; retry deferred until $RETRY_AT."
979+
fi
948980
949981
- name: Review exact event item
950982
id: review-exact-event-item
@@ -1116,7 +1148,10 @@ jobs:
11161148
fi
11171149
if [ -f "$superseded_marker" ]; then
11181150
wait_for_review_group
1119-
review_exit_code=143
1151+
echo "superseded=true" >> "$GITHUB_OUTPUT"
1152+
echo "exit_code=0" >> "$GITHUB_OUTPUT"
1153+
echo "::notice::Exact-review generation stopped because another worker owns the newer queue authority; completing this run as a successful no-op."
1154+
exit 0
11201155
fi
11211156
set -e
11221157
echo "exit_code=$review_exit_code" >> "$GITHUB_OUTPUT"
@@ -1154,9 +1189,10 @@ jobs:
11541189
env:
11551190
REVIEW_EXIT_CODE: ${{ steps.review-exact-event-item.outputs.exit_code || '' }}
11561191
REVIEW_OUTCOME: ${{ steps.review-exact-event-item.outcome || 'not_started' }}
1192+
REVIEW_SUPERSEDED: ${{ steps.review-exact-event-item.outputs.superseded || 'false' }}
11571193
run: |
11581194
args=()
1159-
if [ "$REVIEW_OUTCOME" = "cancelled" ] || [ "$REVIEW_EXIT_CODE" = "130" ] || [ "$REVIEW_EXIT_CODE" = "143" ]; then
1195+
if [ "$REVIEW_SUPERSEDED" = "true" ] || [ "$REVIEW_OUTCOME" = "cancelled" ] || [ "$REVIEW_EXIT_CODE" = "130" ] || [ "$REVIEW_EXIT_CODE" = "143" ]; then
11601196
args=(--interrupt-open-attempts --reason cancelled)
11611197
elif [ "$REVIEW_EXIT_CODE" = "124" ] || [ "$REVIEW_EXIT_CODE" = "137" ]; then
11621198
args=(--interrupt-open-attempts --reason timeout)
@@ -1167,7 +1203,7 @@ jobs:
11671203
11681204
- name: Create exact review artifact bundle
11691205
id: create-exact-review-bundle
1170-
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.live-item.outputs.proceed != 'true' || (steps.review-exact-event-item.outcome == 'success' && steps.review-exact-event-item.outputs.retry_at == '')) }}
1206+
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 == '')) }}
11711207
env:
11721208
EXACT_REVIEW_ACTION_LEDGER_ROOT: ${{ env.CLAWSWEEPER_ACTION_LEDGER_OUTPUT_ROOT }}
11731209
EXACT_REVIEW_BUNDLE_DIR: .artifacts/exact-review-bundle
@@ -1372,13 +1408,17 @@ jobs:
13721408
STATUS_COMMENT_ID: ${{ fromJSON(steps.claim-exact-review-queue.outputs.decision).statusCommentId || '' }}
13731409
RUN_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
13741410
REVIEW_OUTCOME: ${{ steps.review-exact-event-item.outcome }}
1411+
REVIEW_SUPERSEDED: ${{ steps.review-exact-event-item.outputs.superseded || 'false' }}
13751412
RESERVATION_STATUS: ${{ steps.reserve-exact-review-lease.outputs.status }}
13761413
RETRY_AT: ${{ steps.reserve-exact-review-lease.outputs.retry_at || steps.review-exact-event-item.outputs.retry_at }}
13771414
CLAWSWEEPER_ACTION_LEDGER_DISABLED: "1"
13781415
run: |
13791416
state="Failed"
13801417
detail="The exact review did not produce a publishable artifact. The durable queue will retry it."
1381-
if [ "$RESERVATION_STATUS" = "held" ]; then
1418+
if [ "$RESERVATION_STATUS" = "superseded" ] || [ "$REVIEW_SUPERSEDED" = "true" ]; then
1419+
state="Waiting"
1420+
detail="A newer exact-review queue owner superseded this run. This run completed as a no-op."
1421+
elif [ "$RESERVATION_STATUS" = "held" ]; then
13821422
state="Waiting"
13831423
detail="Another exact-head review is already active. The durable queue will retry after its lease expires."
13841424
elif [ "$REVIEW_OUTCOME" = "cancelled" ] || [ -n "$RETRY_AT" ]; then
@@ -1401,12 +1441,16 @@ jobs:
14011441
TARGET_ENABLED: ${{ steps.target.outputs.target_enabled }}
14021442
LIVE_OUTCOME: ${{ steps.live-item.outcome }}
14031443
REVIEW_OUTCOME: ${{ steps.review-exact-event-item.outcome }}
1444+
REVIEW_SUPERSEDED: ${{ steps.review-exact-event-item.outputs.superseded || 'false' }}
1445+
RESERVATION_STATUS: ${{ steps.reserve-exact-review-lease.outputs.status }}
14041446
PUBLICATION_QUEUE_OUTCOME: ${{ steps.queue-exact-review-publication.outcome }}
14051447
DIRECT_PUBLICATION_ACCEPTED: ${{ steps.direct-exact-review-publication.outputs.accepted }}
14061448
run: |
14071449
outcome=failure
14081450
if [ "$TARGET_ENABLED" = "false" ]; then
14091451
outcome=success
1452+
elif [ "$RESERVATION_STATUS" = "superseded" ] || [ "$REVIEW_SUPERSEDED" = "true" ]; then
1453+
outcome=success
14101454
elif [ "$REVIEW_OUTCOME" = "cancelled" ]; then
14111455
outcome=cancelled
14121456
elif [ "$LIVE_OUTCOME" = "success" ] && { [ "$DIRECT_PUBLICATION_ACCEPTED" = "true" ] || [ "$PUBLICATION_QUEUE_OUTCOME" = "success" ]; }; then
@@ -1526,15 +1570,24 @@ jobs:
15261570
(
15271571
(
15281572
steps.direct-exact-review-publication.outputs.accepted != 'true' &&
1529-
steps.complete-exact-review-queue.outcome != 'success'
1573+
steps.complete-exact-review-queue.outcome != 'success' &&
1574+
steps.reserve-exact-review-lease.outputs.status != 'superseded' &&
1575+
steps.review-exact-event-item.outputs.superseded != 'true'
15301576
) ||
15311577
(
15321578
steps.exact-review-generation-result.outputs.outcome != 'success' &&
1533-
steps.reserve-exact-review-lease.outputs.status != 'held'
1579+
steps.reserve-exact-review-lease.outputs.status != 'held' &&
1580+
steps.reserve-exact-review-lease.outputs.status != 'superseded'
15341581
)
15351582
)
15361583
}}
1537-
run: exit 1
1584+
env:
1585+
RESERVATION_STATUS: ${{ steps.reserve-exact-review-lease.outputs.status || 'unknown' }}
1586+
REVIEW_EXIT_CODE: ${{ steps.review-exact-event-item.outputs.exit_code || 'unknown' }}
1587+
REVIEW_OUTCOME: ${{ steps.review-exact-event-item.outcome || 'not_started' }}
1588+
run: |
1589+
echo "::error::Exact review generation failed: classification=codex_or_content_failure reservation=$RESERVATION_STATUS review_outcome=$REVIEW_OUTCOME review_exit=$REVIEW_EXIT_CODE"
1590+
exit 1
15381591
15391592
event-review-publish:
15401593
name: Publish exact review artifact
@@ -2479,7 +2532,9 @@ jobs:
24792532
CLAWSWEEPER_DISPATCH_TOKEN: ${{ github.token }}
24802533
CLAWSWEEPER_INVENTORY_TOKEN_OPENCLAW: ${{ steps.openclaw-token.outputs.token }}
24812534
CLAWSWEEPER_INVENTORY_TOKEN_STEIPETE: ${{ steps.steipete-token.outputs.token || '__public__' }}
2482-
run: pnpm run target-fanout -- coverage --window-days 7 >> "$GITHUB_STEP_SUMMARY"
2535+
CLAWSWEEPER_WEBHOOK_SECRET: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
2536+
REVIEW_COVERAGE_URL: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
2537+
run: pnpm run target-fanout -- coverage --window-days 7 --publish-url "$REVIEW_COVERAGE_URL" >> "$GITHUB_STEP_SUMMARY"
24832538

24842539
- name: Publish fanout cursor
24852540
env:

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ checkpoint, and status-only commits are intentionally omitted.
99

1010
### Changed
1111

12+
- Made exact-review reservation races and mid-generation supersession successful no-ops with bounded jittered retries, surfaced provider throttling separately from content/output failures, renewed overdue canonical records ahead of unseen backlog, and based dashboard coverage on signed live open-item inventory with explicit expired, untracked, protected, and unmanaged cohorts.
1213
- Routed scheduled review through the durable exact-review queue, raised each target plan from one to 20 candidates, and added oldest-age funnel telemetry plus a fleet-wide 200-review/hour admission budget with duplicate, backlog, and lease-safe backpressure.
1314
- Scoped per-target canonical record hydration to the selected repository and skipped unused ledger/assets downloads in workflow lanes, preventing exact-item review publication from collapsing under concurrent full-fleet state setup.
1415
- Doubled exact-review admission to 128 global and 120 per target with a separate 194-slot Actions budget that preserves verdict publication at full review load, doubled scheduled fleet review fanout and canonical publication batch preparation, prioritized six-day oldest-review coverage before hot-item churn, exposed a six-hour fleet coverage summary, and raised automatic apply to 40 closes with proportional scan/runtime budgets without changing close eligibility.

0 commit comments

Comments
 (0)