Skip to content

Commit c5314ce

Browse files
authored
fix(repair): isolate deferred verdict routing (#683)
1 parent 2750946 commit c5314ce

4 files changed

Lines changed: 46 additions & 1 deletion

File tree

‎.github/workflows/repair-comment-router.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ env:
8181
CLAWSWEEPER_AUTHOR_PR_BUDGET_CLOSE_ENABLED: ${{ vars.CLAWSWEEPER_AUTHOR_PR_BUDGET_CLOSE_ENABLED || 'false' }}
8282

8383
concurrency:
84-
group: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.comment_id && format('repair-comment-router-{0}-comment-{1}', github.event.client_payload.target_repo || 'openclaw/openclaw', github.event.client_payload.comment_id) || format('repair-comment-router-{0}', github.event.inputs.target_repo || github.event.client_payload.target_repo || 'openclaw/openclaw') }}
84+
# GitHub retains only one pending run per concurrency group. Exact-item verdict
85+
# handoffs need their own group so unrelated router traffic cannot replace them.
86+
group: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.comment_id && format('repair-comment-router-{0}-comment-{1}', github.event.client_payload.target_repo || 'openclaw/openclaw', github.event.client_payload.comment_id) || github.event_name == 'workflow_dispatch' && github.event.inputs.item_numbers != '' && format('repair-comment-router-{0}-items-{1}', github.event.inputs.target_repo || 'openclaw/openclaw', github.event.inputs.item_numbers) || format('repair-comment-router-{0}', github.event.inputs.target_repo || github.event.client_payload.target_repo || 'openclaw/openclaw') }}
8587
cancel-in-progress: false
8688

8789
jobs:

‎.github/workflows/sweep.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,7 @@ jobs:
16821682
GH_TOKEN: ${{ github.token }}
16831683
TARGET_REPO: ${{ steps.publication-context.outputs.target_repo }}
16841684
TARGET_BRANCH: ${{ steps.publication-context.outputs.target_branch }}
1685+
ITEM_NUMBER: ${{ steps.publication-context.outputs.item_number }}
16851686
CLAWSWEEPER_COMMENT_LOOKBACK_MINUTES: ${{ vars.CLAWSWEEPER_COMMENT_LOOKBACK_MINUTES || '180' }}
16861687
CLAWSWEEPER_COMMENT_MAX_COMMENTS: ${{ vars.CLAWSWEEPER_COMMENT_MAX_COMMENTS || '1000' }}
16871688
run: |
@@ -1691,6 +1692,7 @@ jobs:
16911692
-f execute=true \
16921693
-f target_repo="$TARGET_REPO" \
16931694
-f target_branch="$TARGET_BRANCH" \
1695+
-f item_numbers="$ITEM_NUMBER" \
16941696
-f lookback_minutes="$CLAWSWEEPER_COMMENT_LOOKBACK_MINUTES" \
16951697
-f max_comments="$CLAWSWEEPER_COMMENT_MAX_COMMENTS"
16961698

‎test/e2e/automerge/run.mjs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export function runAutomergeE2E({
5656

5757
try {
5858
const runtimeRoot = createCandidateRuntime(root, candidateRoot);
59+
if (scenario === "resume-intent-persistence") {
60+
assertDeferredVerdictHandoffIsolation(candidateRoot);
61+
}
5962
const targetFixture =
6063
scenario === "ci-regression-29623139111"
6164
? createCiRegressionFixture(root, { fixture })
@@ -405,6 +408,24 @@ export function runAutomergeE2E({
405408
}
406409
}
407410

411+
function assertDeferredVerdictHandoffIsolation(candidateRoot) {
412+
const sweep = fs.readFileSync(path.join(candidateRoot, ".github/workflows/sweep.yml"), "utf8");
413+
const router = fs.readFileSync(
414+
path.join(candidateRoot, ".github/workflows/repair-comment-router.yml"),
415+
"utf8",
416+
);
417+
assert.match(
418+
sweep,
419+
/Queue deferred exact verdict router[\s\S]*-f item_numbers="\$ITEM_NUMBER"/,
420+
"the exact review publisher must identify the PR in its deferred router handoff",
421+
);
422+
assert.match(
423+
router,
424+
/github\.event_name == 'workflow_dispatch' && github\.event\.inputs\.item_numbers != '' && format\('repair-comment-router-\{0\}-items-\{1\}'/,
425+
"deferred verdict handoffs must not share the replaceable repository-wide pending group",
426+
);
427+
}
428+
408429
function createCandidateRuntime(root, candidateRoot) {
409430
const source = path.resolve(candidateRoot);
410431
const runtime = path.join(root, "candidate-runtime");

‎test/sweep-workflow.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,11 @@ test("exact event review hands immutable artifacts to the queue-bounded publishe
497497
assert.match(deferredRoute.if ?? "", /publish-event-result\.outcome == 'success'/);
498498
assert.match(deferredRoute.if ?? "", /routing_deferred == 'true'/);
499499
assert.match(deferredRoute.run ?? "", /repair-comment-router\.yml/);
500+
assert.equal(
501+
deferredRoute.env?.ITEM_NUMBER,
502+
"${{ steps.publication-context.outputs.item_number }}",
503+
);
504+
assert.match(deferredRoute.run ?? "", /-f item_numbers="\$ITEM_NUMBER"/);
500505
const drift = step(publisher, "Queue fresh review after source drift");
501506
assert.match(drift.if ?? "", /requeue_latest == 'true'/);
502507
assert.match(drift.if ?? "", /legacy-exact-artifact\.outputs\.legacy_tupleless == 'true'/);
@@ -1913,6 +1918,21 @@ test("trusted comment router owns command ledger capacity retries", () => {
19131918
assert.match(routerWorkflow, /--wait-for-capacity/);
19141919
});
19151920

1921+
test("deferred exact verdict routers cannot replace each other's pending runs", () => {
1922+
const workflow = readText(".github/workflows/repair-comment-router.yml");
1923+
const concurrency = workflow.slice(workflow.indexOf("concurrency:"), workflow.indexOf("\njobs:"));
1924+
1925+
// GitHub keeps only one pending run per group even when cancel-in-progress is false.
1926+
// Binding exact workflow dispatches to their item preserves both handoffs under load.
1927+
assert.match(concurrency, /github\.event_name == 'workflow_dispatch'/);
1928+
assert.match(concurrency, /github\.event\.inputs\.item_numbers != ''/);
1929+
assert.match(
1930+
concurrency,
1931+
/format\('repair-comment-router-\{0\}-items-\{1\}'[\s\S]*github\.event\.inputs\.item_numbers/,
1932+
);
1933+
assert.match(concurrency, /cancel-in-progress: false/);
1934+
});
1935+
19161936
test("comment commands keep the router-to-sweep dispatch contract", () => {
19171937
const routerWorkflow = readText(".github/workflows/repair-comment-router.yml");
19181938
const sweepWorkflow = readText(".github/workflows/sweep.yml");

0 commit comments

Comments
 (0)