Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions .github/scripts/community-pr-followup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const FAILING_CHECK_CONCLUSIONS = new Set(["FAILURE", "TIMED_OUT", "STARTUP_FAIL
const FAILING_STATUS_STATES = new Set(["FAILURE", "ERROR"]);
const MARKER_PREFIX = "<!-- stablebar-community-pr-followup ";
const MARKER_PATTERN = /<!-- stablebar-community-pr-followup (\{[^\r\n]*\}) -->\s*$/;
// The workflow comments as GitHub Actions (its GraphQL and REST logins). Only its markers count:
// anyone can get another bot, such as CodeRabbit, to repeat text.
const FOLLOWUP_BOT_LOGINS = new Set(["github-actions", "github-actions[bot]"]);

const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;

Expand Down Expand Up @@ -85,6 +88,11 @@ export function isBotUser(user) {
return login === "" || /\[bot\]$/i.test(login);
}

/** A bot account that is still there: a deleted account's comments have no author and prove nothing. */
function isReviewBot(user) {
return Boolean(user?.login) && isBotUser(user);
}

/** Community contributors are non-bot accounts outside OWNER, MEMBER and COLLABORATOR. */
export function isCommunityAuthor(author, authorAssociation) {
if (isBotUser(author)) return false;
Expand Down Expand Up @@ -119,7 +127,7 @@ export function defaultCodeowners(codeownersText) {
/** Parses our own follow-up marker from a bot comment, preferring GitHub's publication timestamp. */
export function readFollowupMarker(comment) {
const actor = comment?.author ?? comment?.user;
if (!actor || !isBotUser(actor)) return null;
if (!actor || !isBotUser(actor) || !FOLLOWUP_BOT_LOGINS.has(actor.login)) return null;
const match = String(comment.body ?? "").match(MARKER_PATTERN);
if (!match) return null;
try {
Expand Down Expand Up @@ -261,25 +269,33 @@ export function evaluatePullRequest(pr, { now, policy = POLICY, fallbackReviewer
}
}

// Pick each unresolved thread's newest reply by createdAt rather than array order.
// An unresolved thread waits on the author when the newest comment that counts came from the team
// or a review bot, and on maintainers when it came from the author, picked by createdAt rather
// than array order. The author's and the team's comments count, and a bot's only when it opened
// the thread: anyone can get a bot to reply. Nobody outside the team can put a pull request on
// its author and get it closed.
let unresolvedAuthorThreads = 0;
let unresolvedMaintainerThreads = 0;
let lastAuthorThreadAt = null;
let lastHumanThreadAt = null;

for (const thread of pr.reviewThreads ?? []) {
const threadComments = thread.comments ?? [];
const opener = threadComments.reduce((first, c) => (first === null
|| (parseTime(c.createdAt) ?? Infinity) < (parseTime(first.createdAt) ?? Infinity) ? c : first), null);
let latestComment = null;
let latestCommentAt = null;
for (const c of threadComments) {
const at = parseTime(c.createdAt);
const fromAuthor = isAuthor(c.author);
if (!isBotUser(c.author)) lastHumanThreadAt = maxTime(lastHumanThreadAt, at);
Comment thread
M4n0x marked this conversation as resolved.
Resolved
if (fromAuthor) lastAuthorThreadAt = maxTime(lastAuthorThreadAt, at);
const counts = fromAuthor || isTeamMember(c.author, c.authorAssociation) || (c === opener && isReviewBot(c.author));
if (!counts) continue;
if (latestComment === null || (at ?? -Infinity) >= (latestCommentAt ?? -Infinity)) {
latestComment = c;
latestCommentAt = at;
}
if (isBotUser(c.author)) continue;
lastHumanThreadAt = maxTime(lastHumanThreadAt, at);
if (isAuthor(c.author)) lastAuthorThreadAt = maxTime(lastAuthorThreadAt, at);
}
if (thread.isResolved || !latestComment) continue;
if (isAuthor(latestComment.author)) {
Expand Down
56 changes: 55 additions & 1 deletion .github/scripts/community-pr-followup.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test("defaultCodeowners parses wildcard user owners and matches the repository f
assert.deepEqual(owners, defaultCodeowners(repoCodeowners));
});

test("readFollowupMarker trusts only bot comments and prefers publication createdAt", () => {
test("readFollowupMarker trusts only the workflow's own comments and prefers publication createdAt", () => {
const body = formatAuthorNudgeComment({
authorLogin: "alice",
headSha: "abc1234",
Expand All @@ -94,6 +94,9 @@ test("readFollowupMarker trusts only bot comments and prefers publication create
assert.equal(fallbackParsed?.at, BASE_TIME - 60_000);

assert.equal(readFollowupMarker({ author: { __typename: "User", login: "alice" }, body, createdAt: daysAgo(1) }), null);
// Anyone can get another bot to repeat text, so only the workflow's own markers count.
assert.equal(readFollowupMarker({ author: { __typename: "Bot", login: "coderabbitai" }, body, createdAt: daysAgo(1) }), null);
assert.equal(readFollowupMarker({ user: { type: "Bot", login: "github-actions[bot]" }, body, created_at: publishedAt })?.kind, "author-nudge");
});

test("analyzeChecks deduplicates reruns and classifies Visual review statuses", () => {
Expand Down Expand Up @@ -420,6 +423,57 @@ test("review threads, CHANGES_REQUESTED, and DISMISSED reviews classify ownershi
assert.deepEqual(waitingMaintainer.labelsToRemove, [LABELS.waitingForAuthor.name]);
});

test("review threads from outsiders don't put a PR on its author, while the team's and review bots' still do", () => {
const thread = (...comments) => ({ isResolved: false, comments });
const outsider = { author: { __typename: "User", login: "mallory" }, authorAssociation: "CONTRIBUTOR", createdAt: daysAgo(9) };
Comment thread
M4n0x marked this conversation as resolved.
Resolved
const bot = { author: { __typename: "Bot", login: "coderabbitai" }, authorAssociation: "NONE", createdAt: daysAgo(9) };
const maintainer = { author: { __typename: "User", login: "Seb-GRAF" }, authorAssociation: "OWNER", createdAt: daysAgo(9) };
const outsiderPlusOne = { ...outsider, createdAt: daysAgo(8) };

const fromOutsider = evaluatePullRequest(makePR({ reviewThreads: [thread(outsider)] }), { now: BASE_TIME });
assert.equal(fromOutsider.court, "maintainer");
assert.equal(fromOutsider.action, "remind-maintainers");

// Review bots are installed by the team, and their threads have to be answered before merging.
const fromBot = evaluatePullRequest(makePR({ reviewThreads: [thread(bot)] }), { now: BASE_TIME });
assert.equal(fromBot.action, "nudge-author");
assert.deepEqual(fromBot.blockers, [{ kind: "unresolved-threads", count: 1 }]);

// Anyone can get a bot to reply, so a bot's reply after the author's doesn't count.
const botReply = { ...bot, createdAt: daysAgo(7) };
const answeredThenBot = evaluatePullRequest(makePR({
reviewThreads: [thread(bot, { author: { __typename: "User", login: "alice" }, authorAssociation: "FIRST_TIME_CONTRIBUTOR", createdAt: daysAgo(8) }, botReply)],
}), { now: BASE_TIME });
assert.equal(answeredThenBot.court, "maintainer");

// A deleted account's comment has no author and doesn't pass for a bot.
const fromDeleted = evaluatePullRequest(makePR({ reviewThreads: [thread({ ...outsider, author: null })] }), { now: BASE_TIME });
assert.equal(fromDeleted.court, "maintainer");

// An outsider's reply after the author's doesn't hand the thread back to the author either.
const authorReply = { author: { __typename: "User", login: "alice" }, authorAssociation: "FIRST_TIME_CONTRIBUTOR", createdAt: daysAgo(8) };
const answeredThenOutsider = evaluatePullRequest(makePR({
reviewThreads: [thread(maintainer, authorReply, { ...outsider, createdAt: daysAgo(7) })],
}), { now: BASE_TIME });
assert.equal(answeredThenOutsider.court, "maintainer");
assert.deepEqual(answeredThenOutsider.maintainerReasons, ["thread-reply"]);

// An outsider's reply after a maintainer's request doesn't take the thread off the author.
const maintainerThenOutsider = evaluatePullRequest(makePR({ reviewThreads: [thread(maintainer, outsiderPlusOne)] }), { now: BASE_TIME });
assert.equal(maintainerThenOutsider.action, "nudge-author");
assert.deepEqual(maintainerThenOutsider.blockers, [{ kind: "unresolved-threads", count: 1 }]);

// Outsiders' recent comments still delay a follow-up in either court.
const recentOutsider = evaluatePullRequest(makePR({ reviewThreads: [thread({ ...outsider, createdAt: daysAgo(2) })] }), { now: BASE_TIME });
assert.equal(recentOutsider.court, "maintainer");
assert.equal(recentOutsider.action, "none");
const maintainerThenRecentOutsider = evaluatePullRequest(makePR({
reviewThreads: [thread(maintainer, { ...outsider, createdAt: daysAgo(2) })],
}), { now: BASE_TIME });
assert.equal(maintainerThenRecentOutsider.court, "author");
assert.equal(maintainerThenRecentOutsider.action, "none");
});

test("PRs waiting on maintainers remind once after 4 days (including workflow approval and visual-ok) and never close", () => {
const day3 = evaluatePullRequest(makePR({
createdAt: daysAgo(3),
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/community-pr-followup.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Community PR follow-up

# Follows up on open community pull requests so they don't sit idle without action:
# - Waiting on contributor (failing checks, conflicts, requested changes, unresolved threads):
# - Waiting on contributor (failing checks, conflicts, requested changes, unresolved team or bot threads):
# labels waiting-for-author and nudges after 7 days, then closes 7 days later if still silent.
# - Draft PRs get a longer window: nudge after 14 days, close 14 days later.
# - Waiting on maintainers (ready for review, visual-ok, or first-time CI approval):
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Reviews are requested automatically from the people listed in [CODEOWNERS](.gith

[cubic](https://cubic.dev) also reviews every pull request once it is out of draft. [CodeRabbit](https://coderabbit.ai) reviews pull requests labeled `deep-review`: the label is added automatically when a pull request changes more than 400 lines or a file listed in [.github/deep-review-paths](.github/deep-review-paths), and you can add it yourself, or ask a maintainer to, when a change is risky. Fix each comment from either or reply why not, then resolve its thread: unresolved conversations block merging. Their rules come from [AGENTS.md](AGENTS.md), [cubic.yaml](cubic.yaml) and [.coderabbit.yaml](.coderabbit.yaml). CodeRabbit allows each pull request author only a few reviews per hour. When its limit holds a review back, the Deep review workflow asks it again every hour, so there's no need to ask with `@coderabbitai review`.

Open community pull requests are followed up on daily by [Community PR follow-up](.github/workflows/community-pr-followup.yml). A pull request waiting on its author (failing checks, merge conflicts, requested changes or unresolved threads) gets `waiting-for-author` and a check-in after 7 days, and closes automatically 7 days later without an update (drafts get 14 days before a check-in and 14 days after). A ready pull request waiting on maintainers (review, `visual-ok` or first-time CI approval) never closes automatically; after 4 days it gets `needs-review` and reminds maintainers. Add `keep-open` to pause follow-ups on a pull request.
Open community pull requests are followed up on daily by [Community PR follow-up](.github/workflows/community-pr-followup.yml). A pull request waiting on its author (failing checks, merge conflicts, requested changes or unresolved review threads from the team or a review bot) gets `waiting-for-author` and a check-in after 7 days, and closes automatically 7 days later without an update (drafts get 14 days before a check-in and 14 days after). A ready pull request waiting on maintainers (review, `visual-ok` or first-time CI approval) never closes automatically; after 4 days it gets `needs-review` and reminds maintainers. Add `keep-open` to pause follow-ups on a pull request.

The contributors' avatars in the [README](README.md#contributing) come from GitHub's contributors list. Every Monday, [README contributors](.github/workflows/readme-contributors.yml) compares them and, when the list changed, opens a pull request from the `readme-contributors` branch. To count a second account under someone's first, or leave out an automation account, edit `ALIASES` or `EXCLUDED` in [readme-contributors.mjs](.github/scripts/readme-contributors.mjs) rather than the README.

Expand Down
2 changes: 1 addition & 1 deletion DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Add an entry when a pull request sets a rule, a policy or a choice not to do som
- **Screens are drawn once they hold still, each scene in a process of its own** (2026-11-20, [#794]). A drawing is kept once three in a row match, held for two seconds while a spinner shows, instead of after a fixed two seconds. Watching the process's threads and run loop instead of its drawings missed changes that only a drawing showed. Scenes draw a few at once, each in a process of its own: several at once in one process shared its main thread and drew pages still loading on CI's three cores, and what a process has drawn changes what it draws later, such as which version of the app's icon an image gets.
- **Scenes draw only dark unless appearance is what they show** (2026-11-24). Every scene drew light and dark, 326 images taking about five minutes on each side of a pull request's comparison. In November's pull requests, about 395 changed screens changed in both appearances, and no scene changed in only one: the five screens that did were docs images, which still draw both. Scenes about contrast, transparency, text that follows its background, themes and their tokens, tinted images, color editors and shadows keep both.
- **A flaky test doesn't block a pull request** (2026-11-17). When up to five Swift Testing tests fail, the Test job runs them once more on their own and passes with a warning naming those that pass then. They still get fixed, in a pull request of their own. A test that fails twice, an XCTest failure, a crash, a hang or more failures fail the job.
- **Community pull requests get state-aware follow-ups** (2026-11-26). [Community PR follow-up](.github/workflows/community-pr-followup.yml) checks open pull requests from outside the team once a day and distinguishes whose court the ball is in. Ready pull requests waiting on their author (failing checks, merge conflicts, requested changes or unresolved threads) get `waiting-for-author` and a nudge after 7 days and close 7 days later if still silent; drafts get 14 days to nudge and 14 days to close. Ready pull requests waiting on maintainers (review, `visual-ok` or first-time CI approval) never go stale or close, and remind maintainers with `needs-review` after 4 days. `keep-open` pauses follow-ups.
- **Community pull requests get state-aware follow-ups** (2026-11-26). [Community PR follow-up](.github/workflows/community-pr-followup.yml) checks open pull requests from outside the team once a day and distinguishes whose court the ball is in. Ready pull requests waiting on their author (failing checks, merge conflicts, requested changes or unresolved review threads from the team or a review bot) get `waiting-for-author` and a nudge after 7 days and close 7 days later if still silent; drafts get 14 days to nudge and 14 days to close. Ready pull requests waiting on maintainers (review, `visual-ok` or first-time CI approval) never go stale or close, and remind maintainers with `needs-review` after 4 days. `keep-open` pauses follow-ups.
- **The README's contributors come from GitHub's list** (2026-12-02). [README contributors](.github/workflows/readme-contributors.yml) rewrites the avatars weekly and proposes them in a pull request, opened with the release app so its required checks run. It keeps the README's own avatars, leaves out bots and merges second accounts, which a contributors image service such as contrib.rocks couldn't, and adds no outside service. all-contributors was too heavy for a list of code contributors.

## Code
Expand Down
Loading