Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

README.md

108 lines7.8 KB

1# Maintainer toolset
2​
3Automation that keeps on top of open PRs, issues, and discussions:
4​
5- **Sweep** (`.github/workflows/maintainer-sweep.yml`, every 3h): assigns each
6 eligible open PR/issue to a maintainer (drafts and suspected drive-by PRs
7 and bot items are skipped), requests the assigned PR maintainer’s review,
8 posts a one-time ack comment with a deterministic pre-review checklist, asks
9 for a reproduction on bug reports that lack one, and reconciles
10 `waiting-on: *` / `ready-to-merge` / `merge-conflicts` / `needs-repro` /
11 `has-pr` labels.
12- **Scorecard** (`.github/workflows/maintainer-scorecard.yml`, daily): posts a
13 to-do digest to Discord — SLA breaches, ready-to-merge PRs, per-maintainer
14 queues (including which items got fresh contributor replies), new/flagged/
15 stale items, unanswered discussions, response-time stats, and review velocity.
16​
17Both are **stateless and API-only**: every metric (first-response time, 7-day
18deltas, SLA clocks) is recomputed from GitHub timelines each run, idempotency
19comes from HTML markers in bot comments plus visible assignment/label state,
20and PR code is never checked out or executed (no `pull_request_target`).
21​
22## Configuration — `.github/maintainers.json`
23​
24| Field | Meaning |
25| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
26| `maintainers[].github` | GitHub login; the roster defines who counts as "a maintainer responded". |
27| `maintainers[].discord` | Discord user id (snowflake) for digest @-mentions; `null` → plain bold name. |
28| `maintainers[].areas` | Optional file globs (`**`, `*`, `?`) giving this maintainer routing priority for matching PRs (issues match package names in title/body). Among equally loaded maintainers, merged-PR history also supplies file/package experience. |
29| `maintainers[].maxOpenAssignments` | Legacy field, ignored by routing. Open-assignment counts never block assignment. |
30| `sla.firstResponseHours` | Deadline for the first human response on a new item (default 24h). |
31| `sla.followUpResponseHours` | Deadline for answering a follow-up message (default 48h). |
32| `sla.staleAuthorDays` | Author silence before an item is a nudge/close candidate (default 14d). |
33| `spam.*` | Drive-by/bounty heuristic: account younger than `maxAccountAgeDays` **and** diff ≤ `maxChangedLines` **and** no linked issue → flagged for human judgment, never auto-acked. |
34| `botAllowlist` | Logins always treated as bots (excluded from human metrics and acks). |
35| `maxCommentsPerRun` | Safety cap on comments per sweep; overflow defers to the next run. |
36​
37## Assignment order
38​
391. If an unassigned PR closes an open issue that already has an assignee, and
40 that assignee is on the roster and did not author the PR, assign the PR to
41 them. This wins over the core-review rule. The first linked issue with a
42 qualifying assignee wins. A missing issue, a non-roster assignee, or an
43 assignee who authored the PR falls through to the steps below.
442. Route unassigned core-owned PRs first. Read `.github/CODEOWNERS` from the
45 default branch through GitHub, including last-match and ownerless exceptions.
46 Assign these PRs to `AlemTuzlak`, regardless of load. If Alem authored the PR,
47 choose another maintainer with the fewest assigned PRs.
483. Route other unassigned PRs to the least-loaded maintainer who is not the
49 author. Break load ties with configured areas and matching files or packages
50 from PRs merged in the last 14 days (authored or reviewed by the maintainer).
51 Remaining ties use a deterministic rotation based on the item number.
524. Route unassigned issues with a separate issue count. Package names in the
53 title/body break load ties using configured areas.
54​
55Every eligible item gets an assignee when the roster has someone other than
56its author. The old assignment caps no longer apply. Existing assignments stay
57in place. Core approval and author exclusions can prevent a perfectly even
58split; later assignments fill the smaller queues first.
59​
60The sweep requests reviews from PR assignees unless they authored the PR,
61already have a pending request, or have submitted a review. This also repairs a
62run that assigned a PR but failed before requesting review. It does not keep
63re-requesting completed reviews. Dry-run output includes review requests.
64​
65## Review velocity
66​
67Each maintainer's digest queue includes:
68​
69- **Reviews/7d:** submitted reviews in the last seven days across open PRs and
70 PRs closed in the 14-day lookback. Repeat reviews count as separate completed
71 reviews; comments, pending reviews, bots, and self-reviews do not count.
72- **Median first review:** hours from the earliest assignment or review request
73 to that maintainer's first submitted review on a PR. The first review must
74 fall in the last seven days. Repeated requests do not reset the clock.
75- **Sample count:** PRs with both timestamps. Reviews without a preceding
76 assignment/request count toward throughput, but have no latency sample.
77​
78PR files, review requests, and review timelines are paginated, so a core-owned
79path or first review beyond the first page is included. Assignment/request
80activity does not count as a conversation reply or reset SLA clocks.
81​
82## Secrets
83​
84- `DISCORD_MAINTAINER_WEBHOOK` — Discord webhook URL for the daily digest
85 (Server Settings → Integrations → Webhooks). Without it, the digest lands in
86 the workflow step summary only.
87- The sweep uses the default `GITHUB_TOKEN` — no extra setup.
88​
89## Running locally
90​
91```bash
92# Dry-run: prints the mutation plan / digest, changes nothing
93pnpm maintainer:sweep --dry-run
94pnpm maintainer:scorecard --dry-run
95​
96# Tests
97pnpm test:maintainer
98```
99​
100Both entries use `GITHUB_TOKEN` if set, else fall back to `gh auth token`.
101​
102## Layout
103​
104Pure logic (`classify.ts` waiting-on state machine + SLA clocks, `route.ts`
105assignment, `metrics.ts` scorecard, `glob.ts`) is fixture-tested and does no
106I/O. `collect.ts` (GraphQL, read-only), `actions.ts` (REST mutations),
107`discord.ts` (webhook) are the I/O seams; `sweep.ts` / `scorecard.ts` are the
108entry points.