Skip to content
Open
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
4 changes: 2 additions & 2 deletions docs/pull-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Every open pull request in a team's connected repositories, people's as much as
One settings-table item per pull request (`pk` = team id, `sk = PRREC#<owner/repo>#<number>`), its body a JSON document written with a version check (`services/common/src/pr_record.rs`).

- **Written from the events CoderHelm already receives**, for every pull request: `pull_request`, `pull_request_review`, review and issue comments, `check_run`, `check_suite`, `status` and `push`. A `status` or `push` event finds its pull request through a pointer item by head commit (`PRRECHEAD#`) or branch (`PRRECREF#`).
- **Kept honest by a sync** (`services/worker/src/passes/pr_records.rs`): one GraphQL search per organization of the team's connected repositories. It fills what events don't carry (the review decision, the branch's rules, conflicts, open conversations), adds pull requests opened before the install, and removes records of pull requests no longer open (only when the search was read to its end, and never one an event touched in the last hour).
- **Kept honest by a sync** (`services/worker/src/passes/pr_records.rs`): one GraphQL search per organization of every repository the installation can see, enabled for CoderHelm's work or not, CoderHelm's own included; nothing is filtered by author or label. It fills what events don't carry (the review decision, the branch's rules, conflicts, open conversations), adds pull requests opened before the install, and removes records of pull requests no longer open (only when the search was read to its end, and never one an event touched in the last hour).
- **Events and the sync never undo each other.** The sync never reopens a record an event closed; each field both write (state, title, draft, head, base, labels, review requests, reviews, review decision, checks, mergeability, auto-merge, the merge queue, size) keeps the time an event last wrote it, and the sync writes that field only when its search was read after that time. A queue, auto-merge or review change that lands while a page is in flight survives the page. The reviews and review requests the sync reads replace the record's lists, so a dismissed review leaves it. A list cut short by its page size is marked partial: a required check that may be on a later page reads as unknown, never as running. The review decision is also worked out at each review and review request event, and bypass and coverage use it only when it is newer than the last review.
- **No expiry while open.** A closed or merged pull request is kept for three days.
- **What it holds:** the author; who worked on it (committers, reviewers, commenters, and who asked CoderHelm); requested reviewers and teams; each person's latest review; the review decision; the checks on the head against the branch's required checks; conflicts; draft; open conversations; labels; links to stacked pull requests, to the same run's other pull requests (`plan_repos`, `repo_ci`) and to the ones named under the description's Compatibility heading; CoderHelm's run; a timeline of the newest events; and the wait ledger (who held the turn, and since when).
Expand Down Expand Up @@ -42,5 +42,5 @@ Both need the "view" capability. The team is always the session's; a record of a
## Cost

- Reading the list costs no GitHub requests: it reads the team's records, its runs on them (one batched read) and the reviewer's records, and reuses them for 10 seconds per installation and team.
- The sync spends from the installation's shared GitHub budget as `sweep:dashboard_prs`: at most 60 requests an hour: at most 10 pages of 30 open pull requests and 5 pages of closed ones per organization each time, once an hour per team and once at install. It runs only while the budget leaves the runs their share.
- The sync spends from the installation's shared GitHub budget as `sweep:dashboard_prs`: at most 60 requests an hour: at most 10 pages of 30 open pull requests and 5 pages of closed ones per organization each time, once an hour per team, once at install, and once when the page finds the team's first read never finished (an install from before this view): that ask is claimed so one goes out per ten minutes, and the page shows the read's progress, repositories read of all. It runs only while the budget leaves the runs their share.
- Each webhook costs one read and one write of its record.
6 changes: 5 additions & 1 deletion docs/pull-requests/api_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Team comes from the session only. 404 from an older backend means "not served ye
"views": {"my_turn": 2, "coderhelm_working": 4, "needs_decision": 1, "ready": 3, "stale": 2}
},
"viewer": "octocat",
"first_read": {"reading": true, "repos_read": 3, "repos_total": 7, "done": false, "outcome": null},
"backfill": [{"owner": "acme", "months_read": 9, "months_total": 14, "done": false, "paused_until": null, "paused_why": null, "repos": {"acme/web": 212, "acme/api": 97}, "updated_at": "..."}],
"synced_at": "2026-01-10T12:00:00Z",
"sources": [{"name": "webhooks", "read": "ok", "detail": ""}, {"name": "reconcile", "read": "ok", "detail": "acme: 37 open pull requests read"}]
Expand Down Expand Up @@ -114,8 +115,11 @@ All settings-table rows, `pk` = team id, body JSON in `doc`. Types live in `serv
pct {cycle: [p50,p85,p95] secs over 90 days, first_review: [p50,p85] over 8 weeks, stage_p85 {stage: secs}, merged}, inherited (repo under 30 merges uses the org's), young (org under 8 weeks: show external bands)`.
Weekly counts are the 7 days to the snapshot. `pr_history::snapshots_of(team, scope, since_day)` reads them oldest first.

## First read (`first_read`)
`GET /api/prs` and `GET /api/prs/overview` return `first_read {reading, repos_read, repos_total, done, outcome}`: the team's first read of every open pull request in every repository the installation can see (`PRFIRST`, `pr_record::FirstRead`). While `reading`, the page says "reading your repositories (repos_read of repos_total)"; `repos_read` moves an organization at a time. A read with nothing to read ends done with `outcome` saying why (`no repositories to read`, `GitHub is not connected`), and the page says that instead of reading. A page GitHub answered only in part (a pull request returned null, or an error not naming one refused field) never counts the listing complete: those pull requests are read from the REST list of each repository's open pull requests, and nothing is removed unless the listing is whole. When the read never finished and nothing asked for it in the last ten minutes (an install from before this view), the request asks the worker for it (`PrRecordsSync`), claimed with a conditional write so one ask goes out at a time.

## History backfill (every pull request, whoever wrote it)
At install and on every hourly reconcile, the worker reads each organization's closed and merged pull requests, a month at a time from the newest, 14 months back (`PRBACKFILL#<owner>` holds the progress, `pr_history::Backfill`), into history rows. People's, bots' and CoderHelm's pull requests alike: the only filter is the team's connected repositories. At most 5 search pages per organization per sweep under `sweep:dashboard_prs` (60 requests an hour); a held budget or GitHub's rate limit pauses it (`paused_until`, `paused_why`) and the next sweep resumes from the stored page cursor. `GET /api/prs` returns the progress as `backfill`, with history rows written per repository.
At install and on every hourly reconcile, the worker reads each organization's closed and merged pull requests, a month at a time from the newest, 14 months back (`PRBACKFILL#<owner>` holds the progress, `pr_history::Backfill`), into history rows. People's, bots' and CoderHelm's pull requests alike: the only filter is the repositories the installation can see (every repository row of the team, enabled for CoderHelm's work or not). At most 5 search pages per organization per sweep under `sweep:dashboard_prs` (60 requests an hour); a held budget or GitHub's rate limit pauses it (`paused_until`, `paused_why`) and the next sweep resumes from the stored page cursor. `GET /api/prs` returns the progress as `backfill`, with history rows written per repository.

## Health signals (from "Org pull request health signals")
On the current row (`PrRecord`):
Expand Down
Loading