The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 12:15 UTC
feat(github): issues and PRs from denounced authors close when opened (#37017)
maria committed
Nov 15, 2026 at 02:46 UTC
88621ac593118a27b78a702d1da02eb69729495c
3 files changed
+68
-8
.github/scripts/pr-limits.cjs
+31
-7
@@ -100,14 +100,22 @@ function parseExemptions(text) {
100
}
101
102
// VOUCHED.td: one `github:login` per line, `#` comments, and `-github:login reason` to denounce.
103
-function vouchedLogins(text) {
104
- const logins = new Set();
103
+// A login listed both ways is an error: pr-vouch.yml's action reads its first line and
104
+// issue-vouch.yml its last, so no answer here would agree with both labels.
105
+function parseVouchList(text) {
106
+ const vouched = new Set();
107
+ const denounced = new Set();
108
for (const raw of text.split("\n")) {
106
- const entry = raw.trim().split(/\s+/)[0];
107
- if (entry.startsWith("github:")) logins.add(entry.slice("github:".length).toLowerCase());
109
+ const match = /^(-?)github:(\S+)/.exec(raw.trim());
110
+ if (!match) continue;
111
+ const login = match[2].toLowerCase();
112
+ const [listed, other] = match[1] ? [denounced, vouched] : [vouched, denounced];
113
+ if (other.has(login))
114
+ throw new Error(`${VOUCHED_PATH}: ${login} is both vouched and denounced`);
115
+ listed.add(login);
116
}
109
- if (logins.size === 0) throw new Error(`${VOUCHED_PATH}: no entries`);
110
- return logins;
117
+ if (vouched.size === 0) throw new Error(`${VOUCHED_PATH}: no entries`);
118
+ return { vouched, denounced };
119
}
120
121
function labeledAt(pr, name) {
@@ -278,7 +286,8 @@ async function enforceOpenLimit({ github, context, core, dryRun }) {
286
// lookups as "not vouched". Every read below throws on failure, and a throw closes nothing.
287
if (pr.user.type === "Bot") return;
288
if (parseExemptions(fs.readFileSync(EXEMPTIONS_PATH, "utf8")).has(author.toLowerCase())) return;
281
- if (vouchedLogins(fs.readFileSync(VOUCHED_PATH, "utf8")).has(author.toLowerCase())) return;
289
+ const { vouched, denounced } = parseVouchList(fs.readFileSync(VOUCHED_PATH, "utf8"));
290
+ if (vouched.has(author.toLowerCase())) return;
291
const { data: access } = await github.rest.repos.getCollaboratorPermissionLevel({
292
...context.repo,
293
username: author,
@@ -289,6 +298,21 @@ async function enforceOpenLimit({ github, context, core, dryRun }) {
298
const reopened = context.payload.action === "reopened";
299
if (reopened && context.payload.sender.login.toLowerCase() !== author.toLowerCase()) return;
300
301
+ if (denounced.has(author.toLowerCase())) {
302
+ if (dryRun) {
303
+ core.notice(`Dry run. PR #${pr.number} would close: ${author} is denounced.`);
304
+ return;
305
+ }
306
+ await closeWithComment(
307
+ github,
308
+ context,
309
+ pr.number,
310
+ `Closing: ${author} is banned from contributing here, so this PR will not be reviewed. See [bans](${guideLink(context, "bans")}).`,
311
+ );
312
+ core.info(`PR #${pr.number}: closed, ${author} is denounced.`);
313
+ return;
314
+ }
315
+
316
const q = `repo:${context.repo.owner}/${context.repo.repo} is:pr is:open author:${author} sort:created-asc`;
317
const { search } = await read(github, AUTHOR_OPEN_PRS_QUERY, { q });
318
// A new PR counts only the older ones, so two opened together cannot close each other.
.github/workflows/issue-vouch.yml
+34
-1
@@ -40,9 +40,14 @@ jobs:
40
ref: context.payload.repository.default_branch,
41
});
42
const statusByUser = new Map();
43
+ const listedBothWays = new Set();
44
for (const raw of Buffer.from(file.content, "base64").toString("utf8").split("\n")) {
45
const match = /^(-?)github:(\S+)/.exec(raw.trim());
45
- if (match) statusByUser.set(match[2].toLowerCase(), match[1] ? "denounced" : "vouched");
46
+ if (!match) continue;
47
+ const login = match[2].toLowerCase();
48
+ const status = match[1] ? "denounced" : "vouched";
49
+ if (statusByUser.has(login) && statusByUser.get(login) !== status) listedBothWays.add(login);
50
+ statusByUser.set(login, status);
51
}
52
53
const issues =
@@ -74,4 +79,32 @@ jobs:
79
await github.rest.issues.addLabels({ owner, repo, issue_number: issue.number, labels: [next] });
80
core.info(`Issue #${issue.number} (${issue.user.login}): ${status} -> ${next}`);
81
}
82
+
83
+ // Only a newly opened issue is closed. One filed before its author was denounced
84
+ // may already have a fix on the way, so the sweep leaves those to maintainers.
85
+ // Someone else reopening it is a maintainer keeping it open.
86
+ const reopenedByOther =
87
+ context.payload.action === "reopened" &&
88
+ context.payload.sender.login.toLowerCase() !== issue.user.login.toLowerCase();
89
+ // The PR rules refuse a list that names a login both ways, so nothing closes for one here.
90
+ const trusted =
91
+ issue.user.type === "Bot" ||
92
+ ["OWNER", "MEMBER", "COLLABORATOR"].includes(issue.author_association) ||
93
+ listedBothWays.has(issue.user.login.toLowerCase());
94
+ if (status === "denounced" && context.eventName === "issues" && !reopenedByOther && !trusted) {
95
+ await github.rest.issues.createComment({
96
+ owner,
97
+ repo,
98
+ issue_number: issue.number,
99
+ body: `Closing: ${issue.user.login} is banned from contributing here, so this issue will not be triaged. See [bans](https://github.com/${owner}/${repo}/blob/main/CONTRIBUTING.md#bans).`,
100
+ });
101
+ await github.rest.issues.update({
102
+ owner,
103
+ repo,
104
+ issue_number: issue.number,
105
+ state: "closed",
106
+ state_reason: "not_planned",
107
+ });
108
+ core.info(`Issue #${issue.number}: closed, ${issue.user.login} is denounced.`);
109
+ }
110
}
CONTRIBUTING.md
+3
@@ -115,6 +115,9 @@ the open PR limit.
115
- If you make our lives harder as reviewers and maintainers, you will be banned. Examples are repeated
116
pings, a fight over a closure, and a second account to get around a limit.
117
118
+A banned account is denounced in [.github/VOUCHED.td](.github/VOUCHED.td). Any issue or PR it opens
119
+is closed when it is opened.
120
+
121
<a id="closure-and-reconsideration"></a>
122
123
## When your PR is closed