Skip to content

Commit 4db25bd

Browse files
committed
Ignore advisory labels in source revisions
1 parent 7b8e703 commit 4db25bd

5 files changed

Lines changed: 156 additions & 0 deletions

File tree

‎src/clawsweeper.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,13 +2200,28 @@ function revisionLabels(labels: unknown): string[] {
22002200

22012201
function isIgnorableSourceRevisionLabel(label: string) {
22022202
return (
2203+
isClawSweeperAdvisorySourceRevisionLabel(label) ||
22032204
(label.startsWith("clawsweeper:") &&
22042205
!["clawsweeper:human-review", "clawsweeper:manual-only"].includes(label)) ||
22052206
label === "no-stale" ||
22062207
label === "stale"
22072208
);
22082209
}
22092210

2211+
function isClawSweeperAdvisorySourceRevisionLabel(label: string): boolean {
2212+
return (
2213+
/^(?:status|rating|proof|merge-risk|impact|issue-rating):/.test(label) ||
2214+
/^p[0-3]$/.test(label) ||
2215+
label === "feature: ✨ showcase" ||
2216+
label === "mantis: telegram-visible-proof" ||
2217+
label === "triage: needs-real-behavior-proof"
2218+
);
2219+
}
2220+
2221+
export function itemSourceRevisionSha256ForTest(issue: unknown, comments: unknown[] = []): string {
2222+
return itemSourceRevisionSha256(issue, comments);
2223+
}
2224+
22102225
function reviewPolicyHash(options: {
22112226
model?: string;
22122227
reasoningEffort?: string;

‎src/repair/issue-source-guard.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,23 @@ function revisionLabels(labels: JsonValue[]): string[] {
8888

8989
function isIgnorableAutomationLabel(label: string) {
9090
return (
91+
isClawSweeperAdvisoryLabel(label) ||
9192
(label.startsWith("clawsweeper:") && !PROTECTED_LABELS.has(label)) ||
9293
label === "no-stale" ||
9394
label === "stale"
9495
);
9596
}
9697

98+
function isClawSweeperAdvisoryLabel(label: string): boolean {
99+
return (
100+
/^(?:status|rating|proof|merge-risk|impact|issue-rating):/.test(label) ||
101+
/^p[0-3]$/.test(label) ||
102+
label === "feature: ✨ showcase" ||
103+
label === "mantis: telegram-visible-proof" ||
104+
label === "triage: needs-real-behavior-proof"
105+
);
106+
}
107+
97108
function isClawSweeperComment(comment: LooseRecord): boolean {
98109
return CLAWSWEEPER_BOTS.has(
99110
String(comment.user?.login ?? "")

‎test/repair/comment-router-core.test.ts‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import {
7171
usesSharedAutomergeStatus,
7272
} from "../../dist/repair/comment-router-core.js";
7373
import { CLAWSWEEPER_CO_AUTHOR_TRAILER } from "../../dist/repair/co-author-credit.js";
74+
import { issueSourceRevisionSha256 } from "../../dist/repair/issue-source-guard.js";
7475
import { parseSimpleYaml, validateJob } from "../../dist/repair/lib.js";
7576

7677
test("planCommandAckConvergence scopes duplicate cleanup to the current status marker", () => {
@@ -1424,6 +1425,68 @@ test("trusted close gates block protected labels, source drift, and unsupported
14241425
};
14251426

14261427
assert.equal(trustedCloseBlockReason(base), null);
1428+
const reviewedIssue = {
1429+
title: "Close duplicate PR",
1430+
body: "Superseded by the canonical fix.",
1431+
labels: [{ name: "bug" }],
1432+
};
1433+
const reviewedRevision = issueSourceRevisionSha256(reviewedIssue, []);
1434+
const advisoryLabelRevision = issueSourceRevisionSha256(
1435+
{
1436+
...reviewedIssue,
1437+
labels: [
1438+
...reviewedIssue.labels,
1439+
{ name: "status: ⏳ waiting on author" },
1440+
{ name: "rating: 🧂 unranked krab" },
1441+
{ name: "proof: sufficient" },
1442+
{ name: "merge-risk: 🚨 automation" },
1443+
{ name: "P1" },
1444+
],
1445+
},
1446+
[],
1447+
);
1448+
const userLabelRevision = issueSourceRevisionSha256(
1449+
{ ...reviewedIssue, labels: [...reviewedIssue.labels, { name: "needs-design" }] },
1450+
[],
1451+
);
1452+
assert.equal(advisoryLabelRevision, reviewedRevision);
1453+
assert.notEqual(userLabelRevision, reviewedRevision);
1454+
assert.equal(
1455+
trustedCloseBlockReason({
1456+
...base,
1457+
expectedSourceRevision: reviewedRevision,
1458+
currentSourceRevision: advisoryLabelRevision,
1459+
currentItemUpdatedAt: "2026-06-25T22:07:00Z",
1460+
sourceCommentId: "123",
1461+
comments: [
1462+
{
1463+
id: "123",
1464+
user: { login: "clawsweeper[bot]" },
1465+
created_at: "2026-06-25T22:05:00Z",
1466+
updated_at: "2026-06-25T22:07:00Z",
1467+
},
1468+
],
1469+
}),
1470+
null,
1471+
);
1472+
assert.match(
1473+
trustedCloseBlockReason({
1474+
...base,
1475+
expectedSourceRevision: reviewedRevision,
1476+
currentSourceRevision: userLabelRevision,
1477+
currentItemUpdatedAt: "2026-06-25T22:07:00Z",
1478+
sourceCommentId: "123",
1479+
comments: [
1480+
{
1481+
id: "123",
1482+
user: { login: "clawsweeper[bot]" },
1483+
created_at: "2026-06-25T22:05:00Z",
1484+
updated_at: "2026-06-25T22:07:00Z",
1485+
},
1486+
],
1487+
}),
1488+
/source issue\/PR changed since trusted close review/,
1489+
);
14271490
assert.equal(
14281491
trustedCloseBlockReason({ ...base, labels: ["release-blocker"] }),
14291492
"protected label: release-blocker",

‎test/repair/issue-source-guard.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ test("source issue revision ignores automation labels but tracks human labels",
5555
...issue,
5656
labels: [
5757
...issue.labels,
58+
{ name: "status: ⏳ waiting on author" },
59+
{ name: "rating: 🧂 unranked krab" },
60+
{ name: "proof: sufficient" },
61+
{ name: "merge-risk: 🚨 automation" },
62+
{ name: "impact:message-loss" },
63+
{ name: "issue-rating: 🦪 silver shellfish" },
64+
{ name: "P1" },
65+
{ name: "feature: ✨ showcase" },
66+
{ name: "mantis: telegram-visible-proof" },
67+
{ name: "triage: needs-real-behavior-proof" },
5868
{ name: "clawsweeper:reviewed" },
5969
{ name: "clawsweeper:autogenerated" },
6070
{ name: "no-stale" },
@@ -79,6 +89,13 @@ test("source issue revision ignores automation labels but tracks human labels",
7989
),
8090
revision,
8191
);
92+
assert.notEqual(
93+
issueSourceRevisionSha256(
94+
{ ...issue, labels: [...issue.labels, { name: "release-blocker" }] },
95+
[],
96+
),
97+
revision,
98+
);
8299
});
83100

84101
test("source issue state blocks drift and protected signals", () => {

‎test/review-comment-rendering.test.ts‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import test from "node:test";
33

44
import {
55
canPatchReviewComment,
6+
itemSourceRevisionSha256ForTest,
67
isCodexReviewCommentBody,
78
renderReviewCommentFromReport,
89
renderReviewStartStatusComment,
@@ -107,6 +108,55 @@ test("review start status comment is marker-backed and crustacean-friendly", ()
107108
assert.doesNotMatch(comment, /Codex review:/);
108109
});
109110

111+
test("review item source revision ignores advisory labels but tracks protected labels", () => {
112+
const item = {
113+
title: "Close duplicate PR",
114+
body: "This was superseded by the canonical fix.",
115+
labels: [{ name: "bug" }],
116+
};
117+
const revision = itemSourceRevisionSha256ForTest(item, []);
118+
119+
assert.equal(
120+
itemSourceRevisionSha256ForTest(
121+
{
122+
...item,
123+
labels: [
124+
...item.labels,
125+
{ name: "status: ⏳ waiting on author" },
126+
{ name: "rating: 🧂 unranked krab" },
127+
{ name: "proof: sufficient" },
128+
{ name: "merge-risk: 🚨 automation" },
129+
{ name: "impact:message-loss" },
130+
{ name: "issue-rating: 🦪 silver shellfish" },
131+
{ name: "P1" },
132+
{ name: "feature: ✨ showcase" },
133+
{ name: "mantis: telegram-visible-proof" },
134+
{ name: "triage: needs-real-behavior-proof" },
135+
{ name: "clawsweeper:reviewed" },
136+
{ name: "no-stale" },
137+
{ name: "stale" },
138+
],
139+
},
140+
[],
141+
),
142+
revision,
143+
);
144+
assert.notEqual(
145+
itemSourceRevisionSha256ForTest(
146+
{ ...item, labels: [...item.labels, { name: "needs-design" }] },
147+
[],
148+
),
149+
revision,
150+
);
151+
assert.notEqual(
152+
itemSourceRevisionSha256ForTest(
153+
{ ...item, labels: [...item.labels, { name: "release-blocker" }] },
154+
[],
155+
),
156+
revision,
157+
);
158+
});
159+
110160
test("pull request keep-open review comments label the change summary", () => {
111161
const comment = renderReviewCommentFromReport(
112162
`${reportFrontMatter({

0 commit comments

Comments
 (0)