Skip to content

Commit 138ee2f

Browse files
authored
fix(review): reuse receipts for scheduled queue runs (#1036)
1 parent daf339e commit 138ee2f

4 files changed

Lines changed: 44 additions & 3 deletions

File tree

‎.github/workflows/sweep.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,7 @@ jobs:
10891089
QUEUE_URL: ${{ vars.CLAWSWEEPER_EXACT_REVIEW_QUEUE_URL || 'https://clawsweeper.openclaw.ai' }}
10901090
REVIEW_LEASE_OWNER: ${{ steps.reserve-exact-review-lease.outputs.owner }}
10911091
REVIEW_LEASE_COMMENT_ID: ${{ steps.reserve-exact-review-lease.outputs.comment_id }}
1092+
SOURCE_ACTION: ${{ fromJSON(steps.claim-exact-review-queue.outputs.decision).sourceAction || '' }}
10921093
run: |
10931094
set -euo pipefail
10941095
test -n "$GH_TOKEN"
@@ -1230,6 +1231,7 @@ jobs:
12301231
--review-lease-comment-id "$REVIEW_LEASE_COMMENT_ID" \
12311232
--shard-index 0 \
12321233
--shard-count 1 \
1234+
--review-source-action "$SOURCE_ACTION" \
12331235
"${additional_prompt_arg[@]}" &
12341236
review_pid=$!
12351237
review_pgid=$review_pid

‎src/clawsweeper-review-preparation.ts‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ import {
1717
import type { Args } from "./clawsweeper-args.js";
1818
import type { CreateReviewCommandWorkflowDependencies } from "./clawsweeper-review-command-dependencies.js";
1919

20+
const AUTOMATIC_REVIEW_SOURCE_ACTIONS = new Set([
21+
"scheduled_hot_intake",
22+
"scheduled_normal_backfill",
23+
]);
24+
25+
export function isExplicitReviewDispatch(args: Args, hasExplicitItemSelection: boolean): boolean {
26+
const sourceAction = stringArg(args.review_source_action, "").trim();
27+
const plannedAutomaticReview =
28+
boolArg(args.planned_automatic_review) || AUTOMATIC_REVIEW_SOURCE_ACTIONS.has(sourceAction);
29+
return !plannedAutomaticReview && hasExplicitItemSelection;
30+
}
31+
2032
export function prepareReviewCommand(
2133
args: Args,
2234
dependencies: CreateReviewCommandWorkflowDependencies,
@@ -159,9 +171,10 @@ export function prepareReviewCommand(
159171
? { mainSha: localRangeData.baseSha, releaseStateComplete: true, latestRelease: null }
160172
: loadReviewGitInfo();
161173
const reviewPolicy = reviewPolicyHash({ model, reasoningEffort, sandboxMode, serviceTier });
162-
const plannedAutomaticReview = boolArg(args.planned_automatic_review);
163-
const explicitDispatch =
164-
!plannedAutomaticReview && (itemNumber !== undefined || itemNumbers !== undefined);
174+
const explicitDispatch = isExplicitReviewDispatch(
175+
args,
176+
itemNumber !== undefined || itemNumbers !== undefined,
177+
);
165178
const maintainerRequest = additionalPrompt.trim().length > 0;
166179

167180
return {

‎test/review-preparation.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import assert from "node:assert/strict";
2+
import test from "node:test";
3+
import { parseArgs } from "../dist/clawsweeper-args.js";
4+
import { isExplicitReviewDispatch } from "../dist/clawsweeper-review-preparation.js";
5+
6+
test("scheduled queue source actions are automatic while exact actions remain explicit", () => {
7+
for (const sourceAction of ["scheduled_hot_intake", "scheduled_normal_backfill"]) {
8+
const args = parseArgs(["--review-source-action", sourceAction]);
9+
assert.equal(isExplicitReviewDispatch(args, true), false, sourceAction);
10+
}
11+
12+
for (const sourceAction of ["issues_opened", "exact_review_command", "legacy_dispatch", ""]) {
13+
const args = sourceAction ? parseArgs(["--review-source-action", sourceAction]) : parseArgs([]);
14+
assert.equal(isExplicitReviewDispatch(args, true), true, sourceAction || "missing action");
15+
}
16+
});
17+
18+
test("planned review compatibility and non-exact selection preserve existing behavior", () => {
19+
assert.equal(isExplicitReviewDispatch(parseArgs(["--planned-automatic-review"]), true), false);
20+
assert.equal(isExplicitReviewDispatch(parseArgs([]), false), false);
21+
});

‎test/sweep-workflow.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5524,6 +5524,11 @@ test("planned background reviews allow safe content-cache reuse without weakenin
55245524
reviewJob,
55255525
/--item-numbers "\$\{\{ matrix\.item_numbers \}\}" \\\n+\s+"\$\{planned_automatic_review_arg\[@\]\}"/,
55265526
);
5527+
assert.match(
5528+
eventReviewJob,
5529+
/SOURCE_ACTION: \$\{\{ fromJSON\(steps\.claim-exact-review-queue\.outputs\.decision\)\.sourceAction \|\| '' \}\}/,
5530+
);
5531+
assert.match(eventReviewJob, /--review-source-action "\$SOURCE_ACTION"/);
55275532
assert.doesNotMatch(eventReviewJob, /--planned-automatic-review/);
55285533
});
55295534

0 commit comments

Comments
 (0)