Skip to content

Commit 1a04edf

Browse files
committed
fix: narrow PR coverage proof candidates
1 parent 06889f4 commit 1a04edf

4 files changed

Lines changed: 148 additions & 2 deletions

File tree

‎src/clawsweeper.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9999,7 +9999,8 @@ const PULL_REQUEST_LINK_LABEL_START = "__clawsweeper_pr_link_label_start__";
99999999
const PULL_REQUEST_LINK_LABEL_END = "__clawsweeper_pr_link_label_end__";
1000010000

1000110001
function pullRequestLinkLabel(label: string): string {
10002-
const trimmed = label.trim();
10002+
const refRegex = sameRepoPullRequestRefRegex();
10003+
const trimmed = (refRegex ? label.replace(refRegex, " ") : label).trim();
1000310004
return trimmed
1000410005
? `${PULL_REQUEST_LINK_LABEL_START} ${trimmed} ${PULL_REQUEST_LINK_LABEL_END} `
1000510006
: "";

‎src/repair/workflow-utils.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,12 @@ function selectedProposedItemNumbers(
343343
}) &&
344344
allowedForTarget(options.targetRepo, type, "duplicate_or_superseded", allowedReasons) &&
345345
(!allowedCloseReasons || allowedCloseReasons.has("duplicate_or_superseded"));
346+
const selectableProofPromotion =
347+
selectablePromotion && hasLinkedPullRequestSupersessionSignal(markdown, options.targetRepo);
346348
if (!selectableClose && !selectablePromotion) return [];
347349
const prCloseCoverageProofCanRun =
348350
type === "pull_request" &&
349-
((selectableClose && reason === "duplicate_or_superseded") || selectablePromotion);
351+
((selectableClose && reason === "duplicate_or_superseded") || selectableProofPromotion);
350352
if (selection === "pr-close-coverage-proof" && !prCloseCoverageProofCanRun) return [];
351353
if (
352354
(reason === "stale_insufficient_info" || reason === "mostly_implemented_on_main") &&

‎test/clawsweeper.test.ts‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8827,6 +8827,108 @@ test("apply-decisions ignores bare refs inside cross-repo markdown link labels f
88278827
}
88288828
});
88298829

8830+
test("apply-decisions ignores bare refs inside same-repo markdown link labels for duplicate proof", () => {
8831+
const root = mkdtempSync(tmpPrefix);
8832+
try {
8833+
const itemsDir = join(root, "items");
8834+
const closedDir = join(root, "closed");
8835+
const plansDir = join(root, "plans");
8836+
const reportPath = join(root, "apply-report.json");
8837+
const proofLogPath = join(root, "proof.log");
8838+
mkdirSync(itemsDir, { recursive: true });
8839+
mkdirSync(plansDir, { recursive: true });
8840+
const synced = reportWithSyncedReviewComment(
8841+
lowSignalCloseReport({
8842+
number: 358,
8843+
title: "Provider route fallback",
8844+
close_reason: "duplicate_or_superseded",
8845+
work_cluster_refs: JSON.stringify([
8846+
"Superseded by [fixes #123](https://github.com/openclaw/openclaw/pull/400)",
8847+
]),
8848+
}).replace(
8849+
"Closing this PR because the branch is not a useful landing base.",
8850+
"Closing this PR as superseded by the linked canonical PR.",
8851+
),
8852+
358,
8853+
"duplicate_or_superseded",
8854+
);
8855+
writeFileSync(join(itemsDir, "358.md"), synced.report, "utf8");
8856+
8857+
withMockGh(
8858+
root,
8859+
promotionGhMock({
8860+
number: 358,
8861+
title: "Provider route fallback",
8862+
comment: synced.comment,
8863+
linkedPulls: {
8864+
123: {
8865+
number: 123,
8866+
title: "Unrelated draft PR",
8867+
html_url: "https://github.com/openclaw/openclaw/pull/123",
8868+
state: "open",
8869+
merged_at: null,
8870+
mergeable_state: "clean",
8871+
draft: true,
8872+
body: "Unrelated provider cleanup.",
8873+
comments: [],
8874+
labels: [],
8875+
},
8876+
400: {
8877+
number: 400,
8878+
title: "Canonical provider replacement",
8879+
html_url: "https://github.com/openclaw/openclaw/pull/400",
8880+
state: "closed",
8881+
merged_at: "2026-05-02T00:00:00Z",
8882+
body: "Covers the provider route fallback behavior.",
8883+
comments: [],
8884+
labels: [],
8885+
},
8886+
},
8887+
}),
8888+
() => {
8889+
withMockCodexProof(
8890+
root,
8891+
{
8892+
type: "decision",
8893+
decision: "keep_open",
8894+
reason: "PR A still has unique fallback route behavior that PR B does not cover.",
8895+
invocationLogPath: proofLogPath,
8896+
expectedPromptIncludes: "Canonical provider replacement",
8897+
},
8898+
() => {
8899+
runApplyDecisionsForTest({
8900+
itemsDir,
8901+
closedDir,
8902+
plansDir,
8903+
reportPath,
8904+
extraArgs: [
8905+
"--target-repo",
8906+
"openclaw/openclaw",
8907+
"--apply-kind",
8908+
"all",
8909+
"--processed-limit",
8910+
"3",
8911+
],
8912+
});
8913+
},
8914+
);
8915+
},
8916+
);
8917+
8918+
const report = JSON.parse(readFileSync(reportPath, "utf8")) as Array<{
8919+
number: number;
8920+
action: string;
8921+
}>;
8922+
assert.equal(
8923+
report.find((entry) => entry.number === 358)?.action,
8924+
"skipped_pr_close_coverage_proof",
8925+
);
8926+
assert.match(readFileSync(proofLogPath, "utf8"), /proof/);
8927+
} finally {
8928+
rmSync(root, { recursive: true, force: true });
8929+
}
8930+
});
8931+
88308932
test("apply-decisions keeps newline-start bare PR refs tied to their own line", () => {
88318933
const root = mkdtempSync(tmpPrefix);
88328934
try {

‎test/repair/workflow-utils.test.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,47 @@ test("workflow utilities select proposed PR closes that can need coverage proof"
693693
"",
694694
].join("\n"),
695695
);
696+
write(
697+
path.join(root, "records/openclaw-openclaw/items/openclaw-openclaw-12.md"),
698+
[
699+
"---",
700+
"repository: openclaw/openclaw",
701+
"type: pull_request",
702+
"decision: keep_open",
703+
"review_status: complete",
704+
"local_checkout_access: verified",
705+
"action_taken: kept_open",
706+
"close_reason: none",
707+
`item_created_at: ${oldDate}`,
708+
`merge_risk_options: ${JSON.stringify([
709+
{
710+
category: "pause_or_close",
711+
recommended: true,
712+
title: "Pause or close",
713+
body: "No replacement PR is identified.",
714+
},
715+
])}`,
716+
"---",
717+
"",
718+
].join("\n"),
719+
);
720+
write(
721+
path.join(root, "records/openclaw-openclaw/items/openclaw-openclaw-13.md"),
722+
[
723+
"---",
724+
"repository: openclaw/openclaw",
725+
"type: pull_request",
726+
"decision: keep_open",
727+
"review_status: complete",
728+
"local_checkout_access: verified",
729+
"action_taken: kept_open",
730+
"close_reason: none",
731+
`item_created_at: ${oldDate}`,
732+
"pr_rating_overall: F",
733+
"---",
734+
"",
735+
].join("\n"),
736+
);
696737

697738
const options = {
698739
targetRepo: "openclaw/openclaw",

0 commit comments

Comments
 (0)