Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Let a maintainer dry run of the triage bot run while paused and on any item

Nguyen Xuan An9d2297054041
diff --git a/.github/workflows/claude-triage.yml b/.github/workflows/claude-triage.yml
index 00c2f613..06c8dfe9 100644
--- a/.github/workflows/claude-triage.yml
+++ b/.github/workflows/claude-triage.yml
@@ -44,7 +44,8 @@ concurrency:
jobs:
triage:
# Cheap early exit before a runner starts; scripts/triage-should-run.mjs checks the same things again.
- if: ${{ vars.TRIAGE_ENABLED != 'false' && github.event.pull_request.draft != true && github.event.sender.type != 'Bot' && !contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association || github.event.issue.author_association) }}
+ # A dry run (workflow_dispatch) posts nothing, so it runs while paused and on any item; the gate script decides.
+ if: ${{ github.event_name == 'workflow_dispatch' || (vars.TRIAGE_ENABLED != 'false' && github.event.pull_request.draft != true && github.event.sender.type != 'Bot' && !contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association || github.event.issue.author_association)) }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
diff --git a/docs/maintainers.md b/docs/maintainers.md
index eff1fb69..6f1298f0 100644
--- a/docs/maintainers.md
+++ b/docs/maintainers.md
@@ -43,7 +43,7 @@ Each run uses the subscription behind that token, with the Sonnet model and at m
### Trying it without posting
-To see what the first pass would say about an item, open the Actions tab, pick "Claude triage", choose "Run workflow" and enter the issue or pull request number. The run applies the same gate and the same Claude step, then prints the comment and the labels it would add to the job log and the step summary. It posts no comment and adds no label. Only people with write access can start it. The gate still skips maintainer-authored items, drafts and items a maintainer has touched; the reason is in the "Decide whether the first pass applies" step. An earlier bot comment does not stop a dry run.
+To see what the first pass would say about an item, open the Actions tab, pick "Claude triage", choose "Run workflow" and enter the issue or pull request number. The run applies the same gate and the same Claude step, then prints the comment and the labels it would add to the job log and the step summary. It posts no comment and adds no label. Only people with write access can start it. A dry run works on any item you name, including your own, closed, held or already triaged items, and it runs while `TRIAGE_ENABLED` is `false`, so you can test the bot before turning it on. Only the daily run limit stops it, because it still uses the subscription. The "Decide whether the first pass applies" step prints the reason when it skips.
### Approval wording
diff --git a/scripts/triage-should-run.mjs b/scripts/triage-should-run.mjs
index 1715183e..40de9be8 100644
--- a/scripts/triage-should-run.mjs
+++ b/scripts/triage-should-run.mjs
@@ -51,10 +51,16 @@ export function decideTriage({
enabled = true,
requireStickyForLaterSteps = false,
}) {
+ const isDispatch = eventName === 'workflow_dispatch';
+ // A dry run is a maintainer naming one item. It posts and labels nothing, so the pause, ownership and hand-over rules
+ // do not apply. Only the daily run limit does, because a dry run still spends the subscription.
+ if (isDispatch) {
+ if (runsToday > MAX_RUNS_PER_DAY) return { run: false, reason: 'daily run limit reached' };
+ return { run: true, reason: 'maintainer dry run' };
+ }
if (!enabled) return { run: false, reason: 'paused by TRIAGE_ENABLED' };
const allowedActions = TRIGGERS[eventName];
if (!allowedActions) return { run: false, reason: `event ${eventName} is not triaged` };
- const isDispatch = eventName === 'workflow_dispatch';
if (!isDispatch && !allowedActions.includes(action)) return { run: false, reason: `action ${action} is not triaged` };
if (item.state && item.state !== 'open') return { run: false, reason: 'closed or merged' };
if (item.merged === true) return { run: false, reason: 'closed or merged' };
diff --git a/tests/triage-bot-hardening.test.js b/tests/triage-bot-hardening.test.js
index 4e812064..a1e26cb0 100644
--- a/tests/triage-bot-hardening.test.js
+++ b/tests/triage-bot-hardening.test.js
@@ -179,15 +179,19 @@ test('the dry run reads the item from a number, accepts only a plain number and
assert.equal(loadTriageItem({ issue: { number: 3 } }, 'o/r', () => ({ number: 3 })).number, 3);
});
-test('a dry run passes the gate for an item an earlier run already triaged, but still skips maintainers and held items', () => {
+test('a dry run passes the gate for any item a maintainer names, even paused, and stops only at the daily limit', () => {
const dispatch = (overrides = {}, event = {}) =>
decideTriage({ eventName: 'workflow_dispatch', item: { ...outsider, ...overrides }, ...event });
assert.equal(dispatch().run, true);
assert.equal(dispatch({}, { alreadyTriaged: true }).run, true);
- assert.equal(dispatch({ author_association: 'OWNER' }).run, false);
- assert.equal(dispatch({ labels: [{ name: 'hold:look-approval' }] }).run, false);
- assert.equal(dispatch({}, { maintainerActivity: 1 }).run, false);
- assert.equal(dispatch({}, { enabled: false }).run, false);
+ assert.equal(dispatch({ author_association: 'OWNER' }).run, true);
+ assert.equal(dispatch({ labels: [{ name: 'hold:look-approval' }] }).run, true);
+ assert.equal(dispatch({}, { maintainerActivity: 1 }).run, true);
+ assert.equal(dispatch({}, { enabled: false }).run, true);
+ assert.equal(dispatch({ state: 'closed' }).run, true);
+ assert.equal(dispatch({}, { runsToday: 10000 }).run, false);
+ const pausedEvent = decideTriage({ eventName: 'issues', action: 'opened', item: outsider, enabled: false });
+ assert.equal(pausedEvent.run, false);
});
test('the workflow offers a number-only manual dry run, and the post and label scripts write nothing in it', () => {