Skip to content

Commit 69edd98

Browse files
committed
fix(workflow): scope comment-only reconciliation
1 parent 0588bda commit 69edd98

3 files changed

Lines changed: 48 additions & 21 deletions

File tree

‎.github/workflows/sweep.yml‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5800,6 +5800,7 @@ jobs:
58005800
validate_coverage_proof_tree ".artifacts/apply-proof/pr-close-coverage-proof" 8 262144 2097152
58015801
58025802
- name: Reconcile before apply preselect
5803+
if: ${{ !(github.event_name == 'schedule' && github.event.schedule == '6,21,36,51 * * * *') && !(github.event_name == 'workflow_dispatch' && (github.event.inputs.apply_sync_comments_only == 'true' || github.event.inputs.apply_item_numbers == '__cursor__')) }}
58035804
env:
58045805
CLAWSWEEPER_WEBHOOK_SECRET: ${{ secrets.CLAWSWEEPER_WEBHOOK_SECRET }}
58055806
GH_TOKEN: ${{ steps.target-write-token.outputs.token }}
@@ -5809,17 +5810,6 @@ jobs:
58095810
set -euo pipefail
58105811
source scripts/apply-workflow-helpers.sh
58115812
item_numbers="${{ github.event_name == 'repository_dispatch' && github.event.client_payload.item_number || github.event.inputs.apply_item_numbers || '' }}"
5812-
if [ "${{ github.event_name == 'schedule' && github.event.schedule == '6,21,36,51 * * * *' && 'true' || 'false' }}" = "true" ]; then
5813-
echo "Deferring reconciliation until the bounded comment-sync cursor is selected."
5814-
exit 0
5815-
fi
5816-
if [ "$item_numbers" = "__cursor__" ]; then
5817-
if [ "${{ github.event.inputs.apply_sync_comments_only || 'false' }}" = "true" ]; then
5818-
echo "Deferring reconciliation until the bounded comment-sync cursor is selected."
5819-
exit 0
5820-
fi
5821-
item_numbers=""
5822-
fi
58235813
prepare_apply_reconciliation_args
58245814
persist_reconciliation "${reconcile_args[@]}"
58255815

‎scripts/apply-workflow-helpers.sh‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,7 @@ prepare_apply_reconciliation_args() {
602602
return 0
603603
fi
604604
reconcile_args+=(--item-numbers "$item_numbers")
605-
if [ "${sync_comments_only:-false}" = "true" ] &&
606-
[ "${sync_open_pr_batch:-false}" = "true" ]; then
605+
if [ "${sync_comments_only:-false}" = "true" ]; then
607606
reconcile_args+=(--only-item-numbers)
608607
fi
609608
}

‎test/sweep-workflow.test.ts‎

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,14 +2077,18 @@ test("apply workflow isolates proof Codex and keeps mutation free of Git recover
20772077
assert.match(applyJob, /queue: max/);
20782078
});
20792079

2080-
test("comment-only proof preparation never scans the full target repository", () => {
2080+
test("comment-only apply preparation never scans the full target repository", () => {
20812081
const workflow = YAML.parse(readText(".github/workflows/sweep.yml")) as {
20822082
jobs: Record<string, { steps: Array<{ name?: string; if?: string; run?: string }> }>;
20832083
};
20842084
const steps = workflow.jobs["apply-proof"]!.steps;
20852085
const reconcile = steps.find((step) => step.name === "Reconcile read-only proof inputs");
2086+
const applyReconcile = workflow.jobs["apply-existing"]!.steps.find(
2087+
(step) => step.name === "Reconcile before apply preselect",
2088+
);
20862089
const select = steps.find((step) => step.name === "Select bounded coverage proof work");
20872090
assert.ok(reconcile?.if, "proof reconciliation must explicitly exclude comment-only runs");
2091+
assert.equal(applyReconcile?.if, reconcile.if, "apply preselect must use the same skip gate");
20882092
assert.ok(select?.run, "proof selection must recognize scheduled comment-only maintenance");
20892093

20902094
const expression = reconcile.if.replace(/^\$\{\{\s*|\s*\}\}$/g, "");
@@ -2114,6 +2118,38 @@ test("comment-only proof preparation never scans the full target repository", ()
21142118
assert.match(select.run, /sync_comments_only="true"/);
21152119
});
21162120

2121+
test("comment-only apply reconciliation scopes only selected items", () => {
2122+
const reconcileArgs = (itemNumbers: string, syncCommentsOnly: boolean) =>
2123+
execFileSync(
2124+
"bash",
2125+
[
2126+
"-lc",
2127+
[
2128+
"source scripts/apply-workflow-helpers.sh",
2129+
'TARGET_REPO="openclaw/openclaw"',
2130+
`item_numbers="${itemNumbers}"`,
2131+
`sync_comments_only=${syncCommentsOnly}`,
2132+
"sync_open_pr_batch=false",
2133+
"prepare_apply_reconciliation_args",
2134+
'printf "%s\\n" "${reconcile_args[@]}"',
2135+
].join("\n"),
2136+
],
2137+
{ encoding: "utf8" },
2138+
)
2139+
.trimEnd()
2140+
.split("\n");
2141+
const baseArgs = ["--target-repo", "openclaw/openclaw", "--skip-closed-at"];
2142+
2143+
assert.deepEqual(reconcileArgs("119890", true), [
2144+
...baseArgs,
2145+
"--item-numbers",
2146+
"119890",
2147+
"--only-item-numbers",
2148+
]);
2149+
assert.deepEqual(reconcileArgs("119890", false), [...baseArgs, "--item-numbers", "119890"]);
2150+
assert.deepEqual(reconcileArgs("", true), baseArgs);
2151+
});
2152+
21172153
test("apply workflow scopes cursor reconciliation and publishes close reconciliation before idle", () => {
21182154
const workflow = readText(".github/workflows/sweep.yml");
21192155
const applyJob = workflow.slice(workflow.indexOf("\n apply-existing:"));
@@ -4942,12 +4978,14 @@ test("sweep workflow coalesces durable issue and PR comment sync batches", () =>
49424978
assert.doesNotMatch(backgroundSync, /-f apply_item_numbers="\$item_numbers"/);
49434979
assert.match(
49444980
cursorPreselect,
4945-
/if \[ "\$item_numbers" = "__cursor__" \]; then\s+if \[ "\$\{\{ github\.event\.inputs\.apply_sync_comments_only \|\| 'false' \}\}" = "true" \]; then\s+echo "Deferring reconciliation until the bounded comment-sync cursor is selected\."\s+exit 0/,
4981+
/if: \$\{\{ .*github\.event\.inputs\.apply_sync_comments_only == 'true' \|\| github\.event\.inputs\.apply_item_numbers == '__cursor__'.*\}\}/,
49464982
);
4947-
assert.match(
4948-
cursorPreselect,
4949-
/if \[ "\$\{\{ github\.event_name == 'schedule' && github\.event\.schedule == '6,21,36,51 \* \* \* \*' && 'true' \|\| 'false' \}\}" = "true" \]; then\s+echo "Deferring reconciliation until the bounded comment-sync cursor is selected\."\s+exit 0/,
4950-
"scheduled comment maintenance must never scan or reconcile the entire repository before selecting its batch",
4983+
assert.doesNotMatch(cursorPreselect, /Deferring reconciliation/);
4984+
assert.ok(
4985+
cursorExecution.indexOf(
4986+
`sync_comments_only="\${{ github.event_name == 'workflow_dispatch' && github.event.inputs.apply_sync_comments_only || 'false' }}"`,
4987+
) < cursorExecution.indexOf("prepare_apply_reconciliation_args"),
4988+
"comment-only mode must be known before execution reconciliation is prepared",
49514989
);
49524990
assert.ok(
49534991
cursorExecution.indexOf('echo "Selected cursor-based comment sync batch: $item_numbers"') <
@@ -4957,8 +4995,8 @@ test("sweep workflow coalesces durable issue and PR comment sync batches", () =>
49574995
assert.match(cursorExecution, /prepare_apply_reconciliation_args/);
49584996
assert.match(
49594997
readText("scripts/apply-workflow-helpers.sh"),
4960-
/if \[ "\$\{sync_comments_only:-false\}" = "true" \] &&\s+\[ "\$\{sync_open_pr_batch:-false\}" = "true" \]; then\s+reconcile_args\+=\(--only-item-numbers\)/,
4961-
"cursor reconciliation must not archive or rewrite unrelated durable records",
4998+
/if \[ "\$\{sync_comments_only:-false\}" = "true" \]; then\s+reconcile_args\+=\(--only-item-numbers\)/,
4999+
"comment-only reconciliation must not archive or rewrite unrelated durable records",
49625000
);
49635001
});
49645002

0 commit comments

Comments
 (0)