Remove the ai-assisted label when an edit drops the disclosure line

Keeps the label a deterministic mirror of the body's disclosure state,
per Greptile's P2 review finding on #518.

AI-assisted: written with an AI agent under maintainer direction.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Abdul Wahab
2026-08-05 22:30:04 +05:00
co-authored by Cursor
parent 38dc50108f
commit 281352ca53
2 changed files with 10 additions and 0 deletions
+1
View File
@@ -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);
+9
View File
@@ -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);