Skip to content

Commit 91272a6

Browse files
authored
fix: keep branchless reviews durable during GitHub limits (#1105)
* fix(review): make branch authority quota-aware * test: prove durable review branch authority
1 parent 19a7449 commit 91272a6

12 files changed

Lines changed: 1456 additions & 25 deletions

File tree

‎.github/workflows/sweep.yml‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ jobs:
262262
- name: Enqueue legacy event through the durable control plane
263263
env:
264264
CLIENT_PAYLOAD: ${{ toJson(github.event.client_payload) }}
265-
GH_TOKEN: ${{ github.token }}
266265
QUEUE_URL: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
267266
CLAWSWEEPER_WEBHOOK_SECRET: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
268267
run: |
@@ -314,18 +313,17 @@ jobs:
314313
echo "Invalid legacy target repository: $target_repo" >&2
315314
exit 1
316315
fi
317-
if [ -z "$target_branch" ]; then
318-
target_branch="$(gh api "repos/$target_repo" --jq .default_branch)"
319-
fi
320-
if ! printf '%s' "$target_branch" | grep -Eq '^[A-Za-z0-9_.\/-]+$'; then
316+
if [ -n "$target_branch" ] && ! printf '%s' "$target_branch" | grep -Eq '^[A-Za-z0-9_.\/-]+$'; then
321317
echo "Invalid legacy target branch for $target_repo: $target_branch" >&2
322318
exit 1
323319
fi
324320
queue_path="/internal/exact-review/enqueue"
325-
if [ "$use_source_authority" = "1" ]; then
321+
if [ -z "$target_branch" ]; then
322+
queue_path="/internal/exact-review/branch-authority"
323+
elif [ "$use_source_authority" = "1" ]; then
326324
queue_path="/internal/exact-review/source-authority"
327325
fi
328-
payload="$(TARGET_REPO="$target_repo" TARGET_BRANCH="$target_branch" node <<'NODE'
326+
payload="$(TARGET_REPO="$target_repo" TARGET_BRANCH="$target_branch" USE_SOURCE_AUTHORITY="$use_source_authority" node <<'NODE'
329327
const payload = JSON.parse(process.env.CLIENT_PAYLOAD || "{}");
330328
const itemKind = payload.item_kind === "pull_request" ? "pull_request" : "issue";
331329
const sourceEvent =
@@ -353,17 +351,22 @@ jobs:
353351
const sourceContentRevision = String(queueClaim.source_content_revision ?? payload.source_content_revision ?? "").trim().toLowerCase();
354352
const sourceUpdatedAt = String(queueClaim.source_updated_at ?? payload.source_updated_at ?? "").trim();
355353
const installationId = Number(queueClaim.installation_id ?? payload.installation_id);
354+
const targetBranch = String(process.env.TARGET_BRANCH || "").trim();
355+
const sourceAuthorityRequired = process.env.USE_SOURCE_AUTHORITY === "1";
356356
process.stdout.write(
357357
JSON.stringify({
358358
delivery_id: dispatchKey
359359
? `router:${dispatchKey}`
360360
: `legacy:${process.env.GITHUB_RUN_ID}:${process.env.GITHUB_RUN_ATTEMPT}`,
361-
...(itemKind === "pull_request" && Number.isInteger(installationId) && installationId > 0
361+
...(Number.isInteger(installationId) && installationId > 0
362362
? { installation_id: installationId }
363363
: {}),
364+
...(!targetBranch && sourceAuthorityRequired
365+
? { source_authority_required: true }
366+
: {}),
364367
decision: {
365368
targetRepo: process.env.TARGET_REPO,
366-
targetBranch: process.env.TARGET_BRANCH,
369+
...(targetBranch ? { targetBranch } : {}),
367370
itemNumber: Number(payload.item_number),
368371
itemKind,
369372
sourceEvent,

0 commit comments

Comments
 (0)