Skip to content

Commit ce25070

Browse files
authored
feat(apply): requeue exact re-reviews for drift-blocked close proposals (#1231)
Close-mode cursor sweeps were closing ~0/40 records per checkpoint: ~50% skipped as changed-since-review (any third-party activity since the last review vetoes the close until a fresh review) and ~35% kept open because their stored review lacks verified local checkout access (legacy records that can never authorize a close). Both blocks have the same cure — a fresh exact review re-verifies the proposal at the current snapshot and writes a close-capable record. After each default close-mode cursor run, the apply job now dispatches up to five clawsweeper_target_sweep exact reviews for those items, drift skips first, so blocked backlog records converge to closeable instead of being re-skipped by every sweep.
1 parent d5b0aa4 commit ce25070

5 files changed

Lines changed: 160 additions & 0 deletions

File tree

‎.github/workflows/sweep.yml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6817,6 +6817,46 @@ jobs:
68176817
-f codex_timeout_ms=1200000
68186818
fi
68196819
6820+
- name: Requeue drift-blocked close reviews
6821+
if: ${{ always() && !cancelled() && steps.primary-apply-result.outputs.succeeded == 'true' && steps.target.outputs.target_repo == 'openclaw/openclaw' }}
6822+
env:
6823+
GH_TOKEN: ${{ github.token }}
6824+
run: |
6825+
set -euo pipefail
6826+
if [ "${APPLY_NOOP:-false}" = "true" ] ||
6827+
[ "${APPLY_SYNC_COMMENTS_ONLY:-false}" = "true" ] ||
6828+
[ "${APPLY_AUTO_SELECTED_BATCH:-false}" != "true" ] ||
6829+
[ ! -f apply-report.json ]; then
6830+
echo "Not a default close-mode cursor run with a merged apply report; skipping drift requeue."
6831+
exit 0
6832+
fi
6833+
items="$(pnpm run --silent workflow -- apply-requeue-review-item-numbers --report apply-report.json --limit 5)"
6834+
if [ -z "$items" ]; then
6835+
echo "No source-drift or unverified-checkout close blocks to requeue."
6836+
exit 0
6837+
fi
6838+
target_branch="$(gh api "repos/${APPLY_TARGET_REPO}" --jq .default_branch)"
6839+
IFS=',' read -r -a requeue_items <<< "$items"
6840+
for item_number in "${requeue_items[@]}"; do
6841+
jq -n \
6842+
--arg target_repo "$APPLY_TARGET_REPO" \
6843+
--arg target_branch "$target_branch" \
6844+
--arg item_number "$item_number" \
6845+
'{
6846+
event_type: "clawsweeper_target_sweep",
6847+
client_payload: {
6848+
target_repo: $target_repo,
6849+
target_branch: $target_branch,
6850+
item_number: $item_number,
6851+
batch_size: "1",
6852+
shard_count: "1",
6853+
hot_intake: "false",
6854+
codex_timeout_ms: "1200000"
6855+
}
6856+
}' | gh api --method POST "repos/${{ github.repository }}/dispatches" --input -
6857+
echo "::notice::Requeued exact review for ${APPLY_TARGET_REPO}#${item_number}: its close was blocked by source drift or an unverified-checkout review."
6858+
done
6859+
68206860
publish-apply-observability:
68216861
name: Publish apply telemetry
68226862
needs: [apply-proof, publish-apply-proof-action-ledger, apply-existing]

‎CHANGELOG.md‎

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

2020
### Changed
2121

22+
- Default close-mode apply runs now requeue up to five exact re-reviews for records whose close was blocked by source drift or an unverified-checkout review, so stale backlog records converge to closeable instead of being skipped by every cursor sweep.
2223
- Live verification now publishes a sanitized, capped dev-server log tail when browser startup fails, and detects a start command that exits before its URL becomes reachable without waiting for the readiness timeout.
2324
- Live verification now installs a missing target package manager on demand after execution is approved, publishes installer failures as verification results, and guides plans toward stable assertions the run can satisfy.
2425
- Live verification now runs immediately after review in the same job and exact reviewed checkout; review judgment gates execution, target children receive a denylist-and-heuristic-sanitized environment, package installs suppress lifecycle scripts unless a repository explicitly opts in, and review jobs default to `ubuntu-latest` without requiring Linux namespaces. Existing publication jobs still validate and upload media before publishing the normal record and comment.

‎docs/scheduler.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,15 @@ limits, live-state checks, or policy gates. Stalled-unproven and abandoned PR
701701
proposals are eligible for apply selection, where the executor re-checks their
702702
PR-only age, activity, proof, status, and human-engagement gates before closing.
703703

704+
After a default close-mode cursor run for `openclaw/openclaw`, the apply job
705+
requeues up to five exact reviews for records whose close was blocked by
706+
source drift (`skipped_changed_since_review`) or by a stored review without
707+
verified local checkout access. Both blocks have the same cure: a fresh exact
708+
review re-verifies the close proposal at the current snapshot and writes a
709+
close-capable record, so the next apply pass can execute instead of skipping
710+
the same stale records every sweep. The per-run cap bounds review spend, and
711+
the exact-item queue's supersession semantics absorb repeat dispatches.
712+
704713
Apply and comment-sync Actions run titles include the target repository. Before
705714
dispatching a default cursor-based apply continuation, the workflow checks
706715
recent active or queued same-target default cursor runs and treats one of those

‎src/repair/workflow-utils.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ async function runCli(): Promise<void> {
332332
case "merge-apply-reports":
333333
mergeApplyReports(requiredString("dir"), requiredString("output"));
334334
break;
335+
case "apply-requeue-review-item-numbers":
336+
process.stdout.write(
337+
applyRequeueReviewItemNumbers(requiredString("report"), numberArg("limit", 0)).join(","),
338+
);
339+
break;
335340
default:
336341
throw new Error(`unknown workflow utility command: ${command}`);
337342
}
@@ -554,6 +559,35 @@ export function countActions(reportPath: string, action: string): number {
554559
return readApplyActions(reportPath).filter((entry) => entry.action === action).length;
555560
}
556561

562+
export const APPLY_REQUEUE_UNVERIFIED_CHECKOUT_REASON =
563+
"review lacks verified local checkout access";
564+
565+
// Close-mode apply cannot close a record whose source drifted since review or
566+
// whose stored review never verified local checkout access. Both blocks have
567+
// the same cure: a fresh exact review. Source-drift skips come first because
568+
// their close proposals are already confirmed and only need re-verification.
569+
export function applyRequeueReviewItemNumbers(reportPath: string, limit: number): number[] {
570+
if (!Number.isInteger(limit) || limit <= 0) return [];
571+
const actions = readApplyActions(reportPath);
572+
const selected: number[] = [];
573+
const seen = new Set<number>();
574+
const push = (entry: ApplyAction): void => {
575+
const number = entry.number;
576+
if (number === undefined || seen.has(number) || selected.length >= limit) return;
577+
seen.add(number);
578+
selected.push(number);
579+
};
580+
for (const entry of actions) {
581+
if (entry.action === "skipped_changed_since_review") push(entry);
582+
}
583+
for (const entry of actions) {
584+
if (entry.action === "kept_open" && entry.reason === APPLY_REQUEUE_UNVERIFIED_CHECKOUT_REASON) {
585+
push(entry);
586+
}
587+
}
588+
return selected;
589+
}
590+
557591
export function applyContinuationBlocker(
558592
values: readonly unknown[],
559593
options: ApplyContinuationBlockerOptions,

‎test/sweep-workflow.test.ts‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6680,3 +6680,79 @@ test("exact review publication enqueue accepts a superseded acknowledgement", ()
66806680
assert.match(run, /jq -e '\.superseded == true'/);
66816681
assert.match(run, /the newer publisher owns final delivery/);
66826682
});
6683+
6684+
test("apply drift requeue selects source-drift skips before unverified-checkout keeps", () => {
6685+
const root = mkdtempSync(tmpPrefix);
6686+
try {
6687+
const reportPath = join(root, "apply-report.json");
6688+
writeFileSync(
6689+
reportPath,
6690+
JSON.stringify([
6691+
{ number: 101, action: "skipped_changed_since_review", reason: "updated_at changed" },
6692+
{ number: 102, action: "kept_open", reason: "review lacks verified local checkout access" },
6693+
{ number: 103, action: "kept_open", reason: "no close proposal" },
6694+
{ number: 104, action: "skipped_changed_since_review", reason: "snapshot changed" },
6695+
{ number: 101, action: "skipped_changed_since_review", reason: "updated_at changed" },
6696+
{ number: 105, action: "kept_open", reason: "review lacks verified local checkout access" },
6697+
{ number: 0, action: "skipped_runtime_budget", reason: "budget" },
6698+
{ number: 106, action: "closed", reason: "implemented on main" },
6699+
]),
6700+
"utf8",
6701+
);
6702+
6703+
const selected = execFileSync(
6704+
process.execPath,
6705+
[
6706+
"dist/repair/workflow-utils.js",
6707+
"apply-requeue-review-item-numbers",
6708+
"--report",
6709+
reportPath,
6710+
"--limit",
6711+
"3",
6712+
],
6713+
{ encoding: "utf8" },
6714+
);
6715+
assert.equal(selected, "101,104,102");
6716+
6717+
const unlimited = execFileSync(
6718+
process.execPath,
6719+
[
6720+
"dist/repair/workflow-utils.js",
6721+
"apply-requeue-review-item-numbers",
6722+
"--report",
6723+
reportPath,
6724+
"--limit",
6725+
"10",
6726+
],
6727+
{ encoding: "utf8" },
6728+
);
6729+
assert.equal(unlimited, "101,104,102,105");
6730+
6731+
const disabled = execFileSync(
6732+
process.execPath,
6733+
[
6734+
"dist/repair/workflow-utils.js",
6735+
"apply-requeue-review-item-numbers",
6736+
"--report",
6737+
reportPath,
6738+
"--limit",
6739+
"0",
6740+
],
6741+
{ encoding: "utf8" },
6742+
);
6743+
assert.equal(disabled, "");
6744+
} finally {
6745+
rmSync(root, { recursive: true, force: true });
6746+
}
6747+
});
6748+
6749+
test("apply job requeues drift-blocked close reviews only for default cursor runs", () => {
6750+
const workflow = readText(".github/workflows/sweep.yml");
6751+
const step = workflow.slice(workflow.indexOf("Requeue drift-blocked close reviews"));
6752+
6753+
assert.match(step, /apply-requeue-review-item-numbers --report apply-report\.json --limit 5/);
6754+
assert.match(step, /APPLY_SYNC_COMMENTS_ONLY:-false.*=.*"true"/s);
6755+
assert.match(step, /APPLY_AUTO_SELECTED_BATCH:-false.*!=.*"true"/s);
6756+
assert.match(step, /event_type: "clawsweeper_target_sweep"/);
6757+
assert.match(step, /shard_count: "1"/);
6758+
});

0 commit comments

Comments
 (0)