diff --git a/scripts/github/issue-gate.mjs b/scripts/github/issue-gate.mjs index 8e141c2b4..b3b5a430f 100644 --- a/scripts/github/issue-gate.mjs +++ b/scripts/github/issue-gate.mjs @@ -181,6 +181,7 @@ export function evaluateIssue(issue, options = {}) { const plan = { ...base, verdict, reasons }; plan.aiAssisted = AI_DISCLOSURE.test(body); if (plan.aiAssisted && !labels.has(AI_LABEL)) plan.labelsToAdd.push(AI_LABEL); + if (!plan.aiAssisted && labels.has(AI_LABEL)) plan.labelsToRemove.push(AI_LABEL); if (verdict === 'pass') { if (labels.has(GATE_LABEL)) plan.labelsToRemove.push(GATE_LABEL); diff --git a/tests/github-issue-gate.test.mjs b/tests/github-issue-gate.test.mjs index bd9ca5bfb..9ff8e7348 100644 --- a/tests/github-issue-gate.test.mjs +++ b/tests/github-issue-gate.test.mjs @@ -222,6 +222,15 @@ describe('issue body gate', () => { assert.deepEqual(plan.labelsToAdd, [AI_LABEL]); }); + it('removes the AI label when an edit drops the disclosure line', () => { + const plan = evaluateIssue(issue({ + labels: [AI_LABEL], + }), { templates }); + assert.equal(plan.verdict, 'pass'); + assert.equal(plan.aiAssisted, false); + assert.deepEqual(plan.labelsToRemove, [AI_LABEL]); + }); + it('exempts maintainers and repo members', () => { const maintainer = evaluateIssue(issue({ authorLogin: 'pbakaus', body: 'quick note' }), { templates }); assert.equal(maintainer.exempt, true);