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

README.md

103 lines7.4 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. Route unassigned core-owned PRs first. Read `.github/CODEOWNERS` from the
40 default branch through GitHub, including last-match and ownerless exceptions.
41 Assign these PRs to `AlemTuzlak`, regardless of load. If Alem authored the PR,
42 choose another maintainer with the fewest assigned PRs.
432. Route other unassigned PRs to the least-loaded maintainer who is not the
44 author. Break load ties with configured areas and matching files or packages
45 from PRs merged in the last 14 days (authored or reviewed by the maintainer).
46 Remaining ties use a deterministic rotation based on the item number.
473. Route unassigned issues with a separate issue count. Package names in the
48 title/body break load ties using configured areas.
49​
50Every eligible item gets an assignee when the roster has someone other than
51its author. The old assignment caps no longer apply. Existing assignments stay
52in place. Core approval and author exclusions can prevent a perfectly even
53split; later assignments fill the smaller queues first.
54​
55The sweep requests reviews from PR assignees unless they authored the PR,
56already have a pending request, or have submitted a review. This also repairs a
57run that assigned a PR but failed before requesting review. It does not keep
58re-requesting completed reviews. Dry-run output includes review requests.
59​
60## Review velocity
61​
62Each maintainer's digest queue includes:
63​
64- **Reviews/7d:** submitted reviews in the last seven days across open PRs and
65 PRs closed in the 14-day lookback. Repeat reviews count as separate completed
66 reviews; comments, pending reviews, bots, and self-reviews do not count.
67- **Median first review:** hours from the earliest assignment or review request
68 to that maintainer's first submitted review on a PR. The first review must
69 fall in the last seven days. Repeated requests do not reset the clock.
70- **Sample count:** PRs with both timestamps. Reviews without a preceding
71 assignment/request count toward throughput, but have no latency sample.
72​
73PR files, review requests, and review timelines are paginated, so a core-owned
74path or first review beyond the first page is included. Assignment/request
75activity does not count as a conversation reply or reset SLA clocks.
76​
77## Secrets
78​
79- `DISCORD_MAINTAINER_WEBHOOK` — Discord webhook URL for the daily digest
80 (Server Settings → Integrations → Webhooks). Without it, the digest lands in
81 the workflow step summary only.
82- The sweep uses the default `GITHUB_TOKEN` — no extra setup.
83​
84## Running locally
85​
86```bash
87# Dry-run: prints the mutation plan / digest, changes nothing
88pnpm maintainer:sweep --dry-run
89pnpm maintainer:scorecard --dry-run
90​
91# Tests
92pnpm test:maintainer
93```
94​
95Both entries use `GITHUB_TOKEN` if set, else fall back to `gh auth token`.
96​
97## Layout
98​
99Pure logic (`classify.ts` waiting-on state machine + SLA clocks, `route.ts`
100assignment, `metrics.ts` scorecard, `glob.ts`) is fixture-tested and does no
101I/O. `collect.ts` (GraphQL, read-only), `actions.ts` (REST mutations),
102`discord.ts` (webhook) are the I/O seams; `sweep.ts` / `scorecard.ts` are the
103entry points.