Skip to content

Commit 6b52dff

Browse files
authored
fix(github): preserve sufficient proof against negative relabel (#85567)
1 parent 5ca734f commit 6b52dff

2 files changed

Lines changed: 72 additions & 2 deletions

File tree

scripts/github/barnacle-auto-response.mjs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,15 @@ function shouldRemoveProofSufficientLabel(
833833
return true;
834834
}
835835

836+
const negativeProofLabels = new Set([NEEDS_REAL_BEHAVIOR_PROOF_LABEL, MOCK_ONLY_PROOF_LABEL]);
837+
838+
function shouldPreserveClawSweeperProofJudgment(context, labelSet) {
839+
return (
840+
labelSet.has(PROOF_SUFFICIENT_LABEL) &&
841+
!["edited", "synchronize"].includes(context.payload.action)
842+
);
843+
}
844+
836845
async function applyPullRequestCandidateLabels(github, context, core, pullRequest, labelSet) {
837846
const files = await listPullRequestFiles(github, context, pullRequest);
838847
const hasExactHeadClawSweeperProof =
@@ -854,8 +863,11 @@ async function applyPullRequestCandidateLabels(github, context, core, pullReques
854863
},
855864
files,
856865
);
866+
const candidateLabelsToApply = shouldPreserveClawSweeperProofJudgment(context, labelSet)
867+
? classifiedLabels.filter((label) => !negativeProofLabels.has(label))
868+
: classifiedLabels;
857869
const staleProofLabels = structuralProofLabelValues.filter(
858-
(label) => labelSet.has(label) && !classifiedLabels.includes(label),
870+
(label) => labelSet.has(label) && !candidateLabelsToApply.includes(label),
859871
);
860872
if (
861873
labelSet.has(PROOF_SUFFICIENT_LABEL) &&
@@ -870,7 +882,14 @@ async function applyPullRequestCandidateLabels(github, context, core, pullReques
870882
staleProofLabels.push(PROOF_SUFFICIENT_LABEL);
871883
}
872884
await removeLabels(github, context, pullRequest.number, staleProofLabels, labelSet);
873-
await addMissingLabels(github, context, core, pullRequest.number, classifiedLabels, labelSet);
885+
await addMissingLabels(
886+
github,
887+
context,
888+
core,
889+
pullRequest.number,
890+
candidateLabelsToApply,
891+
labelSet,
892+
);
874893
}
875894

876895
function isAutomationUser(user, fallbackLogin = "") {

test/scripts/barnacle-auto-response.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,57 @@ describe("barnacle-auto-response", () => {
10111011
});
10121012

10131013
expect(calls.removeLabel).toEqual([]);
1014+
expect(calls.addLabels.flatMap((call) => call.labels)).not.toContain(
1015+
candidateLabels.needsRealBehaviorProof,
1016+
);
1017+
});
1018+
1019+
it("does not re-add negative proof labels while sufficient proof is present", async () => {
1020+
const { calls, github } = barnacleGithub([file("src/gateway/server.ts")]);
1021+
1022+
await runBarnacleAutoResponse({
1023+
github,
1024+
context: barnacleContext({}, [PROOF_SUFFICIENT_LABEL], {
1025+
action: "unlabeled",
1026+
label: { name: candidateLabels.needsRealBehaviorProof },
1027+
sender: { login: "maintainer", type: "User" },
1028+
}),
1029+
core: {
1030+
info: () => undefined,
1031+
},
1032+
});
1033+
1034+
expect(calls.removeLabel).toEqual([]);
1035+
expect(calls.addLabels.flatMap((call) => call.labels)).not.toContain(
1036+
candidateLabels.needsRealBehaviorProof,
1037+
);
1038+
});
1039+
1040+
it("removes negative proof labels when sufficient proof is already present", async () => {
1041+
const { calls, github } = barnacleGithub([file("src/gateway/server.ts")]);
1042+
1043+
await runBarnacleAutoResponse({
1044+
github,
1045+
context: barnacleContext(
1046+
{},
1047+
[PROOF_SUFFICIENT_LABEL, candidateLabels.needsRealBehaviorProof],
1048+
{
1049+
action: "labeled",
1050+
label: { name: "status: ready for maintainer look" },
1051+
sender: { login: "openclaw-clawsweeper[bot]", type: "Bot" },
1052+
},
1053+
),
1054+
core: {
1055+
info: () => undefined,
1056+
},
1057+
});
1058+
1059+
expect(calls.removeLabel).toEqual([
1060+
expectedRemoveLabel(123, candidateLabels.needsRealBehaviorProof),
1061+
]);
1062+
expect(calls.addLabels.flatMap((call) => call.labels)).not.toContain(
1063+
candidateLabels.needsRealBehaviorProof,
1064+
);
10141065
});
10151066

10161067
it("does not let Barnacle veto ClawSweeper's sufficient proof label add", async () => {

0 commit comments

Comments
 (0)